forked from ocsigen/js_of_ocaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (83 loc) · 3.57 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
MLOBJS= js.cmo dom.cmo typed_array.cmo dom_html.cmo file.cmo dom_events.cmo firebug.cmo lwt_js.cmo sys_js.cmo regexp.cmo CSS.cmo url.cmo form.cmo xmlHttpRequest.cmo event_arrows.cmo lwt_js_events.cmo json.cmo webGL.cmo webSockets.cmo keycode.cmo
MLINTFS= $(MLOBJS:.cmo=.mli)
COBJS= stubs$(OBJEXT)
OBJS=$(MLOBJS) $(COBJS)
JSON_OBJS=$(addprefix deriving_json/,deriving_Json_lexer.cmo deriving_Json.cmo)
include ../Makefile.conf
-include ../Makefile.local
ifneq "${DERIVING}" ""
PA_DERIVING=syntax/pa_deriving_Json.cmo
DERIVING_JSON=deriving_json.cma
ifeq "$(BEST)" "opt"
DERIVING_JSON += deriving_json.cmxs
ifeq "${NATDYNLINK}" "YES"
PA_DERIVING_NDL= syntax/pa_deriving_Json.cmx syntax/pa_deriving_Json.cmxs
endif
endif
endif
PA_JS= syntax/pa_js.cmo
ifeq "${BEST}" "opt"
ifeq "${NATDYNLINK}" "YES"
PA_JS_NDL= syntax/pa_js.cmx syntax/pa_js.cmxs
endif
endif
all: $(LIBNAME).cma \
${PA_JS} ${PA_JS_NDL} \
${PA_DERIVING} ${PA_DERIVING_NDL} \
${DERIVING_JSON}
$(LIBNAME).cma: $(OBJS)
ocamlmklib -o $(LIBNAME) $(OBJS)
deriving_json.cma: $(JSON_OBJS)
ocamlfind ocamlc -a -o $@ $^
deriving_json.cmxa: $(JSON_OBJS:.cmo=.cmx)
ocamlfind ocamlopt -a -o $@ $^
deriving_json.cmxs: deriving_json.cmxa
ocamlfind ocamlopt -shared -linkall -o $@ $^
syntax/pa_js.cmo: syntax/pa_js.ml
ocamlfind ocamlc -package camlp4.extend,camlp4.quotations -syntax camlp4o -c $<
syntax/pa_js.cmx: syntax/pa_js.ml
ocamlfind ocamlopt -package camlp4.extend,camlp4.quotations -syntax camlp4o -c $<
syntax/pa_js.cmxs: syntax/pa_js.cmx
ocamlfind ocamlopt -shared -linkall -o $@ $<
syntax/pa_deriving_Json.cmo: syntax/pa_deriving_Json.ml
ocamlfind ocamlc -package deriving.syntax.common,camlp4.quotations.o -syntax camlp4o -c $<
syntax/pa_deriving_Json.cmx: syntax/pa_deriving_Json.ml
ocamlfind ocamlopt -package deriving.syntax.common,camlp4.quotations.o -syntax camlp4o -c $<
syntax/pa_deriving_Json.cmxs: syntax/pa_deriving_Json.cmx
ocamlfind ocamlopt -shared -linkall -o $@ $<
%.cmo: %.ml syntax/pa_js.cmo
ocamlfind ocamlc -pp "camlp4o syntax/pa_js.cmo" -package lwt -c -g $<
%.cmi: %.mli
ocamlfind ocamlc -package lwt -I deriving_json -c $<
%.ml: %.mll
ocamllex $<
${JSON_OBJS}: %.cmo: %.ml ${PA_DERIVING}
ocamlfind ocamlc -package deriving.syntax.common -syntax camlp4o -ppopt ${PA_DERIVING} -I deriving_json -c $<
${JSON_OBJS:.cmo=.cmx}: %.cmx: %.ml ${PA_DERIVING}
ocamlfind ocamlopt -package deriving.syntax.common -syntax camlp4o -ppopt ${PA_DERIVING} -I deriving_json -c $<
%$(OBJEXT): %.c
ocamlfind ocamlc -package lwt -c $<
stubs.c: $(MLOBJS:cmo=ml)
(echo "#include <stdlib.h>"; \
echo "#include <stdio.h>"; \
echo "#define D(f) void f () { fprintf(stderr, \"Unimplemented Javascript primitive %s!\\\\n\", #f); exit(1); }"; \
(sed -n -e 's/.*external.*"\([^"%]*\)".*/D(\1)/p' $(MLOBJS:cmo=ml) | \
sort | uniq)) \
> stubs.c
clean:
rm -f *.cm[xioa] *.[ao] *.so *.cmx[sa]
rm -f syntax/*.cm[xioa] syntax/*.[ao] syntax/*.so syntax/*.cmx[sa]
rm -f deriving_json/*.cm[xioa] deriving_json/*.[ao] deriving_json/*.so
rm -f deriving_json/deriving_Json_lexer.ml
rm -f stubs.c
depend: syntax/pa_js.cmo ${PA_DERIVING}
ocamldep -pp "camlp4o syntax/pa_js.cmo" *.ml *.mli > .depend
ifneq "${DERIVING}" ""
${MAKE} --no-print-directory deriving_json/deriving_Json_lexer.ml
ls deriving_json/*.mli deriving_json/*.ml | \
grep -v deriving_Json_stdlib.mli | \
xargs ocamlfind ocamldep -I deriving_json -package deriving.syntax.common -syntax camlp4o -ppopt ${PA_DERIVING} >> .depend
@# camlp4 3.12.0 fails on (module type of ...)
ocamldep -I deriving_json deriving_json/deriving_Json_stdlib.mli >> .depend
endif
include .depend