forked from biocaml/biocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOMakeroot
324 lines (277 loc) · 9.93 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
open build/OCaml
DefineCommandVars()
################################################################################
.PHONY: clean distclean install install_library uninstall uninstall_library \
test install_app uninstall_app doc install_doc dist configure print_conf
USE_OCAMLFIND = true
if $(not $(OCAMLFIND_EXISTS))
eprintln(This project requires ocamlfind, but is was not found.)
eprintln(You need to install ocamlfind and run "omake --configure".)
exit 1
.INCLUDE: local_configuration.om
if $(not $(file-exists local_configuration.om))
echo "# Default configuration" > local_configuration.om
echo "COMPILE_BIOCAML_APP=true" >> local_configuration.om
echo "COMPILE_BIOCAML_TESTS=true" >> local_configuration.om
echo "INSTALL_PREFIX=$(PWD)/usr" >> local_configuration.om
configurable(user_var,local_var) =
if $(defined $(user_var))
echo "User defined $(user_var): $(getvar $(user_var))"
echo "$(local_var)=$(getvar $(user_var))" >> local_configuration.om
else
echo "Keeping previous $(user_var): $(getvar $(local_var))"
configure:
configurable(BUILD_APP, COMPILE_BIOCAML_APP)
configurable(BUILD_TESTS, COMPILE_BIOCAML_TESTS)
configurable(PREFIX, INSTALL_PREFIX)
INSTALL_BINDIR=$(INSTALL_PREFIX)/bin/
INSTALL_DOCDIR=$(INSTALL_PREFIX)/share/doc
DefineCommandVars()
# We call DefineCommandVars so that the user can keep overriding the
# previous variables from command line
print_conf:
echo "COMPILE_BIOCAML_APP: $(COMPILE_BIOCAML_APP)"
echo "COMPILE_BIOCAML_TESTS: $(COMPILE_BIOCAML_TESTS)"
echo "INSTALL_PREFIX: $(INSTALL_PREFIX)"
echo "INSTALL_BINDIR: $(INSTALL_BINDIR)"
echo "INSTALL_DOCDIR: $(INSTALL_DOCDIR)"
NATIVE_ENABLED = $(OCAMLOPT_EXISTS)
BYTE_ENABLED = true
OCAMLFLAGS = -bin-annot -annot -warn-error P -thread
OCAMLCFLAGS =
OCAMLOPTFLAGS =
OCAML_LINK_FLAGS +=
OCAML_BYTE_LINK_FLAGS =
OCAML_NATIVE_LINK_FLAGS =
OCAMLFINDFLAGS = -syntax camlp4o
PROJECT_NAME= biocaml
PROJECT_VERSION= 0.3.0-dev
LIB_NAME=$(PROJECT_NAME)
LIB_VERSION=$(PROJECT_VERSION)
LIB_MODULES[] =
biocaml
biocaml_internal_pervasives
biocaml_transform
biocaml_msg
biocaml_zip
biocaml_bam
biocaml_pos
biocaml_about
biocaml_accu
biocaml_bar
biocaml_bed
biocaml_bpmap
biocaml_cel
biocaml_chr
biocaml_entrez
biocaml_fasta
biocaml_fastq
biocaml_genomeMap
biocaml_gff
biocaml_histogram
biocaml_interval_tree
biocaml_iset
biocaml_jaspar
biocaml_line
biocaml_lines
biocaml_math
biocaml_phred_score
biocaml_psl
biocaml_pwm
biocaml_range
biocaml_roc
biocaml_romanNum
biocaml_rSet
biocaml_sam
biocaml_sbml
biocaml_seq
biocaml_solexa_score
biocaml_sgr
biocaml_strandName
biocaml_stream
biocaml_streamable
biocaml_track
biocaml_tags
biocaml_vcf
biocaml_wig
biocaml_mzData
biocaml_table
biocaml_transcripts
LIB_STUBS= biocaml_pwm_stub biocaml_mzData_stubs
LIB_DESCRIPTION=The OCaml Bioinformatics Library <http://biocaml.org>
LIB_SOURCES= $(add-wrapper src/lib/, .ml, $(LIB_MODULES))
DEPENDENCIES=core threads zip unix xmlm pcre
PACKAGES= $(DEPENDENCIES) sexplib.syntax
APP_NAME=$(PROJECT_NAME)
APP_MODULES[]=
biocaml_app_bed_operations
biocaml_app_random
biocaml_app_common
biocaml_app_transform
biocaml_app_count_alignments
biocaml_main
biocaml_app_demux
biocaml_app_entrez
APP_PACKAGES= flow
UNIT_TESTS_NAME=biocaml_unit_test
UNIT_TESTS[]=
test_bed
test_fasta
test_gff
test_interval_tree
test_phred_score
test_pwm
test_roc
test_rset
test_sam
test_stream
test_table
test_track
test_vcf
test_wig
test_zip
UNIT_TESTS_PACKAGES= oUnit
# Run the tests' main executable
test: _build/tests/$(UNIT_TESTS_NAME)
$<
BENCHMARKS_NAME=biocaml_benchmarks
BENCHMARKS[]=
benchmark_zip
BENCHMARKS_PACKAGES=
clean:
rm -fr _build
distclean: clean
rm -fr OMakefile.omc OMakeroot.omc .omakedb .omakedb.lock local_configuration.om
install: install_library install_app
uninstall: uninstall_library uninstall_app
install_app: _build/app/$(APP_NAME)
echo "Installing $< in $(INSTALL_BINDIR)"
mkdir -p $(INSTALL_BINDIR)
install $< $(INSTALL_BINDIR)
uninstall_app:
echo "Removing $(APP_NAME) from $(BINDIR)"
rm -f $(INSTALL_BINDIR)/$(APP_NAME)
#
# Create _build/dist/biocaml-x.y.z.tar.gz
#
DIST_FILES=Changes INSTALL LICENSE OMakeroot README.md src
dist:
rm -fr _build/dist/
mkdir -p _build/dist/$(PROJECT_NAME)-$(PROJECT_VERSION)/
cp -r $(DIST_FILES) _build/dist/$(PROJECT_NAME)-$(PROJECT_VERSION)/
cd _build/dist/ && tar cvfz $(PROJECT_NAME)-$(PROJECT_VERSION).tar.gz \
$(PROJECT_NAME)-$(PROJECT_VERSION) \
&& md5sum $(PROJECT_NAME)-$(PROJECT_VERSION).tar.gz > \
_build/dist/$(PROJECT_NAME)-$(PROJECT_VERSION).tar.gz.md5
# → wierd path to the file, required because OMake interprets it
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)
################################################################################
# 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)))
################################################################################
# Build of the documentation:
#
DOCLIB_DIR=_build/doclib/
$(DOCLIB_DIR)/biocaml.css: src/doc/biocaml.css
mkdir -p _build/doclib
cp src/doc/biocaml.css $@
$(DOCLIB_DIR)/index.html: $(DOCLIB_DIR)/biocaml.css _build/biohtml.cmo _build/lib/$(LIB_NAME).cma
cp src/doc/figures/* $(DOCLIB_DIR)/
ocamlfind ocamldoc \
-g _build/biohtml.cmo \
-css-style biocaml.css \
-syntax camlp4o -package xmlm,zip,pcre,core,sexplib.syntax \
-charset UTF-8 -d $(DOCLIB_DIR) -t "The Biocaml Library" \
-keep-code -colorize-code _build/lib/*.mli _build/lib/*.ml \
-sort -I _build/lib/. \
-intro src/doc/intro.txt
_build/biohtml.cmo: src/odoc/biohtml.ml
ocamlfind ocamlc -c src/odoc/biohtml.ml -o $@ -I +ocamldoc -I +compiler-libs
doc: $(DOCLIB_DIR)/index.html
install_doc: doc
echo "Installing documentation in $(INSTALL_DOCDIR)/biocaml"
rm -fr $(INSTALL_DOCDIR)/biocaml
mkdir -p $(INSTALL_DOCDIR)
cp -r _build/doclib $(INSTALL_DOCDIR)/biocaml
################################################################################
# Definition of the sub-directories
#
ensure_path(path) =
mkdir -p $(path)
.SUBDIRS: .
ensure_path(_build/lib)
ensure_path(_build/app)
ensure_path(_build/tests)
ensure_path(_build/benchmark)
vmount(-l, src/, _build/)
.SUBDIRS: _build/lib
OCAMLPACKS[] = $(PACKAGES)
biocaml_about.ml: :value: $(PROJECT_VERSION)
echo '(** Version string of the library: ["$(PROJECT_VERSION)"] *)' > $@
echo 'let version = "$(PROJECT_VERSION)"' >> $@
META:
echo "description = \"$(LIB_DESCRIPTION)\"" > META
echo "version = \"$(LIB_VERSION)\"" >> META
echo "archive(byte) = \"$(LIB_NAME).cma\"" >> META
echo "archive(native) = \"$(LIB_NAME).cmxa\"" >> META
echo "requires = \"$(DEPENDENCIES)\"" >> META
install_library: $(LIB_NAME).cma $(LIB_NAME).cmxa META uninstall_library
ocamlfind install $(LIB_NAME) META \
*.cm[iox] *.o $(LIB_NAME).cma $(LIB_NAME).cmxa *.a -dll *.so
uninstall_library:
ocamlfind remove $(LIB_NAME)
.DEFAULT: $(OCamlLibraryWithCFiles biocaml, $(LIB_MODULES), $(LIB_STUBS))
.SUBDIRS: _build/app
OCAML_LIBS = ../lib/biocaml
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(PACKAGES) $(APP_PACKAGES)
%.ml: ../lib/biocaml.cma
if $(COMPILE_BIOCAML_APP)
echo "conf: Building biocaml application"
.DEFAULT: $(OCamlProgram $(APP_NAME), $(APP_MODULES))
.SUBDIRS: _build/tests
OCAML_LIBS = ../lib/biocaml
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(PACKAGES) $(UNIT_TESTS_PACKAGES)
%.ml: ../lib/biocaml.cma
if $(COMPILE_BIOCAML_TESTS)
echo "conf: Building biocaml tests"
.DEFAULT: $(OCamlProgram $(UNIT_TESTS_NAME), main $(UNIT_TESTS))
.SUBDIRS: _build/benchmark
OCAML_LIBS = ../lib/biocaml
OCAMLINCLUDES += $(dir ../lib/)
OCAMLPACKS[] = $(PACKAGES) $(BENCHMARKS_PACKAGES)
%.ml: ../lib/biocaml.cma
if $(COMPILE_BIOCAML_TESTS)
echo "conf: Building biocaml benchmarks"
.DEFAULT: $(OCamlProgram $(BENCHMARKS_NAME), $(BENCHMARKS))