1 ######################################################################
2 # Residual auto-configuration
3 ######################################################################
6 MKFILES := Makefile config.mk $(wildcard $(CFG_SRC_DIR)/mk/*.mk)
8 ifneq ($(MAKE_RESTARTS),)
9 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
12 CFG_INFO := $(info cfg: building on $(CFG_OSTYPE) $(CFG_CPUTYPE))
14 ifdef CFG_DISABLE_OPTIMIZE
15 $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
22 CFG_RUSTC_FLAGS += --save-temps
25 CFG_RUSTC_FLAGS += --time-passes
27 ifdef TIME_LLVM_PASSES
28 CFG_RUSTC_FLAGS += --time-llvm-passes
31 CFG_RUSTC_FLAGS += --no-typestate
37 # platform-specific auto-configuration
38 include $(CFG_SRC_DIR)/mk/platform.mk
40 # Run the stage1/2 compilers under valgrind
41 ifdef VALGRIND_COMPILE
42 CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
44 CFG_VALGRIND_COMPILE :=
47 CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
48 CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm)
49 CFG_STDLIB :=$(call CFG_LIB_NAME,std)
50 CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
52 # version-string calculation
53 CFG_GIT_DIR := $(CFG_SRC_DIR).git
54 CFG_VERSION = prerelease
55 ifneq ($(wildcard $(CFG_GIT)),)
56 ifneq ($(wildcard $(CFG_GIT_DIR)),)
57 CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
58 --pretty=format:'(%h %ci)')
62 ifdef CFG_DISABLE_VALGRIND
63 $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND))
66 ifdef CFG_BAD_VALGRIND
67 $(info cfg: disabling valgrind due to its unreliability on this platform)
72 ifeq ($(CFG_MAKEINFO),)
73 $(info cfg: no makeinfo found, omitting doc/rust.html)
78 ifeq ($(CFG_TEXI2PDF),)
79 $(info cfg: no texi2pdf found, omitting doc/rust.pdf)
82 $(info cfg: no tex found, omitting doc/rust.pdf)
88 ifdef CFG_DISABLE_DOCS
89 $(info cfg: disabling doc build (CFG_DISABLE_DOCS))
93 ######################################################################
94 # Target-and-rule "utility variables"
95 ######################################################################
106 X := $(CFG_EXE_SUFFIX)
108 # Look in doc and src dirs.
109 VPATH := $(S)doc $(S)src
111 # Compilers we build, we now know how to run.
112 STAGE0 := $(Q)$(call CFG_RUN_TARG,stage0,\
113 stage0/rustc$(X) $(CFG_RUSTC_FLAGS))
114 STAGE1 := $(Q)$(call CFG_RUN_TARG,stage0, \
115 $(CFG_VALGRIND_COMPILE) stage1/rustc$(X) \
117 STAGE2 := $(Q)$(call CFG_RUN_TARG,stage1, \
118 $(CFG_VALGRIND_COMPILE) stage2/rustc$(X) \
120 STAGE3 := $(Q)$(call CFG_RUN_TARG,stage2, \
121 $(CFG_VALGRIND_COMPILE) stage3/rustc$(X) \
124 # "Source" files we generate in builddir along the way.
127 # Delete the built-in rules.
135 ######################################################################
136 # Standard library variables
137 ######################################################################
139 STDLIB_CRATE := $(S)src/lib/std.rc
140 STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rc *.rs */*.rs))
142 ######################################################################
143 # rustc crate variables
144 ######################################################################
146 COMPILER_CRATE := $(S)src/comp/rustc.rc
147 COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \
148 rustc.rc *.rs */*.rs */*/*.rs))
150 ######################################################################
151 # Main target dependency variables
152 ######################################################################
154 LREQ := rt/$(CFG_RUNTIME) rustllvm/$(CFG_RUSTLLVM)
155 SREQ0 := stage0/rustc$(X) $(LREQ) rt/main.o stage0/lib/glue.o \
156 stage0/lib/$(CFG_STDLIB)
157 SREQ1 := stage1/rustc$(X) $(LREQ) rt/main.o stage1/lib/glue.o \
158 stage1/lib/$(CFG_STDLIB)
159 SREQ2 := stage2/rustc$(X) $(LREQ) rt/main.o stage2/lib/glue.o \
160 stage2/lib/$(CFG_STDLIB)
163 ######################################################################
164 # Exports for sub-utilities
165 ######################################################################
170 export CFG_ENABLE_MINGW_CROSS
172 ######################################################################
174 ######################################################################
176 LLVM_AS := $(CFG_LLVM_BINDIR)/llvm-as$(X)
178 LLC := $(CFG_LLVM_BINDIR)/llc$(X)
180 ######################################################################
181 # Single-target rules
182 ######################################################################
184 ifneq ($(CFG_IN_TRANSITION),)
186 CFG_INFO := $(info cfg:)
187 CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
188 CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
189 CFG_INFO := $(info cfg:)
191 all: rt/$(CFG_RUNTIME) \
192 rustllvm/$(CFG_RUSTLLVM) \
193 stage0/lib/$(CFG_STDLIB) \
194 stage0/intrinsics.bc \
198 stage1/lib/$(CFG_STDLIB) \
199 stage1/intrinsics.bc \
205 all: rt/$(CFG_RUNTIME) \
206 rustllvm/$(CFG_RUSTLLVM) \
207 stage0/lib/$(CFG_STDLIB) \
208 stage0/intrinsics.bc \
212 stage1/lib/$(CFG_STDLIB) \
213 stage1/intrinsics.bc \
216 stage2/lib/$(CFG_STDLIB) \
217 stage2/intrinsics.bc \
220 stage3/lib/$(CFG_STDLIB) \
222 stage3/intrinsics.bc \
228 ######################################################################
230 ######################################################################
232 config.mk: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
233 @$(call E, cfg: reconfiguring)
234 $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
237 ######################################################################
238 # Primary-target makefiles
239 ######################################################################
241 include $(CFG_SRC_DIR)/mk/intrinsics.mk
242 include $(CFG_SRC_DIR)/mk/stage0.mk
243 include $(CFG_SRC_DIR)/mk/stage1.mk
244 include $(CFG_SRC_DIR)/mk/stage2.mk
245 include $(CFG_SRC_DIR)/mk/stage3.mk
246 include $(CFG_SRC_DIR)/mk/rt.mk
247 include $(CFG_SRC_DIR)/mk/rustllvm.mk
248 include $(CFG_SRC_DIR)/mk/autodep.mk
249 include $(CFG_SRC_DIR)/mk/fuzzer.mk
250 include $(CFG_SRC_DIR)/mk/docs.mk
253 ######################################################################
254 # Secondary makefiles, conditionalized for speed
255 ######################################################################
257 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
258 $(findstring check,$(MAKECMDGOALS)) \
259 $(findstring test,$(MAKECMDGOALS)) \
260 $(findstring clean,$(MAKECMDGOALS))),)
261 CFG_INFO := $(info cfg: including dist rules)
262 include $(CFG_SRC_DIR)/mk/dist.mk
265 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
266 $(findstring clean,$(MAKECMDGOALS))),)
267 CFG_INFO := $(info cfg: including snap rules)
268 include $(CFG_SRC_DIR)/mk/snap.mk
271 ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
272 CFG_INFO := $(info cfg: including reformat rules)
273 include $(CFG_SRC_DIR)/mk/pp.mk
276 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
277 $(findstring test,$(MAKECMDGOALS)) \
278 $(findstring tidy,$(MAKECMDGOALS))),)
279 CFG_INFO := $(info cfg: including test rules)
280 include $(CFG_SRC_DIR)/mk/tests.mk
283 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
284 CFG_INFO := $(info cfg: including clean rules)
285 include $(CFG_SRC_DIR)/mk/clean.mk