/
Makefile
240 lines (203 loc) · 6.96 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
ifneq ($(MAKECMDGOALS),ci)
Makefile.config: configure
@if [ -e "$@" ]; then \
echo "configure file has changed. Please rerun ./configure"; exit 1; \
else \
echo "Please run ./configure first"; exit 1; \
fi
include Makefile.config
endif
-include Makefile.local
# Variables for packagers.
PREFIX=/usr
DISTRIB_DIR=distribution
BUILD_DIR=_build/default
EXE = \
bin/distrib/connex.exe \
bin/distrib/consang.exe \
bin/distrib/ged2gwb.exe \
bin/distrib/gwb2ged.exe \
bin/distrib/gwc.exe \
bin/distrib/gwd.exe \
bin/distrib/gwdiff.exe \
bin/distrib/gwtp.exe \
bin/distrib/gwu.exe \
bin/distrib/setup.exe \
bin/distrib/update_nldb.exe \
###### [BEGIN] Generated files section
CAMLP5_PA_EXTEND_FILES = \
bin/distrib/ged2gwb/ged2gwb \
lib/templ \
bin/distrib/setup/setup
CAMLP5_Q_MLAST_FILES = \
lib/templ
CAMLP5_FILES = $(sort $(CAMLP5_Q_MLAST_FILES) $(CAMLP5_PA_EXTEND_FILES))
$(CAMLP5_PA_EXTEND_FILES:=.ml): CAMLP5_OPT += pa_extend.cmo
$(CAMLP5_Q_MLAST_FILES:=.ml): CAMLP5_OPT += q_MLast.cmo
%.ml: CAMLP5_OPT=
%.ml: %.camlp5.ml
@([ -z "$(CAMLP5_OPT)" ] \
|| false \
&& echo "ERROR generating $@: CAMLP5_OPT variable must be defined") \
|| (echo -n "Generating $@..." \
&& echo "(* DO NOT EDIT *)" > $@ \
&& echo "(* This file was generated from $< *)" >> $@ \
&& camlp5o pr_o.cmo $(CAMLP5_OPT) -impl $< >> $@ \
&& sed -i.bak -E 's/[(]\* (\[@.+\]) \*[)]/\1/g' $@ \
&& sed -i.bak -E 's/[(]\* (#[^\*]+) \*[)]/\1/g' $@ \
&& rm $@.bak \
&& echo " Done!")
lib/gwlib.ml:
@echo -n "Generating $@..."
@echo "let prefix =" > $@
@echo " try Sys.getenv \"GWPREFIX\"" >> $@
@echo " with Not_found -> \"$(PREFIX)\"" | sed -e 's|\\|/|g' >> $@
@echo " Done!"
CPPO_D=$(API_D) $(GWDB_D)
%/dune: %/dune.in
@echo -n "Generating $@..." \
&& cat $< \
| cppo -n $(CPPO_D) \
| sed \
-e "s/%%%CPPO_D%%%/$(CPPO_D)/g" \
-e "s/%%%API_PKG%%%/$(API_PKG)/g" \
-e "s/%%%SOSA_PKG%%%/$(SOSA_PKG)/g" \
-e "s/%%%GWDB_PKG%%%/$(GWDB_PKG)/g" \
-e "s/%%%DUNE_DIRS_EXCLUDE%%%/$(DUNE_DIRS_EXCLUDE)/g" \
> $@ \
&& echo " Done!"
hd/etc/version.txt:
@echo -n "Generating $@..."
@echo "GeneWeb[:] [compiled on %s from commit %s:::" > $@
@echo "$$(date '+%Y-%m-%d'):" >> $@
@echo "$$(git show -s --date=short --pretty=format:'<a href="https://github.com/geneweb/geneweb/commit/%h">%h (%cd)</a>')]" >> $@
@echo " Done!"
.PHONY:hd/etc/version.txt
###### [End] Generated files section
GENERATED_FILES_DEP = \
hd/etc/version.txt \
lib/gwlib.ml \
$(CAMLP5_FILES:=.ml) \
benchmark/dune \
bin/distrib/dune \
lib/dune \
test/dune \
ifdef API_D
piqi:
$(foreach p, $(wildcard lib/*.proto), \
piqi of-proto --normalize $(p) ; \
piqic-ocaml -C lib/ --ext $(p).piqi ; \
)
$(RM) lib/*.piqi
else
piqi:
endif
.PHONY: piqi
geneweb.install:
dune build @install
.PHONY: geneweb.install
%.exe: | piqi $(GENERATED_FILES_DEP)
dune build $@
exe:
dune build $(ALL_EXE:=.exe)
.DEFAULT_GOAL = exe
geneweb.install exe: $(GENERATED_FILES_DEP) piqi
###### [BEGIN] Installation / Distribution section
install: geneweb.install
dune install geneweb
uninstall: geneweb.install
dune uninstall geneweb
BUILD_DISTRIB_DIR=$(BUILD_DIR)/bin/distrib/
distrib: exe
$(RM) -r $(DISTRIB_DIR)
mkdir $(DISTRIB_DIR)
mkdir -p $(DISTRIB_DIR)/bases
cp CHANGES $(DISTRIB_DIR)/CHANGES.txt
cp LICENSE $(DISTRIB_DIR)/LICENSE.txt
cp etc/README.txt $(DISTRIB_DIR)/.
cp etc/LISEZMOI.txt $(DISTRIB_DIR)/.
cp etc/START.htm $(DISTRIB_DIR)/.
if test $(OS_TYPE) = "Win"; then \
cp etc/Windows/gwd.bat $(DISTRIB_DIR); \
cp etc/Windows/gwsetup.bat $(DISTRIB_DIR); \
cp -f etc/Windows/README.txt $(DISTRIB_DIR)/README.txt; \
cp -f etc/Windows/LISEZMOI.txt $(DISTRIB_DIR)/LISEZMOI.txt; \
elif test $(OS_TYPE) = "Darwin"; then \
cp etc/gwd $(DISTRIB_DIR)/gwd.command; \
cp etc/gwsetup $(DISTRIB_DIR)/gwsetup.command; \
cp etc/macOS/geneweb.command $(DISTRIB_DIR); \
else \
cp etc/gwd $(DISTRIB_DIR); \
cp etc/gwsetup $(DISTRIB_DIR); \
fi
mkdir $(DISTRIB_DIR)/gw
cp etc/a.gwf $(DISTRIB_DIR)/gw/.
echo "127.0.0.1" > $(DISTRIB_DIR)/gw/only.txt
echo "-setup_link" > $(DISTRIB_DIR)/gw/gwd.arg
cp $(BUILD_DISTRIB_DIR)gwc.exe $(DISTRIB_DIR)/gw/gwc$(EXT);
cp $(BUILD_DISTRIB_DIR)consang.exe $(DISTRIB_DIR)/gw/consang$(EXT);
cp $(BUILD_DISTRIB_DIR)gwd.exe $(DISTRIB_DIR)/gw/gwd$(EXT);
cp $(BUILD_DISTRIB_DIR)gwu.exe $(DISTRIB_DIR)/gw/gwu$(EXT);
cp $(BUILD_DISTRIB_DIR)ged2gwb.exe $(DISTRIB_DIR)/gw/ged2gwb$(EXT);
cp $(BUILD_DISTRIB_DIR)gwb2ged.exe $(DISTRIB_DIR)/gw/gwb2ged$(EXT);
cp $(BUILD_DISTRIB_DIR)connex.exe $(DISTRIB_DIR)/gw/connex$(EXT);
cp $(BUILD_DISTRIB_DIR)gwdiff.exe $(DISTRIB_DIR)/gw/gwdiff$(EXT);
cp $(BUILD_DISTRIB_DIR)setup.exe $(DISTRIB_DIR)/gw/gwsetup$(EXT);
cp $(BUILD_DISTRIB_DIR)update_nldb.exe $(DISTRIB_DIR)/gw/update_nldb$(EXT);
mkdir $(DISTRIB_DIR)/gw/gwtp_tmp
mkdir $(DISTRIB_DIR)/gw/gwtp_tmp/lang
cp bin/distrib/gwtp/README $(DISTRIB_DIR)/gw/gwtp_tmp/.
cp $(BUILD_DISTRIB_DIR)/gwtp.exe $(DISTRIB_DIR)/gw/gwtp_tmp/gwtp$(EXT)
cp bin/distrib/gwtp/lang/*.txt $(DISTRIB_DIR)/gw/gwtp_tmp/lang/.
mkdir $(DISTRIB_DIR)/gw/setup
cp bin/distrib/setup/intro.txt $(DISTRIB_DIR)/gw/setup/
mkdir $(DISTRIB_DIR)/gw/setup/lang
cp bin/distrib/setup/setup.gwf $(DISTRIB_DIR)/gw/setup/
cp bin/distrib/setup/setup.css $(DISTRIB_DIR)/gw/setup/
cp bin/distrib/setup/lang/*.htm $(DISTRIB_DIR)/gw/setup/lang/
cp bin/distrib/setup/lang/lexicon.txt $(DISTRIB_DIR)/gw/setup/lang/
cp bin/distrib/setup/lang/intro.txt $(DISTRIB_DIR)/gw/setup/lang/
cp -R hd/* $(DISTRIB_DIR)/gw/
$(RM) $(DISTRIB_DIR)/exe-version.txt
echo "Commit: `git log -1 | grep commit | cut -c8-15`, `date`" > $(DISTRIB_DIR)/commit.txt
echo "`ocaml -version`" >> $(DISTRIB_DIR)/commit.txt
echo "`camlp5 -v 2>&1`" >> $(DISTRIB_DIR)/commit.txt
echo "-----" >> $(DISTRIB_DIR)/commit.txt
.PHONY: install uninstall distrib
###### [END] Installation / Distribution section
doc: | piqi $(GENERATED_FILES_DEP)
dune build @doc
.PHONY: doc
test: | piqi $(GENERATED_FILES_DEP)
dune build @runtest
.PHONY: test
bench: | piqi $(GENERATED_FILES_DEP)
dune build @runbench
.PHONY: bench
BENCH_FILE ?= /tmp/geneweb-bench.bin
bench-marshal: | piqi $(GENERATED_FILES_DEP) benchmark/bench.exe
ifdef BENCH_NAME
_build/default/benchmark/bench.exe --marshal --name ${BENCH_NAME} ${BENCH_FILE}
else
$(error BENCH_NAME variable is empty)
endif
.PHONY: bench-marshal
bench-tabulate: | piqi $(GENERATED_FILES_DEP) benchmark/bench.exe
_build/default/benchmark/bench.exe --tabulate ${BENCH_FILE}
.PHONY: bench-tabulate
clean:
@echo -n "Cleaning..."
@$(RM) $(GENERATED_FILES_DEP) lib/*_piqi*.ml
@$(RM) -r $(DISTRIB_DIR)
@dune clean
@echo " Done!"
.PHONY: clean
ci:
@./configure && BENCH_NAME=vanilla $(MAKE) -s clean test bench-marshal clean
@./configure --sosa-num && BENCH_NAME=num $(MAKE) -s clean test bench-marshal clean
@./configure --sosa-zarith && BENCH_NAME=zarith $(MAKE) -s clean test bench-marshal clean
ifndef OS
@./configure --api && BENCH_NAME=api $(MAKE) -s clean bench-marshal test clean
endif
@$(MAKE) -s bench-tabulate
.PHONY: ci