-
Notifications
You must be signed in to change notification settings - Fork 25
/
OMakefile
548 lines (476 loc) · 13.7 KB
/
OMakefile
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
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
########################################################################
# Configuration.
#
###################################
# DEV MODE
# Turn it off when release
# BYTE_ENABLED=true
# NATIVE_ENABLED=false
###################################
open build/C
open build/svn_realclean
include mk/defaults
include mk/make_gen
BOOTDIR=$(dir boot)
BUILDDIR=$(dir .)
.PHONY: realclean distclean clean install all main
.PHONY: dvi html info pdf ps txt # documentation targets
#
# Location of the OCaml library
#
if $(not $(defined CAMLLIB))
CAMLLIB = $(dir $(string $(getenv CAMLLIB, $(getenv OCAMLLIB, $(OCAMLLIB)))))
export
#
# Architecture-specific configuration
#
if $(equal $(OSTYPE), Win32)
#
# Extra options for the C compiler
#
if $(equal $(CCOMPTYPE), msvc)
CFLAGS += /MT /DWIN32 /W4
export
else
CFLAGS += -DWIN32 -g -O2 -Wall -Wno-unused -isystem$(CAMLLIB)
export
#
# Don't build man pages
#
MAN_ENABLED = false
#
# Always use threads
#
THREADS_ENABLED = true
export
else
#
# Extra options for the C compiler
#
CFLAGS += -g -O2 -Wall -Wno-unused
#
# We never need threads on Unix
#
THREADS_ENABLED = false
export
#
# General options
#
SCANNER_MODE = error
#
# OCaml options
#
OCAMLFLAGS[] = -safe-string -strict-sequence -g -w -a-40 -I +unix
if $(THREADS_ENABLED)
OCAMLFLAGS += -thread
export
compiler_config(a_compiler) =
config = $(Map)
foreach(key_value_line => ..., $(shella $(a_compiler) -config))
export config
lex($(open-in-string $(key_value_line)))
case $'^\([^:]*\):[[:blank:]]*\(.*\)$'
export config
config = $(config.add $1, $2)
return $(config)
static. =
OCAMLOPT_OPTIMIZER_FLAGS[] =
if $(NATIVE_ENABLED)
OCAMLOPT_CONFIG = $(compiler_config $(OCAMLOPT))
ConfMsgChecking($'if ocamlopt was compiled with flambda')
if $(and $(OCAMLOPT_CONFIG.mem flambda), $(equal $(OCAMLOPT_CONFIG.find flambda), true))
ConfMsgResult($'yes')
OCAMLOPT_OPTIMIZER_FLAGS[] = -O3
export
else
ConfMsgResult($'no')
export
OCAMLOPTFLAGS[] = $(OCAMLFLAGS) $(OCAMLOPT_OPTIMIZER_FLAGS)
#
# Support for profiling
#
if $(not $(defined NATIVE_PROFILE))
NATIVE_PROFILE = false
export
if $(NATIVE_PROFILE)
OCAMLOPTFLAGS += -p -inline 0
CFLAGS += -pg
if $(equal $(NATIVE_PROFILE), compact)
OCAMLOPTFLAGS += -compact
export
export
#
# Libraries (without suffixes)
#
OCAML_OTHER_LIBS = unix
if $(THREADS_ENABLED)
OCAML_OTHER_LIBS += threads
export
#
# C options
#
INCLUDES += $(CAMLLIB) .
EXTRA_CLIBS[] =
if $(READLINE_ENABLED)
CFLAGS += $(READLINE_CFLAGS)
EXTRA_CLIBS += $(READLINE_CLIBS)
export
if $(NCURSES_ENABLED)
CFLAGS += $(NCURSES_CFLAGS)
EXTRA_CLIBS += $(NCURSES_CLIBS)
export
if $(FAM_ENABLED)
CFLAGS += $(FAM_CFLAGS)
EXTRA_CLIBS += $(FAM_CLIBS)
export
OCAML_LINK_FLAGS = $(mapprefix -cclib, $(set $(EXTRA_CLIBS)))
#
# Name of the genmagic program
#
VERSION_TXT = $(file version.txt)
GENMAGIC = $(file src/magic/omake_gen_magic)
########################################################################
# Clean up
#
CLEAN = rm -rf *.cm* *~ .\#* *.o *.obj *.a *.lib *.exe *.omc *.install *.tmp
clean:
$(CLEAN) boot .config.omc .config.local.omc .omakedb* mk/*.omc .omake omake-boot$(EXE) lib/*.default download
if $(not $(defined FORCE_REALCLEAN))
FORCE_REALCLEAN = false
export
realclean: clean
svn_realclean $(if $(FORCE_REALCLEAN), -f) -i .omakedb -i .omakedb.lock -i .config -i .config.local
########################################################################
# Source code
#
.SUBDIRS: src
########################################################################
# Packaging
#
.PHONY: rpm tar zip pkg dmg osxclean publish
.PHONY: package
VERSION=$(string $(cat version.txt))
BASENAME = omake-$(VERSION)
PUBFILES[] =
README.md
README.WIN32
INSTALL
LICENSE
LICENSE.OMake
ChangeLog
ChangeLog_old.txt
CONTRIBUTORS.org
omake.spec
omake.spec.in
omake.aip
version.txt
OMakefile
OMakeroot
Makefile
configure
configure.ml
build
build.ml
make
make.ml
src/OMakefile
src/Makefile
src/*/OMakefile
src/*/*.ml
src/*/*.mly
src/*/*.mll
src/*/*.mli
src/*/*.h
src/*/*.c
src/env/omake_ast_parse.input
lib/OMakefile.default
lib/OMakeroot.default
lib/OMakeroot.install
lib/OMakeroot.om
lib/Pervasives.install
lib/Pervasives.om
lib/boot/Default
lib/boot/License
lib/build/*.install
lib/build/*.om
lib/configure/*.install
lib/configure/*.om
lib/parse/C/*.install
lib/parse/C/*.om
lib/parse/LaTeX/*.install
lib/parse/LaTeX/*.om
lib/web/*.install
lib/web/*.om
mk/defaults
mk/make_config
mk/make_gen
mk/osconfig_mingw.mk
mk/osconfig_msvc.mk
mk/osconfig_unix.mk
doc/OMakefile
doc/omake.1
doc/html/*.html
doc/html/*.css
doc/images/*.ai
doc/images/*.eps
doc/images/*.gif
doc/images/*.psd
doc/info/omake-doc.info
doc/info/omake-doc.info-*
doc/ps/omake-doc.pdf
doc/src/*.hva
doc/src/*.sty
doc/src/*.tex
doc/txt/omake-doc.txt
bench/OMakefile
bench/mandel/Test1
osx_resources/Description.plist
osx_resources/Info.plist.in
osx_resources/OMake.pmproj
osx_resources/installer_files/License.txt
osx_resources/installer_files/preflight
osx_resources/installer_files/ReadMe.txt
test/awk/Test2/stdout.expected
test/awk/Test2/awk.osh
test/awk/Test2/run.osh
test/awk/Test3/stdout.expected
test/awk/Test3/awk.osh
test/awk/Test3/run.osh
test/awk/Test1/stdout.expected
test/awk/Test1/awk.osh
test/awk/Test1/run.osh
test/awk/Awk.out
test/awk/Awk.in
test/awk/Subst.in
test/awk/Test4/Subst.in
test/awk/Test4/Subst.out.expected
test/awk/Test4/OMakeroot
test/awk/Test4/OMakefile
test/awk/Test4/run.osh
test/syntax/Test2
test/syntax/Test3
test/syntax/Test1
test/exec/Test1/xxx
test/exec/Test1/OMakeroot
test/exec/Test1/OMakefile
test/parse/C/Test2/test.c
test/parse/C/Test2/OMakeroot
test/parse/C/Test2/OMakefile
test/parse/C/Test3/test.c
test/parse/C/Test3/OMakeroot
test/parse/C/Test3/OMakefile
test/parse/C/Test1/test.c
test/parse/C/Test1/OMakeroot
test/parse/C/Test1/OMakefile
test/parse/C/test2.c
test/exn/Test2
test/exn/Test3/exn.om
test/exn/Test3/run.osh
test/exn/Test5
test/exn/Test4
test/vmount/Test1/src/foo.c
test/vmount/Test1/src/OMakefile
test/vmount/Test1/build/.dummy
test/vmount/Test1/OMakeroot
test/vmount/Test1/OMakefile
test/simple/Test7
test/simple/Test2/a/x/.dummy
test/simple/Test2/a/y/.dummy
test/simple/Test2/OMakeroot
test/simple/Test2/OMakefile
test/simple/Test9
test/simple/Test10
test/simple/Test3/OMakeroot
test/simple/Test3/OMakefile
test/simple/Test5
test/simple/Test1/OMakeroot
test/simple/Test1/OMakefile
test/simple/Test12
test/simple/Test8/stdout.expected
test/simple/Test8/simple.om
test/simple/Test8/run.osh
test/simple/Test11
test/simple/Test4/stdout.expected
test/simple/Test4/simple.om
test/simple/Test4/run.osh
test/simple/Test6
test/diff.om
test/targets/Test2/OMakeroot
test/targets/Test2/OMakefile
test/targets/Test3/OMakeroot
test/targets/Test3/OMakefile
test/targets/Test3/run.osh
test/targets/Test5/OMakeroot
test/targets/Test5/run.osh
test/targets/Test1/OMakeroot
test/targets/Test1/OMakefile
test/targets/Test4/OMakeroot
test/curry/Test2
test/curry/Test3
test/curry/Test5
test/curry/Test1
test/curry/Test4
test/object/Test13
test/object/Test09
test/object/Test10
test/object/Test17
test/object/Test18
test/object/Test15
test/object/Test16
test/object/Test11
test/object/Test03
test/object/Test14
test/object/Test05
test/object/Test07
test/object/Test06
test/object/Test04
test/object/Test08
test/object/Test02
test/object/Test01/stdout.expected
test/object/Test01/OMakeroot
test/object/Test01/OMakefile
test/object/Test01/run.osh
test/object/Test01/object.om
test/regex/Test2
test/regex/Test3
test/regex/Test1
test/regex/Test4
test/memo/Test2/stdout.expected
test/memo/Test2/OMakeroot
test/memo/Test2/run.osh
test/memo/Test3/stdout.expected
test/memo/Test3/OMakeroot
test/memo/Test3/run.osh
test/memo/Test5/stdout.expected
test/memo/Test5/run.osh
test/memo/Test5/fib.om
test/memo/Test1/stdout.expected
test/memo/Test1/OMakeroot
test/memo/Test1/run.osh
test/memo/Test4/stdout.expected
test/memo/Test4/memo.om
test/memo/Test4/run.osh
test/memo/Test6/test.om
test/memo/Test6/OMakeroot
test/OMakefile
test/README
test/lazy/Test1
test/return/Test2
test/return/Test1
test/static/Test2/stdout.expected
test/static/Test2/OMakeroot
test/static/Test2/run.osh
test/static/Test3/stdout.expected
test/static/Test3/OMakeroot
test/static/Test3/run.osh
test/static/Test1/stdout.expected
test/static/Test1/OMakeroot
test/static/Test1/run.osh
test/calculator/Test
test/calculator/Test.input1
test/calculator/Test.input2
test/keyword/Test2
test/keyword/Test3
test/keyword/Test5
test/keyword/Test1
test/keyword/Test4
test/keyword/Test6
test/shell/Test7/OMakeroot
test/shell/Test2/stdout.expected
test/shell/Test2/OMakeroot
test/shell/Test2/OMakefile
test/shell/Test2/run.osh
test/shell/Test3/run.osh
test/shell/Test5
test/shell/Test1/shell.om
test/shell/Test1/run.osh
test/shell/Test4/run.osh
test/shell/Test6/run.osh
PUBFILES_EXCLUDE[] =
src/env/omake_ast_parse.mly
src/libmojave/lm_thread_core.ml
src/libmojave/lm_thread_pool.ml
src/magic/omake_magic.ml
src/shell/omake_shell_sys.ml
package: packages/$(BASENAME).tar.gz
packages/$(BASENAME):
rm -rf packages/$(BASENAME)
mkdir -p packages/$(BASENAME)
foreach(pat => ..., $(PUBFILES))
files = $(glob $(pat))
foreach(file => ..., $(files))
if $(test -f $(file))
mkdir -p packages/$(BASENAME)/$(dirname $(file))
cp $(file) packages/$(BASENAME)/$(file)
foreach(file => ..., $(PUBFILES_EXCLUDE))
rm -f packages/$(BASENAME)/$(file)
packages/$(BASENAME).tar.gz: packages/$(BASENAME)
section
cd packages
rm -f $(BASENAME).tar.gz
tar czf $(BASENAME).tar.gz $(BASENAME)
.PHONY: clean-package
rm -rf packages/$(BASENAME)
rm -f packages/$(BASENAME).tar.gz
rpm: version.txt make_rpm make_checkout
./make_rpm
dmg: version.txt
./make_dmg dmg
pkg: version.txt
./make_dmg pkg
osxclean: version.txt
./make_dmg clean
omake.spec: omake.spec.in
echo $"%define index $(RELEASE)" > $@
echo $"Version: $(VERSION)" >> $@
cat $< >> $@
.DEFAULT: omake.spec
########################################################################
# Documentation
#
.SUBDIRS: doc
.PHONY: doc
doc: doc/txt doc/info doc/html doc/tex
########################################################################
# Standard library
#
.SUBDIRS: $(subdirs C, lib)
%.install: %.om $(GENMAGIC)$(EXE) $(VERSION_TXT)
$(GENMAGIC) -o $@ --version $(VERSION_TXT) --root $<
clean:
$(CLEAN)
STDLIBFILES = $(find lib -name *.om)
INSTALLFILES = $(replacesuffixes .om, .install, $(STDLIBFILES))
STDLIBNAMES = $(removesuffix .om, $(in lib, $(STDLIBFILES)))
BOOTFILES[] =
lib/boot/License
lib/boot/Default
DEFAULTFILES[] =
lib/OMakeroot.default
lib/OMakefile.default
lib/OMakeroot.default: $(BOOTFILES)
fprint($@, $(OMakeroot))
lib/OMakefile.default: $(BOOTFILES)
fprint($@, $(OMakefile))
########################################################################
# Installation
#
all: $(DEFAULTFILES) $(INSTALLFILES) $(ROOT)/src/Makefile
# omaketop
omaketop: src/clib/clib.a src/libmojave/lm.cma src/front/frt.cma src/top/boot_repl.cma src/magic/magic.cma src/ast/ast.cma src/ir/ir.cma src/env/env.cma src/eval/eval.cma src/shell/shell.cma src/exec/exec.cma src/build/build.cma src/builtin/builtin.cma
$(OCAMLC) -custom -verbose -I +compiler-libs -linkall ocamlcommon.cma ocamlbytecomp.cma ocamltoplevel.cma unix.cma src/clib/clib.a src/libmojave/lm.cma src/front/frt.cma src/top/boot_repl.cma src/magic/magic.cma src/ast/ast.cma src/ir/ir.cma src/env/env.cma src/eval/eval.cma src/shell/shell.cma src/exec/exec.cma src/build/build.cma src/builtin/builtin.cma -cclib -lreadline topstart.cmo -o $@
omakeutop:src/clib/clib.a src/libmojave/lm.cma src/front/frt.cma src/top/boot_repl.cma src/magic/magic.cma src/ast/ast.cma src/ir/ir.cma src/env/env.cma src/eval/eval.cma src/shell/shell.cma src/exec/exec.cma src/build/build.cma src/builtin/builtin.cma src/top/myutop.cmo
ocamlfind ocamlc -custom -o omakeutop -thread -linkpkg -linkall -predicates create_toploop \
-package compiler-libs.toplevel,utop src/clib/clib.a src/libmojave/lm.cma src/front/frt.cma src/top/boot_repl.cma src/magic/magic.cma src/ast/ast.cma src/ir/ir.cma src/env/env.cma src/eval/eval.cma src/shell/shell.cma src/exec/exec.cma src/build/build.cma src/builtin/builtin.cma -cclib -lreadline src/top/myutop.cmo
install: $(DEFAULTFILES) $(INSTALLFILES)
mkdir -p $(INSTALL_LIBDIR)/omake
cp -f -m 444 $(DEFAULTFILES) $(INSTALL_LIBDIR)/omake/
foreach(name => ..., $(STDLIBNAMES))
node = $(file $(INSTALL_LIBDIR)/omake/$(name).om)
mkdir -p $(dirof $(node))
cp -f -m 444 lib/$(name).install $(node)
########################################################################
# Testing
#
.PHONY: check bench
.SUBDIRS: test bench