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