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 = $(filter-out $(CFG_BUILD),$(CFG_HOST))
74 NON_BUILD_TARGET = $(filter-out $(CFG_BUILD),$(CFG_TARGET))
76 ifneq ($(MAKE_RESTARTS),)
77 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
80 CFG_INFO := $(info cfg: build triple $(CFG_BUILD))
81 CFG_INFO := $(info cfg: host triples $(CFG_HOST))
82 CFG_INFO := $(info cfg: target triples $(CFG_TARGET))
84 ifneq ($(wildcard $(NON_BUILD_HOST)),)
85 CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST))
87 ifneq ($(wildcard $(NON_BUILD_TARGET)),)
88 CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET))
91 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
93 CFG_GCCISH_LINK_FLAGS :=
95 ifdef CFG_DISABLE_OPTIMIZE
96 $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
99 # The rtopt cfg turns off runtime sanity checks
100 CFG_RUSTC_FLAGS += -O --cfg rtopt
103 ifdef CFG_DISABLE_DEBUG
104 CFG_RUSTC_FLAGS += --cfg ndebug
105 CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
107 $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
108 CFG_RUSTC_FLAGS += --cfg debug
109 CFG_GCCISH_CFLAGS += -DRUST_DEBUG
113 CFG_RUSTC_FLAGS += --save-temps
116 CFG_RUSTC_FLAGS += -Z asm-comments
119 CFG_RUSTC_FLAGS += -Z time-passes
121 ifdef TIME_LLVM_PASSES
122 CFG_RUSTC_FLAGS += -Z time-llvm-passes
125 CFG_RUSTC_FLAGS += -Z trace
128 RUSTFLAGS_STAGE0 += -Z no-debug-borrows
129 RUSTFLAGS_STAGE1 += -Z no-debug-borrows
130 RUSTFLAGS_STAGE2 += -Z no-debug-borrows
133 # The executables crated during this compilation process have no need to include
134 # static copies of libstd and libextra. We also generate dynamic versions of all
135 # libraries, so in the interest of space, prefer dynamic linking throughout the
136 # compilation process.
137 RUSTFLAGS_STAGE1 += -Z prefer-dynamic
138 RUSTFLAGS_STAGE2 += -Z prefer-dynamic
139 RUSTFLAGS_STAGE3 += -Z prefer-dynamic
141 # platform-specific auto-configuration
142 include $(CFG_SRC_DIR)mk/platform.mk
144 # Run the stage1/2 compilers under valgrind
145 ifdef VALGRIND_COMPILE
146 CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
148 CFG_VALGRIND_COMPILE :=
151 # version-string calculation
152 CFG_GIT_DIR := $(CFG_SRC_DIR).git
153 CFG_RELEASE = 0.9-pre
154 CFG_VERSION = $(CFG_RELEASE)
155 # windows exe's need numeric versions - don't use anything but
156 # numbers and dots here
157 CFG_VERSION_WIN = 0.9
159 # since $(CFG_GIT) may contain spaces (especially on Windows),
160 # we need to escape them. (" " to r"\ ")
161 # Note that $(subst ...) ignores space after `subst`,
162 # so we use a hack: define $(SPACE) which contains space character.
165 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT))),)
166 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),)
167 CFG_VERSION += $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 \
168 --pretty=format:'(%h %ci)')
169 CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD)
173 ifdef CFG_ENABLE_VALGRIND
174 $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
178 ifdef CFG_BAD_VALGRIND
179 $(info cfg: disabling valgrind due to its unreliability on this platform)
184 ######################################################################
185 # Target-and-rule "utility variables"
186 ######################################################################
199 X_$(1) := $(CFG_EXE_SUFFIX_$(1))
201 $(foreach target,$(CFG_TARGET),\
202 $(eval $(call DEF_X,$(target))))
204 # Look in doc and src dirs.
205 VPATH := $(S)doc $(S)src
207 # "Source" files we generate in builddir along the way.
210 # Delete the built-in rules.
219 ######################################################################
221 ######################################################################
225 CFG_RUNTIME_$(1) :=$(call CFG_LIB_NAME_$(1),rustrt)
226 CFG_RUSTLLVM_$(1) :=$(call CFG_LIB_NAME_$(1),rustllvm)
227 CFG_STDLIB_$(1) :=$(call CFG_LIB_NAME_$(1),std)
228 CFG_EXTRALIB_$(1) :=$(call CFG_LIB_NAME_$(1),extra)
229 CFG_LIBRUSTC_$(1) :=$(call CFG_LIB_NAME_$(1),rustc)
230 CFG_LIBSYNTAX_$(1) :=$(call CFG_LIB_NAME_$(1),syntax)
231 CFG_LIBRUSTPKG_$(1) :=$(call CFG_LIB_NAME_$(1),rustpkg)
232 CFG_LIBRUSTDOC_$(1) :=$(call CFG_LIB_NAME_$(1),rustdoc)
233 CFG_LIBRUSTUV_$(1) :=$(call CFG_LIB_NAME_$(1),rustuv)
235 EXTRALIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),extra)
236 STDLIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),std)
237 LIBRUSTC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustc)
238 LIBSYNTAX_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),syntax)
239 LIBRUSTPKG_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustpkg)
240 LIBRUSTDOC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustdoc)
241 LIBRUSTUV_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustuv)
242 EXTRALIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),extra)
243 STDLIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),std)
244 LIBRUSTC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustc)
245 LIBSYNTAX_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),syntax)
246 LIBRUSTPKG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustpkg)
247 LIBRUSTDOC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc)
248 LIBRUSTUV_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustuv)
250 EXTRALIB_RGLOB_$(1) :=$(call CFG_RLIB_GLOB,extra)
251 STDLIB_RGLOB_$(1) :=$(call CFG_RLIB_GLOB,std)
252 LIBRUSTUV_RGLOB_$(1) :=$(call CFG_RLIB_GLOB,rustuv)
256 # $(1) is the path for directory to match against
257 # $(2) is the glob to use in the match
258 # $(3) is filename (usually the target being created) to filter out from match
259 # (i.e. filename is not out-of-date artifact from prior Rust version/build)
261 # Note that a common bug is to accidentally construct the glob denoted
262 # by $(2) with a space character prefix, which invalidates the
263 # construction $(1)$(2).
264 define CHECK_FOR_OLD_GLOB_MATCHES_EXCEPT
265 $(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "warning: there are previous" \'$(2)\' "libraries:" $$MATCHES; fi
268 # Same interface as above, but deletes rather than just listing the files.
269 define REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT
270 $(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "warning: removing previous" \'$(2)\' "libraries:" $$MATCHES; rm $$MATCHES ; fi
273 # We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
274 # than in the macros above because it needs the result of running the
275 # `ls` command after other rules in the command list have run; the
276 # macro-expander for $(wildcard ...) would deliver its results too
277 # soon. (This is in contrast to the macros above, which are meant to
278 # be run at the outset of a command list in a rule.)
280 define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
281 @echo "info: now are following matches for" '$(2)' "libraries:"
282 @( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) || true )
285 define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
289 $(foreach target,$(CFG_TARGET),\
290 $(eval $(call DEF_LIBS,$(target))))
292 ######################################################################
293 # Standard library variables
294 ######################################################################
296 STDLIB_CRATE := $(S)src/libstd/lib.rs
297 STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
298 *.rs */*.rs */*/*rs */*/*/*rs))
300 ######################################################################
301 # Extra library variables
302 ######################################################################
304 EXTRALIB_CRATE := $(S)src/libextra/lib.rs
305 EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
308 ######################################################################
309 # Rust UV library variables
310 ######################################################################
312 LIBRUSTUV_CRATE := $(S)src/librustuv/lib.rs
313 LIBRUSTUV_INPUTS := $(wildcard $(addprefix $(S)src/librustuv/, \
316 ######################################################################
317 # rustc crate variables
318 ######################################################################
320 COMPILER_CRATE := $(S)src/librustc/lib.rs
321 COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
322 *.rs */*.rs */*/*.rs */*/*/*.rs))
324 LIBSYNTAX_CRATE := $(S)src/libsyntax/lib.rs
325 LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
326 *.rs */*.rs */*/*.rs */*/*/*.rs))
328 DRIVER_CRATE := $(S)src/driver/driver.rs
330 ######################################################################
332 ######################################################################
335 LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \
336 interpreter instrumentation
339 # The configure script defines these variables with the target triples
340 # separated by Z. This defines new ones with the expected format.
341 CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
342 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
344 # Any rules that depend on LLVM should depend on LLVM_CONFIG
345 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
346 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
347 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
348 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
349 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
350 LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
351 LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
352 LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
353 # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
354 # so we replace -I with -iquote to ensure that it searches bundled LLVM first.
355 LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
356 LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
358 LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
359 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
363 $(foreach host,$(CFG_HOST), \
364 $(eval $(call DEF_LLVM_VARS,$(host))))
366 ######################################################################
367 # Exports for sub-utilities
368 ######################################################################
370 # Note that any variable that re-configure should pick up needs to be
376 export CFG_VERSION_WIN
379 export CFG_ENABLE_MINGW_CROSS
383 ######################################################################
385 ######################################################################
387 ######################################################################
388 # Per-stage targets and runner
389 ######################################################################
392 # $(1) is the stage number
393 # $(2) is the target triple
394 # $(3) is the host triple
396 # Destinations of artifacts for the host compiler
397 HROOT$(1)_H_$(3) = $(3)/stage$(1)
398 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
399 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
401 # Destinations of artifacts for target architectures
402 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
403 TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
404 TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
406 # The name of the standard and extra libraries used by rustc
407 HSTDLIB_DEFAULT$(1)_H_$(3) = \
408 $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB_$(3))
409 TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
410 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2))
412 HEXTRALIB_DEFAULT$(1)_H_$(3) = \
413 $$(HLIB$(1)_H_$(3))/$(CFG_EXTRALIB_$(3))
414 TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
415 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
417 HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
418 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC_$(3))
419 TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
420 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2))
422 HLIBRUSTUV_DEFAULT$(1)_H_$(3) = \
423 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTUV_$(3))
424 TLIBRUSTUV_DEFAULT$(1)_T_$(2)_H_$(3) = \
425 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2))
427 # Preqrequisites for using the stageN compiler
429 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
430 $$(HLIB$(1)_H_$(3))/$(CFG_RUNTIME_$(3)) \
431 $$(HLIB$(1)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
432 $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
433 $$(HEXTRALIB_DEFAULT$(1)_H_$(3)) \
434 $$(HLIBSYNTAX_DEFAULT$(1)_H_$(3)) \
435 $$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \
436 $$(HLIBRUSTUV_DEFAULT$(1)_H_$(3)) \
439 # Prerequisites for using the stageN compiler to build target artifacts
440 TSREQ$(1)_T_$(2)_H_$(3) = \
441 $$(HSREQ$(1)_H_$(3)) \
442 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)) \
443 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
445 # Prerequisites for a working stageN compiler and libraries, for a specific target
446 SREQ$(1)_T_$(2)_H_$(3) = \
447 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
448 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
449 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)) \
450 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2))
452 # Prerequisites for a working stageN compiler and libraries, for a specific target
453 CSREQ$(1)_T_$(2)_H_$(3) = \
454 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
455 $$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
456 $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
457 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \
458 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTDOC_$(3)) \
459 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
460 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)) \
461 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(2)) \
462 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2)) \
463 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2)) \
464 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTDOC_$(2)) \
465 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2))
468 # Don't run the the stage0 compiler under valgrind - that ship has sailed
469 CFG_VALGRIND_COMPILE$(1) =
471 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
474 # Add RUSTFLAGS_STAGEN values to the build command
475 EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
477 CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
479 # Pass --cfg stage0 only for the build->host part of stage0;
480 # if you're building a cross config, the host->* parts are
481 # effectively stage1, since it uses the just-built stage0.
483 ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
484 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
488 STAGE$(1)_T_$(2)_H_$(3) := \
489 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
490 $$(CFG_VALGRIND_COMPILE$(1)) \
491 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
492 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
493 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
496 PERF_STAGE$(1)_T_$(2)_H_$(3) := \
497 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
499 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
500 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
501 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
506 $(foreach build,$(CFG_HOST), \
507 $(eval $(foreach target,$(CFG_TARGET), \
508 $(eval $(foreach stage,$(STAGES), \
509 $(eval $(call SREQ,$(stage),$(target),$(build))))))))
511 ######################################################################
514 # Builds a functional Rustc for the given host.
515 ######################################################################
517 define DEF_RUSTC_STAGE_TARGET
518 # $(1) == architecture
521 rustc-stage$(2)-H-$(1): \
522 $$(foreach target,$$(CFG_TARGET), \
523 $$(SREQ$(2)_T_$$(target)_H_$(1)))
527 $(foreach host,$(CFG_HOST), \
528 $(eval $(foreach stage,1 2 3, \
529 $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
531 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
532 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
533 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
535 define DEF_RUSTC_TARGET
536 # $(1) == architecture
538 rustc-H-$(1): rustc-stage2-H-$(1)
541 $(foreach host,$(CFG_TARGET), \
542 $(eval $(call DEF_RUSTC_TARGET,$(host))))
544 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
545 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
546 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
547 rustc: rustc-H-$(CFG_BUILD)
549 rustc-H-all: $(foreach host,$(CFG_HOST),rustc-H-$(host))
551 ######################################################################
553 ######################################################################
557 ifneq ($(CFG_IN_TRANSITION),)
559 CFG_INFO := $(info cfg:)
560 CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
561 CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
562 CFG_INFO := $(info cfg:)
564 #XXX This is surely busted
565 all: $(SREQ1$(CFG_BUILD)) $(GENERATED) docs
570 ifneq ($$(findstring $(1),$$(CFG_HOST)),)
572 all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
574 # This is a target only
575 all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
579 $(foreach target,$(CFG_TARGET), \
580 $(foreach host,$(CFG_HOST), \
581 $(eval $(call ALL_TARGET_N,$(target),$(host)))))
583 ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
584 $(foreach host,$(CFG_HOST), \
585 all-target-$(target)-host-$(host)))
587 all: $(ALL_TARGET_RULES) $(GENERATED) docs
592 ######################################################################
594 ######################################################################
596 ifndef CFG_DISABLE_MANAGE_SUBMODULES
597 # This is a pretty expensive operation but I don't see any way to avoid it
598 NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
603 ifeq ($(NEED_GIT_RECONFIG),0)
605 # If the submodules have changed then always execute config.mk
609 Makefile config.mk: config.stamp
611 config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
612 @$(call E, cfg: reconfiguring)
613 $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
616 ######################################################################
617 # Primary-target makefiles
618 ######################################################################
620 # Issue #9531: If you change the order of any of the following (or add
621 # new definitions), make sure definitions always precede their uses,
622 # especially for the dependency lists of recipes.
624 include $(CFG_SRC_DIR)mk/rt.mk
625 include $(CFG_SRC_DIR)mk/target.mk
626 include $(CFG_SRC_DIR)mk/host.mk
627 include $(CFG_SRC_DIR)mk/stage0.mk
628 include $(CFG_SRC_DIR)mk/rustllvm.mk
629 include $(CFG_SRC_DIR)mk/tools.mk
630 include $(CFG_SRC_DIR)mk/docs.mk
631 include $(CFG_SRC_DIR)mk/llvm.mk
633 ######################################################################
634 # Secondary makefiles, conditionalized for speed
635 ######################################################################
637 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
638 $(findstring check,$(MAKECMDGOALS)) \
639 $(findstring test,$(MAKECMDGOALS)) \
640 $(findstring tidy,$(MAKECMDGOALS)) \
641 $(findstring clean,$(MAKECMDGOALS))),)
642 CFG_INFO := $(info cfg: including dist rules)
643 include $(CFG_SRC_DIR)mk/dist.mk
646 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
647 $(findstring clean,$(MAKECMDGOALS))),)
648 CFG_INFO := $(info cfg: including snap rules)
649 include $(CFG_SRC_DIR)mk/snap.mk
652 ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
653 CFG_INFO := $(info cfg: including reformat rules)
654 include $(CFG_SRC_DIR)mk/pp.mk
657 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
658 $(findstring test,$(MAKECMDGOALS)) \
659 $(findstring perf,$(MAKECMDGOALS)) \
660 $(findstring tidy,$(MAKECMDGOALS))),)
661 CFG_INFO := $(info cfg: including test rules)
662 include $(CFG_SRC_DIR)mk/tests.mk
665 ifneq ($(findstring perf,$(MAKECMDGOALS)),)
666 CFG_INFO := $(info cfg: including perf rules)
667 include $(CFG_SRC_DIR)mk/perf.mk
670 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
671 CFG_INFO := $(info cfg: including clean rules)
672 include $(CFG_SRC_DIR)mk/clean.mk
675 ifneq ($(findstring install,$(MAKECMDGOALS)),)
676 CFG_INFO := $(info cfg: including install rules)
677 include $(CFG_SRC_DIR)mk/install.mk
680 ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
681 $(findstring TAGS.vi,$(MAKECMDGOALS))),)
682 CFG_INFO := $(info cfg: including ctags rules)
683 include $(CFG_SRC_DIR)mk/ctags.mk
686 # Find all of the .d files and include them to add information about
687 # header file dependencies.
688 ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
689 -include $(ALL_DEP_FILES)