#------------------------------------------------------------------------
#   Copyright (C) 2014-2016  Serge Iovleff, University Lille1, Inria
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------
#   Project:    MixAll
#   Created on: Feb 17, 2014
#   Authors:    Serge IOVLEFF <serge_DOT_iov..._AT_stkpp_DOT_org>
#-----------------------------------------------------------------------
# Name of the MixAll library

LIB_MIXALL_A = libMixAll.a

PKG_DIR    = ../inst
PKGLIB_DIR = $(PKG_DIR)/lib
PKGLIB     = $(PKGLIB_DIR)/$(LIB_MIXALL_A)

## Use the R_HOME indirection to support installations of multiple R version
CXX_STD = CXX11
PKG_CXXFLAGS = `${R_HOME}/bin/Rscript -e "rtkore:::CxxFlags()"` -I../inst/projects/ -I../inst/include/ \
               $(SHLIB_OPENMP_CXXFLAGS)
PKG_CPPFLAGS = `${R_HOME}/bin/Rscript -e "rtkore:::CppFlags()"` \
 		#						-DSTK_MIXTURE_VERBOSE -DSTK_MIXTURE_DEBUG  -DSTK_MIXTURE_VERY_VERBOSE

PKG_LIBS = $(PKGLIB) `$(R_HOME)/bin/Rscript -e "rtkore:::LdFlags()"` \
           $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

STK_CPPFLAGS  = $(ALL_CPPFLAGS) #-DSTK_MIXTURE_VERBOSE -DSTK_MIXTURE_DEBUG -DSTK_MIXTURE_VERY_VERBOSE
STK_CXXFLAGS  = $(ALL_CXXFLAGS)

export

.PHONY: all mixall


all: $(SHLIB)
$(SHLIB): mixall

mixall:
	(cd $(PKG_DIR) && $(MAKE))
	(cd $(PKG_DIR) && $(MAKE) clean)

