This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (64 loc) · 3.2 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
R = R_LIBS=$(shell pwd)/Rpackages R --vanilla
CRAN_REPOS = c("http://cran.uk.r-project.org")
PGDIR = $(shell dirname `ls -1 /usr/lib/postgresql/9.*/bin/initdb /usr/bin/initdb /bin/initdb 2>/dev/null | head -1`)
PGDATA = pgdata
PGNAME = mf
PGSOCKET = /tmp/pg_mfdb
all: dependencies check install
mfdb/:
[ ! -d mfdb/.git ] && { git clone git://github.com/mareframe/mfdb.git ; cd mfdb && git remote set-url --push origin [email protected]:mareframe/mfdb.git; } || true
cd mfdb && git pull
$(PGDATA):
[ -e "$(PGDIR)/initdb" ] || { "Cannot find initdb"; exit 1; }
$(PGDIR)/initdb -D $(PGDATA)
db_start: $(PGDATA)
[ -e "$(PGDIR)/postmaster" ] || { "Cannot find postmaster"; exit 1; }
rmdir $(PGSOCKET) || true
mkdir $(PGSOCKET)
$(PGDIR)/postmaster -D "$(PGDATA)" \
-c log_statement=all \
--unix_socket_directories="$(PGSOCKET)" \
--listen_addresses=""
db_create:
[ -e "$(PGDIR)/createdb" ] || { "Cannot find createdb"; exit 1; }
$(PGDIR)/createdb -h $(PGSOCKET) $(PGNAME)
db_shell:
[ -e "$(PGDIR)/psql" ] || { "Cannot find psql"; exit 1; }
$(PGDIR)/psql -h $(PGSOCKET) $(PGNAME)
# One can't install one thing locally and another from repo, so install
# dependencies manually
dependencies: mfdb/
/bin/echo -E 'install.packages(Filter(nzchar, unlist(strsplit(read.dcf("mfdb/DESCRIPTION")[,"Imports"], "\\W+"))), dependencies = TRUE, repos = $(CRAN_REPOS))' | $(R)
/bin/echo -E 'install.packages(Filter(nzchar, unlist(strsplit(read.dcf("mfdb/DESCRIPTION")[,"Suggests"], "\\W+"))), dependencies = TRUE, repos = $(CRAN_REPOS))' | $(R)
check: R/*.R tests/*.R
rm mfdb_*.tar.gz 2>/dev/null || true
$(R) CMD build mfdb && $(R) CMD check mfdb_*.tar.gz
install:
$(R) CMD INSTALL --install-tests --html --example mfdb
test: install
/bin/echo -E "for (f in list.files('mfdb/tests', full.names = TRUE)) source(f, chdir = TRUE)" | $(R) --slave
inttest: test
for f in */demo/inttest-*.R; do echo "=== $$f ============="; Rscript $$f || break; done
example-iceland example-datras: install
rm -r $@-model || true
mkdir $@-model
cp [email protected]/timings $@-model/timings
echo -n $$(git --git-dir=mfdb/.git log --pretty=format:'%h %s %d' --abbrev-commit HEAD^..HEAD) >> $@-model/timings
R_LIBS=$(shell pwd)/Rpackages \
time -ao$@-model/timings \
--format=" %U user %S system %E elapsed %P CPU" \
R --vanilla < mfdb/demo/[email protected] > $@-model/stdout
find $@-model -type f -print0 | xargs -0 sed -ri 's/^(\; Generated by mfdb).*/\1/'
git diff --no-index --color-words [email protected] $@-model
shell: install
R_DEVPKG=mfdb R_LIBS=$(shell pwd)/Rpackages R --no-save --no-environ
documentation: install
cp -vr Rpackages/mfdb mareframe.github.io/packages/
echo "<html><body><h1>Demos</h1><hr/><ul>" > mareframe.github.io/packages/mfdb/demo/index.html
ls -1 mareframe.github.io/packages/mfdb/demo/ | awk '{ print "<ul><a href=\"" $$1 "\">" $$1 "</a></ul>"; }' >> mareframe.github.io/packages/mfdb/demo/index.html
echo "</ul></body></html>" >> mareframe.github.io/packages/mfdb/demo/index.html
cd mareframe.github.io && git add -A && git commit -av
# Individual R files require no comilation
R/*.R:
tests/*.R:
.PHONY: dependencies check install test db_start db_create db_shell