# Makevars file for Harman R package

# Compile package using: R CMD INSTALL --preclean --build Harman

## Use the R_HOME indirection to support installations of multiple R version

# compile form source:
#  R CMD INSTALL --preclean --build Harman -l ~/R/library
#
# Global environment variables can be changed in: $R_HOME/etc/x64/Makevars file (e.g. optimisation and debug symbol flags -O2 -g etc. )
# Users may also have a Makevars in their home directory ~/.R folder


# For unix based systems change to the appropriate path:

# INTELOMP="-openmp  -openmp-report2  -vec-report1"
# GNUOMP="-fopenmp"
# GPUOMP_LIB=-gomp

## See: http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-May/005880.html
## See: http://stackoverflow.com/questions/12306462/using-r-cmd-shlib-with-openmp-not-for-package-building

## Old buggy flags...
## PKG_CPPFLAGS  = `$(R_HOME)/bin/Rscript -e "Rcpp:::CxxFlags()"`-I. -D_USE_RCPP=1 -D_ARRAYALIGNEMT=4 
## PKG_CXXFLAGS  =  $(SHLIB_OPENMP_CXXFLAG) 
## PKG_LIBS      = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(SHLIB_OPENMP_CXXFLAG)


## PKG_CPPFLAGS=`$(R_HOME)/bin/Rscript -e "Rcpp:::CxxFlags()"`-I. -D_USE_RCPP=1 -D_ARRAYALIGNEMT=4 
## PKG_CPPFLAGS= -D_USE_RCPP=1 -D_ARRAYALIGNEMT=4 
## PKG_CXXFLAGS=$(shell $(R_HOME)/bin/Rscript -e "Rcpp:::CxxFlags()") -I. # $(SHLIB_OPENMP_CXXFLAGS)
## PKG_LIBS=$(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()") # $(SHLIB_OPENMP_CXXFLAGS)


PKG_CPPFLAGS = -D_ARRAYALIGNEMT=4 -D_USE_RCPP=1
PKG_CXXFLAGS=`$(R_HOME)/bin/Rscript -e "Rcpp:::CxxFlags()"` -I. ### $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS=`$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` ### $(SHLIB_OPENMP_CXXFLAGS)

## -lOpenCL -D_USE_CPP11 


## As an alternative, one can also add this code in a file 'configure'
##
##    PKG_LIBS=`${R_HOME}/bin/Rscript -e "Rcpp:::LdFlags()"`
## 
##    sed -e "s|@PKG_LIBS@|${PKG_LIBS}|" \
##        src/Makevars.in > src/Makevars
## 
## which together with the following file 'src/Makevars.in'
##
##    PKG_LIBS = @PKG_LIBS@
##
## can be used to create src/Makevars dynamically. This scheme is more
## powerful and can be expanded to also check for and link with other
## libraries.  It should be complemented by a file 'cleanup'
##
##    rm src/Makevars
##
## which removes the autogenerated file src/Makevars. 
##
## Of course, autoconf can also be used to write configure files. This is
## done by a number of packages, but recommended only for more advanced users
## comfortable with autoconf and its related tools.
