Makefile 5.47 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
Thierry Martinez's avatar
Thierry Martinez committed
9
VERSION=4.0.$(shell date +%Y%m%d)
Thierry Martinez's avatar
Thierry Martinez committed
10

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

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

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

CFLAGS=$(addprefix -I, $(INCLUDEDIRS)) $(PLCFLAGS)
CXXFLAGS=$(CFLAGS) -Wno-logical-op-parentheses `pkg-config --cflags libgvc`
Thierry Martinez's avatar
SBML    
Thierry Martinez committed
26

27
LDFLAGS=$(PLLDFLAGS) $(addprefix -L, $(PLBASE)/lib/$(PLARCH)/)
Thierry Martinez's avatar
Thierry Martinez committed
28

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
29
30
LIBSBML=$(shell pkg-config --silence-errors --libs libsbml)
ifeq ($(strip $(LIBSBML)),)
31
32
33
  LIBSBML=-lsbml
endif
LDLIBS=$(PLLIB) `pkg-config --libs libgvc` $(LIBSBML) -lgsl -lgslcblas -lm
Thierry Martinez's avatar
Thierry Martinez committed
34

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

Thierry Martinez's avatar
Thierry Martinez committed
37
38
CMAES_LIB=library/cmaes.c library/cmaes.h library/cmaes_interface.h

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

Sylvain Soliman's avatar
Sylvain Soliman committed
41
42
quick: unit_tests

43
.PHONY: all slow test unit_tests clean web cabernet cabernet_restart \
44
  jupyter gadagne gadagne_restart
Thierry Martinez's avatar
Thierry Martinez committed
45

46
biocham: $(SWIPL) $(MODULES) toc.org $(CMAES_LIB) \
47
	library/gsl_solver.o library/cmaes.o library/csv_reader.o Makefile
Sylvain Soliman's avatar
Sylvain Soliman committed
48
	$(SWIPL) -q -o biocham \
49
50
51
52
		--goal="\
			set_prolog_flag(verbose, normal), \
			start" \
		--toplevel=toplevel -c $(MODULES)
Thierry Martinez's avatar
Thierry Martinez committed
53

54
55
biocham_debug: $(SWIPL) $(MODULES) $(TEST_MODULES) toc.org \
	library/gsl_solver.o Makefile
56
57
58
59
	$(SWIPL) -q -o biocham_debug \
		--goal="\
			set_prolog_flag(verbose, normal), \
			initialize" -c $(MODULES) $(TEST_MODULES)
David Rosenblueth's avatar
David Rosenblueth committed
60

61
62
63
64
65
66
$(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
67
	for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir ; done
68
	$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) $(LDLIBS) -lstdc++ -o $@
69

70
71
72
73
74
75
76
# 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
77
78
unit_tests: biocham_debug
	echo "run_tests_and_halt." | ./biocham_debug
Thierry Martinez's avatar
Thierry Martinez committed
79

80
doc/index.html doc/commands.js: biocham
Thierry Martinez's avatar
Thierry Martinez committed
81
82
	./biocham --generate-doc

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
83
84
test: biocham_debug
	echo "flag(slow_test, _, true), run_tests_and_halt." | ./biocham_debug
Sylvain Soliman's avatar
Sylvain Soliman committed
85

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
86
87
# runs test unit %
test_%: biocham_debug
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
88
89
	echo "flag(slow_test, _, true), run_tests_and_halt('$*')." | ./biocham_debug

90
jupyter: biocham biocham_kernel/commands.js biocham_kernel/commands.py
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
91
	- jupyter kernelspec install --user --name=biocham biocham_kernel
92
	- jupyter nbextension install --user biocham_kernel/bc_nb_extensions/menu
93
	- jupyter nbextension install --user biocham_kernel/bc_nb_extensions/biocham_gui
94
	- cd biocham_kernel/bc_nb_extensions
95
	- jupyter nbextension enable --user menu/main
96
	- jupyter nbextension enable --user biocham_gui/main
97
	- jupyter nbextension uninstall --user gui_toolbar
98

99
100
101
102
103
104
105
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 ']' >> $@

106
107
biocham_kernel/commands.js: doc/commands.js
	cp -f $< $@
108

SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
109
clean:
110
	- for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir clean ; done
Thierry Martinez's avatar
Thierry Martinez committed
111
112
113
	- rm biocham
	- rm biocham_debug
	- rm biocham_tests
Sylvain Soliman's avatar
Sylvain Soliman committed
114
	- rm biocham_full_tests
Thierry Martinez's avatar
Thierry Martinez committed
115
116
	- rm swipl-biocham
	- rm swipl-biocham.o
Thierry Martinez's avatar
Thierry Martinez committed
117
	- rm library/gsl_solver.o
118
119
	- rm library/cmaes.o
	- rm library/csv_reader.o
120

121
122
123
124
125
126
127
128
129
130
$(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
131
132

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

135
136
137
web/biocham.zip: biocham-src-$(shell git rev-parse --short HEAD).zip
	cp $< $@

138
web: web/biocham.zip web/index.html web/logo.png doc/index.html
139
	-rsync -avz $^ lifeware:/nfs/web-epi/biocham4/
140
	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
141

142
143
144
145
146
147
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
148
149
150
151
152
153
154

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'
SOLIMAN Sylvain's avatar
SOLIMAN Sylvain committed
155
156
157
158
159
160
161
162
163

release:
	@read -p "Version number (e.g. 4.1.0): " version && \
	sed -i'' -e "s/^version('.*')/version('$$version')/" about.pl && \
	sed -i'' -e "s+^<h1>version.*</h1>+<h1>version $$version $(shell date '+%b %Y')</h1>+" web/index.html
	@read -p "We will now commit tag and push the new version [press any key]" dummy
	git commit about.pl web/index.html -m $Version $$version$
	git tag -a v$$version -m "Version $$version"
	git push --tags