-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOcamlrules.mk.in
125 lines (92 loc) · 3.03 KB
/
Ocamlrules.mk.in
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
all_sources=$(LIB_MODULES) $(NON_LIB_MODULES)
sources_mli=$(LIB_MODULES:%.ml=%.mli)
native_cmx=$(all_sources:%.ml=%.cmx)
byte_cmo=$(all_sources:%.ml=%.cmo)
neutral_cmi=$(sources_mli:%.mli=%.cmi)
test_native_cmx=$(TEST_MODULES:%.ml=%.cmx)
test_byte_cmo=$(TEST_MODULES:%.ml=%.cmo)
test_native=$(TEST_MODULES:%.ml=%.native_test)
test_byte=$(TEST_MODULES:%.ml=%.byte_test)
ifdef PACK
byte_targets_deps=$(PACK).cmo
native_targets_deps=$(PACK).cmx
OCAMLOPT_OPTS:=-for-pack \
$(shell echo $(PACK) | sed 's/\([a-z]\)\([a-zA-Z0-9]*\)/\u\1\2/g') \
$(OCAMLOPT_OPTS)
else
byte_targets_deps=$(byte_cmo)
native_targets_deps=$(native_cmx)
endif
.PHONY: byte-code native-code clean
.PHONY: test-byte-code test-native-code test
$(BYTE_TARGETS): $(byte_targets_deps)
$(NATIVE_TARGETS): $(native_targets_deps)
$(PACK).cmx: $(native_cmx)
ocamlfind ocamlopt -pack -o $@ $^
$(PACK).cmo: $(byte_cmo)
ocamlfind ocamlc -pack -o $@ $^
$(native_cmx): $(EXTERNAL_DEPS)
$(byte_cmo): $(EXTERNAL_DEPS)
$(neutral_cmi): $(EXTERNAL_DEPS)
$(test_native): $(test_native_cmx)
$(test_byte): $(test_byte_cmo)
byte-code: $(BYTE_TARGETS)
native-code: $(NATIVE_TARGETS)
test-byte-code: $(test_byte)
test-native-code: $(test_native)
$(test_native_cmx): $(TEST_DEPS)
$(test_byte_cmo): $(TEST_DEPS)
test: $(test_byte) $(test_native)
for test in $^ ; do \
./$$test ; \
done
%.cmxa: %.cmx
ifeq ($@, $(PACK).cmxa)
ocamlfind ocamlopt $(OCAMLOPT_OPTS) -a -thread -I +camlp4 -o $@ $(PACK).cmx
else
ocamlfind ocamlopt $(OCAMLOPT_OPTS) -a -thread -I +camlp4 -o $@ $^
endif
%.cma: %.cmo
ifeq ($@, $(PACK).cma)
ocamlfind ocamlc $(OCAMLC_OPTS) -custom -a -thread -I +camlp4 -o $@ $(PACK).cmo
else
ocamlfind ocamlc $(OCAMLC_OPTS) -custom -a -thread -I +camlp4 -o $@ $^
endif
%.cmx: %.ml
ocamlfind ocamlopt -thread -I +camlp4 $(OCAMLOPT_OPTS) $(CAMLP4) -c \
$(patsubst %.cmx,%.ml,$@)
%.cmi: %.mli
ocamlfind ocamlc -thread -I +camlp4 $(OCAMLC_OPTS) -c $(patsubst %.cmi,%.mli,$@)
%.cmo: %.ml
ocamlfind ocamlc -thread -I +camlp4 $(OCAMLC_OPTS) $(CAMLP4) -c \
$(patsubst %.cmo,%.ml,$@)
%.native: %.cmx
ocamlfind ocamlopt $(OCAMLOPT_OPTS) -thread -linkpkg -o $@ \
$(patsubst %.ml,%.cmx,$(shell \
ocamlfind ocamldep $(OCAMLDEP_OPTS) -sort $(patsubst %.cmx,%.ml,$^)))
%.native_test: %.cmx
ocamlfind ocamlopt $(OCAMLOPT_OPTS) -thread -linkpkg -g -o $@ \
$(patsubst %.native_test,%.cmx,$@)
%.byte: %.cmo
ocamlfind ocamlc $(OCAMLC_OPTS) -thread -custom -linkpkg -o $@ \
$(patsubst %.ml,%.cmo,$(shell \
ocamlfind ocamldep $(OCAMLDEP_OPTS) -sort $(patsubst %.cmo,%.ml,$^)))
%.byte_test: %.cmo
ocamlfind ocamlc $(OCAMLC_OPTS) -thread -custom -linkpkg -g -o $@ \
$(patsubst %.byte_test,%.cmo,$@)
.d: $(all_sources) $(sources_mli)
ocamlfind ocamldep $(OCAMLDEP_OPTS) $(CAMLP4) $(all_sources) $(sources_mli) > .d
clean:
-rm -f \
$(BYTE_TARGETS) \
$(NATIVE_TARGETS) \
$(native_cmx) \
$(byte_cmo) \
$(neutral_cmi) \
$(test_byte) \
$(test_native) \
$(test_byte_cmo) \
$(test_native_cmx) \
.d *.o *.a *.cmi
# This won't exist until it is generated, so .d needs to run first
-include .d