Skip to content

Instantly share code, notes, and snippets.

@QuantTraderEd
Last active August 29, 2015 14:23
Show Gist options
  • Save QuantTraderEd/93c9449438a62b445f36 to your computer and use it in GitHub Desktop.
Save QuantTraderEd/93c9449438a62b445f36 to your computer and use it in GitHub Desktop.
R stat
SrcSuf = cxx
ObjSuf = o
OutPutOpt = -o
SoSuf = so
#=======================================
R_HOME := $(shell R RHOME)
RCPPFLAGS := $(shell $(R_HOME)/bin/R CMD config --cppflgs)
RLDFLAGS := $(shell $(R_HOME)/bin/R CMD config --ldflags)
RBLAS := $(shell $(R_HOME)/bin/R CMD config BLAS_LIBS)
RLAPACK := $(shell $(R_HOME)/bin/R CMD config LAPACK_LIBS)
RCPPINCL := $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RCPPLIBS := $(shell echo 'Rcpp:::LdFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RINSIDEINCL := $(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RINSIDELIBS := $(shell echo 'RInside:::LdFlags()' | $(R_HOME)/bin/R --vanilla --slave)
RCPPARMAINCL := $(shell echo 'RcppArmadillo:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave)
#=======================================
CXX := g++
CXXFLAGS := -g -c -std=c++11 -Wall -O2 \
$(shell $(R_HOME)/bin/R CMD config CPPFLAGS) \
$(RCPPFLAGS) $(RCPPINCL) $(RCPPARMAINCL) $(RINSIDEINCL)
# -I/Library/Frameworks/R.framework/Resources/include \
# -I/Library/Frameworks/R.framework/Resources/library/RInside/include \
# -I/Library/Frameworks/R.framework/Resources/library/Rcpp/include
LDFLAGS = \
$(RLDFLAGS) $(RRPATH) $(RBLAS) $(RLAPACK) $(RCPPLIBs) $(RINSIDELIBS)
# -L/Library/Frameworks/R.framework/Resources/lib \
# -L/Library/Frameworks/R.framework/Resources/library/RInside/libs \
# -L/Library/Frameworks/R.framework/Resources/library/Rcpp/libs \
# -lR -lRblas -lRlapack -lcpp -lRinside
TARGET = $(n)
SRCS = $(n).$(SrcSuf)
OBJECTS = $(n).$(ObjSuf)
#=======================================
$(TARGET): $(OBJECTS)
$(CXX) $(OBJECTS) $(LDFLAGS) -o $(TARGET)
.SUFFIXES: .$(SrcSuf)
.$(SrcSuf).$(ObjSuf):
$(CXX) $(CXXFLAGS) $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment