]> git.lizzy.rs Git - rust.git/blob - mk/main.mk
Add verbose option to rustdoc in order to fix problem with --version
[rust.git] / mk / main.mk
1 # Copyright 2014 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 ######################################################################
12 # Version numbers and strings
13 ######################################################################
14
15 # The version number
16 CFG_RELEASE_NUM=0.13.0
17
18 CFG_FILENAME_EXTRA=4e7c5e5c
19
20 ifeq ($(CFG_RELEASE_CHANNEL),stable)
21 # This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"
22 CFG_RELEASE=$(CFG_RELEASE_NUM)
23 # This is the string used in dist artifact file names, e.g. "0.12.0", "nightly"
24 CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)
25 endif
26 ifeq ($(CFG_RELEASE_CHANNEL),beta)
27 CFG_RELEASE=$(CFG_RELEASE_NUM)-beta
28 # When building beta/nightly distributables just reuse the same "beta"
29 # name so when we upload we'll always override the previous
30 # nighly. This doesn't actually impact the version reported by rustc -
31 # it's just for file naming.
32 CFG_PACKAGE_VERS=beta
33 endif
34 ifeq ($(CFG_RELEASE_CHANNEL),nightly)
35 CFG_RELEASE=$(CFG_RELEASE_NUM)-nightly
36 CFG_PACKAGE_VERS=nightly
37 endif
38 ifeq ($(CFG_RELEASE_CHANNEL),dev)
39 CFG_RELEASE=$(CFG_RELEASE_NUM)-dev
40 CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev
41 endif
42
43 # The name of the package to use for creating tarballs, installers etc.
44 CFG_PACKAGE_NAME=rust-$(CFG_PACKAGE_VERS)
45
46 # The version string plus commit information - this is what rustc reports
47 CFG_VERSION = $(CFG_RELEASE)
48 CFG_GIT_DIR := $(CFG_SRC_DIR).git
49 # since $(CFG_GIT) may contain spaces (especially on Windows),
50 # we need to escape them. (" " to r"\ ")
51 # Note that $(subst ...) ignores space after `subst`,
52 # so we use a hack: define $(SPACE) which contains space character.
53 SPACE :=
54 SPACE +=
55 ifneq ($(CFG_GIT),)
56 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),)
57     CFG_VER_DATE = $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 --pretty=format:'%ci')
58     CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD)
59     CFG_SHORT_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse --short=9 HEAD)
60     CFG_VERSION += ($(CFG_SHORT_VER_HASH) $(CFG_VER_DATE))
61 endif
62 endif
63
64 # Windows exe's need numeric versions - don't use anything but
65 # numbers and dots here
66 CFG_VERSION_WIN = $(CFG_RELEASE_NUM)
67
68
69 ######################################################################
70 # More configuration
71 ######################################################################
72
73 # We track all of the object files we might build so that we can find
74 # and include all of the .d files in one fell swoop.
75 ALL_OBJ_FILES :=
76
77 MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
78 MKFILES_FOR_TARBALL:=$(MKFILE_DEPS)
79 ifneq ($(NO_MKFILE_DEPS),)
80 MKFILE_DEPS :=
81 endif
82 NON_BUILD_HOST = $(filter-out $(CFG_BUILD),$(CFG_HOST))
83 NON_BUILD_TARGET = $(filter-out $(CFG_BUILD),$(CFG_TARGET))
84
85 ifneq ($(MAKE_RESTARTS),)
86 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
87 endif
88
89 CFG_INFO := $(info cfg: build triple $(CFG_BUILD))
90 CFG_INFO := $(info cfg: host triples $(CFG_HOST))
91 CFG_INFO := $(info cfg: target triples $(CFG_TARGET))
92
93 ifneq ($(wildcard $(NON_BUILD_HOST)),)
94 CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST))
95 endif
96 ifneq ($(wildcard $(NON_BUILD_TARGET)),)
97 CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET))
98 endif
99
100 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
101 CFG_GCCISH_CFLAGS :=
102 CFG_GCCISH_LINK_FLAGS :=
103
104 # Turn off broken quarantine (see jemalloc/jemalloc#161)
105 CFG_JEMALLOC_FLAGS := --disable-fill
106
107 ifdef CFG_DISABLE_OPTIMIZE
108   $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
109   CFG_RUSTC_FLAGS +=
110   CFG_JEMALLOC_FLAGS += --enable-debug
111 else
112   # The rtopt cfg turns off runtime sanity checks
113   CFG_RUSTC_FLAGS += -O --cfg rtopt
114 endif
115
116 CFG_JEMALLOC_FLAGS += $(JEMALLOC_FLAGS)
117
118 ifdef CFG_DISABLE_DEBUG
119   CFG_RUSTC_FLAGS += --cfg ndebug
120   CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
121 else
122   $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
123   CFG_RUSTC_FLAGS += --cfg debug
124   CFG_GCCISH_CFLAGS += -DRUST_DEBUG
125 endif
126
127 ifdef SAVE_TEMPS
128   CFG_RUSTC_FLAGS += --save-temps
129 endif
130 ifdef ASM_COMMENTS
131   CFG_RUSTC_FLAGS += -Z asm-comments
132 endif
133 ifdef TIME_PASSES
134   CFG_RUSTC_FLAGS += -Z time-passes
135 endif
136 ifdef TIME_LLVM_PASSES
137   CFG_RUSTC_FLAGS += -Z time-llvm-passes
138 endif
139 ifdef TRACE
140   CFG_RUSTC_FLAGS += -Z trace
141 endif
142 ifdef CFG_ENABLE_RPATH
143 CFG_RUSTC_FLAGS += -C rpath
144 endif
145
146 # The executables crated during this compilation process have no need to include
147 # static copies of libstd and libextra. We also generate dynamic versions of all
148 # libraries, so in the interest of space, prefer dynamic linking throughout the
149 # compilation process.
150 #
151 # Note though that these flags are omitted for the *bins* in stage2+. This means
152 # that the snapshot will be generated with a statically linked rustc so we only
153 # have to worry about the distribution of one file (with its native dynamic
154 # dependencies)
155 RUSTFLAGS_STAGE0 += -C prefer-dynamic
156 RUSTFLAGS_STAGE1 += -C prefer-dynamic
157 RUST_LIB_FLAGS_ST2 += -C prefer-dynamic
158 RUST_LIB_FLAGS_ST3 += -C prefer-dynamic
159
160 # Landing pads require a lot of codegen. We can get through bootstrapping faster
161 # by not emitting them.
162 RUSTFLAGS_STAGE0 += -Z no-landing-pads
163
164 # platform-specific auto-configuration
165 include $(CFG_SRC_DIR)mk/platform.mk
166
167 # Run the stage1/2 compilers under valgrind
168 ifdef VALGRIND_COMPILE
169   CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
170 else
171   CFG_VALGRIND_COMPILE :=
172 endif
173
174
175 ifndef CFG_DISABLE_VALGRIND_RPASS
176   $(info cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS))
177   CFG_VALGRIND_RPASS :=$(CFG_VALGRIND)
178 else
179   CFG_VALGRIND_RPASS :=
180 endif
181
182
183 ifdef CFG_ENABLE_VALGRIND
184   $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
185 else
186   CFG_VALGRIND :=
187 endif
188
189 ######################################################################
190 # Target-and-rule "utility variables"
191 ######################################################################
192
193 define DEF_FOR_TARGET
194 X_$(1) := $(CFG_EXE_SUFFIX_$(1))
195 ifndef CFG_LLVM_TARGET_$(1)
196 CFG_LLVM_TARGET_$(1) := $(1)
197 endif
198 endef
199 $(foreach target,$(CFG_TARGET), \
200   $(eval $(call DEF_FOR_TARGET,$(target))))
201
202 # "Source" files we generate in builddir along the way.
203 GENERATED :=
204
205 # Delete the built-in rules.
206 .SUFFIXES:
207 %:: %,v
208 %:: RCS/%,v
209 %:: RCS/%
210 %:: s.%
211 %:: SCCS/s.%
212
213
214 ######################################################################
215 # Cleaning out old crates
216 ######################################################################
217
218 # $(1) is the path for directory to match against
219 # $(2) is the glob to use in the match
220 #
221 # Note that a common bug is to accidentally construct the glob denoted
222 # by $(2) with a space character prefix, which invalidates the
223 # construction $(1)$(2).
224 define CHECK_FOR_OLD_GLOB_MATCHES
225   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: there are previous" \'$(notdir $(2))\' "libraries:" $$MATCHES; fi
226 endef
227
228 # Same interface as above, but deletes rather than just listing the files.
229 ifdef VERBOSE
230 define REMOVE_ALL_OLD_GLOB_MATCHES
231   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: removing previous" \'$(notdir $(1))\' "libraries:" $$MATCHES; rm $$MATCHES ; fi
232 endef
233 else
234 define REMOVE_ALL_OLD_GLOB_MATCHES
235   $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then rm $$MATCHES ; fi
236 endef
237 endif
238
239 # We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
240 # than in the macros above because it needs the result of running the
241 # `ls` command after other rules in the command list have run; the
242 # macro-expander for $(wildcard ...) would deliver its results too
243 # soon. (This is in contrast to the macros above, which are meant to
244 # be run at the outset of a command list in a rule.)
245 ifdef VERBOSE
246 define LIST_ALL_OLD_GLOB_MATCHES
247   @echo "info: now are following matches for" '$(notdir $(1))' "libraries:"
248   @( ls $(1) 2>/dev/null || true )
249 endef
250 else
251 define LIST_ALL_OLD_GLOB_MATCHES
252 endef
253 endif
254
255 ######################################################################
256 # LLVM macros
257 ######################################################################
258
259 # FIXME: x86-ism
260 LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser mcjit \
261                 interpreter instrumentation
262
263 # Only build these LLVM tools
264 LLVM_TOOLS=bugpoint llc llvm-ar llvm-as llvm-dis llvm-mc opt llvm-extract
265
266 define DEF_LLVM_VARS
267 # The configure script defines these variables with the target triples
268 # separated by Z. This defines new ones with the expected format.
269 ifeq ($$(CFG_LLVM_ROOT),)
270 CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
271 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
272 else
273 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_ROOT)
274 endif
275
276 # Any rules that depend on LLVM should depend on LLVM_CONFIG
277 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
278 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
279 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
280 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
281 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
282 LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
283 LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
284 LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
285 # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
286 # so we replace -I with -iquote to ensure that it searches bundled LLVM first.
287 LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
288 LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
289
290 LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
291 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
292
293 endef
294
295 $(foreach host,$(CFG_HOST), \
296  $(eval $(call DEF_LLVM_VARS,$(host))))
297
298 ######################################################################
299 # Exports for sub-utilities
300 ######################################################################
301
302 # Note that any variable that re-configure should pick up needs to be
303 # exported
304
305 export CFG_SRC_DIR
306 export CFG_BUILD_DIR
307 ifdef CFG_VER_DATE
308 export CFG_VER_DATE
309 endif
310 ifdef CFG_VER_HASH
311 export CFG_VER_HASH
312 endif
313 export CFG_VERSION
314 export CFG_VERSION_WIN
315 export CFG_RELEASE
316 export CFG_PACKAGE_NAME
317 export CFG_BUILD
318 export CFG_LLVM_ROOT
319 export CFG_PREFIX
320 export CFG_LIBDIR
321 export CFG_LIBDIR_RELATIVE
322 export CFG_DISABLE_INJECT_STD_VERSION
323
324 ######################################################################
325 # Per-stage targets and runner
326 ######################################################################
327
328 STAGES = 0 1 2 3
329
330 define SREQ
331 # $(1) is the stage number
332 # $(2) is the target triple
333 # $(3) is the host triple
334
335 # Destinations of artifacts for the host compiler
336 HROOT$(1)_H_$(3) = $(3)/stage$(1)
337 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
338 ifeq ($$(CFG_WINDOWSY_$(3)),1)
339 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
340 else
341 ifeq ($(1),0)
342 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
343 else
344 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
345 endif
346 endif
347
348 # Destinations of artifacts for target architectures
349 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2)
350 TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
351 TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
352
353 # Preqrequisites for using the stageN compiler
354 ifeq ($(1),0)
355 HSREQ$(1)_H_$(3) = $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))
356 else
357 HSREQ$(1)_H_$(3) = \
358         $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
359         $$(MKFILE_DEPS) \
360         tmp/install-debugger-scripts$(1)_H_$(3).done
361 endif
362
363 # Prerequisites for using the stageN compiler to build target artifacts
364 TSREQ$(1)_T_$(2)_H_$(3) = \
365         $$(HSREQ$(1)_H_$(3)) \
366         $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a \
367         $$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a
368
369 # Prerequisites for a working stageN compiler and libraries, for a specific
370 # target
371 SREQ$(1)_T_$(2)_H_$(3) = \
372         $$(TSREQ$(1)_T_$(2)_H_$(3)) \
373         $$(foreach dep,$$(TARGET_CRATES), \
374             $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \
375         tmp/install-debugger-scripts$(1)_T_$(2)_H_$(3).done
376
377 # Prerequisites for a working stageN compiler and complete set of target
378 # libraries
379 CSREQ$(1)_T_$(2)_H_$(3) = \
380         $$(TSREQ$(1)_T_$(2)_H_$(3)) \
381         $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
382         $$(foreach dep,$$(CRATES),$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep))
383
384 ifeq ($(1),0)
385 # Don't run the stage0 compiler under valgrind - that ship has sailed
386 CFG_VALGRIND_COMPILE$(1) =
387 else
388 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
389 endif
390
391 # Add RUSTFLAGS_STAGEN values to the build command
392 EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
393
394 CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
395
396 endef
397
398 # Same macro/variables as above, but defined in a separate loop so it can use
399 # all the variables above for all archs. The RPATH_VAR setup sometimes needs to
400 # reach across triples to get things in order.
401 #
402 # Defines (with the standard $(1)_T_$(2)_H_$(3) suffix):
403 # * `LD_LIBRARY_PATH_ENV_NAME`: the name for the key to use in the OS
404 #   environment to access or extend the lookup path for dynamic
405 #   libraries.  Note on Windows, that key is `$PATH`, and thus not
406 #   only conflates programs with dynamic libraries, but also often
407 #   contains spaces which confuse make.
408 # * `LD_LIBRARY_PATH_ENV_HOSTDIR`: the entry to add to lookup path for the host
409 # * `LD_LIBRARY_PATH_ENV_TARGETDIR`: the entry to add to lookup path for target
410 #
411 # Below that, HOST_RPATH_VAR and TARGET_RPATH_VAR are defined in terms of the
412 # above settings.
413 #
414 define SREQ_CMDS
415
416 ifeq ($$(OSTYPE_$(3)),apple-darwin)
417   LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := DYLD_LIBRARY_PATH
418 else
419 ifeq ($$(CFG_WINDOWSY_$(3)),1)
420   LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := PATH
421 else
422   LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := LD_LIBRARY_PATH
423 endif
424 endif
425
426 LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3) := \
427     $$(CURDIR)/$$(HLIB$(1)_H_$(3))
428 LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3) := \
429     $$(CURDIR)/$$(TLIB1_T_$(2)_H_$(CFG_BUILD))
430
431 HOST_RPATH_VAR$(1)_T_$(2)_H_$(3) := \
432   $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3)):$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))
433 TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3) := \
434   $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3)):$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))
435
436 RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3))
437
438 # Pass --cfg stage0 only for the build->host part of stage0;
439 # if you're building a cross config, the host->* parts are
440 # effectively stage1, since it uses the just-built stage0.
441 #
442 # This logic is similar to how the LD_LIBRARY_PATH variable must
443 # change be slightly different when doing cross compilations.
444 # The build doesn't copy over all target libraries into
445 # a new directory, so we need to point the library path at
446 # the build directory where all the target libraries came
447 # from (the stage0 build host). Otherwise the relative rpaths
448 # inside of the rustc binary won't get resolved correctly.
449 ifeq ($(1),0)
450 ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
451 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
452
453 RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3))
454 endif
455 endif
456
457 STAGE$(1)_T_$(2)_H_$(3) := \
458         $$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3)) \
459                 $$(call CFG_RUN_TARG_$(3),$(1), \
460                 $$(CFG_VALGRIND_COMPILE$(1)) \
461                 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
462                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
463                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
464                 $$(RUSTC_FLAGS_$(2))
465
466 PERF_STAGE$(1)_T_$(2)_H_$(3) := \
467         $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
468                 $$(CFG_PERF_TOOL) \
469                 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
470                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
471                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
472                 $$(RUSTC_FLAGS_$(2))
473
474 endef
475
476 $(foreach build,$(CFG_HOST), \
477  $(eval $(foreach target,$(CFG_TARGET), \
478   $(eval $(foreach stage,$(STAGES), \
479    $(eval $(call SREQ,$(stage),$(target),$(build))))))))
480
481 $(foreach build,$(CFG_HOST), \
482  $(eval $(foreach target,$(CFG_TARGET), \
483   $(eval $(foreach stage,$(STAGES), \
484    $(eval $(call SREQ_CMDS,$(stage),$(target),$(build))))))))
485
486 ######################################################################
487 # rustc-H-targets
488 #
489 # Builds a functional Rustc for the given host.
490 ######################################################################
491
492 define DEF_RUSTC_STAGE_TARGET
493 # $(1) == architecture
494 # $(2) == stage
495
496 rustc-stage$(2)-H-$(1): \
497         $$(foreach target,$$(CFG_TARGET),$$(SREQ$(2)_T_$$(target)_H_$(1)))
498
499 endef
500
501 $(foreach host,$(CFG_HOST), \
502  $(eval $(foreach stage,1 2 3, \
503   $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
504
505 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
506 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
507 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
508
509 define DEF_RUSTC_TARGET
510 # $(1) == architecture
511
512 rustc-H-$(1): rustc-stage2-H-$(1)
513 endef
514
515 $(foreach host,$(CFG_TARGET), \
516  $(eval $(call DEF_RUSTC_TARGET,$(host))))
517
518 rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
519 rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
520 rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
521 rustc: rustc-H-$(CFG_BUILD)
522
523 rustc-H-all: $(foreach host,$(CFG_HOST),rustc-H-$(host))
524
525 ######################################################################
526 # Entrypoint rule
527 ######################################################################
528
529 .DEFAULT_GOAL := all
530
531 define ALL_TARGET_N
532 ifneq ($$(findstring $(1),$$(CFG_HOST)),)
533 # This is a host
534 all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
535 else
536 # This is a target only
537 all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
538 endif
539 endef
540
541 $(foreach target,$(CFG_TARGET), \
542  $(foreach host,$(CFG_HOST), \
543  $(eval $(call ALL_TARGET_N,$(target),$(host)))))
544
545 ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
546         $(foreach host,$(CFG_HOST), \
547  all-target-$(target)-host-$(host)))
548
549 all: $(ALL_TARGET_RULES) $(GENERATED) docs
550
551 ######################################################################
552 # Build system documentation
553 ######################################################################
554
555 # $(1) is the name of the doc <section> in Makefile.in
556 # pick everything between tags | remove first line | remove last line
557 # | remove extra (?) line | strip leading `#` from lines
558 SHOW_DOCS = $(Q)awk '/<$(1)>/,/<\/$(1)>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^\# \?//'
559
560 help:
561         $(call SHOW_DOCS,help)
562
563 tips:
564         $(call SHOW_DOCS,tips)
565
566 nitty-gritty:
567         $(call SHOW_DOCS,nitty-gritty)