]> git.lizzy.rs Git - rust.git/blob - Makefile.in
mk: Remove the concept of 'snapshot transitions'
[rust.git] / Makefile.in
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.
4 #
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.
10
11 # <help>
12 #
13 # # The Rust Build System
14 #
15 # Start with these these build targets:
16 #
17 # * all - The default rule. Builds a complete stage2 compiler, std,
18 #           and extra for all hosts and targets
19 # * docs - Generate HTML documentation for the std and extra libraries
20 #            from source code comments
21 # * rustc - The stage 2 compiler for the build platform with standard
22 #             and extra libraries
23 # * install
24 # * uninstall
25 # * check - Run tests
26 # * check-stage1-$(crate) - Run tests for a crate, e.g. `check-stage1-std`
27 # * check-stage1-rpass - Run the language tests
28 # * check-docs - Run the doc tests
29 #
30 # Then mix in some of these environment variables to harness the
31 # ultimate power of Rust Build System.
32 #
33 # * `VERBOSE=1` - Print all commands. Use this to see what's going on.
34 # * `RUSTFLAGS=...` - Add compiler flags to all `rustc` invocations
35 # * `CFG_ENABLE_VALGRIND=1` - Run tests under valgrind
36 # * `VALGRIND_COMPILE=1` - Run the compiler itself under valgrind
37 #                          (may require `CFG_ENABLE_VALGRIND`)
38 # * `NO_REBUILD=1` - Don't rebootstrap when testing std
39 #                    (and possibly other crates)
40 # * `SAVE_TEMPS=1` - Use `--save-temps` flag on all `rustc` invocations
41 # * `ASM_COMMENTS=1` - Use `-Z asm-comments`
42 # * `TIME_PASSES=1` - Use `-Z time-passes`
43 # * `TIME_LLVM_PASSES=1` - Use `-Z time-llvm-passes`
44 # * `TRACE=1` - Use `-Z trace`
45 #
46 # This is hardly all there is to know of The Rust Build System's
47 # mysteries. Your journey continues on the wiki[1][2].
48 #
49 # [1]: https://github.com/mozilla/rust/wiki/Note-build-system
50 # [2]: https://github.com/mozilla/rust/wiki/Note-testsuite
51 #
52 # </help>
53 #
54 # # An (old) explanation of how the build is structured:
55 #
56 # *Note: Hey, like, this is probably inaccurate, and is definitely
57 # an outdated and insufficient explanation of the remarkable
58 # and discomfiting Rust Build System.*
59 #
60 # There are multiple build stages (0-3) needed to verify that the
61 # compiler is properly self-hosting. Each stage is divided between
62 # 'host' artifacts and 'target' artifacts, where the stageN host
63 # compiler builds artifacts for 1 or more stageN target architectures.
64 # Once the stageN target compiler has been built for the host
65 # architecture it is promoted (copied) to a stageN+1 host artifact.
66 #
67 # The stage3 host compiler is a compiler that successfully builds
68 # itself and should (in theory) be bitwise identical to the stage2
69 # host compiler. The process is bootstrapped using a stage0 host
70 # compiler downloaded from a previous snapshot.
71 #
72 # At no time should stageN artifacts be interacting with artifacts
73 # from other stages. For consistency, we use the 'promotion' logic
74 # for all artifacts, even those that don't make sense on non-host
75 # architectures.
76 #
77 # The directory layout for a stage is intended to match the layout
78 # of the installed compiler, and looks like the following:
79 #
80 # stageN - this is the system root, corresponding to, e.g. /usr
81 #   bin - binaries compiled for the host
82 #   lib - libraries used by the host compiler
83 #     rustlib - rustc's own place to organize libraries
84 #       $(target) - target-specific artifacts
85 #         bin - binaries for target architectures
86 #         lib - libraries for target architectures
87 #
88 # A note about host libraries:
89 #
90 # The only libraries that get promoted to stageN/lib are those needed
91 # by rustc. In general, rust programs, even those compiled for the
92 # host architecture will use libraries from the target
93 # directories. This gives rust some freedom to experiment with how
94 # libraries are managed and versioned without polluting the common
95 # areas of the filesystem.
96 #
97 # General rust binaries may stil live in the host bin directory; they
98 # will just link against the libraries in the target lib directory.
99 #
100 # Admittedly this is a little convoluted.
101
102 STAGES = 0 1 2 3
103
104 ######################################################################
105 # Residual auto-configuration
106 ######################################################################
107
108 # Recursive wildcard function
109 # http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
110 rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
111   $(filter $(subst *,%,$2),$d))
112
113 include config.mk
114
115 # We track all of the object files we might build so that we can find
116 # and include all of the .d files in one fell swoop.
117 ALL_OBJ_FILES :=
118
119 MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
120 NON_BUILD_HOST = $(filter-out $(CFG_BUILD),$(CFG_HOST))
121 NON_BUILD_TARGET = $(filter-out $(CFG_BUILD),$(CFG_TARGET))
122
123 ifneq ($(MAKE_RESTARTS),)
124 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
125 endif
126
127 CFG_INFO := $(info cfg: build triple $(CFG_BUILD))
128 CFG_INFO := $(info cfg: host triples $(CFG_HOST))
129 CFG_INFO := $(info cfg: target triples $(CFG_TARGET))
130
131 ifneq ($(wildcard $(NON_BUILD_HOST)),)
132 CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST))
133 endif
134 ifneq ($(wildcard $(NON_BUILD_TARGET)),)
135 CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET))
136 endif
137
138 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
139 CFG_GCCISH_CFLAGS :=
140 CFG_GCCISH_LINK_FLAGS :=
141
142 ifdef CFG_DISABLE_OPTIMIZE
143   $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
144   CFG_RUSTC_FLAGS +=
145 else
146   # The rtopt cfg turns off runtime sanity checks
147   CFG_RUSTC_FLAGS += -O --cfg rtopt
148 endif
149
150 ifdef CFG_DISABLE_DEBUG
151   CFG_RUSTC_FLAGS += --cfg ndebug
152   CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
153 else
154   $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
155   CFG_RUSTC_FLAGS += --cfg debug
156   CFG_GCCISH_CFLAGS += -DRUST_DEBUG
157 endif
158
159 ifdef SAVE_TEMPS
160   CFG_RUSTC_FLAGS += --save-temps
161 endif
162 ifdef ASM_COMMENTS
163   CFG_RUSTC_FLAGS += -Z asm-comments
164 endif
165 ifdef TIME_PASSES
166   CFG_RUSTC_FLAGS += -Z time-passes
167 endif
168 ifdef TIME_LLVM_PASSES
169   CFG_RUSTC_FLAGS += -Z time-llvm-passes
170 endif
171 ifdef TRACE
172   CFG_RUSTC_FLAGS += -Z trace
173 endif
174 ifdef CFG_DISABLE_RPATH
175 CFG_RUSTC_FLAGS += -C no-rpath
176 endif
177
178 # The executables crated during this compilation process have no need to include
179 # static copies of libstd and libextra. We also generate dynamic versions of all
180 # libraries, so in the interest of space, prefer dynamic linking throughout the
181 # compilation process.
182 #
183 # Note though that these flags are omitted for stage2+. This means that the
184 # snapshot will be generated with a statically linked rustc so we only have to
185 # worry about the distribution of one file (with its native dynamic
186 # dependencies)
187 RUSTFLAGS_STAGE0 += -C prefer-dynamic
188 RUSTFLAGS_STAGE1 += -C prefer-dynamic
189
190 # platform-specific auto-configuration
191 include $(CFG_SRC_DIR)mk/platform.mk
192
193 # Run the stage1/2 compilers under valgrind
194 ifdef VALGRIND_COMPILE
195   CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
196 else
197   CFG_VALGRIND_COMPILE :=
198 endif
199
200 # version-string calculation
201 CFG_GIT_DIR := $(CFG_SRC_DIR).git
202 CFG_RELEASE = 0.10-pre
203 CFG_VERSION = $(CFG_RELEASE)
204 # windows exe's need numeric versions - don't use anything but
205 # numbers and dots here
206 CFG_VERSION_WIN = 0.10
207
208 # since $(CFG_GIT) may contain spaces (especially on Windows),
209 # we need to escape them. (" " to r"\ ")
210 # Note that $(subst ...) ignores space after `subst`,
211 # so we use a hack: define $(SPACE) which contains space character.
212 SPACE :=
213 SPACE +=
214 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT))),)
215 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),)
216     CFG_VERSION += $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 \
217                      --pretty=format:'(%h %ci)')
218     CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD)
219 endif
220 endif
221
222 ifdef CFG_ENABLE_VALGRIND
223   $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
224 else
225   CFG_VALGRIND :=
226 endif
227 ifdef CFG_BAD_VALGRIND
228   $(info cfg: disabling valgrind due to its unreliability on this platform)
229   CFG_VALGRIND :=
230 endif
231
232
233 ######################################################################
234 # Target-and-rule "utility variables"
235 ######################################################################
236
237 ifdef VERBOSE
238   Q :=
239   E =
240 else
241   Q := @
242   E = echo $(1)
243 endif
244
245 S := $(CFG_SRC_DIR)
246
247 define DEF_X
248 X_$(1) := $(CFG_EXE_SUFFIX_$(1))
249 endef
250 $(foreach target,$(CFG_TARGET),\
251   $(eval $(call DEF_X,$(target))))
252
253 # "Source" files we generate in builddir along the way.
254 GENERATED :=
255
256 # Delete the built-in rules.
257 .SUFFIXES:
258 %:: %,v
259 %:: RCS/%,v
260 %:: RCS/%
261 %:: s.%
262 %:: SCCS/s.%
263
264
265 ######################################################################
266 # Cleaning out old crates
267 ######################################################################
268
269 # $(1) is the path for directory to match against
270 # $(2) is the glob to use in the match
271 #
272 # Note that a common bug is to accidentally construct the glob denoted
273 # by $(2) with a space character prefix, which invalidates the
274 # construction $(1)$(2).
275 define CHECK_FOR_OLD_GLOB_MATCHES
276   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: there are previous" \'$(notdir $(2))\' "libraries:" $$MATCHES; fi
277 endef
278
279 # Same interface as above, but deletes rather than just listing the files.
280 ifdef VERBOSE
281 define REMOVE_ALL_OLD_GLOB_MATCHES
282   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: removing previous" \'$(notdir $(1))\' "libraries:" $$MATCHES; rm $$MATCHES ; fi
283 endef
284 else
285 define REMOVE_ALL_OLD_GLOB_MATCHES
286   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then rm $$MATCHES ; fi
287 endef
288 endif
289
290 # We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
291 # than in the macros above because it needs the result of running the
292 # `ls` command after other rules in the command list have run; the
293 # macro-expander for $(wildcard ...) would deliver its results too
294 # soon. (This is in contrast to the macros above, which are meant to
295 # be run at the outset of a command list in a rule.)
296 ifdef VERBOSE
297 define LIST_ALL_OLD_GLOB_MATCHES
298   @echo "info: now are following matches for" '$(notdir $(1))' "libraries:"
299   @( ls $(1) 2>/dev/null || true )
300 endef
301 else
302 define LIST_ALL_OLD_GLOB_MATCHES
303 endef
304 endif
305
306 ######################################################################
307 # LLVM macros
308 ######################################################################
309
310 # FIXME: x86-ism
311 LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \
312                 interpreter instrumentation
313
314 # Only build these LLVM tools
315 LLVM_TOOLS=bugpoint llc llvm-ar llvm-as llvm-dis llvm-mc opt llvm-extract
316
317 define DEF_LLVM_VARS
318 # The configure script defines these variables with the target triples
319 # separated by Z. This defines new ones with the expected format.
320 CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
321 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
322
323 # Any rules that depend on LLVM should depend on LLVM_CONFIG
324 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
325 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
326 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
327 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
328 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
329 LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
330 LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
331 LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
332 # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
333 # so we replace -I with -iquote to ensure that it searches bundled LLVM first.
334 LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
335 LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
336
337 LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
338 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
339
340 endef
341
342 $(foreach host,$(CFG_HOST), \
343  $(eval $(call DEF_LLVM_VARS,$(host))))
344
345 ######################################################################
346 # Exports for sub-utilities
347 ######################################################################
348
349 # Note that any variable that re-configure should pick up needs to be
350 # exported
351
352 export CFG_SRC_DIR
353 export CFG_BUILD_DIR
354 export CFG_VERSION
355 export CFG_VERSION_WIN
356 export CFG_RELEASE
357 export CFG_BUILD
358 export CFG_LLVM_ROOT
359 export CFG_ENABLE_MINGW_CROSS
360 export CFG_PREFIX
361 export CFG_LIBDIR
362 export CFG_RUSTLIBDIR
363 export CFG_LIBDIR_RELATIVE
364 export CFG_DISABLE_INJECT_STD_VERSION
365
366 ######################################################################
367 # Per-stage targets and runner
368 ######################################################################
369
370 include $(CFG_SRC_DIR)mk/crates.mk
371
372 define SREQ
373 # $(1) is the stage number
374 # $(2) is the target triple
375 # $(3) is the host triple
376
377 # Destinations of artifacts for the host compiler
378 HROOT$(1)_H_$(3) = $(3)/stage$(1)
379 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
380 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
381
382 # Destinations of artifacts for target architectures
383 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLIBDIR)/$(2)
384 TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
385 TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
386
387 # Preqrequisites for using the stageN compiler
388 ifeq ($(1),0)
389 HSREQ$(1)_H_$(3) = $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))
390 else
391 HSREQ$(1)_H_$(3) = \
392         $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
393         $$(HLIB$(1)_H_$(3))/stamp.rustc \
394         $$(foreach dep,$$(RUST_DEPS_rustc),$$(HLIB$(1)_H_$(3))/stamp.$$(dep)) \
395         $$(MKFILE_DEPS)
396 endif
397
398 # Prerequisites for using the stageN compiler to build target artifacts
399 TSREQ$(1)_T_$(2)_H_$(3) = \
400         $$(HSREQ$(1)_H_$(3)) \
401         $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a \
402         $$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a
403
404 # Prerequisites for a working stageN compiler and libraries, for a specific
405 # target
406 SREQ$(1)_T_$(2)_H_$(3) = \
407         $$(TSREQ$(1)_T_$(2)_H_$(3)) \
408         $$(foreach dep,$$(TARGET_CRATES),\
409             $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep))
410
411 # Prerequisites for a working stageN compiler and complete set of target
412 # libraries
413 CSREQ$(1)_T_$(2)_H_$(3) = \
414         $$(TSREQ$(1)_T_$(2)_H_$(3)) \
415         $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
416         $$(foreach dep,$$(CRATES),$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \
417         $$(foreach dep,$$(HOST_CRATES),$$(HLIB$(1)_H_$(3))/stamp.$$(dep))
418
419 ifeq ($(1),0)
420 # Don't run the the stage0 compiler under valgrind - that ship has sailed
421 CFG_VALGRIND_COMPILE$(1) =
422 else
423 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
424 endif
425
426 # Add RUSTFLAGS_STAGEN values to the build command
427 EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
428
429 CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
430
431 # Pass --cfg stage0 only for the build->host part of stage0;
432 # if you're building a cross config, the host->* parts are
433 # effectively stage1, since it uses the just-built stage0.
434 ifeq ($(1),0)
435 ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
436 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
437 endif
438 endif
439
440 ifdef CFG_DISABLE_RPATH
441 ifeq ($$(OSTYPE_$(3)),apple-darwin)
442   RPATH_VAR$(1)_T_$(2)_H_$(3) := \
443       DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(HLIB$(1)_H_$(3))"
444 else
445   RPATH_VAR$(1)_T_$(2)_H_$(3) := \
446       LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(HLIB$(1)_H_$(3))"
447 endif
448 else
449     RPATH_VAR$(1)_T_$(2)_H_$(3) :=
450 endif
451
452 STAGE$(1)_T_$(2)_H_$(3) :=                                              \
453         $$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3))                            \
454                 $$(call CFG_RUN_TARG_$(3),$(1),                         \
455                 $$(CFG_VALGRIND_COMPILE$(1))                            \
456                 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))                     \
457                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3))                     \
458                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
459                 $$(RUSTC_FLAGS_$(2))
460
461 PERF_STAGE$(1)_T_$(2)_H_$(3) :=                                         \
462         $$(Q)$$(call CFG_RUN_TARG_$(3),$(1),                            \
463                 $$(CFG_PERF_TOOL)                                       \
464                 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))                     \
465                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3))                     \
466                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
467                 $$(RUSTC_FLAGS_$(2))
468
469 endef
470
471 $(foreach build,$(CFG_HOST), \
472  $(eval $(foreach target,$(CFG_TARGET), \
473   $(eval $(foreach stage,$(STAGES), \
474    $(eval $(call SREQ,$(stage),$(target),$(build))))))))
475
476 ######################################################################
477 # rustc-H-targets
478 #
479 # Builds a functional Rustc for the given host.
480 ######################################################################
481
482 define DEF_RUSTC_STAGE_TARGET
483 # $(1) == architecture
484 # $(2) == stage
485
486 rustc-stage$(2)-H-$(1):                                                 \
487         $$(foreach target,$$(CFG_TARGET),$$(SREQ$(2)_T_$$(target)_H_$(1)))
488
489 endef
490
491 $(foreach host,$(CFG_HOST),                                             \
492  $(eval $(foreach stage,1 2 3,                                          \
493   $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
494
495 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
496 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
497 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
498
499 define DEF_RUSTC_TARGET
500 # $(1) == architecture
501
502 rustc-H-$(1): rustc-stage2-H-$(1)
503 endef
504
505 $(foreach host,$(CFG_TARGET),                   \
506  $(eval $(call DEF_RUSTC_TARGET,$(host))))
507
508 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
509 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
510 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
511 rustc: rustc-H-$(CFG_BUILD)
512
513 rustc-H-all: $(foreach host,$(CFG_HOST),rustc-H-$(host))
514
515 ######################################################################
516 # Entrypoint rule
517 ######################################################################
518
519 .DEFAULT_GOAL := all
520
521 define ALL_TARGET_N
522 ifneq ($$(findstring $(1),$$(CFG_HOST)),)
523 # This is a host
524 all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
525 else
526 # This is a target only
527 all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
528 endif
529 endef
530
531 $(foreach target,$(CFG_TARGET), \
532  $(foreach host,$(CFG_HOST), \
533  $(eval $(call ALL_TARGET_N,$(target),$(host)))))
534
535 ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
536         $(foreach host,$(CFG_HOST), \
537  all-target-$(target)-host-$(host)))
538
539 all: $(ALL_TARGET_RULES) $(GENERATED) docs
540
541
542 ######################################################################
543 # Re-configuration
544 ######################################################################
545
546 ifndef CFG_DISABLE_MANAGE_SUBMODULES
547 # This is a pretty expensive operation but I don't see any way to avoid it
548 NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
549 else
550 NEED_GIT_RECONFIG=0
551 endif
552
553 ifeq ($(NEED_GIT_RECONFIG),0)
554 else
555 # If the submodules have changed then always execute config.mk
556 .PHONY: config.stamp
557 endif
558
559 Makefile config.mk: config.stamp
560
561 config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
562         @$(call E, cfg: reconfiguring)
563         $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
564
565
566 ######################################################################
567 # Primary-target makefiles
568 ######################################################################
569
570 # Issue #9531: If you change the order of any of the following (or add
571 # new definitions), make sure definitions always precede their uses,
572 # especially for the dependency lists of recipes.
573
574 include $(CFG_SRC_DIR)mk/rt.mk
575 include $(CFG_SRC_DIR)mk/target.mk
576 include $(CFG_SRC_DIR)mk/host.mk
577 include $(CFG_SRC_DIR)mk/stage0.mk
578 include $(CFG_SRC_DIR)mk/rustllvm.mk
579 include $(CFG_SRC_DIR)mk/docs.mk
580 include $(CFG_SRC_DIR)mk/llvm.mk
581
582 ######################################################################
583 # Secondary makefiles, conditionalized for speed
584 ######################################################################
585
586 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS))   \
587                $(findstring check,$(MAKECMDGOALS))  \
588                $(findstring test,$(MAKECMDGOALS))   \
589                $(findstring tidy,$(MAKECMDGOALS))   \
590                $(findstring clean,$(MAKECMDGOALS))),)
591   CFG_INFO := $(info cfg: including dist rules)
592   include $(CFG_SRC_DIR)mk/dist.mk
593 endif
594
595 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS))   \
596                $(findstring clean,$(MAKECMDGOALS))),)
597   CFG_INFO := $(info cfg: including snap rules)
598   include $(CFG_SRC_DIR)mk/snap.mk
599 endif
600
601 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
602                $(findstring test,$(MAKECMDGOALS))  \
603                $(findstring perf,$(MAKECMDGOALS))  \
604                $(findstring tidy,$(MAKECMDGOALS))),)
605   CFG_INFO := $(info cfg: including test rules)
606   include $(CFG_SRC_DIR)mk/tests.mk
607 endif
608
609 ifneq ($(findstring perf,$(MAKECMDGOALS)),)
610   CFG_INFO := $(info cfg: including perf rules)
611   include $(CFG_SRC_DIR)mk/perf.mk
612 endif
613
614 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
615   CFG_INFO := $(info cfg: including clean rules)
616   include $(CFG_SRC_DIR)mk/clean.mk
617 endif
618
619 ifneq ($(findstring install,$(MAKECMDGOALS)),)
620   CFG_INFO := $(info cfg: including install rules)
621   include $(CFG_SRC_DIR)mk/install.mk
622 endif
623
624 ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
625                $(findstring TAGS.vi,$(MAKECMDGOALS))),)
626   CFG_INFO := $(info cfg: including ctags rules)
627   include $(CFG_SRC_DIR)mk/ctags.mk
628 endif
629
630 # Find all of the .d files and include them to add information about
631 # header file dependencies.
632 ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
633 -include $(ALL_DEP_FILES)
634
635 help:
636 # Show the comments from this file as "help"
637 # pick everything between tags | remove first line | remove last line
638 # | remove extra (?) line | strip leading `#` from lines
639         $(Q)awk '/<help>/,/<\/help>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^# \?//'