]> git.lizzy.rs Git - rust.git/blob - Makefile.in
a7594261c295e39f489aeeb2890bdfde0c1831ed
[rust.git] / Makefile.in
1 # An explanation of how the build is structured:
2 #
3 # There are multiple build stages (0-3) needed to verify that the
4 # compiler is properly self-hosting. Each stage is divided between
5 # 'host' artifacts and 'target' artifacts, where the stageN host
6 # compiler builds artifacts for 1 or more stageN target architectures.
7 # Once the stageN target compiler has been built for the host
8 # architecture it is promoted (copied) to a stageN+1 host artifact.
9 #
10 # The stage3 host compiler is a compiler that successfully builds
11 # itself and should (in theory) be bitwise identical to the stage2
12 # host compiler. The process is bootstrapped using a stage0 host
13 # compiler downloaded from a previous snapshot.
14 #
15 # At no time should stageN artifacts be interacting with artifacts
16 # from other stages. For consistency, we use the 'promotion' logic
17 # for all artifacts, even those that don't make sense on non-host
18 # architectures.
19 #
20 # The directory layout for a stage is intended to match the layout
21 # of the installed compiler, and looks like the following:
22 #
23 # stageN - this is the system root, corresponding to, e.g. /usr
24 #   bin - binaries compiled for the host
25 #   lib - libraries used by the host compiler
26 #     rustc - rustc's own place to organize libraries
27 #       $(target) - target-specific artifacts
28 #         bin - binaries for target architectures
29 #         lib - libraries for target architectures
30 #
31 # A note about host libraries:
32 #
33 # The only libraries that get promoted to stageN/lib are those needed
34 # by rustc. In general, rust programs, even those compiled for the
35 # host architecture will use libraries from the target
36 # directories. This gives rust some freedom to experiment with how
37 # libraries are managed and versioned without polluting the common
38 # areas of the filesystem.
39 #
40 # General rust binaries may stil live in the host bin directory; they
41 # will just link against the libraries in the target lib directory.
42 #
43 # Admittedly this is a little convoluted.
44
45 STAGES = 0 1 2 3
46
47 ######################################################################
48 # Residual auto-configuration
49 ######################################################################
50
51 # Recursive wildcard function
52 # http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
53 rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
54   $(filter $(subst *,%,$2),$d))
55
56 include config.mk
57
58 # We track all of the object files we might build so that we can find
59 # and include all of the .d files in one fell swoop.
60 ALL_OBJ_FILES :=
61
62 MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
63 NON_HOST_TRIPLES = $(filter-out $(CFG_HOST_TRIPLE),$(CFG_TARGET_TRIPLES))
64
65 ifneq ($(MAKE_RESTARTS),)
66 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
67 endif
68
69 CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE))
70
71 ifneq ($(wildcard $(NON_HOST_TRIPLES)),)
72 CFG_INFO := $(info cfg: non host triples $(NON_HOST_TRIPLES))
73 endif
74
75 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
76 CFG_GCCISH_CFLAGS :=
77 CFG_GCCISH_LINK_FLAGS :=
78
79 ifdef CFG_DISABLE_OPTIMIZE
80   $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
81   CFG_RUSTC_FLAGS +=
82 else
83   CFG_RUSTC_FLAGS += -O
84 endif
85
86 ifdef CFG_ENABLE_DEBUG
87   $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
88   CFG_RUSTC_FLAGS +=
89   CFG_GCCISH_CFLAGS += -DRUST_DEBUG
90 else
91   CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
92 endif
93
94 ifdef SAVE_TEMPS
95   CFG_RUSTC_FLAGS += --save-temps
96 endif
97 ifdef TIME_PASSES
98   CFG_RUSTC_FLAGS += -Z time-passes
99 endif
100 ifdef TIME_LLVM_PASSES
101   CFG_RUSTC_FLAGS += -Z time-llvm-passes
102 endif
103 ifdef TRACE
104   CFG_RUSTC_FLAGS += -Z trace
105 endif
106
107 # platform-specific auto-configuration
108 include $(CFG_SRC_DIR)mk/platform.mk
109
110 # Run the stage1/2 compilers under valgrind
111 ifdef VALGRIND_COMPILE
112   CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
113 else
114   CFG_VALGRIND_COMPILE :=
115 endif
116
117 CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
118 CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm)
119 CFG_CORELIB :=$(call CFG_LIB_NAME,core)
120 CFG_STDLIB :=$(call CFG_LIB_NAME,std)
121 CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
122 CFG_LIBSYNTAX :=$(call CFG_LIB_NAME,syntax)
123
124 STDLIB_GLOB :=$(call CFG_LIB_GLOB,std)
125 CORELIB_GLOB :=$(call CFG_LIB_GLOB,core)
126 LIBRUSTC_GLOB :=$(call CFG_LIB_GLOB,rustc)
127 LIBSYNTAX_GLOB :=$(call CFG_LIB_GLOB,syntax)
128 STDLIB_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,std)
129 CORELIB_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,core)
130 LIBRUSTC_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,rustc)
131 LIBSYNTAX_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,syntax)
132
133 # version-string calculation
134 CFG_GIT_DIR := $(CFG_SRC_DIR).git
135 CFG_RELEASE = 0.4
136 CFG_VERSION = $(CFG_RELEASE)
137
138 ifneq ($(wildcard $(CFG_GIT)),)
139 ifneq ($(wildcard $(CFG_GIT_DIR)),)
140     CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
141                      --pretty=format:'(%h %ci)')
142     CFG_VER_HASH = $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
143                      --pretty=format:'%H')
144 endif
145 endif
146
147 ifdef CFG_DISABLE_VALGRIND
148   $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND))
149   CFG_VALGRIND :=
150 endif
151 ifdef CFG_BAD_VALGRIND
152   $(info cfg: disabling valgrind due to its unreliability on this platform)
153   CFG_VALGRIND :=
154 endif
155
156
157 ######################################################################
158 # Target-and-rule "utility variables"
159 ######################################################################
160
161 ifdef VERBOSE
162   Q :=
163   E =
164 else
165   Q := @
166   E = echo $(1)
167 endif
168
169 S := $(CFG_SRC_DIR)
170 X := $(CFG_EXE_SUFFIX)
171
172 # Look in doc and src dirs.
173 VPATH := $(S)doc $(S)src
174
175 # "Source" files we generate in builddir along the way.
176 GENERATED :=
177
178 # Delete the built-in rules.
179 .SUFFIXES:
180 %:: %,v
181 %:: RCS/%,v
182 %:: RCS/%
183 %:: s.%
184 %:: SCCS/s.%
185
186 ######################################################################
187 # Core library variables
188 ######################################################################
189
190 CORELIB_CRATE := $(S)src/libcore/core.rc
191 CORELIB_INPUTS := $(wildcard $(addprefix $(S)src/libcore/,        \
192                                            core.rc *.rs */*.rs))
193
194 ######################################################################
195 # Standard library variables
196 ######################################################################
197
198 STDLIB_CRATE := $(S)src/libstd/std.rc
199 STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/,          \
200                                           std.rc *.rs */*.rs))
201
202 ######################################################################
203 # rustc crate variables
204 ######################################################################
205
206 COMPILER_CRATE := $(S)src/rustc/rustc.rc
207 COMPILER_INPUTS := $(filter-out $(S)src/rustc/driver/rustc.rs,     \
208                        $(wildcard $(addprefix $(S)src/rustc/,      \
209                            rustc.rc *.rs */*.rs */*/*.rs */*/*/*.rs)))
210
211 LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rc
212 LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
213                             syntax.rc *.rs */*.rs */*/*.rs))
214
215 RUSTC_INPUTS := $(S)src/rustc/driver/rustc.rs
216
217 ######################################################################
218 # LLVM macros
219 ######################################################################
220
221 # FIXME: x86-ism
222 LLVM_COMPONENTS=x86 ipo bitreader bitwriter linker asmparser jit mcjit \
223                 interpreter
224
225 define DEF_LLVM_VARS
226 # The configure script defines these variables with the target triples
227 # separated by Z. This defines new ones with the expected format.
228 CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
229 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
230
231 # Any rules that depend on LLVM should depend on LLVM_CONFIG
232 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X)
233 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X)
234 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
235 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
236 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
237 LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
238 LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
239 LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
240 # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
241 # so we replace -I with -iquote to ensure that it searches bundled LLVM first.
242 LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
243 LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
244
245 LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X)
246 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X)
247
248 endef
249
250 $(foreach target,$(CFG_TARGET_TRIPLES), \
251  $(eval $(call DEF_LLVM_VARS,$(target))))
252
253 ######################################################################
254 # Exports for sub-utilities
255 ######################################################################
256
257 # Note that any variable that re-configure should pick up needs to be
258 # exported
259
260 export CFG_SRC_DIR
261 export CFG_BUILD_DIR
262 export CFG_VERSION
263 export CFG_HOST_TRIPLE
264 export CFG_LLVM_ROOT
265 export CFG_ENABLE_MINGW_CROSS
266 export CFG_PREFIX
267 export CFG_LIBDIR
268
269 ######################################################################
270 # Subprograms
271 ######################################################################
272
273 ######################################################################
274 # Per-stage targets and runner
275 ######################################################################
276
277 define SREQ
278 # $(1) is the stage number
279 # $(2) is the target triple
280 # $(3) is the host triple
281
282 # Destinations of artifacts for the host compiler
283 HROOT$(1)_H_$(3) = $(3)/stage$(1)
284 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
285 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
286
287 # Destinations of artifacts for target architectures
288 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
289 TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
290 TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
291
292 # The name of the core and standard libraries used by rustc
293 ifdef CFG_DISABLE_SHAREDSTD
294   HCORELIB_DEFAULT$(1)_H_$(3) = \
295     $$(HLIB$(1)_H_$(3))/libcore.rlib
296   TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
297     $$(TLIB$(1)_T_$(2)_H_$(3))/libcore.rlib
298
299   HSTDLIB_DEFAULT$(1)_H_$(3) = \
300     $$(HLIB$(1)_H_$(3))/libstd.rlib
301   TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
302     $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
303
304   HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
305     $$(HLIB$(1)_H_$(3))/librustc.rlib
306   TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
307     $$(TLIB$(1)_T_$(2)_H_$(3))/librustc.rlib
308 else
309   HCORELIB_DEFAULT$(1)_H_$(3) = \
310     $$(HLIB$(1)_H_$(3))/$(CFG_CORELIB)
311   TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
312     $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_CORELIB)
313
314   HSTDLIB_DEFAULT$(1)_H_$(3) = \
315     $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB)
316   TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
317     $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB)
318
319   HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
320     $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC)
321   TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
322     $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC)
323 endif
324
325 # Preqrequisites for using the stageN compiler
326 HSREQ$(1)_H_$(3) = \
327         $$(HBIN$(1)_H_$(3))/rustc$$(X) \
328         $$(HLIB$(1)_H_$(3))/$$(CFG_RUNTIME) \
329         $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLLVM) \
330         $$(HCORELIB_DEFAULT$(1)_H_$(3)) \
331         $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
332         $$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \
333         $$(MKFILE_DEPS)
334
335 # Prerequisites for using the stageN compiler to build target artifacts
336 TSREQ$(1)_T_$(2)_H_$(3) = \
337         $$(HSREQ$(1)_H_$(3)) \
338         $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME) \
339         $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
340
341 # Prerequisites for complete stageN targets
342 SREQ$(1)_T_$(2)_H_$(3) = \
343         $$(TSREQ$(1)_T_$(2)_H_$(3)) \
344         $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
345         $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB)  \
346         $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC)
347
348 ifeq ($(1),0)
349 # Don't run the the stage0 compiler under valgrind - that ship has sailed
350 CFG_VALGRIND_COMPILE$(1) =
351 else
352 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
353 endif
354
355 # Add RUSTFLAGS_STAGEN values to the build command
356 EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
357
358 CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
359
360 # Pass --cfg stage0 only for the build->host part of stage0;
361 # if you're building a cross config, the host->* parts are
362 # effectively stage1, since it uses the just-built stage0.
363 ifeq ($(1),0)
364 ifneq ($(strip $(CFG_HOST_TRIPLE)),$(strip $(3)))
365 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
366 endif
367 endif
368
369 STAGE$(1)_T_$(2)_H_$(3) :=                                              \
370         $$(Q)$$(call CFG_RUN_TARG,$(1),                         \
371                 $$(CFG_VALGRIND_COMPILE$(1))                    \
372                 $$(HBIN$(1)_H_$(3))/rustc$$(X)                  \
373                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3))                     \
374                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2))
375
376 PERF_STAGE$(1)_T_$(2)_H_$(3) :=                                 \
377         $$(Q)$$(call CFG_RUN_TARG,$(1),                         \
378                 $$(CFG_PERF_TOOL)                                               \
379                 $$(HBIN$(1)_H_$(3))/rustc$$(X)                  \
380                 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3))                     \
381                 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2))
382
383 endef
384
385 $(foreach build,$(CFG_TARGET_TRIPLES), \
386  $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
387   $(eval $(foreach stage,$(STAGES), \
388    $(eval $(call SREQ,$(stage),$(target),$(build))))))))
389
390 ######################################################################
391 # rustc-H-targets
392 #
393 # Builds a functional Rustc for the given host.
394 ######################################################################
395
396 define DEF_RUSTC_STAGE_TARGET
397 # $(1) == architecture
398 # $(2) == stage
399
400 rustc-stage$(2)-H-$(1):                                                 \
401         $$(foreach target,$$(CFG_TARGET_TRIPLES),       \
402                 $$(SREQ$(2)_T_$$(target)_H_$(1)))
403
404 endef
405
406 $(foreach host,$(CFG_TARGET_TRIPLES),                                                   \
407  $(eval $(foreach stage,1 2 3,                                                                  \
408   $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
409
410 rustc-stage1: rustc-stage1-H-$(CFG_HOST_TRIPLE)
411 rustc-stage2: rustc-stage2-H-$(CFG_HOST_TRIPLE)
412 rustc-stage3: rustc-stage3-H-$(CFG_HOST_TRIPLE)
413
414 define DEF_RUSTC_TARGET
415 # $(1) == architecture
416
417 rustc-H-$(1): rustc-stage2-H-$(1)
418 endef
419
420 $(foreach host,$(CFG_TARGET_TRIPLES),                   \
421  $(eval $(call DEF_RUSTC_TARGET,$(host))))
422
423 rustc-stage1: rustc-stage1-H-$(CFG_HOST_TRIPLE)
424 rustc-stage2: rustc-stage2-H-$(CFG_HOST_TRIPLE)
425 rustc-stage3: rustc-stage3-H-$(CFG_HOST_TRIPLE)
426 rustc: rustc-H-$(CFG_HOST_TRIPLE)
427
428 rustc-H-all: $(foreach host,$(CFG_TARGET_TRIPLES),rustc-H-$(host))
429
430 ######################################################################
431 # Entrypoint rule
432 ######################################################################
433
434 .DEFAULT_GOAL := all
435
436 ifneq ($(CFG_IN_TRANSITION),)
437
438 CFG_INFO := $(info cfg:)
439 CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
440 CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
441 CFG_INFO := $(info cfg:)
442
443 all: $(SREQ1$(CFG_HOST_TRIPLE)) $(GENERATED) docs
444
445 else
446
447 TSREQS :=                                                                                       \
448         $(foreach target,$(CFG_TARGET_TRIPLES),                 \
449                 $(SREQ3_T_$(target)_H_$(CFG_HOST_TRIPLE)))
450 FUZZ := $(HBIN2_H_$(CFG_HOST_TRIPLE))/fuzzer$(X)
451 CARGO := $(HBIN2_H_$(CFG_HOST_TRIPLE))/cargo$(X)
452 RUSTDOC := $(HBIN2_H_$(CFG_HOST_TRIPLE))/rustdoc$(X)
453
454 all: rustc $(GENERATED) docs $(FUZZ) $(CARGO) $(RUSTDOC)
455
456 endif
457
458
459 ######################################################################
460 # Re-configuration
461 ######################################################################
462
463 ifndef CFG_DISABLE_MANAGE_SUBMODULES
464 # This is a pretty expensive operation but I don't see any way to avoid it
465 NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
466 else
467 NEED_GIT_RECONFIG=0
468 endif
469
470 ifeq ($(NEED_GIT_RECONFIG),0)
471 else
472 # If the submodules have changed then always execute config.mk
473 .PHONY: config.stamp
474 endif
475
476 Makefile config.mk: config.stamp
477
478 config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
479         @$(call E, cfg: reconfiguring)
480         $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
481
482
483 ######################################################################
484 # Primary-target makefiles
485 ######################################################################
486
487 include $(CFG_SRC_DIR)mk/target.mk
488 include $(CFG_SRC_DIR)mk/host.mk
489 include $(CFG_SRC_DIR)mk/stage0.mk
490 include $(CFG_SRC_DIR)mk/rt.mk
491 include $(CFG_SRC_DIR)mk/rustllvm.mk
492 include $(CFG_SRC_DIR)mk/tools.mk
493 include $(CFG_SRC_DIR)mk/docs.mk
494 include $(CFG_SRC_DIR)mk/llvm.mk
495
496 ######################################################################
497 # Secondary makefiles, conditionalized for speed
498 ######################################################################
499
500 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS))   \
501                $(findstring check,$(MAKECMDGOALS))  \
502                $(findstring test,$(MAKECMDGOALS))   \
503                $(findstring tidy,$(MAKECMDGOALS))   \
504                $(findstring clean,$(MAKECMDGOALS))),)
505   CFG_INFO := $(info cfg: including dist rules)
506   include $(CFG_SRC_DIR)mk/dist.mk
507 endif
508
509 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS))   \
510                $(findstring clean,$(MAKECMDGOALS))),)
511   CFG_INFO := $(info cfg: including snap rules)
512   include $(CFG_SRC_DIR)mk/snap.mk
513 endif
514
515 ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
516   CFG_INFO := $(info cfg: including reformat rules)
517   include $(CFG_SRC_DIR)mk/pp.mk
518 endif
519
520 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
521                $(findstring test,$(MAKECMDGOALS))  \
522                $(findstring perf,$(MAKECMDGOALS))  \
523                $(findstring tidy,$(MAKECMDGOALS))),)
524   CFG_INFO := $(info cfg: including test rules)
525   include $(CFG_SRC_DIR)mk/tests.mk
526 endif
527
528 ifneq ($(findstring perf,$(MAKECMDGOALS)),)
529   CFG_INFO := $(info cfg: including perf rules)
530   include $(CFG_SRC_DIR)mk/perf.mk
531 endif
532
533 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
534   CFG_INFO := $(info cfg: including clean rules)
535   include $(CFG_SRC_DIR)mk/clean.mk
536 endif
537
538 ifneq ($(findstring install,$(MAKECMDGOALS)),)
539   ifdef DESTDIR
540     CFG_INFO := $(info cfg: setting CFG_PREFIX via DESTDIR, $(DESTDIR)/$(CFG_PREFIX))
541     CFG_PREFIX:=$(DESTDIR)/$(CFG_PREFIX)
542     export CFG_PREFIX
543   endif
544
545   CFG_INFO := $(info cfg: including install rules)
546   include $(CFG_SRC_DIR)mk/install.mk
547 endif
548
549 ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
550                $(findstring TAGS.vi,$(MAKECMDGOALS))),)
551   CFG_INFO := $(info cfg: including ctags rules)
552   include $(CFG_SRC_DIR)mk/ctags.mk
553 endif
554
555 # Find all of the .d files and include them to add information about
556 # header file dependencies.
557 ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
558 -include $(ALL_DEP_FILES)