## With R 3.1.0 or later, you can uncomment the following line to tell R to
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here.  It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it
CXX_STD = CXX17

## PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
## RcppArmadilloForward.h injects extra members into arma::Mat/Col/Row
## (RcppArmadillo interop methods, R RNG plug-in) before <armadillo> is
## included. exuber's own sources get this via RcppArmadillo.h; the vendored
## exubercore source doesn't include that header (it's meant to stay R-free
## in its own repo) and so builds a differently-shaped arma::Mat -- an ODR
## violation across translation units in the same DLL that segfaults at
## call time. Forcing the same header into every TU keeps arma::Mat
## identical everywhere it's compiled.
PKG_CPPFLAGS = -Ivendor/exubercore/include -include RcppArmadillo/interface/RcppArmadilloForward.h
PKG_LIBS =  $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) ## $(SHLIB_OPENMP_CFLAGS)

# rls_gsadf.cpp is a thin Rcpp wrapper around the vendored exubercore
# numerics (see tools/vendor-exubercore.sh); R's default build only picks
# up src/*.cpp, so the vendored source needs to be listed explicitly here.
OBJECTS = RcppExports.o rls_gsadf.o vendor/exubercore/src/radf.o

# R CMD build only sweeps top-level src/*.o; the clean target lets it remove
# the vendored object too. `all` must stay the first target (WRE 1.2.1).
all: $(SHLIB)
clean:
	rm -f $(OBJECTS) $(SHLIB)
