#------------------------------------------------------------------------
#   Copyright (C) Inria 2014
#
#   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:    rtkpp
#   Created on: Feb 17, 2014
#   Authors:    Serge IOVLEFF <serge.iovleff@stkpp.org>
#						    Vincent KUBICKI <vincent.kubicki@inria.fr>
#-----------------------------------------------------------------------
# Name of the STK++ library
LIB_STKPP_A = libSTKpp.a

STKPP_DIR = ../inst
STKPP_LIB = $(STKPP_DIR)/lib/$(LIB_STKPP_A)

# STK_FLAGS = -Wno-long-long    ## remove warnings at compilation
# -march=native -funroll-loops  ## optimisation does not work under window

## Use the R_HOME indirection to support installations of multiple R version
PKG_CXXFLAGS += `${R_HOME}/bin/Rscript -e "Rcpp:::CxxFlags()"` $(STK_FLAGS)
PKG_CPPFLAGS += -I../inst/projects/ -I../inst/include/ -DIS_RTKPP_LIB

PKG_LIBS     += `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(STKPP_LIB)

## Define STK flags at this level
STK_CXXFLAGS = $(PKG_CXXFLAGS) -DIS_RTKPP_LIB -DSTKUSELAPACK

export

.PHONY: all pkglib

## $(SHLIB) is the usual default target that is built automatically from all source
## files in this directory. pkglib is an additional target for the library
## that will be installed in inst/ and which users can link against.
all: $(SHLIB)
$(SHLIB): pkglib

pkglib:
	($(MAKE) -C $(STKPP_DIR))
	(cd $(STKPP_DIR) && $(MAKE) clean_obj)
	