blob: f8379485e2c60fea407e3873b42b8c8ca6cd6708 [file] [log] [blame]
Graydon Hoared1affff2012-12-11 01:32:481# 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
Brian Anderson6e654562011-10-02 03:12:0811# 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# rustc - 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
Brian Anderson19797df2011-11-03 17:53:4944# by rustc. In general, rust programs, even those compiled for the
Brian Anderson6e654562011-10-02 03:12:0845# 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
Niko Matsakis9c12c7c2011-11-21 21:11:4055STAGES = 0 1 2 3
56
Graydon Hoare9c6e7e62011-03-16 16:17:3257######################################################################
58# Residual auto-configuration
59######################################################################
60
Graydon Hoare071dbfc2012-03-26 23:04:3761# Recursive wildcard function
62# http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
63rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
64 $(filter $(subst *,%,$2),$d))
65
Graydon Hoare9c6e7e62011-03-16 16:17:3266include config.mk
Graydon Hoare9c6e7e62011-03-16 16:17:3267
Michael Sullivanf99f2e82012-06-14 18:07:1968# 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.
70ALL_OBJ_FILES :=
71
Graydon Hoare071dbfc2012-03-26 23:04:3772MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
Brian Anderson15c0c352013-02-22 00:15:0173NON_BUILD_HOST_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_HOST_TRIPLES))
74NON_BUILD_TARGET_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_TARGET_TRIPLES))
Niko Matsakis8371beb2011-11-22 21:04:5275
Graydon Hoare9c6e7e62011-03-16 16:17:3276ifneq ($(MAKE_RESTARTS),)
77CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
78endif
79
Brian Anderson15c0c352013-02-22 00:15:0180CFG_INFO := $(info cfg: build triple $(CFG_BUILD_TRIPLE))
81CFG_INFO := $(info cfg: host triples $(CFG_HOST_TRIPLES))
82CFG_INFO := $(info cfg: target triples $(CFG_TARGET_TRIPLES))
Graydon Hoaref9044532012-03-26 23:05:4983
Brian Anderson15c0c352013-02-22 00:15:0184ifneq ($(wildcard $(NON_BUILD_HOST_TRIPLES)),)
85CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST_TRIPLES))
86endif
87ifneq ($(wildcard $(NON_BUILD_TARGET_TRIPLES)),)
88CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET_TRIPLES))
Graydon Hoaref9044532012-03-26 23:05:4989endif
Graydon Hoare9c6e7e62011-03-16 16:17:3290
Brian Andersonc8426d12012-05-20 01:27:1291CFG_RUSTC_FLAGS := $(RUSTFLAGS)
Brian Andersonf4529732012-03-30 02:10:3892CFG_GCCISH_CFLAGS :=
93CFG_GCCISH_LINK_FLAGS :=
94
Graydon Hoarecae703c2011-04-08 22:44:4195ifdef CFG_DISABLE_OPTIMIZE
Graydon Hoare19ebc0f2011-04-08 23:29:1996 $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
Brian Andersonf4529732012-03-30 02:10:3897 CFG_RUSTC_FLAGS +=
Graydon Hoarecae703c2011-04-08 22:44:4198else
Brian Anderson30a7a5b2013-08-17 06:14:5599 # The rtopt cfg turns off runtime sanity checks
100 CFG_RUSTC_FLAGS += -O --cfg rtopt
Brian Andersonf4529732012-03-30 02:10:38101endif
102
Alex Crichton04427642013-09-21 08:49:38103ifdef CFG_DISABLE_DEBUG
Alex Crichton833a64d2013-09-18 04:02:11104 CFG_RUSTC_FLAGS += --cfg ndebug
Brian Andersonf4529732012-03-30 02:10:38105 CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
Alex Crichton04427642013-09-21 08:49:38106else
107 $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
108 CFG_RUSTC_FLAGS += --cfg debug
109 CFG_GCCISH_CFLAGS += -DRUST_DEBUG
Graydon Hoarecae703c2011-04-08 22:44:41110endif
Graydon Hoare4c2245d2011-03-18 06:51:45111
Patrick Walton3f77e7d2011-04-25 21:20:28112ifdef SAVE_TEMPS
Marijn Haverbeke6b11f6c2011-04-26 18:32:08113 CFG_RUSTC_FLAGS += --save-temps
Patrick Walton3f77e7d2011-04-25 21:20:28114endif
Niko Matsakis989d0082013-05-04 18:29:32115ifdef ASM_COMMENTS
Niko Matsakis682bb412013-06-16 00:15:38116 CFG_RUSTC_FLAGS += -Z asm-comments
Niko Matsakis989d0082013-05-04 18:29:32117endif
Patrick Walton648c4ae2011-04-29 18:55:32118ifdef TIME_PASSES
Niko Matsakis5be8bf12012-05-18 04:53:49119 CFG_RUSTC_FLAGS += -Z time-passes
Patrick Walton648c4ae2011-04-29 18:55:32120endif
Brian Anderson27522842011-06-19 00:26:41121ifdef TIME_LLVM_PASSES
Niko Matsakis5be8bf12012-05-18 04:53:49122 CFG_RUSTC_FLAGS += -Z time-llvm-passes
Brian Anderson27522842011-06-19 00:26:41123endif
Niko Matsakis5e36a992012-08-28 22:54:45124ifdef TRACE
125 CFG_RUSTC_FLAGS += -Z trace
126endif
Patrick Walton08e561a2013-05-15 21:01:54127ifndef DEBUG_BORROWS
128 RUSTFLAGS_STAGE1 += -Z no-debug-borrows
129 RUSTFLAGS_STAGE2 += -Z no-debug-borrows
130endif
Patrick Walton3f77e7d2011-04-25 21:20:28131
Graydon Hoare40624e32011-05-01 20:18:52132# platform-specific auto-configuration
Graydon Hoare89dec282012-03-26 23:05:33133include $(CFG_SRC_DIR)mk/platform.mk
Graydon Hoare4c2245d2011-03-18 06:51:45134
Brian Andersoncad8c732011-05-14 03:20:34135# Run the stage1/2 compilers under valgrind
136ifdef VALGRIND_COMPILE
137 CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
138else
139 CFG_VALGRIND_COMPILE :=
140endif
141
Graydon Hoare1e03f002011-05-06 18:21:51142# version-string calculation
143CFG_GIT_DIR := $(CFG_SRC_DIR).git
Brian Anderson695cb9f2013-09-21 23:25:08144CFG_RELEASE = 0.8
Graydon Hoare80c7bfb2012-01-18 00:49:44145CFG_VERSION = $(CFG_RELEASE)
Brian Anderson59905d12013-06-27 22:36:05146# windows exe's need numeric versions - don't use anything but
147# numbers and dots here
Brian Andersonb0a9d812013-07-08 17:25:45148CFG_VERSION_WIN = 0.8
Graydon Hoare80c7bfb2012-01-18 00:49:44149
Graydon Hoare0a8f9a32011-06-13 21:45:26150ifneq ($(wildcard $(CFG_GIT)),)
Graydon Hoare1e03f002011-05-06 18:21:51151ifneq ($(wildcard $(CFG_GIT_DIR)),)
152 CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
153 --pretty=format:'(%h %ci)')
Ramkumar Ramachandra1a987262013-06-05 13:44:00154 CFG_VER_HASH = $(shell git --git-dir=$(CFG_GIT_DIR) rev-parse HEAD)
Graydon Hoare1e03f002011-05-06 18:21:51155endif
Graydon Hoare0a8f9a32011-06-13 21:45:26156endif
Graydon Hoare1e03f002011-05-06 18:21:51157
Brian Anderson55d134d2012-10-20 21:27:56158ifdef CFG_ENABLE_VALGRIND
159 $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
160else
Graydon Hoare4c2245d2011-03-18 06:51:45161 CFG_VALGRIND :=
Graydon Hoare9c6e7e62011-03-16 16:17:32162endif
Patrick Walton518e2d22011-05-06 01:11:40163ifdef CFG_BAD_VALGRIND
164 $(info cfg: disabling valgrind due to its unreliability on this platform)
165 CFG_VALGRIND :=
166endif
Graydon Hoare9c6e7e62011-03-16 16:17:32167
Graydon Hoare28a4e772011-03-23 17:37:35168
Graydon Hoare4c2245d2011-03-18 06:51:45169######################################################################
170# Target-and-rule "utility variables"
171######################################################################
172
173ifdef VERBOSE
174 Q :=
175 E =
176else
177 Q := @
178 E = echo $(1)
179endif
180
Graydon Hoare4c2245d2011-03-18 06:51:45181S := $(CFG_SRC_DIR)
Young-il Choi7714d522013-03-02 12:25:12182
183define DEF_X
184X_$(1) := $(CFG_EXE_SUFFIX_$(1))
185endef
186$(foreach target,$(CFG_TARGET_TRIPLES),\
187 $(eval $(call DEF_X,$(target))))
Graydon Hoare4c2245d2011-03-18 06:51:45188
189# Look in doc and src dirs.
190VPATH := $(S)doc $(S)src
191
Graydon Hoare4c2245d2011-03-18 06:51:45192# "Source" files we generate in builddir along the way.
Graydon Hoare40624e32011-05-01 20:18:52193GENERATED :=
Graydon Hoare4c2245d2011-03-18 06:51:45194
195# Delete the built-in rules.
196.SUFFIXES:
197%:: %,v
198%:: RCS/%,v
199%:: RCS/%
200%:: s.%
201%:: SCCS/s.%
Graydon Hoare9c6e7e62011-03-16 16:17:32202
Young-il Choi7714d522013-03-02 12:25:12203
204######################################################################
205# Crates
206######################################################################
207
208define DEF_LIBS
Graydon Hoare28a4e772011-03-23 17:37:35209
Young-il Choi26a5dc52013-02-27 05:53:35210CFG_RUNTIME_$(1) :=$(call CFG_LIB_NAME_$(1),rustrt)
211CFG_RUSTLLVM_$(1) :=$(call CFG_LIB_NAME_$(1),rustllvm)
Young-il Choi26a5dc52013-02-27 05:53:35212CFG_STDLIB_$(1) :=$(call CFG_LIB_NAME_$(1),std)
Patrick Walton0c820d42013-05-17 17:45:09213CFG_EXTRALIB_$(1) :=$(call CFG_LIB_NAME_$(1),extra)
Young-il Choi26a5dc52013-02-27 05:53:35214CFG_LIBRUSTC_$(1) :=$(call CFG_LIB_NAME_$(1),rustc)
215CFG_LIBSYNTAX_$(1) :=$(call CFG_LIB_NAME_$(1),syntax)
Young-il Choi26a5dc52013-02-27 05:53:35216CFG_LIBRUSTPKG_$(1) :=$(call CFG_LIB_NAME_$(1),rustpkg)
217CFG_LIBRUSTDOC_$(1) :=$(call CFG_LIB_NAME_$(1),rustdoc)
218CFG_LIBRUSTI_$(1) :=$(call CFG_LIB_NAME_$(1),rusti)
219CFG_LIBRUST_$(1) :=$(call CFG_LIB_NAME_$(1),rust)
220
Patrick Waltonf3723cf2013-05-17 22:28:44221EXTRALIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),extra)
222STDLIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),std)
Young-il Choi26a5dc52013-02-27 05:53:35223LIBRUSTC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustc)
224LIBSYNTAX_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),syntax)
Young-il Choi26a5dc52013-02-27 05:53:35225LIBRUSTPKG_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustpkg)
226LIBRUSTDOC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustdoc)
227LIBRUSTI_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rusti)
228LIBRUST_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rust)
Patrick Walton0c820d42013-05-17 17:45:09229EXTRALIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),extra)
Young-il Choi26a5dc52013-02-27 05:53:35230STDLIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),std)
Young-il Choi26a5dc52013-02-27 05:53:35231LIBRUSTC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustc)
232LIBSYNTAX_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),syntax)
Young-il Choi26a5dc52013-02-27 05:53:35233LIBRUSTPKG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustpkg)
234LIBRUSTDOC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc)
235LIBRUSTI_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rusti)
236LIBRUST_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rust)
237
238endef
239
Felix S. Klock II033ac542013-07-04 14:51:45240# $(1) is the path for directory to match against
241# $(2) is the glob to use in the match
242# $(3) is filename (usually the target being created) to filter out from match
243# (i.e. filename is not out-of-date artifact from prior Rust version/build)
Felix S. Klock II25f51ee2013-07-08 16:35:47244#
245# Note that a common bug is to accidentally construct the glob denoted
246# by $(2) with a space character prefix, which invalidates the
247# construction $(1)$(2).
Felix S. Klock II033ac542013-07-04 14:51:45248define CHECK_FOR_OLD_GLOB_MATCHES_EXCEPT
Felix S. Klock II25f51ee2013-07-08 16:35:47249 $(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "Warning: there are previous" \'$(2)\' "libraries:" $$MATCHES; fi
Felix S. Klock II033ac542013-07-04 14:51:45250endef
251
252# Same interface as above, but deletes rather than just listing the files.
253define REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT
Felix S. Klock IIb6a01382013-07-18 07:43:19254 $(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "Warning: removing previous" \'$(2)\' "libraries:" $$MATCHES; rm $$MATCHES ; fi
Felix S. Klock II033ac542013-07-04 14:51:45255endef
256
Felix S. Klock II25f51ee2013-07-08 16:35:47257# We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
258# than in the macros above because it needs the result of running the
259# `ls` command after other rules in the command list have run; the
260# macro-expander for $(wildcard ...) would deliver its results too
261# soon. (This is in contrast to the macros above, which are meant to
262# be run at the outset of a command list in a rule.)
Felix S. Klock II033ac542013-07-04 14:51:45263ifdef VERBOSE
264define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
265 @echo "Info: now are following matches for" '$(2)' "libraries:"
266 @( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) || true )
267endef
268else
269define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
270endef
271endif
272
Young-il Choi7714d522013-03-02 12:25:12273$(foreach target,$(CFG_TARGET_TRIPLES),\
274 $(eval $(call DEF_LIBS,$(target))))
Graydon Hoare9c6e7e62011-03-16 16:17:32275
Graydon Hoare4c2245d2011-03-18 06:51:45276######################################################################
277# Standard library variables
278######################################################################
279
Alex Crichton42b44b22013-06-10 20:00:38280STDLIB_CRATE := $(S)src/libstd/std.rs
Patrick Walton0c820d42013-05-17 17:45:09281STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
Alex Crichton42b44b22013-06-10 20:00:38282 *.rs */*.rs */*/*rs */*/*/*rs))
Patrick Walton0c820d42013-05-17 17:45:09283
284######################################################################
285# Extra library variables
286######################################################################
287
Alex Crichton42b44b22013-06-10 20:00:38288EXTRALIB_CRATE := $(S)src/libextra/extra.rs
Patrick Walton0c820d42013-05-17 17:45:09289EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
Alex Crichton42b44b22013-06-10 20:00:38290 *.rs */*.rs))
Graydon Hoare4c2245d2011-03-18 06:51:45291
292######################################################################
293# rustc crate variables
294######################################################################
295
Alex Crichton42b44b22013-06-10 20:00:38296COMPILER_CRATE := $(S)src/librustc/rustc.rs
Brian Anderson69a8b4d2012-11-07 03:44:58297COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
Alex Crichton42b44b22013-06-10 20:00:38298 *.rs */*.rs */*/*.rs */*/*/*.rs))
Haitao Libc95ccb2011-12-20 10:17:13299
Alex Crichton42b44b22013-06-10 20:00:38300LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs
Kevin Cantu7dcbaed2012-05-30 04:35:12301LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
Huon Wilson44acdad2013-07-20 14:37:47302 *.rs */*.rs */*/*.rs */*/*/*.rs))
Brian Andersona0ed1fb2012-03-22 22:27:35303
Brian Anderson69a8b4d2012-11-07 03:44:58304DRIVER_CRATE := $(S)src/driver/driver.rs
Graydon Hoare4c2245d2011-03-18 06:51:45305
306######################################################################
Brian Andersona0ff3db2011-11-02 00:09:44307# LLVM macros
308######################################################################
309
Brian Andersona92218e2011-11-27 06:38:36310# FIXME: x86-ism
Jyun-Yan You5150b982013-01-29 14:28:08311LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \
James Millerd694e282013-05-27 23:15:31312 interpreter instrumentation
Brian Andersona92218e2011-11-27 06:38:36313
Brian Anderson4b6585c2011-11-02 23:21:17314define DEF_LLVM_VARS
315# The configure script defines these variables with the target triples
316# separated by Z. This defines new ones with the expected format.
317CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
318CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
Brian Andersona0ff3db2011-11-02 00:09:44319
Brian Anderson4b6585c2011-11-02 23:21:17320# Any rules that depend on LLVM should depend on LLVM_CONFIG
Young-il Choi7714d522013-03-02 12:25:12321LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
322LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
Brian Anderson4b6585c2011-11-02 23:21:17323LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
324LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
325LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
326LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
Brian Andersona92218e2011-11-27 06:38:36327LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
Brian Anderson4b6585c2011-11-02 23:21:17328LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
Jyun-Yan You5e250b62012-01-26 09:13:57329# On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
330# so we replace -I with -iquote to ensure that it searches bundled LLVM first.
331LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
Brian Anderson4b6585c2011-11-02 23:21:17332LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
333
Young-il Choi7714d522013-03-02 12:25:12334LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
335LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
Brian Anderson4b6585c2011-11-02 23:21:17336
337endef
338
Brian Anderson15c0c352013-02-22 00:15:01339$(foreach host,$(CFG_HOST_TRIPLES), \
340 $(eval $(call DEF_LLVM_VARS,$(host))))
Brian Anderson4b6585c2011-11-02 23:21:17341
Brian Andersona0ff3db2011-11-02 00:09:44342######################################################################
Graydon Hoared987b492011-05-03 06:37:52343# Exports for sub-utilities
344######################################################################
345
Brian Anderson6e654562011-10-02 03:12:08346# Note that any variable that re-configure should pick up needs to be
347# exported
348
Graydon Hoared987b492011-05-03 06:37:52349export CFG_SRC_DIR
Graydon Hoaread954fc2011-07-23 19:26:47350export CFG_BUILD_DIR
Graydon Hoare1e03f002011-05-06 18:21:51351export CFG_VERSION
Brian Anderson59905d12013-06-27 22:36:05352export CFG_VERSION_WIN
Brian Anderson15c0c352013-02-22 00:15:01353export CFG_BUILD_TRIPLE
Graydon Hoare6a4a85f2011-05-18 19:00:26354export CFG_LLVM_ROOT
Graydon Hoare0dc2aa32011-06-28 18:18:25355export CFG_ENABLE_MINGW_CROSS
Brian Anderson6e654562011-10-02 03:12:08356export CFG_PREFIX
Brian Anderson9e40e432012-01-11 01:45:03357export CFG_LIBDIR
Graydon Hoared987b492011-05-03 06:37:52358
Patrick Walton04f966f2011-05-05 01:28:30359######################################################################
360# Subprograms
361######################################################################
362
Graydon Hoared987b492011-05-03 06:37:52363######################################################################
Graydon Hoarefafb42e2011-07-15 23:12:41364# Per-stage targets and runner
365######################################################################
366
367define SREQ
Niko Matsakis9c12c7c2011-11-21 21:11:40368# $(1) is the stage number
369# $(2) is the target triple
Graydon Hoare766e29c2011-11-30 03:28:15370# $(3) is the host triple
Brian Andersoned106dd2011-09-30 19:08:51371
Brian Anderson38c67a42011-09-30 19:24:28372# Destinations of artifacts for the host compiler
Niko Matsakis9c12c7c2011-11-21 21:11:40373HROOT$(1)_H_$(3) = $(3)/stage$(1)
374HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
Brian Anderson9e40e432012-01-11 01:45:03375HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
Brian Anderson38c67a42011-09-30 19:24:28376
Brian Anderson9563c172011-10-01 02:00:19377# Destinations of artifacts for target architectures
Niko Matsakis9c12c7c2011-11-21 21:11:40378TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
379TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
Brian Anderson9e40e432012-01-11 01:45:03380TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
Brian Andersoned106dd2011-09-30 19:08:51381
Patrick Walton0c820d42013-05-17 17:45:09382# The name of the standard and extra libraries used by rustc
Rafael Ávila de Espíndola88894b62011-07-20 20:02:36383ifdef CFG_DISABLE_SHAREDSTD
Niko Matsakis9c12c7c2011-11-21 21:11:40384 HSTDLIB_DEFAULT$(1)_H_$(3) = \
385 $$(HLIB$(1)_H_$(3))/libstd.rlib
386 TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
387 $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
Graydon Hoare4f826b32011-12-17 01:21:18388
Patrick Walton0c820d42013-05-17 17:45:09389 HEXTRALIB_DEFAULT$(1)_H_$(3) = \
390 $$(HLIB$(1)_H_$(3))/libextra.rlib
391 TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
392 $$(TLIB$(1)_T_$(2)_H_$(3))/libextra.rlib
393
Graydon Hoare4f826b32011-12-17 01:21:18394 HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
395 $$(HLIB$(1)_H_$(3))/librustc.rlib
396 TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
397 $$(TLIB$(1)_T_$(2)_H_$(3))/librustc.rlib
Brian Andersonf634eb22011-09-30 23:11:47398else
Niko Matsakis9c12c7c2011-11-21 21:11:40399 HSTDLIB_DEFAULT$(1)_H_$(3) = \
Young-il Choi26a5dc52013-02-27 05:53:35400 $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB_$(3))
Niko Matsakis9c12c7c2011-11-21 21:11:40401 TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
Young-il Choi26a5dc52013-02-27 05:53:35402 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2))
Graydon Hoare4f826b32011-12-17 01:21:18403
Patrick Walton0c820d42013-05-17 17:45:09404 HEXTRALIB_DEFAULT$(1)_H_$(3) = \
405 $$(HLIB$(1)_H_$(3))/$(CFG_EXTRALIB_$(3))
406 TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
407 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
408
Graydon Hoare4f826b32011-12-17 01:21:18409 HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
Young-il Choi26a5dc52013-02-27 05:53:35410 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC_$(3))
Graydon Hoare4f826b32011-12-17 01:21:18411 TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
Young-il Choi7714d522013-03-02 12:25:12412 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2))
Brian Andersonf634eb22011-09-30 23:11:47413endif
414
Brian Anderson6e654562011-10-02 03:12:08415# Preqrequisites for using the stageN compiler
Niko Matsakis9c12c7c2011-11-21 21:11:40416HSREQ$(1)_H_$(3) = \
Young-il Choi7714d522013-03-02 12:25:12417 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
Young-il Choi26a5dc52013-02-27 05:53:35418 $$(HLIB$(1)_H_$(3))/$(CFG_RUNTIME_$(3)) \
419 $$(HLIB$(1)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
Niko Matsakis9c12c7c2011-11-21 21:11:40420 $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
Patrick Walton0c820d42013-05-17 17:45:09421 $$(HEXTRALIB_DEFAULT$(1)_H_$(3)) \
Brian Andersoncf002e92012-11-13 21:32:49422 $$(HLIBSYNTAX_DEFAULT$(1)_H_$(3)) \
Graydon Hoare4f826b32011-12-17 01:21:18423 $$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \
Niko Matsakis5ce33ce2011-11-29 20:42:05424 $$(MKFILE_DEPS)
Brian Anderson6e654562011-10-02 03:12:08425
426# Prerequisites for using the stageN compiler to build target artifacts
Niko Matsakis9c12c7c2011-11-21 21:11:40427TSREQ$(1)_T_$(2)_H_$(3) = \
428 $$(HSREQ$(1)_H_$(3)) \
Young-il Choi26a5dc52013-02-27 05:53:35429 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)) \
Niko Matsakis9c12c7c2011-11-21 21:11:40430 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
Brian Anderson6e654562011-10-02 03:12:08431
Brian Andersone4c0fad2012-11-16 02:13:37432# Prerequisites for a working stageN compiler and libraries, for a specific target
Niko Matsakis9c12c7c2011-11-21 21:11:40433SREQ$(1)_T_$(2)_H_$(3) = \
434 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
Patrick Walton0c820d42013-05-17 17:45:09435 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
436 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
Brian Andersoncf002e92012-11-13 21:32:49437
Brian Andersone4c0fad2012-11-16 02:13:37438# Prerequisites for a working stageN compiler and libraries, for a specific target
Brian Andersoncf002e92012-11-13 21:32:49439CSREQ$(1)_T_$(2)_H_$(3) = \
440 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
Young-il Choi7714d522013-03-02 12:25:12441 $$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
442 $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
443 $$(HBIN$(1)_H_$(3))/rusti$$(X_$(3)) \
444 $$(HBIN$(1)_H_$(3))/rust$$(X_$(3)) \
Young-il Choi26a5dc52013-02-27 05:53:35445 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \
446 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTDOC_$(3)) \
447 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTI_$(3)) \
448 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUST_$(3)) \
Patrick Walton0c820d42013-05-17 17:45:09449 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
450 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)) \
Young-il Choi7714d522013-03-02 12:25:12451 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(2)) \
452 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2)) \
Young-il Choi7714d522013-03-02 12:25:12453 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2)) \
454 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTDOC_$(2)) \
455 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTI_$(2)) \
456 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUST_$(2))
Graydon Hoarefafb42e2011-07-15 23:12:41457
Brian Andersone3d3aaa2011-08-26 18:11:49458ifeq ($(1),0)
459# Don't run the the stage0 compiler under valgrind - that ship has sailed
460CFG_VALGRIND_COMPILE$(1) =
461else
462CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
463endif
464
Brian Andersonc88ab582012-06-27 23:01:19465# Add RUSTFLAGS_STAGEN values to the build command
466EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
467
Brian Andersoncb341382012-09-23 21:05:44468CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
469
Graydon Hoaree7b83882012-09-26 21:57:35470# Pass --cfg stage0 only for the build->host part of stage0;
471# if you're building a cross config, the host->* parts are
472# effectively stage1, since it uses the just-built stage0.
473ifeq ($(1),0)
Brian Anderson15c0c352013-02-22 00:15:01474ifneq ($(strip $(CFG_BUILD_TRIPLE)),$(strip $(3)))
Graydon Hoaree7b83882012-09-26 21:57:35475CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
476endif
477endif
478
Niko Matsakis9c12c7c2011-11-21 21:11:40479STAGE$(1)_T_$(2)_H_$(3) := \
Young-il Choi7714d522013-03-02 12:25:12480 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
Brian Anderson55d134d2012-10-20 21:27:56481 $$(CFG_VALGRIND_COMPILE$(1)) \
Young-il Choi7714d522013-03-02 12:25:12482 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
Brian Andersoncb341382012-09-23 21:05:44483 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
Young-il Choi7714d522013-03-02 12:25:12484 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
485 $$(RUSTC_FLAGS_$(2))
Brian Anderson7dbce102011-09-29 19:06:37486
Niko Matsakis9c12c7c2011-11-21 21:11:40487PERF_STAGE$(1)_T_$(2)_H_$(3) := \
Young-il Choi7714d522013-03-02 12:25:12488 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
Niko Matsakis9c12c7c2011-11-21 21:11:40489 $$(CFG_PERF_TOOL) \
Young-il Choi7714d522013-03-02 12:25:12490 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
Brian Andersoncb341382012-09-23 21:05:44491 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
Young-il Choi7714d522013-03-02 12:25:12492 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
493 $$(RUSTC_FLAGS_$(2))
Brian Anderson7dbce102011-09-29 19:06:37494
Graydon Hoarefafb42e2011-07-15 23:12:41495endef
496
Brian Anderson15c0c352013-02-22 00:15:01497$(foreach build,$(CFG_HOST_TRIPLES), \
Niko Matsakis9c12c7c2011-11-21 21:11:40498 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
499 $(eval $(foreach stage,$(STAGES), \
500 $(eval $(call SREQ,$(stage),$(target),$(build))))))))
Graydon Hoarefafb42e2011-07-15 23:12:41501
502######################################################################
Niko Matsakis3bbfe512011-12-03 00:04:27503# rustc-H-targets
504#
505# Builds a functional Rustc for the given host.
506######################################################################
507
Niko Matsakis15d60322011-12-06 22:02:03508define DEF_RUSTC_STAGE_TARGET
509# $(1) == architecture
510# $(2) == stage
511
512rustc-stage$(2)-H-$(1): \
513 $$(foreach target,$$(CFG_TARGET_TRIPLES), \
514 $$(SREQ$(2)_T_$$(target)_H_$(1)))
515
516endef
517
Brian Anderson15c0c352013-02-22 00:15:01518$(foreach host,$(CFG_HOST_TRIPLES), \
Niko Matsakis15d60322011-12-06 22:02:03519 $(eval $(foreach stage,1 2 3, \
520 $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
521
Brian Anderson15c0c352013-02-22 00:15:01522rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
523rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
524rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
Niko Matsakisc28ada02011-12-09 16:16:04525
Niko Matsakis3bbfe512011-12-03 00:04:27526define DEF_RUSTC_TARGET
527# $(1) == architecture
528
Haitao Li394a80c2012-01-16 05:42:03529rustc-H-$(1): rustc-stage2-H-$(1)
Niko Matsakis3bbfe512011-12-03 00:04:27530endef
531
532$(foreach host,$(CFG_TARGET_TRIPLES), \
533 $(eval $(call DEF_RUSTC_TARGET,$(host))))
534
Brian Anderson15c0c352013-02-22 00:15:01535rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
536rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
537rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
538rustc: rustc-H-$(CFG_BUILD_TRIPLE)
Niko Matsakis68c62722011-12-13 04:28:35539
Brian Anderson15c0c352013-02-22 00:15:01540rustc-H-all: $(foreach host,$(CFG_HOST_TRIPLES),rustc-H-$(host))
Niko Matsakis3bbfe512011-12-03 00:04:27541
542######################################################################
Graydon Hoarefafb42e2011-07-15 23:12:41543# Entrypoint rule
Graydon Hoare4c2245d2011-03-18 06:51:45544######################################################################
545
Brian Andersonc9b14cc2011-12-13 20:02:17546.DEFAULT_GOAL := all
547
Graydon Hoareae784df2011-05-14 00:00:43548ifneq ($(CFG_IN_TRANSITION),)
549
Graydon Hoare9ac29482011-05-16 22:14:58550CFG_INFO := $(info cfg:)
Graydon Hoareae784df2011-05-14 00:00:43551CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
552CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
Graydon Hoare9ac29482011-05-16 22:14:58553CFG_INFO := $(info cfg:)
Graydon Hoareae784df2011-05-14 00:00:43554
Brian Andersone4c0fad2012-11-16 02:13:37555#XXX This is surely busted
Brian Anderson15c0c352013-02-22 00:15:01556all: $(SREQ1$(CFG_BUILD_TRIPLE)) $(GENERATED) docs
Brian Andersonb0560962011-09-30 23:15:02557
Graydon Hoareae784df2011-05-14 00:00:43558else
Brian Anderson86ed9052011-09-30 03:27:28559
Brian Andersone4c0fad2012-11-16 02:13:37560define ALL_TARGET_N
Brian Anderson15c0c352013-02-22 00:15:01561ifneq ($$(findstring $(1),$$(CFG_HOST_TRIPLES)),)
562# This is a host
Brian Andersone4c0fad2012-11-16 02:13:37563all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
Brian Anderson15c0c352013-02-22 00:15:01564else
565# This is a target only
566all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
567endif
Brian Andersone4c0fad2012-11-16 02:13:37568endef
569
570$(foreach target,$(CFG_TARGET_TRIPLES), \
Brian Anderson15c0c352013-02-22 00:15:01571 $(foreach host,$(CFG_HOST_TRIPLES), \
572 $(eval $(call ALL_TARGET_N,$(target),$(host)))))
Brian Andersone4c0fad2012-11-16 02:13:37573
574ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \
Brian Anderson15c0c352013-02-22 00:15:01575 $(foreach host,$(CFG_HOST_TRIPLES), \
576 all-target-$(target)-host-$(host)))
Brian Andersone4c0fad2012-11-16 02:13:37577
Alex Crichton44be4a42013-09-04 06:47:13578all: $(ALL_TARGET_RULES) $(GENERATED) docs
Brian Anderson6e654562011-10-02 03:12:08579
Graydon Hoareae784df2011-05-14 00:00:43580endif
581
Graydon Hoare10f33602011-03-25 17:29:45582
583######################################################################
584# Re-configuration
585######################################################################
586
Brian Anderson8d7863f2011-11-29 01:50:23587ifndef CFG_DISABLE_MANAGE_SUBMODULES
Brian Anderson0e150112011-11-01 01:19:40588# This is a pretty expensive operation but I don't see any way to avoid it
Brian Anderson143f8782011-11-26 04:00:48589NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
Brian Anderson8d7863f2011-11-29 01:50:23590else
591NEED_GIT_RECONFIG=0
592endif
Brian Anderson0e150112011-11-01 01:19:40593
594ifeq ($(NEED_GIT_RECONFIG),0)
595else
596# If the submodules have changed then always execute config.mk
Graydon Hoare071dbfc2012-03-26 23:04:37597.PHONY: config.stamp
Brian Anderson0e150112011-11-01 01:19:40598endif
599
Graydon Hoare071dbfc2012-03-26 23:04:37600Makefile config.mk: config.stamp
601
602config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
Graydon Hoare10f33602011-03-25 17:29:45603 @$(call E, cfg: reconfiguring)
Graydon Hoaredf8161d2011-06-30 20:41:20604 $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
Graydon Hoare10f33602011-03-25 17:29:45605
606
Graydon Hoaree961f532011-03-21 18:23:19607######################################################################
Graydon Hoare79ba3152011-06-25 19:23:27608# Primary-target makefiles
Graydon Hoaree961f532011-03-21 18:23:19609######################################################################
610
Felix S. Klock II2835df22013-09-26 21:56:53611# Issue #9531: If you change the order of any of the following (or add
612# new definitions), make sure definitions always precede their uses,
613# especially for the dependency lists of recipes.
614
Graydon Hoare89dec282012-03-26 23:05:33615include $(CFG_SRC_DIR)mk/target.mk
616include $(CFG_SRC_DIR)mk/host.mk
617include $(CFG_SRC_DIR)mk/stage0.mk
618include $(CFG_SRC_DIR)mk/rt.mk
619include $(CFG_SRC_DIR)mk/rustllvm.mk
Graydon Hoare89dec282012-03-26 23:05:33620include $(CFG_SRC_DIR)mk/tools.mk
621include $(CFG_SRC_DIR)mk/docs.mk
622include $(CFG_SRC_DIR)mk/llvm.mk
Graydon Hoare79ba3152011-06-25 19:23:27623
Graydon Hoare79ba3152011-06-25 19:23:27624######################################################################
625# Secondary makefiles, conditionalized for speed
626######################################################################
627
Graydon Hoaredf8161d2011-06-30 20:41:20628ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
629 $(findstring check,$(MAKECMDGOALS)) \
630 $(findstring test,$(MAKECMDGOALS)) \
Graydon Hoare39151f22011-07-13 22:44:09631 $(findstring tidy,$(MAKECMDGOALS)) \
Graydon Hoaredf8161d2011-06-30 20:41:20632 $(findstring clean,$(MAKECMDGOALS))),)
633 CFG_INFO := $(info cfg: including dist rules)
Graydon Hoare89dec282012-03-26 23:05:33634 include $(CFG_SRC_DIR)mk/dist.mk
Graydon Hoare79ba3152011-06-25 19:23:27635endif
636
Graydon Hoaredf8161d2011-06-30 20:41:20637ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
638 $(findstring clean,$(MAKECMDGOALS))),)
639 CFG_INFO := $(info cfg: including snap rules)
Graydon Hoare89dec282012-03-26 23:05:33640 include $(CFG_SRC_DIR)mk/snap.mk
Graydon Hoare79ba3152011-06-25 19:23:27641endif
642
643ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
Graydon Hoaredf8161d2011-06-30 20:41:20644 CFG_INFO := $(info cfg: including reformat rules)
Graydon Hoare89dec282012-03-26 23:05:33645 include $(CFG_SRC_DIR)mk/pp.mk
Graydon Hoare79ba3152011-06-25 19:23:27646endif
647
Graydon Hoaredf8161d2011-06-30 20:41:20648ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
649 $(findstring test,$(MAKECMDGOALS)) \
Graydon Hoared5b2d622011-09-13 22:06:21650 $(findstring perf,$(MAKECMDGOALS)) \
Graydon Hoaredf8161d2011-06-30 20:41:20651 $(findstring tidy,$(MAKECMDGOALS))),)
652 CFG_INFO := $(info cfg: including test rules)
Graydon Hoare89dec282012-03-26 23:05:33653 include $(CFG_SRC_DIR)mk/tests.mk
Graydon Hoare79ba3152011-06-25 19:23:27654endif
655
Graydon Hoared5b2d622011-09-13 22:06:21656ifneq ($(findstring perf,$(MAKECMDGOALS)),)
657 CFG_INFO := $(info cfg: including perf rules)
Graydon Hoare89dec282012-03-26 23:05:33658 include $(CFG_SRC_DIR)mk/perf.mk
Graydon Hoared5b2d622011-09-13 22:06:21659endif
660
Graydon Hoare79ba3152011-06-25 19:23:27661ifneq ($(findstring clean,$(MAKECMDGOALS)),)
Graydon Hoaredf8161d2011-06-30 20:41:20662 CFG_INFO := $(info cfg: including clean rules)
Graydon Hoare89dec282012-03-26 23:05:33663 include $(CFG_SRC_DIR)mk/clean.mk
Michael Sullivanb01ecb12011-07-21 18:58:01664endif
Brian Anderson9563c172011-10-01 02:00:19665
666ifneq ($(findstring install,$(MAKECMDGOALS)),)
Kevin Cantuc9d53ca2012-01-20 12:17:32667 ifdef DESTDIR
Luca Bruno27a984e2012-10-01 21:09:56668 CFG_INFO := $(info cfg: setting CFG_PREFIX via DESTDIR, $(DESTDIR)/$(CFG_PREFIX))
669 CFG_PREFIX:=$(DESTDIR)/$(CFG_PREFIX)
Kevin Cantuc9d53ca2012-01-20 12:17:32670 export CFG_PREFIX
671 endif
672
Brian Anderson9563c172011-10-01 02:00:19673 CFG_INFO := $(info cfg: including install rules)
Graydon Hoare89dec282012-03-26 23:05:33674 include $(CFG_SRC_DIR)mk/install.mk
Niko Matsakise1c470c2011-10-12 19:10:21675endif
676
677ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
678 $(findstring TAGS.vi,$(MAKECMDGOALS))),)
679 CFG_INFO := $(info cfg: including ctags rules)
Graydon Hoare89dec282012-03-26 23:05:33680 include $(CFG_SRC_DIR)mk/ctags.mk
Niko Matsakise1c470c2011-10-12 19:10:21681endif
Michael Sullivanf99f2e82012-06-14 18:07:19682
683# Find all of the .d files and include them to add information about
684# header file dependencies.
685ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
686-include $(ALL_DEP_FILES)