| 1 |
## -*- mode: make; tab-width: 8; -*- |
| 2 |
## |
| 3 |
## Simple Makefile |
| 4 |
|
| 5 |
## comment this out if you need a different version of R, |
| 6 |
## and set set R_HOME accordingly as an environment variable |
| 7 |
R_HOME := $(shell R RHOME) |
| 8 |
|
| 9 |
sources := $(wildcard *.cpp) |
| 10 |
programs := $(sources:.cpp=) |
| 11 |
|
| 12 |
|
| 13 |
## include headers and libraries for R |
| 14 |
RCPPFLAGS := $(shell $(R_HOME)/bin/R CMD config --cppflags) |
| 15 |
RLDFLAGS := $(shell $(R_HOME)/bin/R CMD config --ldflags) |
| 16 |
RBLAS := $(shell $(R_HOME)/bin/R CMD config BLAS_LIBS) |
| 17 |
RLAPACK := $(shell $(R_HOME)/bin/R CMD config LAPACK_LIBS) |
| 18 |
|
| 19 |
## if you need to set an rpath to R itself, also uncomment |
| 20 |
#RRPATH := -Wl,-rpath,$(R_HOME)/lib |
| 21 |
|
| 22 |
## include headers and libraries for Rcpp interface classes |
| 23 |
## note that RCPPLIBS will be empty with Rcpp (>= 0.11.0) and can be omitted |
| 24 |
RCPPINCL := $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave) |
| 25 |
RCPPLIBS := $(shell echo 'Rcpp:::LdFlags()' | $(R_HOME)/bin/R --vanilla --slave) |
| 26 |
|
| 27 |
|
| 28 |
## include headers and libraries for RInside embedding classes |
| 29 |
RINSIDEINCL := $(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave) |
| 30 |
RINSIDELIBS := $(shell echo 'RInside:::LdFlags()' | $(R_HOME)/bin/R --vanilla --slave) |
| 31 |
|
| 32 |
## RcppEigen headers |
| 33 |
RCPPEIGENINCL := $(shell echo 'cat(paste("-I", system.file("include", package = "RcppEigen"), sep = ""))' | $(R_HOME)/bin/R --vanilla --slave) |
| 34 |
|
| 35 |
## compiler etc settings used in default make rules |
| 36 |
CXX := $(shell $(R_HOME)/bin/R CMD config CXX) |
| 37 |
CPPFLAGS := -Wall $(shell $(R_HOME)/bin/R CMD config CPPFLAGS) |
| 38 |
CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RCPPEIGENINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R CMD config CXXFLAGS) |
| 39 |
LDLIBS := $(RLDFLAGS) $(RRPATH) $(RBLAS) $(RLAPACK) $(RCPPLIBS) $(RINSIDELIBS) |
| 40 |
|
| 41 |
all: $(programs) |
| 42 |
@test -x /usr/bin/strip && strip $^ |
| 43 |
|
| 44 |
run: $(programs) |
| 45 |
@for p in $(programs); do echo; echo "Running $$p:"; ./$$p; done |
| 46 |
|
| 47 |
clean: |
| 48 |
rm -vf $(programs) |
| 49 |
rm -vrf *.dSYM |
| 50 |
|
| 51 |
runAll: |
| 52 |
for p in $(programs); do echo "Running $$p"; ./$$p; done |