-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
84 lines (60 loc) · 1.89 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
R=R
# -> you can do R=R-devel make ....
PACKAGE=compResidual
VERSION=$(shell sed -n '/^Version: /s///p' ${PACKAGE}/DESCRIPTION)
TARBALL=${PACKAGE}_${VERSION}.tar.gz
ZIPFILE=${PACKAGE}_${VERSION}.zip
CPP_SRC = $(PACKAGE)/src/*.cpp
SUBDIRS := $(wildcard test/*/.)
.PHONY: test testseq testone $(SUBDIRS) all check clean install
ifeq (testone,$(firstword $(MAKECMDGOALS)))
ARG := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(ARG):;@:)
endif
all:
make doc-update
make build-package
make install
make pdf
doc-update: $(PACKAGE)/R/*.R
echo "library(roxygen2);roxygenize(\"$(PACKAGE)\")" | $(R) --slave
@touch doc-update
namespace-update :: $(PACKAGE)/NAMESPACE
$(PACKAGE)/NAMESPACE: $(PACKAGE)/R/*.R
echo "library(roxygen2);roxygenize(\"$(PACKAGE)\")" | $(R) --slave
build-package: $(TARBALL)
$(TARBALL): $(PACKAGE)/NAMESPACE
$(R) CMD build --resave-data=no $(PACKAGE)
install: $(TARBALL)
$(R) CMD INSTALL --preclean $(TARBALL)
@touch install
debug-install: $(PACKAGE)/src/compResidual.so
$(R) CMD INSTALL $(PACKAGE)
$(PACKAGE)/src/compResidual.so: $(PACKAGE)/src/compResidual.cpp $(CPP_SRC)
touch $(PACKAGE)/src/compResidual.cpp
cd $(PACKAGE)/src; echo "library(TMB); compile('compResidual.cpp','-O0 -g', libinit=FALSE)" | $(R) --slave
unexport TEXINPUTS
pdf: $(PACKAGE).pdf
$(PACKAGE).pdf: $(PACKAGE)/man/*.Rd
rm -f $(PACKAGE).pdf
$(R) CMD Rd2pdf --no-preview $(PACKAGE)
check:
$(R) CMD build --resave-data=no $(PACKAGE)
$(R) CMD check $(TARBALL)
clean:
\rm -f install doc-update compResidual_* compResidual.pdf compResidual/src/*.o compResidual/src/*.so compResidual/src/*.dll
NPROCS:=1
OS:=$(shell uname -s)
ifeq ($(OS),Linux)
NPROCS:=$(shell grep -c ^processor /proc/cpuinfo)
endif
MAKEFLAGS += --silent
test:
$(MAKE) -j $(NPROCS) testseq
testseq: $(SUBDIRS)
testone:
@$(MAKE) test/$(ARG)/.
$(SUBDIRS):
@cp test/Makefile $@
@$(MAKE) -i -s -C $@
@rm -f $@/Makefile