camlboot/Makefile
Gabriel Scherer c61d94ed0e turn hello.ml into a more convenient test
Now you can run

    make compiler-test

from the root of the repository to run hello.ml, and compare its
output to a version-controlled reference output.

If the output changes for good reasons, you can update the reference
file with

    make compiler-test-promote

Note: it may sound unpleasant to version-control program-generated
outputs, but in fact (as long as those outputs are kept
human-readable) this is an excellent idea for testing: it means that
any change to the testing output will be part of the commits/diffs,
making it easier for reviewers to understand the impact of a change.
2020-12-11 18:42:18 +01:00

104 lines
3.0 KiB
Makefile

BOOT=_boot
OCAMLSRC=ocaml-src
CONFIG=$(OCAMLSRC)/config/Makefile
OCAMLRUN=_boot/byterun/ocamlrun
.PHONY: configure-ocaml
configure-ocaml:
cd $(OCAMLSRC) && bash configure
make -C $(OCAMLSRC) ocamlyacc && cp $(OCAMLSRC)/yacc/ocamlyacc $(OCAMLSRC)/boot
make -C $(OCAMLSRC)/stdlib sys.ml
make -C $(OCAMLSRC) utils/config.ml
make -C $(OCAMLSRC) parsing/parser.ml
make -C $(OCAMLSRC) CAMLLEX=ocamllex CAMLRUN=ocamlrun parsing/lexer.ml
make -C $(OCAMLSRC) bytecomp/runtimedef.ml
make -C $(OCAMLSRC) CAMLLEX=ocamllex CAMLRUN=ocamlrun CAMLC=ocamlc bytecomp/opcodes.ml
.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
$(BOOT)/driver: $(OCAMLSRC)/driver $(OCAMLSRC)/otherlibs/dynlink $(CONFIG)
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)
make -C $(OCAMLSRC)/byterun all
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
$(BOOT)/bytecomp: $(OCAMLSRC)/bytecomp $(CONFIG)
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
$(BOOT)/typing: $(OCAMLSRC)/typing $(CONFIG)
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
$(BOOT)/parsing: $(OCAMLSRC)/parsing $(CONFIG) patches/parsetree.patch
mkdir -p $(BOOT)
rm -rf $@
cp -r $< $@
patch $(BOOT)/parsing/parsetree.mli patches/parsetree.patch
$(BOOT)/utils: $(OCAMLSRC)/utils $(CONFIG) 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) 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
COPY_TARGETS=\
$(BOOT)/bytecomp \
$(BOOT)/byterun \
$(BOOT)/driver \
$(BOOT)/parsing \
$(BOOT)/stdlib \
$(BOOT)/typing \
$(BOOT)/utils
.PHONY: copy
copy: $(COPY_TARGETS)
.PHONY: ocamlrun
ocamlrun: $(OCAMLRUN)
$(OCAMLRUN): $(BOOT)/byterun
$(BOOT)/ocamlc: $(COPY_TARGETS)
make -C $(OCAMLSRC)/yacc all
make -C miniml/compiler miniml
make -C miniml/interp interp
cd $(BOOT)/stdlib && ../../compile_stdlib.sh
mkdir -p $(BOOT)/compilerlibs
cd $(BOOT) && ../compile_ocamlc.sh
.PHONY: test-compiler
test-compiler: $(OCAMLRUN)
make -s -C miniml/compiler/test all OCAMLRUN=../../../$(OCAMLRUN)
.PHONY: test-compiler-promote
test-compiler-promote: $(OCAMLRUN)
make -C miniml/compiler/test promote OCAMLRUN=../../../$(OCAMLRUN)