|
| 1 | +###################################################################### |
| 2 | +# Residual auto-configuration |
| 3 | +###################################################################### |
| 4 | + |
| 5 | +include config.mk |
| 6 | +MKFILES := Makefile config.mk |
| 7 | + |
| 8 | +ifneq ($(MAKE_RESTARTS),) |
| 9 | +CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS)) |
| 10 | +endif |
| 11 | + |
| 12 | +CFG_INFO := $(info cfg: building on $(CFG_OSTYPE) $(CFG_CPUTYPE)) |
| 13 | + |
| 14 | +ifdef CFG_OCAMLC_OPT |
| 15 | + $(info cfg: using ocaml native compiler) |
| 16 | + OPT=.opt |
| 17 | +else |
| 18 | + $(info cfg: using ocaml bytecode compiler) |
| 19 | +endif |
| 20 | + |
| 21 | +ifdef PROFILE_BOOT |
| 22 | + $(info cfg: building bootstrap compiler with profiling (forcing native)) |
| 23 | + CFG_NATIVE_BOOT := 1 |
| 24 | + CFG_OCAMLOPT_PROFILE_FLAGS := -p |
| 25 | +endif |
| 26 | + |
| 27 | +ifdef DEBUG |
| 28 | + $(info cfg: forcing bytecode bootstrap compiler) |
| 29 | + CFG_NATIVE_BOOT := |
| 30 | +endif |
| 31 | + |
| 32 | +ifdef CFG_NATIVE_BOOT |
| 33 | + $(info cfg: building native bootstrap compiler) |
| 34 | +else |
| 35 | + $(info cfg: building bytecode bootstrap compiler) |
| 36 | +endif |
| 37 | + |
| 38 | +ifdef NO_VALGRIND |
| 39 | + CFG_VALGRIND := |
| 40 | +endif |
| 41 | + |
| 42 | + |
| 43 | +###################################################################### |
| 44 | +# Bootstrap compiler variables |
| 45 | +###################################################################### |
| 46 | + |
| 47 | +# We must list them in link order. |
| 48 | +# Nobody calculates the link-order DAG automatically, sadly. |
| 49 | + |
| 50 | +BOOT_MLS := \ |
| 51 | + $(addsuffix .ml, \ |
| 52 | + $(addprefix boot/util/, version fmt common bits) \ |
| 53 | + $(addprefix boot/driver/, session) \ |
| 54 | + $(addprefix boot/fe/, ast token lexer parser \ |
| 55 | + extfmt pexp item cexp fuzz) \ |
| 56 | + $(addprefix boot/be/, asm il abi) \ |
| 57 | + $(addprefix boot/me/, walk semant resolve alias \ |
| 58 | + simplify type dead layer effect typestate \ |
| 59 | + loop layout transutil trans dwarf) \ |
| 60 | + $(addprefix boot/be/, x86 ra pe elf macho) \ |
| 61 | + $(addprefix boot/driver/, lib glue main)) \ |
| 62 | + |
| 63 | +BOOT_CMOS := $(BOOT_MLS:.ml=.cmo) |
| 64 | +BOOT_CMXS := $(BOOT_MLS:.ml=.cmx) |
| 65 | +BOOT_OBJS := $(BOOT_MLS:.ml=.o) |
| 66 | +BOOT_CMIS := $(BOOT_MLS:.ml=.cmi) |
| 67 | + |
| 68 | +ML_DEP_INCS := -I $(S)boot/fe -I $(S)boot/me -I $(S)boot/be \ |
| 69 | + -I $(S)boot/driver -I $(S)boot/util |
| 70 | + |
| 71 | +ML_INCS := $(ML_DEP_INCS) |
| 72 | +ML_LIBS := unix.cma nums.cma bigarray.cma |
| 73 | +ML_NATIVE_LIBS := unix.cmxa nums.cmxa bigarray.cmxa |
| 74 | +OCAMLC_FLAGS := -g $(ML_INCS) -w Ael -warn-error Ael |
| 75 | + |
| 76 | + |
| 77 | +###################################################################### |
| 78 | +# Target-and-rule "utility variables" |
| 79 | +###################################################################### |
| 80 | + |
| 81 | +ifdef VERBOSE |
| 82 | + Q := |
| 83 | + E = |
| 84 | +else |
| 85 | + Q := @ |
| 86 | + E = echo $(1) |
| 87 | +endif |
| 88 | + |
| 89 | +S := $(CFG_SRC_DIR) |
| 90 | +X := $(CFG_EXE_SUFFIX) |
| 91 | + |
| 92 | +# Look in src dir. |
| 93 | +VPATH := $(CFG_SRC_DIR) |
| 94 | + |
| 95 | +# Delete the built-in rules. |
| 96 | +.SUFFIXES: |
| 97 | +%:: %,v |
| 98 | +%:: RCS/%,v |
| 99 | +%:: RCS/% |
| 100 | +%:: s.% |
| 101 | +%:: SCCS/s.% |
| 102 | + |
| 103 | +###################################################################### |
| 104 | +# Targets and rules |
| 105 | +###################################################################### |
| 106 | + |
| 107 | +all: rustboot$(X) |
| 108 | + |
| 109 | +ifdef CFG_NATIVE_BOOT |
| 110 | +rustboot$(X): $(BOOT_CMXS) $(MKFILES) |
| 111 | + @$(call E, compile: $@) |
| 112 | + $(Q)ocamlopt$(OPT) -o $@ $(OCAMLOPT_FLAGS) $(ML_NATIVE_LIBS) \ |
| 113 | + $(BOOT_CMXS) |
| 114 | +else |
| 115 | +rustboot$(X): $(BOOT_CMOS) $(MKFILES) |
| 116 | + @$(call E, compile: $@) |
| 117 | + $(Q)ocamlc$(OPT) -o $@ $(OCAMLC_FLAGS) $(ML_LIBS) $(BOOT_CMOS) |
| 118 | +endif |
| 119 | + |
| 120 | + |
| 121 | +boot/util/version.ml: $(MKFILES) |
| 122 | + $(Q)git log -1 \ |
| 123 | + --pretty=format:'let version = "prerelease (%h %ci)";;' >$@ || exit 1 |
| 124 | + |
| 125 | +%.cmo: %.ml $(MKFILES) |
| 126 | + @$(call E, compile: $@) |
| 127 | + $(Q)ocamlc$(OPT) -c -o $@ $(OCAMLC_FLAGS) $< |
| 128 | + |
| 129 | +%.cmo: %.cmi $(MKFILES) |
0 commit comments