forked from biocaml/biocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOMakeroot
497 lines (403 loc) · 14.4 KB
/
OMakeroot
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
open build/OCaml
DefineCommandVars()
.PHONY: lib lib_ez lib_lwt lib_async app tests benchmarks odoc doc \
install_lib install_app install_doc \
uninstall_lib uninstall_app \
clean distclean \
print_config merlinize
clean:
rm -rf _build
distclean: clean
rm -rf OMakefile.omc OMakeroot.omc .omakedb .omakedb.lock configure.omc
################################################################################
# General Project Information
PROJECT = biocaml
DESCRIPTION = The OCaml Bioinformatics Library
VERSION = 0.4-dev
if $(test -e .git)
GIT_COMMIT = $(shell git rev-parse HEAD)
export
else
GIT_COMMIT =
export
LIB_NAME = $(PROJECT)
LIB_MODULES[] =
$(removesuffix $(basename $(ls src/lib/*.ml)))
$(PROJECT)_about
LIB_STUBS = $(PROJECT)_pwm_stub $(PROJECT)_mzData_stubs
LIB_PACKAGES = core threads zip unix xmlm cfstream sexplib.syntax future.std \
comparelib.syntax re.perl
LIB_EZ_NAME = $(PROJECT)_ez
LIB_EZ_MODULES[] =
$(removesuffix $(basename $(ls src/lib_ez/*.ml)))
LIB_EZ_PACKAGES = $(LIB_PACKAGES)
LIB_LWT_NAME = $(PROJECT)_lwt
LIB_LWT_MODULES[] =
$(removesuffix $(basename $(ls src/lib_lwt/*.ml)))
LIB_LWT_PACKAGES = $(LIB_PACKAGES) lwt lwt.syntax future.lwt
LIB_ASYNC_NAME = $(PROJECT)_async
LIB_ASYNC_MODULES[] =
$(removesuffix $(basename $(ls src/lib_async/*.ml)))
LIB_ASYNC_PACKAGES = $(LIB_PACKAGES) async future.async
APP_NAME = $(PROJECT)
APP_MODULES[] =
$(removesuffix $(basename $(ls src/app/*.ml)))
APP_PACKAGES = $(LIB_PACKAGES) flow
TESTS_NAME = $(PROJECT)_tests
TESTS_MODULES[] =
$(removesuffix $(basename $(ls src/tests/test_*.ml)))
TESTS_PACKAGES = $(LIB_PACKAGES) oUnit
BENCHMARKS_NAME = $(PROJECT)_benchmarks
BENCHMARKS_MODULES[] =
$(removesuffix $(basename $(ls src/benchmarks/*.ml)))
BENCHMARKS_PACKAGES = $(LIB_PACKAGES)
ODOC_NAME = $(PROJECT)_odoc
ODOC_MODULES[] =
$(removesuffix $(basename $(ls src/odoc/*.ml)))
ODOC_PACKAGES = $(LIB_PACKAGES)
IMAGES[] =
$(basename $(ls src/doc/img/*.svg))
################################################################################
# Directory and File Names
CONFIG_FILE = configure.om
DEFAULT_PREFIX = _build/usr
$(CONFIG_FILE):
if $(not $(file-exists $(CONFIG_FILE)))
echo "Generating default $@. Change as desired."
echo "COMPILE_APP = true" > $(CONFIG_FILE)
echo "COMPILE_LIB_EZ = true" >> $(CONFIG_FILE)
echo "COMPILE_LIB_LWT = true" >> $(CONFIG_FILE)
echo "COMPILE_LIB_ASYNC = true" >> $(CONFIG_FILE)
echo "COMPILE_TESTS = true" >> $(CONFIG_FILE)
echo "COMPILE_BENCHMARKS = true" >> $(CONFIG_FILE)
echo "PREFIX = $(DEFAULT_PREFIX)" >> $(CONFIG_FILE)
else
echo "$@ exists. Will not change."
if $(file-exists $(CONFIG_FILE))
include $(CONFIG_FILE)
export
DefineCommandVars()
if $(not $(defined PREFIX))
PREFIX = $(DEFAULT_PREFIX)
export
if $(not $(defined BINDIR))
BINDIR = $(PREFIX)/bin
export
if $(not $(defined DOCDIR))
DOCDIR = $(PREFIX)/doc
export
if $(not $(defined COMPILE_LIB_EZ))
COMPILE_LIB_EZ = true
export
if $(not $(defined COMPILE_LIB_LWT))
COMPILE_LIB_LWT = true
export
if $(not $(defined COMPILE_LIB_ASYNC))
COMPILE_LIB_ASYNC = true
export
if $(not $(defined COMPILE_APP))
COMPILE_APP = true
export
if $(not $(defined COMPILE_TESTS))
COMPILE_TESTS = true
export
if $(not $(defined COMPILE_BENCHMARKS))
COMPILE_BENCHMARKS = true
export
print_config:
echo "COMPILE_LIB_EZ: $(COMPILE_LIB_EZ)"
echo "COMPILE_LIB_LWT: $(COMPILE_LIB_LWT)"
echo "COMPILE_LIB_ASYNC: $(COMPILE_LIB_ASYNC)"
echo "COMPILE_APP: $(COMPILE_APP)"
echo "COMPILE_TESTS: $(COMPILE_TESTS)"
echo "COMPILE_TESTS: $(COMPILE_BENCHMARKS)"
echo "PREFIX: $(PREFIX)"
echo "BINDIR: $(BINDIR)"
echo "DOCDIR: $(DOCDIR)"
################################################################################
# Build Parameters
USE_OCAMLFIND = true
if $(not $(OCAMLFIND_EXISTS))
eprintln(This project requires ocamlfind, but it was not found.)
eprintln(You need to install ocamlfind and run "omake --configure".)
exit 1
NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
BYTE_ENABLED = $(OCAMLC_EXISTS)
OCAMLFLAGS = -bin-annot -annot -warn-error P -thread -short-paths -g
OCAMLCFLAGS =
OCAMLOPTFLAGS =
OCAML_LINK_FLAGS +=
OCAML_BYTE_LINK_FLAGS =
OCAML_NATIVE_LINK_FLAGS =
OCAMLFINDFLAGS = -syntax camlp4o
################################################################################
# Biocaml is a bit more complex than what OCamlLibrary can provide so
# we define this function:
#
public.OCamlLibraryWithCFiles(name, files, c_files) =
protected.name = $(file $(name))
protected.OFILES = $(addsuffix $(EXT_OBJ), $(files))
protected.CMOFILES = $(addsuffix .cmo, $(files))
protected.CMXFILES = $(addsuffix .cmx, $(files))
protected.CLIB = $(file $(name)$(EXT_LIB))
protected.BYTELIB = $(file $(name).cma)
protected.NATIVELIB = $(file $(name).cmxa)
protected.STUB_C_FILES = $(addsuffix .o, $(c_files))
foreach(f => ..., $(c_files))
$(f).o: $(f).c
$(OCAMLC) -c $<
#
# Thanks to Gerd's recipes + OCaml.om in OMake's std-lib
# http://www.camlcity.org/knowledge/kb_001_omake_recipes.html
if $(BYTE_ENABLED)
$(BYTELIB): $(CMOFILES) $(STUB_C_FILES)
ocamlmklib -o $(name) $(OCamlLinkSort $(CMOFILES)) \
$(STUB_C_FILES) $(OCAML_BYTE_LINK_FLAGS)
if $(NATIVE_ENABLED)
$(NATIVELIB) $(CLIB): $(CMXFILES) $(OFILES) $(STUB_C_FILES)
ocamlmklib -custom -o $(name) \
$(OCamlLinkSort $(CMXFILES)) $(STUB_C_FILES) $(OCAML_NATIVE_LINK_FLAGS)
return $(array \
$(if $(NATIVE_ENABLED), $(NATIVELIB)), \
$(if $(NATIVE_ENABLED), $(CLIB)), \
$(if $(BYTE_ENABLED), $(BYTELIB)) \
)
merlinize: .merlin
.merlin:
rm -f .merlin
echo 'S ./src/app/' >> .merlin
echo 'S ./src/lib/' >> .merlin
echo 'S ./src/lib_async/' >> .merlin
echo 'S ./src/lib_lwt/' >> .merlin
echo 'S ./src/lib_ez/' >> .merlin
echo 'S ./src/tests/' >> .merlin
echo 'B _build/app/' >> .merlin
echo 'B _build/benchmarks' >> .merlin
echo 'B _build/lib' >> .merlin
echo 'B _build/lib_async' >> .merlin
echo 'B _build/lib_ez' >> .merlin
echo 'B _build/lib_lwt' >> .merlin
echo 'B _build/tests' >> .merlin
foreach(m => ..., $(LIB_ASYNC_PACKAGES))
echo "PKG $(m)" >> .merlin
foreach(m => ..., $(LIB_LWT_PACKAGES))
echo "PKG $(m)" >> .merlin
################################################################################
# Sub-directories
.SUBDIRS: .
mkdir -p _build/lib
mkdir -p _build/lib_ez
mkdir -p _build/lib_lwt
mkdir -p _build/lib_async
mkdir -p _build/app
mkdir -p _build/tests
mkdir -p _build/benchmarks
mkdir -p _build/odoc
mkdir -p _build/doc
vmount(-l, src/, _build/)
##############################################################################
# Library
.SUBDIRS: _build/lib
OCAMLPACKS[] = $(LIB_PACKAGES)
$(PROJECT)_about.ml: :value: $(VERSION)
echo '(** General information about this library. *)' > $@
echo '' >> $@
echo '(** Version: ["$(VERSION)"] *)' >> $@
echo 'let version = "$(VERSION)"' >> $@
echo '' >> $@
echo '(** Git commit if known. *)' >> $@
if $(equal $(GIT_COMMIT), $(EMPTY))
echo 'let git_commit = None' >> $@
else
echo 'let git_commit = Some "$(GIT_COMMIT)"' >> $@
lib: $(OCamlLibraryWithCFiles $(LIB_NAME), $(LIB_MODULES), $(LIB_STUBS))
.DEFAULT: lib
##############################################################################
# Ez Library
.SUBDIRS: _build/lib_ez
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(LIB_EZ_PACKAGES)
lib_ez: $(OCamlLibrary $(LIB_EZ_NAME), $(LIB_EZ_MODULES))
if $(COMPILE_LIB_EZ)
echo "conf: Building $(PROJECT) ez library"
.DEFAULT: lib_ez
##############################################################################
# Lwt Library
.SUBDIRS: _build/lib_lwt
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(LIB_LWT_PACKAGES)
lib_lwt: $(OCamlLibrary $(LIB_LWT_NAME), $(LIB_LWT_MODULES))
if $(COMPILE_LIB_LWT)
echo "conf: Building $(PROJECT) lwt library"
.DEFAULT: lib_lwt
##############################################################################
# Async Library
.SUBDIRS: _build/lib_async
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(LIB_ASYNC_PACKAGES)
lib_async: $(OCamlLibrary $(LIB_ASYNC_NAME), $(LIB_ASYNC_MODULES))
if $(COMPILE_LIB_ASYNC)
echo "conf: Building $(PROJECT) async library"
.DEFAULT: lib_async
##############################################################################
# Command Line App
.SUBDIRS: _build/app
OCAML_LIBS = ../lib/$(PROJECT)
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(APP_PACKAGES)
%.ml: ../lib/$(PROJECT).cma
app: $(OCamlProgram $(APP_NAME), $(APP_MODULES))
if $(COMPILE_APP)
echo "conf: Building $(PROJECT) application"
.DEFAULT: app
##############################################################################
# Tests
.SUBDIRS: _build/tests
OCAML_LIBS = ../lib/$(PROJECT)
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(TESTS_PACKAGES)
%.ml: ../lib/$(PROJECT).cma
tests: $(OCamlProgram $(TESTS_NAME), main utils $(TESTS_MODULES))
if $(COMPILE_TESTS)
echo "conf: Building $(PROJECT) tests"
.DEFAULT: tests
##############################################################################
# Benchmarks
.SUBDIRS: _build/benchmarks
OCAML_LIBS = ../lib/$(PROJECT)
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(BENCHMARKS_PACKAGES)
%.ml: ../lib/$(PROJECT).cma
benchmarks: $(OCamlProgram $(BENCHMARKS_NAME), $(BENCHMARKS_MODULES))
if $(COMPILE_BENCHMARKS)
echo "conf: Building $(PROJECT) benchmarks"
.DEFAULT: benchmarks
##############################################################################
# OCamldoc Custom Generator
.SUBDIRS: _build/odoc
OCAMLINCLUDES += $(dir ../lib/) +ocamldoc +compiler-libs
OCAMLPACKS[] = $(ODOC_PACKAGES)
%.ml: ../lib/$(PROJECT).cma
$(PROJECT)_odoc.cmxs: biohtml.ml
ocamlfind ocamlopt -shared $^ -o $@ -I +ocamldoc -I +compiler-libs
odoc: $(PROJECT)_odoc.cmxs $(OCamlLibrary $(ODOC_NAME), biohtml)
.DEFAULT: odoc
##############################################################################
# Documentation
.SUBDIRS: _build/doc
index.txt: index.txt.in
cat index.txt.in > $@
echo "" >> $@
echo "Documentation generated on: {i $(shell date)}" >> $@
if $(not $(equal $(GIT_COMMIT), $(EMPTY)))
echo "" >> $@
echo 'Git commit: {i $(GIT_COMMIT)}' >> $@
api/index.html: $(PROJECT).css \
$(addprefix img/, $(IMAGES)) \
index.txt \
../odoc/$(ODOC_NAME).cma \
../lib/$(LIB_NAME).cma
rm -rf api
mkdir api
cp $(PROJECT).css api/
cp img/* api/
ocamlfind ocamldoc \
-g ../odoc/$(ODOC_NAME).cma \
-css-style $(PROJECT).css \
-syntax camlp4o \
-package $(concat \,, $(ODOC_PACKAGES)) \
-charset UTF-8 \
-d api \
-t "$(capitalize $(PROJECT)) $(VERSION)" \
-keep-code \
-colorize-code \
-sort \
-intro index.txt \
-I ../lib \
-thread \
../lib/*.mli ../lib/*.ml
doc: odoc api/index.html
################################################################################
# OTAGS Support
TAGS_INCLUDE=-I $(shell ocamlfind query sexplib.syntax) \
-I $(shell ocamlfind query type_conv)
TAGS_LINK=-pa pa_type_conv.cma -pa pa_sexp_conv.cma
TAGS_SOURCES=$(shell find src -name "*.ml")
TAGS:
otags $(TAGS_INCLUDE) $(TAGS_LINK) -o TAGS $(TAGS_SOURCES)
################################################################################
# Install and Uninstall
# - libraries, app, and doc
# - support for findlib and OPAM
if $(not $(defined OPAM_PACKAGE_NAME))
OPAM_PACKAGE_NAME = $(PROJECT)
export
_build/META:
echo "description = \"$(DESCRIPTION)\"" > $@
echo "version = \"$(VERSION)\"" >> $@
echo "requires = \"$(LIB_PACKAGES)\"" >> $@
echo "archive(byte) = \"$(LIB_NAME).cma\"" >> $@
echo "archive(native) = \"$(LIB_NAME).cmxa\"" >> $@
echo "exists_if = \"$(LIB_NAME).cma\"" >> $@
echo "" >> $@
echo "package \"ez\" (" >> $@
echo " description = \"$(DESCRIPTION)\"" >> $@
echo " version = \"$(VERSION)\"" >> $@
echo " requires = \"$(LIB_EZ_PACKAGES) $(PROJECT)\"" >> $@
echo " archive(byte) = \"$(LIB_EZ_NAME).cma\"" >> $@
echo " archive(native) = \"$(LIB_EZ_NAME).cmxa\"" >> $@
echo " exists_if = \"$(LIB_EZ_NAME).cma\"" >> $@
echo ")" >> $@
echo "" >> $@
echo "package \"lwt\" (" >> $@
echo " description = \"$(DESCRIPTION)\"" >> $@
echo " version = \"$(VERSION)\"" >> $@
echo " requires = \"$(LIB_LWT_PACKAGES) $(PROJECT)\"" >> $@
echo " archive(byte) = \"$(LIB_LWT_NAME).cma\"" >> $@
echo " archive(native) = \"$(LIB_LWT_NAME).cmxa\"" >> $@
echo " exists_if = \"$(LIB_LWT_NAME).cma\"" >> $@
echo ")" >> $@
echo "" >> $@
echo "package \"async\" (" >> $@
echo " description = \"$(DESCRIPTION)\"" >> $@
echo " version = \"$(VERSION)\"" >> $@
echo " requires = \"$(LIB_ASYNC_PACKAGES) $(PROJECT)\"" >> $@
echo " archive(byte) = \"$(LIB_ASYNC_NAME).cma\"" >> $@
echo " archive(native) = \"$(LIB_ASYNC_NAME).cmxa\"" >> $@
echo " exists_if = \"$(LIB_ASYNC_NAME).cma\"" >> $@
echo ")" >> $@
install_lib: uninstall_lib _build/META
ocamlfind install $(PROJECT) \
_build/META \
-optional \
_build/lib/*.[ao] \
_build/lib/*.cm[aiox] \
_build/lib/*.cmx[as] \
_build/lib/$(PROJECT).ml \
_build/lib/*.mli \
_build/lib_{ez,lwt,async}/*.[ao] \
_build/lib_{ez,lwt,async}/*.cm[aiox] \
_build/lib_{ez,lwt,async}/*.cmx[as] \
_build/lib_{ez,lwt,async}/$(PROJECT)_*.ml \
-dll _build/lib/*.so
uninstall_lib:
ocamlfind remove $(PROJECT)
if $(COMPILE_APP)
install_app: _build/app/$(APP_NAME)
echo "Installing $< in $(BINDIR)"
mkdir -p $(BINDIR)
cp -f _build/app/$(APP_NAME).run $(BINDIR)/$(APP_NAME)
cp -f _build/app/$(APP_NAME).opt $(BINDIR)/$(APP_NAME)
uninstall_app:
echo "Removing $(APP_NAME) from $(BINDIR)"
rm -f $(BINDIR)/$(APP_NAME)
install_doc: doc
echo "Installing documentation in $(DOCDIR)"
rm -rf $(DOCDIR)
mkdir -p $(DOCDIR)
cp -r _build/doc/api $(DOCDIR)
$(OPAM_PACKAGE_NAME).install:
echo $"bin: [" > $@
echo " "\"?_build/app/$(APP_NAME).run\" {\"$(APP_NAME)\"} >> $@
echo " "\"?_build/app/$(APP_NAME).opt\" {\"$(APP_NAME)\"} >> $@
echo $"]" >> $@