Makefile 5.74 KB
Newer Older
1
2
3
4
ADDITIONAL_MODULES= \
  modules/sbml/sbml_utils.pl \
  modules/partialfrac/partialfraction.pl \
  modules/glucose/glucose.pl
Thierry Martinez's avatar
Thierry Martinez committed
5
6
MODULES=$(shell sed -n -E 's/^[+-] (.*\.pl)$$/\1/p' toc.org) \
  $(ADDITIONAL_MODULES)
7
# load_test_files/1 should make this useless, but I cannot find how to use it
8
TEST_MODULES=$(wildcard $(MODULES:.pl=.plt)) junit.pl
9
10
11
12

ifndef $(PREFIX)
  PREFIX=/usr/local
endif
Thierry Martinez's avatar
Thierry Martinez committed
13

14
$(foreach var, CC PLBASE PLARCH PLLIB PLCFLAGS PLLDFLAGS PLSOEXT, \
Thierry Martinez's avatar
Thierry Martinez committed
15
16
17
18
  $(eval \
    $(shell \
      swipl -dump-runtime-variables | \
      grep ^$(var)= | \
19
      sed -E 's/^/export /;s/="/=/;s/";$$//')))
Thierry Martinez's avatar
Thierry Martinez committed
20

21
SUBDIRS=$(dir $(wildcard modules/*/Makefile))
Thierry Martinez's avatar
Thierry Martinez committed
22

23
24
25
26
# glucose source needs its own header files
INCLUDEDIRS=$(PLBASE)/include $(SUBDIRS) \
  modules/glucose/glucose-syrup modules/glucose/glucose-syrup/core

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
27
28
29
30
RPATH=
ifneq ($(LD_RUN_PATH),)
  RPATH=-Wl,-rpath=$(LD_RUN_PATH)
endif
31
32
CFLAGS=$(addprefix -I, $(INCLUDEDIRS)) $(PLCFLAGS)
CXXFLAGS=$(CFLAGS) -Wno-logical-op-parentheses `pkg-config --cflags libgvc`
Thierry Martinez's avatar
SBML    
Thierry Martinez committed
33

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
34
LDFLAGS=$(PLLDFLAGS) $(RPATH) $(addprefix -L, $(PLBASE)/lib/$(PLARCH)/)
Thierry Martinez's avatar
Thierry Martinez committed
35

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
36
37
LIBSBML=$(shell pkg-config --silence-errors --libs libsbml)
ifeq ($(strip $(LIBSBML)),)
38
39
40
  LIBSBML=-lsbml
endif
LDLIBS=$(PLLIB) `pkg-config --libs libgvc` $(LIBSBML) -lgsl -lgslcblas -lm
Thierry Martinez's avatar
Thierry Martinez committed
41

Thierry Martinez's avatar
Thierry Martinez committed
42
43
SWIPL=$(PWD)/swipl-biocham

Thierry Martinez's avatar
Thierry Martinez committed
44
45
CMAES_LIB=library/cmaes.c library/cmaes.h library/cmaes_interface.h

46
all: biocham biocham_debug test doc/index.html jupyter
Thierry Martinez's avatar
Thierry Martinez committed
47

Sylvain Soliman's avatar
Sylvain Soliman committed
48
49
quick: unit_tests

50
.PHONY: all slow test unit_tests clean web cabernet cabernet_restart \
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
51
  jupyter gadagne gadagne_restart jupyter_tests install pldoc
PRIMET Romain's avatar
PRIMET Romain committed
52

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
53
# should we depend on jupyter target?
PRIMET Romain's avatar
PRIMET Romain committed
54
55
install: biocham biocham_debug
	mkdir -p $(PREFIX)/bin
56
57
	mkdir -p $(PREFIX)/share/biocham
	cp $? $(PREFIX)/share/biocham/
58
59
	ln -fs $(PREFIX)/share/biocham/biocham $(PREFIX)/bin/biocham
	ln -fs $(PREFIX)/share/biocham/biocham_debug $(PREFIX)/bin/biocham_debug
60
	cp -r library $(PREFIX)/share/biocham/
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
61
62
	cp -r doc $(PREFIX)/share/biocham/
	cp -r biocham_kernel $(PREFIX)/share/biocham/
Thierry Martinez's avatar
Thierry Martinez committed
63

64
biocham: $(SWIPL) $(MODULES) toc.org $(CMAES_LIB) \
65
	library/gsl_solver.o library/cmaes.o library/csv_reader.o Makefile
Sylvain Soliman's avatar
Sylvain Soliman committed
66
	$(SWIPL) -q -o biocham \
67
68
69
		--goal="\
			set_prolog_flag(verbose, normal), \
			start" \
70
		--toplevel=toplevel --stand_alone=true -O -c $(MODULES)
Thierry Martinez's avatar
Thierry Martinez committed
71

72
73
biocham_debug: $(SWIPL) $(MODULES) $(TEST_MODULES) toc.org \
	library/gsl_solver.o Makefile
74
75
76
	$(SWIPL) -q -o biocham_debug \
		--goal="\
			set_prolog_flag(verbose, normal), \
77
			initialize" --stand_alone=true -c $(MODULES) $(TEST_MODULES)
David Rosenblueth's avatar
David Rosenblueth committed
78

79
80
81
82
83
84
$(SWIPL): $(SWIPL).c \
		modules/graphviz/graphviz_swiprolog.c \
		modules/sbml/sbml_swiprolog.c \
		modules/partialfrac/roots.c \
		modules/glucose/glucose_swiprolog.cc \
		modules/glucose/glucose-syrup/core/Solver.cc
85
	for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir ; done
86
	$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) $(LDLIBS) -lstdc++ -o $@
87

88
89
90
91
92
93
94
# patch line is to remove output of noisy comment on stdout
modules/glucose/glucose-syrup/core/Solver.cc: modules/glucose/Solver.patch
	curl -fsSLO http://www.labri.fr/perso/lsimon/downloads/softwares/glucose-syrup.tgz
	tar -C $(dir $<) -xf glucose-syrup.tgz
	rm -f glucose-syrup.tgz
	patch $@ < $<

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
95
doc/index.html doc/commands.js: biocham pldoc
Thierry Martinez's avatar
Thierry Martinez committed
96
97
	./biocham --generate-doc

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
98
99
100
pldoc:
	echo "doc_save(., [if(true), doc_root('doc/pldoc')])." | swipl -q

101
102
103
104
105
106
# quick ones only
unit_tests: biocham_debug
	echo "run_tests_and_halt." | ./biocham_debug

# slow tests too
test: biocham_debug jupyter_tests
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
107
	echo "flag(slow_test, _, true), run_tests_and_halt." | ./biocham_debug
Sylvain Soliman's avatar
Sylvain Soliman committed
108

109
110
111
jupyter_tests: jupyter
	PYTHONPATH=$(PWD) jupyter nbconvert --execute --stdout library/examples/cmsb_2017/sigmoids.ipynb > /dev/null

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
112
113
# runs test unit %
test_%: biocham_debug
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
114
115
	echo "flag(slow_test, _, true), run_tests_and_halt('$*')." | ./biocham_debug

116
jupyter: biocham biocham_kernel/commands.js biocham_kernel/commands.py
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
117
	- jupyter kernelspec install --user --name=biocham biocham_kernel
118
119
	- jupyter nbextension install --user biocham_gui/menu
	- jupyter nbextension install --user biocham_gui/biocham_gui
dcoudrin's avatar
dcoudrin committed
120
121
	- jupyter nbextension enable --user menu/main
	- jupyter nbextension enable --user biocham_gui/main
122

123
124
125
126
127
128
129
biocham_kernel/commands.py: biocham
	rm -f $@
	echo '# Auto generated file, please do not edit manually' > $@
	echo 'commands = [' >> $@
	./biocham --list-commands | tail -n +4 | sort -u | sed -e 's/^\(.*\)$$/    "\1",/' >> $@
	echo ']' >> $@

130
131
biocham_kernel/commands.js: doc/commands.js
	cp -f $< $@
132

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
133
clean:
134
	- for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
Thierry Martinez's avatar
Thierry Martinez committed
135
136
137
	- rm biocham
	- rm biocham_debug
	- rm biocham_tests
Sylvain Soliman's avatar
Sylvain Soliman committed
138
	- rm biocham_full_tests
Thierry Martinez's avatar
Thierry Martinez committed
139
140
	- rm swipl-biocham
	- rm swipl-biocham.o
Thierry Martinez's avatar
Thierry Martinez committed
141
	- rm library/gsl_solver.o
142
143
	- rm library/cmaes.o
	- rm library/csv_reader.o
144

145
146
147
148
149
150
151
152
153
154
$(CMAES_LIB): modules/c-cmaes/src
	cp $</$(notdir $@) $@

modules/c-cmaes/src:
	if [ -d .git ] ; then \
		git submodule init && \
		git submodule update ; \
	else \
		git clone https://github.com/CMA-ES/c-cmaes.git modules/c-cmaes ; \
	fi
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
155
156

biocham-src-%.zip:
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
157
	git archive --prefix=biocham/ -o $@ HEAD
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
158

159
160
161
web/biocham.zip: biocham-src-$(shell git rev-parse --short HEAD).zip
	cp $< $@

162
web: web/biocham.zip web/index.html web/logo.png doc/index.html
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
163
	-rsync -avz $^ doc lifeware:/nfs/web-epi/biocham4/
164
	ssh -t lifeware 'sudo chmod -R g+w /nfs/web-epi/biocham4/ && sudo chown -R www-data.lifeware /nfs/web-epi/biocham4/'
Thierry Martinez's avatar
Thierry Martinez committed
165

166
167
168
169
170
171
cabernet: web
	-rsync -avz tmpnb/* lifeware@cabernet:/usr/local/share/tmpbc/
	ssh -t lifeware@cabernet 'cd /usr/local/share/tmpbc/lifeware_biocham && sudo docker build --no-cache -t lifeware/biocham .'

cabernet_restart: cabernet
	ssh -t lifeware@cabernet 'cd /usr/local/share/tmpbc/ && sudo ./cleanup.sh && sudo ./tmpnb_biocham.sh'
SOLIMAN Sylvain's avatar
gadagne    
SOLIMAN Sylvain committed
172
173
174
175
176
177
178

gadagne: web
	-rsync -avz tmpnb/* gadagne:/opt/tmpnb/
	ssh -t gadagne 'cd /opt/tmpnb/lifeware_biocham && sudo docker build --no-cache -t lifeware/biocham .'

gadagne_restart: gadagne
	ssh -t gadagne 'cd /opt/tmpnb/ && sudo ./cleanup.sh && sudo ./tmpnb_biocham.sh'