1 # Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
11 # An explanation of how the build is structured:
13 # There are multiple build stages (0-3) needed to verify that the
14 # compiler is properly self-hosting. Each stage is divided between
15 # 'host' artifacts and 'target' artifacts, where the stageN host
16 # compiler builds artifacts for 1 or more stageN target architectures.
17 # Once the stageN target compiler has been built for the host
18 # architecture it is promoted (copied) to a stageN+1 host artifact.
20 # The stage3 host compiler is a compiler that successfully builds
21 # itself and should (in theory) be bitwise identical to the stage2
22 # host compiler. The process is bootstrapped using a stage0 host
23 # compiler downloaded from a previous snapshot.
25 # At no time should stageN artifacts be interacting with artifacts
26 # from other stages. For consistency, we use the 'promotion' logic
27 # for all artifacts, even those that don't make sense on non-host
30 # The directory layout for a stage is intended to match the layout
31 # of the installed compiler, and looks like the following:
33 # stageN - this is the system root, corresponding to, e.g. /usr
34 # bin - binaries compiled for the host
35 # lib - libraries used by the host compiler
36 # rustc - rustc's own place to organize libraries
37 # $(target) - target-specific artifacts
38 # bin - binaries for target architectures
39 # lib - libraries for target architectures
41 # A note about host libraries:
43 # The only libraries that get promoted to stageN/lib are those needed
44 # by rustc. In general, rust programs, even those compiled for the
45 # host architecture will use libraries from the target
46 # directories. This gives rust some freedom to experiment with how
47 # libraries are managed and versioned without polluting the common
48 # areas of the filesystem.
50 # General rust binaries may stil live in the host bin directory; they
51 # will just link against the libraries in the target lib directory.
53 # Admittedly this is a little convoluted.
57 ######################################################################
58 # Residual auto-configuration
59 ######################################################################
61 # Recursive wildcard function
62 # http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
63 rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
64 $(filter $(subst *,%,$2),$d))
68 # We track all of the object files we might build so that we can find
69 # and include all of the .d files in one fell swoop.
72 MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
73 NON_BUILD_HOST_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_HOST_TRIPLES))
74 NON_BUILD_TARGET_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_TARGET_TRIPLES))
76 ifneq ($(MAKE_RESTARTS),)
77 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
80 CFG_INFO := $(info cfg: build triple $(CFG_BUILD_TRIPLE))
81 CFG_INFO := $(info cfg: host triples $(CFG_HOST_TRIPLES))
82 CFG_INFO := $(info cfg: target triples $(CFG_TARGET_TRIPLES))
84 ifneq ($(wildcard $(NON_BUILD_HOST_TRIPLES)),)
85 CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST_TRIPLES))
87 ifneq ($(wildcard $(NON_BUILD_TARGET_TRIPLES)),)
88 CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET_TRIPLES))
91 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
93 CFG_GCCISH_LINK_FLAGS :=
95 ifdef CFG_DISABLE_OPTIMIZE
96 $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
102 ifdef CFG_ENABLE_DEBUG
103 $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
104 CFG_RUSTC_FLAGS += --cfg debug
105 CFG_GCCISH_CFLAGS += -DRUST_DEBUG
107 CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
111 CFG_RUSTC_FLAGS += --save-temps
114 CFG_RUSTC_FLAGS += -Z asm-comments
117 CFG_RUSTC_FLAGS += -Z time-passes
119 ifdef TIME_LLVM_PASSES
120 CFG_RUSTC_FLAGS += -Z time-llvm-passes
123 CFG_RUSTC_FLAGS += -Z trace
126 RUSTFLAGS_STAGE1 += -Z no-debug-borrows
127 RUSTFLAGS_STAGE2 += -Z no-debug-borrows
130 # platform-specific auto-configuration
131 include $(CFG_SRC_DIR)mk/platform.mk
133 # Run the stage1/2 compilers under valgrind
134 ifdef VALGRIND_COMPILE
135 CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
137 CFG_VALGRIND_COMPILE :=
140 # version-string calculation
141 CFG_GIT_DIR := $(CFG_SRC_DIR).git
143 CFG_VERSION = $(CFG_RELEASE)
144 # windows exe's need numeric versions - don't use anything but
145 # numbers and dots here
146 CFG_VERSION_WIN = 0.7
148 ifneq ($(wildcard $(CFG_GIT)),)
149 ifneq ($(wildcard $(CFG_GIT_DIR)),)
150 CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
151 --pretty=format:'(%h %ci)')
152 CFG_VER_HASH = $(shell git --git-dir=$(CFG_GIT_DIR) rev-parse HEAD)
156 ifdef CFG_ENABLE_VALGRIND
157 $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
161 ifdef CFG_BAD_VALGRIND
162 $(info cfg: disabling valgrind due to its unreliability on this platform)
167 ######################################################################
168 # Target-and-rule "utility variables"
169 ######################################################################
182 X_$(1) := $(CFG_EXE_SUFFIX_$(1))
184 $(foreach target,$(CFG_TARGET_TRIPLES),\
185 $(eval $(call DEF_X,$(target))))
187 # Look in doc and src dirs.
188 VPATH := $(S)doc $(S)src
190 # "Source" files we generate in builddir along the way.
193 # Delete the built-in rules.
202 ######################################################################
204 ######################################################################
208 CFG_RUNTIME_$(1) :=$(call CFG_LIB_NAME_$(1),rustrt)
209 CFG_RUSTLLVM_$(1) :=$(call CFG_LIB_NAME_$(1),rustllvm)
210 CFG_STDLIB_$(1) :=$(call CFG_LIB_NAME_$(1),std)
211 CFG_EXTRALIB_$(1) :=$(call CFG_LIB_NAME_$(1),extra)
212 CFG_LIBRUSTC_$(1) :=$(call CFG_LIB_NAME_$(1),rustc)
213 CFG_LIBSYNTAX_$(1) :=$(call CFG_LIB_NAME_$(1),syntax)
214 CFG_LIBRUSTPKG_$(1) :=$(call CFG_LIB_NAME_$(1),rustpkg)
215 CFG_LIBRUSTDOC_$(1) :=$(call CFG_LIB_NAME_$(1),rustdoc)
216 CFG_LIBRUSTI_$(1) :=$(call CFG_LIB_NAME_$(1),rusti)
217 CFG_LIBRUST_$(1) :=$(call CFG_LIB_NAME_$(1),rust)
219 EXTRALIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),extra)
220 STDLIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),std)
221 LIBRUSTC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustc)
222 LIBSYNTAX_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),syntax)
223 LIBRUSTPKG_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustpkg)
224 LIBRUSTDOC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustdoc)
225 LIBRUSTI_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rusti)
226 LIBRUST_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rust)
227 EXTRALIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),extra)
228 STDLIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),std)
229 LIBRUSTC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustc)
230 LIBSYNTAX_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),syntax)
231 LIBRUSTPKG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustpkg)
232 LIBRUSTDOC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc)
233 LIBRUSTI_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rusti)
234 LIBRUST_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rust)
238 # $(1) is the path for directory to match against
239 # $(2) is the glob to use in the match
240 # $(3) is filename (usually the target being created) to filter out from match
241 # (i.e. filename is not out-of-date artifact from prior Rust version/build)
242 # The glob denoted by $(2) often is constructed with a space character prefix,
243 # which is why we cannot just do `ls` on $(1)/$(2).
244 define CHECK_FOR_OLD_GLOB_MATCHES_EXCEPT
245 $(Q)( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) > /dev/null && echo "Warning: there are previous" '$(2)' "libraries:" || true )
246 $(Q)( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) || true )
249 # Same interface as above, but deletes rather than just listing the files.
250 define REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT
251 $(Q)( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) > /dev/null && echo "Warning: removing previous" '$(2)' "libraries:" || true )
252 $(Q)( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) | xargs rm -v )
256 define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
257 @echo "Info: now are following matches for" '$(2)' "libraries:"
258 @( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) || true )
261 define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
265 $(foreach target,$(CFG_TARGET_TRIPLES),\
266 $(eval $(call DEF_LIBS,$(target))))
268 ######################################################################
269 # Standard library variables
270 ######################################################################
272 STDLIB_CRATE := $(S)src/libstd/std.rs
273 STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
274 *.rs */*.rs */*/*rs */*/*/*rs))
276 ######################################################################
277 # Extra library variables
278 ######################################################################
280 EXTRALIB_CRATE := $(S)src/libextra/extra.rs
281 EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
284 ######################################################################
285 # rustc crate variables
286 ######################################################################
288 COMPILER_CRATE := $(S)src/librustc/rustc.rs
289 COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
290 *.rs */*.rs */*/*.rs */*/*/*.rs))
292 LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs
293 LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
294 *.rs */*.rs */*/*.rs))
296 DRIVER_CRATE := $(S)src/driver/driver.rs
298 ######################################################################
300 ######################################################################
303 LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \
304 interpreter instrumentation
307 # The configure script defines these variables with the target triples
308 # separated by Z. This defines new ones with the expected format.
309 CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
310 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
312 # Any rules that depend on LLVM should depend on LLVM_CONFIG
313 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
314 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
315 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
316 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
317 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
318 LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
319 LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
320 LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
321 # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
322 # so we replace -I with -iquote to ensure that it searches bundled LLVM first.
323 LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
324 LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
326 LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
327 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
331 $(foreach host,$(CFG_HOST_TRIPLES), \
332 $(eval $(call DEF_LLVM_VARS,$(host))))
334 ######################################################################
335 # Exports for sub-utilities
336 ######################################################################
338 # Note that any variable that re-configure should pick up needs to be
344 export CFG_VERSION_WIN
345 export CFG_BUILD_TRIPLE
347 export CFG_ENABLE_MINGW_CROSS
351 ######################################################################
353 ######################################################################
355 ######################################################################
356 # Per-stage targets and runner
357 ######################################################################
360 # $(1) is the stage number
361 # $(2) is the target triple
362 # $(3) is the host triple
364 # Destinations of artifacts for the host compiler
365 HROOT$(1)_H_$(3) = $(3)/stage$(1)
366 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
367 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
369 # Destinations of artifacts for target architectures
370 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
371 TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
372 TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
374 # The name of the standard and extra libraries used by rustc
375 ifdef CFG_DISABLE_SHAREDSTD
376 HSTDLIB_DEFAULT$(1)_H_$(3) = \
377 $$(HLIB$(1)_H_$(3))/libstd.rlib
378 TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
379 $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
381 HEXTRALIB_DEFAULT$(1)_H_$(3) = \
382 $$(HLIB$(1)_H_$(3))/libextra.rlib
383 TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
384 $$(TLIB$(1)_T_$(2)_H_$(3))/libextra.rlib
386 HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
387 $$(HLIB$(1)_H_$(3))/librustc.rlib
388 TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
389 $$(TLIB$(1)_T_$(2)_H_$(3))/librustc.rlib
391 HSTDLIB_DEFAULT$(1)_H_$(3) = \
392 $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB_$(3))
393 TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
394 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2))
396 HEXTRALIB_DEFAULT$(1)_H_$(3) = \
397 $$(HLIB$(1)_H_$(3))/$(CFG_EXTRALIB_$(3))
398 TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
399 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
401 HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
402 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC_$(3))
403 TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
404 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2))
407 # Preqrequisites for using the stageN compiler
409 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
410 $$(HLIB$(1)_H_$(3))/$(CFG_RUNTIME_$(3)) \
411 $$(HLIB$(1)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
412 $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
413 $$(HEXTRALIB_DEFAULT$(1)_H_$(3)) \
414 $$(HLIBSYNTAX_DEFAULT$(1)_H_$(3)) \
415 $$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \
418 # Prerequisites for using the stageN compiler to build target artifacts
419 TSREQ$(1)_T_$(2)_H_$(3) = \
420 $$(HSREQ$(1)_H_$(3)) \
421 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)) \
422 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
424 # Prerequisites for a working stageN compiler and libraries, for a specific target
425 SREQ$(1)_T_$(2)_H_$(3) = \
426 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
427 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
428 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
430 # Prerequisites for a working stageN compiler and libraries, for a specific target
431 CSREQ$(1)_T_$(2)_H_$(3) = \
432 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
433 $$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
434 $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
435 $$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
436 $$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
437 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \
438 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTDOC_$(3)) \
439 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTI_$(3)) \
440 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUST_$(3)) \
441 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
442 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)) \
443 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(2)) \
444 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2)) \
445 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2)) \
446 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTDOC_$(2)) \
447 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTI_$(2)) \
448 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUST_$(2))
451 # Don't run the the stage0 compiler under valgrind - that ship has sailed
452 CFG_VALGRIND_COMPILE$(1) =
454 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
457 # Add RUSTFLAGS_STAGEN values to the build command
458 EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
460 CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
462 # Pass --cfg stage0 only for the build->host part of stage0;
463 # if you're building a cross config, the host->* parts are
464 # effectively stage1, since it uses the just-built stage0.
466 ifneq ($(strip $(CFG_BUILD_TRIPLE)),$(strip $(3)))
467 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
471 STAGE$(1)_T_$(2)_H_$(3) := \
472 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
473 $$(CFG_VALGRIND_COMPILE$(1)) \
474 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
475 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
476 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
479 PERF_STAGE$(1)_T_$(2)_H_$(3) := \
480 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
482 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
483 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
484 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
489 $(foreach build,$(CFG_HOST_TRIPLES), \
490 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
491 $(eval $(foreach stage,$(STAGES), \
492 $(eval $(call SREQ,$(stage),$(target),$(build))))))))
494 ######################################################################
497 # Builds a functional Rustc for the given host.
498 ######################################################################
500 define DEF_RUSTC_STAGE_TARGET
501 # $(1) == architecture
504 rustc-stage$(2)-H-$(1): \
505 $$(foreach target,$$(CFG_TARGET_TRIPLES), \
506 $$(SREQ$(2)_T_$$(target)_H_$(1)))
510 $(foreach host,$(CFG_HOST_TRIPLES), \
511 $(eval $(foreach stage,1 2 3, \
512 $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
514 rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
515 rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
516 rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
518 define DEF_RUSTC_TARGET
519 # $(1) == architecture
521 rustc-H-$(1): rustc-stage2-H-$(1)
524 $(foreach host,$(CFG_TARGET_TRIPLES), \
525 $(eval $(call DEF_RUSTC_TARGET,$(host))))
527 rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
528 rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
529 rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
530 rustc: rustc-H-$(CFG_BUILD_TRIPLE)
532 rustc-H-all: $(foreach host,$(CFG_HOST_TRIPLES),rustc-H-$(host))
534 ######################################################################
536 ######################################################################
540 ifneq ($(CFG_IN_TRANSITION),)
542 CFG_INFO := $(info cfg:)
543 CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
544 CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
545 CFG_INFO := $(info cfg:)
547 #XXX This is surely busted
548 all: $(SREQ1$(CFG_BUILD_TRIPLE)) $(GENERATED) docs
553 ifneq ($$(findstring $(1),$$(CFG_HOST_TRIPLES)),)
555 all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
557 # This is a target only
558 all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
562 $(foreach target,$(CFG_TARGET_TRIPLES), \
563 $(foreach host,$(CFG_HOST_TRIPLES), \
564 $(eval $(call ALL_TARGET_N,$(target),$(host)))))
566 ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \
567 $(foreach host,$(CFG_HOST_TRIPLES), \
568 all-target-$(target)-host-$(host)))
570 all: rustllvm/llvm-auto-clean-stamp \
571 $(ALL_TARGET_RULES) $(GENERATED) docs
575 # This is used to independently force an LLVM clean rebuild
576 # when we changed something not otherwise captured by builtin
577 # dependencies. In these cases, commit a change that touches
578 # the stamp in the source dir.
579 rustllvm/llvm-auto-clean-stamp: $(S)src/rustllvm/llvm-auto-clean-trigger
580 $(Q)$(MAKE) clean-llvm
584 ######################################################################
586 ######################################################################
588 ifndef CFG_DISABLE_MANAGE_SUBMODULES
589 # This is a pretty expensive operation but I don't see any way to avoid it
590 NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
595 ifeq ($(NEED_GIT_RECONFIG),0)
597 # If the submodules have changed then always execute config.mk
601 Makefile config.mk: config.stamp
603 config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
604 @$(call E, cfg: reconfiguring)
605 $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
608 ######################################################################
609 # Primary-target makefiles
610 ######################################################################
612 include $(CFG_SRC_DIR)mk/target.mk
613 include $(CFG_SRC_DIR)mk/host.mk
614 include $(CFG_SRC_DIR)mk/stage0.mk
615 include $(CFG_SRC_DIR)mk/rt.mk
616 include $(CFG_SRC_DIR)mk/rustllvm.mk
617 include $(CFG_SRC_DIR)mk/tools.mk
618 include $(CFG_SRC_DIR)mk/docs.mk
619 include $(CFG_SRC_DIR)mk/llvm.mk
621 ######################################################################
622 # Secondary makefiles, conditionalized for speed
623 ######################################################################
625 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
626 $(findstring check,$(MAKECMDGOALS)) \
627 $(findstring test,$(MAKECMDGOALS)) \
628 $(findstring tidy,$(MAKECMDGOALS)) \
629 $(findstring clean,$(MAKECMDGOALS))),)
630 CFG_INFO := $(info cfg: including dist rules)
631 include $(CFG_SRC_DIR)mk/dist.mk
634 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
635 $(findstring clean,$(MAKECMDGOALS))),)
636 CFG_INFO := $(info cfg: including snap rules)
637 include $(CFG_SRC_DIR)mk/snap.mk
640 ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
641 CFG_INFO := $(info cfg: including reformat rules)
642 include $(CFG_SRC_DIR)mk/pp.mk
645 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
646 $(findstring test,$(MAKECMDGOALS)) \
647 $(findstring perf,$(MAKECMDGOALS)) \
648 $(findstring tidy,$(MAKECMDGOALS))),)
649 CFG_INFO := $(info cfg: including test rules)
650 include $(CFG_SRC_DIR)mk/tests.mk
653 ifneq ($(findstring perf,$(MAKECMDGOALS)),)
654 CFG_INFO := $(info cfg: including perf rules)
655 include $(CFG_SRC_DIR)mk/perf.mk
658 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
659 CFG_INFO := $(info cfg: including clean rules)
660 include $(CFG_SRC_DIR)mk/clean.mk
663 ifneq ($(findstring install,$(MAKECMDGOALS)),)
665 CFG_INFO := $(info cfg: setting CFG_PREFIX via DESTDIR, $(DESTDIR)/$(CFG_PREFIX))
666 CFG_PREFIX:=$(DESTDIR)/$(CFG_PREFIX)
670 CFG_INFO := $(info cfg: including install rules)
671 include $(CFG_SRC_DIR)mk/install.mk
674 ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
675 $(findstring TAGS.vi,$(MAKECMDGOALS))),)
676 CFG_INFO := $(info cfg: including ctags rules)
677 include $(CFG_SRC_DIR)mk/ctags.mk
680 # Find all of the .d files and include them to add information about
681 # header file dependencies.
682 ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
683 -include $(ALL_DEP_FILES)