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