-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
160 lines (136 loc) · 6.18 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
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
BOOT=_boot
OCAMLSRC=ocaml-src
CONFIG=$(OCAMLSRC)/config/Makefile
OCAMLRUN=$(OCAMLSRC)/byterun/ocamlrun
GENERATED=$(OCAMLSRC)/bytecomp/opcodes.ml
$(OCAMLRUN): $(CONFIG)
touch $(OCAMLSRC)/byterun/.depend && $(MAKE) -C $(OCAMLSRC)/byterun depend
$(MAKE) -C $(OCAMLSRC)/byterun all
touch $(OCAMLSRC)/asmrun/.depend && $(MAKE) -C $(OCAMLSRC)/asmrun depend
$(MAKE) -C $(OCAMLSRC)/asmrun all
.PHONY: configure-ocaml
configure-ocaml:
rm -f $(OCAMLSRC)/boot/ocamlc $(OCAMLSRC)/boot/ocamllex
find $(OCAMLSRC) -iname .depend | xargs rm -f
touch $(OCAMLSRC)/.depend $(OCAMLSRC)/stdlib/.depend $(OCAMLSRC)/lex/.depend
cd $(OCAMLSRC) && bash configure
$(MAKE) -C $(OCAMLSRC) ocamlyacc && cp $(OCAMLSRC)/yacc/ocamlyacc $(OCAMLSRC)/boot
$(MAKE) -C $(OCAMLSRC)/lex parser.ml
# Here, including $(CONFIG) would provide $(ARCH), but it leads to a recursive
# dependency because its rule has a dependency that reloads this Makefile.
.PHONY: ocaml-generated-files
ocaml-generated-files: $(OCAMLRUN) lex make_opcodes cvt_emit
$(MAKE) -C $(OCAMLSRC)/stdlib sys.ml
$(MAKE) -C $(OCAMLSRC) utils/config.ml
$(MAKE) -C $(OCAMLSRC) parsing/parser.ml
cd $(OCAMLSRC); ../miniml/interp/lex.sh parsing/lexer.mll
$(MAKE) -C $(OCAMLSRC) bytecomp/runtimedef.ml
miniml/interp/make_opcodes.sh -opcodes < $(OCAMLSRC)/byterun/caml/instruct.h > $(OCAMLSRC)/bytecomp/opcodes.ml
$(MAKE) -C $(OCAMLSRC) asmcomp/arch.ml asmcomp/proc.ml asmcomp/selection.ml asmcomp/CSE.ml asmcomp/reload.ml asmcomp/scheduling.ml
miniml/interp/cvt_emit.sh < $(OCAMLSRC)/asmcomp/$(shell cat $(CONFIG) | grep '^ARCH=' | cut -f2 -d=)/emit.mlp > $(OCAMLSRC)/asmcomp/emit.ml
.PHONY: lex
lex: $(OCAMLRUN)
touch miniml/interp/.depend
$(MAKE) -C miniml/interp lex.byte
.PHONY: make_opcodes
make_opcodes: $(OCAMLRUN) lex
$(MAKE) -C miniml/interp make_opcodes.byte
.PHONY: cvt_emit
cvt_emit: $(OCAMLRUN) lex
$(MAKE) -C miniml/interp cvt_emit.byte
.PHONY: makedepend
makedepend: $(OCAMLRUN) lex
$(MAKE) -C miniml/interp makedepend.byte
.PHONY: clean-ocaml-config
clean-ocaml-config:
cd $(OCAMLSRC) && make distclean
# this dependency is fairly coarse-grained, so feel free to
# use clean-ocaml-config if make a small change to $(OCAMLSRC)
# that you believe does require re-configuring.
$(CONFIG): $(OCAMLSRC)/VERSION
$(MAKE) configure-ocaml
$(GENERATED): $(OCAMLRUN) lex make_opcodes
$(MAKE) ocaml-generated-files
$(BOOT)/driver: $(OCAMLSRC)/driver $(OCAMLSRC)/otherlibs/dynlink $(CONFIG) $(GENERATED)
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
cp $(OCAMLSRC)/otherlibs/dynlink/dynlink.mli $@/compdynlink.mli
grep -v 'REMOVE_ME for ../../debugger/dynlink.ml' \
$(OCAMLSRC)/otherlibs/dynlink/dynlink.ml > $@/compdynlink.mlbyte
$(BOOT)/byterun: $(OCAMLSRC)/byterun $(CONFIG) $(GENERATED)
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
$(BOOT)/bytecomp: $(OCAMLSRC)/bytecomp $(CONFIG) $(GENERATED)
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
$(BOOT)/typing: $(OCAMLSRC)/typing $(CONFIG) $(GENERATED)
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
$(BOOT)/parsing: $(OCAMLSRC)/parsing $(CONFIG) $(GENERATED) patches/parsetree.patch lex
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
#patch $(BOOT)/parsing/parsetree.mli patches/parsetree.patch
$(BOOT)/utils: $(OCAMLSRC)/utils $(CONFIG) $(GENERATED) patches/disable-profiling.patch
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
cp $(BOOT)/utils/profile.ml $(BOOT)/utils/profile.ml.noprof
patch $(BOOT)/utils/profile.ml.noprof patches/disable-profiling.patch
$(BOOT)/stdlib: $(OCAMLSRC)/stdlib $(CONFIG) $(GENERATED) patches/compflags.patch
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
patch $(BOOT)/stdlib/Compflags patches/compflags.patch
awk -f $(BOOT)/stdlib/expand_module_aliases.awk < $(BOOT)/stdlib/stdlib.mli > $(BOOT)/stdlib/stdlib.pp.mli
awk -f $(BOOT)/stdlib/expand_module_aliases.awk < $(BOOT)/stdlib/stdlib.ml > $(BOOT)/stdlib/stdlib.pp.ml
cp $(OCAMLSRC)/asmrun/libasmrun.a $(BOOT)/stdlib/
cp Makefile.stdlib $(BOOT)/stdlib/Makefile
COPY_TARGETS=\
$(BOOT)/bytecomp \
$(BOOT)/byterun \
$(BOOT)/driver \
$(BOOT)/parsing \
$(BOOT)/stdlib \
$(BOOT)/typing \
$(BOOT)/utils
.PHONY: copy
copy: $(COPY_TARGETS)
cp Makefile.ocamlc $(BOOT)/Makefile
.PHONY: ocamlrun
ocamlrun: $(OCAMLRUN)
$(BOOT)/ocamlc: copy makedepend
$(MAKE) -C $(OCAMLSRC)/yacc all
$(MAKE) -C miniml/interp depend
./timed.sh $(MAKE) $(MAKEFLAGS) -C miniml/interp interpopt.opt
touch _boot/stdlib/.depend && $(MAKE) -C _boot/stdlib depend
touch _boot/.depend && $(MAKE) -C _boot depend
./timed.sh $(MAKE) $(MAKEFLAGS) -C _boot/stdlib all
# cd $(BOOT)/stdlib && ../../timed.sh ../../compile_stdlib.sh
mkdir -p $(BOOT)/compilerlibs
./timed.sh $(MAKE) $(MAKEFLAGS) -C _boot ocamlc
# cd $(BOOT) && ../timed.sh ../compile_ocamlc.sh
# Remove dependency on $(BOOT)/ocamlc, because it seems to cause ocamlc to be rebuilt even if it was just built
fullboot:
cp $(BOOT)/ocamlc $(OCAMLSRC)/boot/
cp miniml/interp/lex.byte $(OCAMLSRC)/boot/ocamllex
cp $(OCAMLSRC)/byterun/ocamlrun $(OCAMLSRC)/boot/ocamlrun$(EXE)
touch $(OCAMLSRC)/stdlib/.depend && ./timed.sh $(MAKE) $(MAKEFLAGS) -C $(OCAMLSRC)/stdlib CAMLDEP="../boot/ocamlc -depend" depend
./timed.sh $(MAKE) $(MAKEFLAGS) -C $(OCAMLSRC)/stdlib COMPILER="" CAMLC="../boot/ocamlc -use-prims ../byterun/primitives" all
cd $(OCAMLSRC)/stdlib; cp stdlib.cma std_exit.cmo *.cmi camlheader ../boot
cd $(OCAMLSRC)/boot; ln -sf ../byterun/libcamlrun.a .
touch $(OCAMLSRC)/tools/.depend && ./timed.sh $(MAKE) $(MAKEFLAGS) -C $(OCAMLSRC)/tools CAMLC="../boot/ocamlc -nostdlib -I ../boot -use-prims ../byterun/primitives -I .." make_opcodes cvt_emit
touch $(OCAMLSRC)/lex/.depend && ./timed.sh $(MAKE) $(MAKEFLAGS) -C $(OCAMLSRC)/lex CAMLDEP="../boot/ocamlc -depend" depend
./timed.sh $(MAKE) $(MAKEFLAGS) -C $(OCAMLSRC) CAMLDEP="boot/ocamlc -depend" depend
./timed.sh $(MAKE) $(MAKEFLAGS) -C $(OCAMLSRC) CAMLC="boot/ocamlc -nostdlib -I boot -use-prims byterun/primitives" ocamlc
./timed.sh $(MAKE) $(MAKEFLAGS) -C $(OCAMLSRC)/lex CAMLC="../boot/ocamlc -strict-sequence -nostdlib -I ../boot -use-prims ../byterun/primitives" all
.PHONY: test-compiler
test-compiler: $(OCAMLRUN)
$(MAKE) -C miniml/compiler/test all OCAMLRUN=../../../$(OCAMLRUN)
.PHONY: test-compiler-promote
test-compiler-promote: $(OCAMLRUN)
$(MAKE) -C miniml/compiler/test promote OCAMLRUN=../../../$(OCAMLRUN)