Skip to content

Commit 9c6e7e6

Browse files
committed
Beginning of build-system upgrade.
1 parent e65e171 commit 9c6e7e6

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed

src/Makefile.in

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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)

src/configure.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
CFG_SRC_DIR=${0%${0##*/}}
4+
CFG_BUILD_DIR=$PWD
5+
6+
CFG_OSTYPE=$(uname -s)
7+
CFG_CPUTYPE=$(uname -m)
8+
9+
echo "configuring on $CFG_CPUTYPE $CFG_OSTYPE"
10+
11+
echo "setting up build directories"
12+
for i in boot/{fe,me,be,driver,util} \
13+
rt/{isaac,bigint,sync,test} \
14+
stage{0,1,2} \
15+
test/{run-pass,compile-{pass,fail}}
16+
do
17+
mkdir -p -v $i
18+
done
19+
20+
CFG_VALGRIND=$(sh which valgrind)
21+
CFG_OCAMLC_OPT=$(sh which ocamlc.opt)
22+
23+
echo "copying Makefile"
24+
cp -v ${CFG_SRC_DIR}Makefile.in ./Makefile
25+
26+
echo "writing config.mk"
27+
cat >config.mk <<EOF
28+
29+
CFG_OSTYPE := $CFG_OSTYPE
30+
CFG_CPUTYPE := $CFG_CPUTYPE
31+
CFG_SRC_DIR := $CFG_SRC_DIR
32+
CFG_BUILD_DIR := $CFG_BUILD_DIR
33+
34+
CFG_VALGRIND := $CFG_VALGRIND
35+
CFG_OCAMLC_OPT := $CFG_OCAMLC_OPT
36+
37+
EOF
38+
39+
echo "configured ok"

0 commit comments

Comments
 (0)