Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 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 |
Brian Anderson | 19797df | 2011-11-03 17:53:49 | [diff] [blame] | 34 | # by rustc. In general, rust programs, even those compiled for the |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 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 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 45 | STAGES = 0 1 2 3 |
| 46 | |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 47 | ###################################################################### |
| 48 | # Residual auto-configuration |
| 49 | ###################################################################### |
| 50 | |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 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 | |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 56 | include config.mk |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 57 | |
Michael Sullivan | f99f2e8 | 2012-06-14 18:07:19 | [diff] [blame] | 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 | |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 62 | MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*) |
Niko Matsakis | 8371beb | 2011-11-22 21:04:52 | [diff] [blame] | 63 | NON_HOST_TRIPLES = $(filter-out $(CFG_HOST_TRIPLE),$(CFG_TARGET_TRIPLES)) |
| 64 | |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 65 | ifneq ($(MAKE_RESTARTS),) |
| 66 | CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS)) |
| 67 | endif |
| 68 | |
Graydon Hoare | 1321580 | 2011-09-21 18:24:59 | [diff] [blame] | 69 | CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE)) |
Graydon Hoare | f904453 | 2012-03-26 23:05:49 | [diff] [blame] | 70 | |
| 71 | ifneq ($(wildcard $(NON_HOST_TRIPLES)),) |
Niko Matsakis | 8371beb | 2011-11-22 21:04:52 | [diff] [blame] | 72 | CFG_INFO := $(info cfg: non host triples $(NON_HOST_TRIPLES)) |
Graydon Hoare | f904453 | 2012-03-26 23:05:49 | [diff] [blame] | 73 | endif |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 74 | |
Brian Anderson | c8426d1 | 2012-05-20 01:27:12 | [diff] [blame] | 75 | CFG_RUSTC_FLAGS := $(RUSTFLAGS) |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 76 | CFG_GCCISH_CFLAGS := |
| 77 | CFG_GCCISH_LINK_FLAGS := |
| 78 | |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 79 | ifdef CFG_DISABLE_OPTIMIZE |
Graydon Hoare | 19ebc0f | 2011-04-08 23:29:19 | [diff] [blame] | 80 | $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 81 | CFG_RUSTC_FLAGS += |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 82 | else |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 83 | CFG_RUSTC_FLAGS += -O |
| 84 | endif |
| 85 | |
| 86 | ifdef CFG_ENABLE_DEBUG |
| 87 | $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG)) |
Brian Anderson | 1bd4e35 | 2012-07-03 00:21:27 | [diff] [blame] | 88 | CFG_RUSTC_FLAGS += |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 89 | CFG_GCCISH_CFLAGS += -DRUST_DEBUG |
| 90 | else |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 91 | CFG_GCCISH_CFLAGS += -DRUST_NDEBUG |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 92 | endif |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 93 | |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 94 | ifdef SAVE_TEMPS |
Marijn Haverbeke | 6b11f6c | 2011-04-26 18:32:08 | [diff] [blame] | 95 | CFG_RUSTC_FLAGS += --save-temps |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 96 | endif |
Patrick Walton | 648c4ae | 2011-04-29 18:55:32 | [diff] [blame] | 97 | ifdef TIME_PASSES |
Niko Matsakis | 5be8bf1 | 2012-05-18 04:53:49 | [diff] [blame] | 98 | CFG_RUSTC_FLAGS += -Z time-passes |
Patrick Walton | 648c4ae | 2011-04-29 18:55:32 | [diff] [blame] | 99 | endif |
Brian Anderson | 2752284 | 2011-06-19 00:26:41 | [diff] [blame] | 100 | ifdef TIME_LLVM_PASSES |
Niko Matsakis | 5be8bf1 | 2012-05-18 04:53:49 | [diff] [blame] | 101 | CFG_RUSTC_FLAGS += -Z time-llvm-passes |
Brian Anderson | 2752284 | 2011-06-19 00:26:41 | [diff] [blame] | 102 | endif |
Niko Matsakis | 5e36a99 | 2012-08-28 22:54:45 | [diff] [blame] | 103 | ifdef TRACE |
| 104 | CFG_RUSTC_FLAGS += -Z trace |
| 105 | endif |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 106 | |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 107 | # platform-specific auto-configuration |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 108 | include $(CFG_SRC_DIR)mk/platform.mk |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 109 | |
Brian Anderson | cad8c73 | 2011-05-14 03:20:34 | [diff] [blame] | 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 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 117 | CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt) |
Graydon Hoare | 7ac885e | 2011-03-22 06:06:42 | [diff] [blame] | 118 | CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm) |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 119 | CFG_CORELIB :=$(call CFG_LIB_NAME,core) |
Haitao Li | b4f450a | 2011-11-18 08:00:28 | [diff] [blame] | 120 | CFG_STDLIB :=$(call CFG_LIB_NAME,std) |
Brian Anderson | 5fb9cad | 2011-07-01 06:16:01 | [diff] [blame] | 121 | CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc) |
Kevin Cantu | 7dcbaed | 2012-05-30 04:35:12 | [diff] [blame] | 122 | CFG_LIBSYNTAX :=$(call CFG_LIB_NAME,syntax) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 123 | |
Haitao Li | 6dbd4c2 | 2011-12-02 16:51:59 | [diff] [blame] | 124 | STDLIB_GLOB :=$(call CFG_LIB_GLOB,std) |
| 125 | CORELIB_GLOB :=$(call CFG_LIB_GLOB,core) |
| 126 | LIBRUSTC_GLOB :=$(call CFG_LIB_GLOB,rustc) |
Kevin Cantu | 7dcbaed | 2012-05-30 04:35:12 | [diff] [blame] | 127 | LIBSYNTAX_GLOB :=$(call CFG_LIB_GLOB,syntax) |
Josh Matthews | 8142438 | 2012-03-21 22:56:20 | [diff] [blame] | 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) |
Kevin Cantu | 7dcbaed | 2012-05-30 04:35:12 | [diff] [blame] | 131 | LIBSYNTAX_DSYM_GLOB :=$(call CFG_LIB_DSYM_GLOB,syntax) |
Haitao Li | 6dbd4c2 | 2011-12-02 16:51:59 | [diff] [blame] | 132 | |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 133 | # version-string calculation |
| 134 | CFG_GIT_DIR := $(CFG_SRC_DIR).git |
Brian Anderson | 65b05a6c | 2012-08-30 21:05:49 | [diff] [blame] | 135 | CFG_RELEASE = 0.4 |
Graydon Hoare | 80c7bfb | 2012-01-18 00:49:44 | [diff] [blame] | 136 | CFG_VERSION = $(CFG_RELEASE) |
| 137 | |
Graydon Hoare | 0a8f9a3 | 2011-06-13 21:45:26 | [diff] [blame] | 138 | ifneq ($(wildcard $(CFG_GIT)),) |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 139 | ifneq ($(wildcard $(CFG_GIT_DIR)),) |
| 140 | CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \ |
| 141 | --pretty=format:'(%h %ci)') |
Paul Stansifer | fa882d4 | 2012-07-17 23:15:37 | [diff] [blame] | 142 | CFG_VER_HASH = $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \ |
| 143 | --pretty=format:'%H') |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 144 | endif |
Graydon Hoare | 0a8f9a3 | 2011-06-13 21:45:26 | [diff] [blame] | 145 | endif |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 146 | |
Graydon Hoare | 94731fa | 2011-03-30 04:45:09 | [diff] [blame] | 147 | ifdef CFG_DISABLE_VALGRIND |
| 148 | $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND)) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 149 | CFG_VALGRIND := |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 150 | endif |
Patrick Walton | 518e2d2 | 2011-05-06 01:11:40 | [diff] [blame] | 151 | ifdef CFG_BAD_VALGRIND |
| 152 | $(info cfg: disabling valgrind due to its unreliability on this platform) |
| 153 | CFG_VALGRIND := |
| 154 | endif |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 155 | |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 156 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 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 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 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 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 175 | # "Source" files we generate in builddir along the way. |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 176 | GENERATED := |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 177 | |
| 178 | # Delete the built-in rules. |
| 179 | .SUFFIXES: |
| 180 | %:: %,v |
| 181 | %:: RCS/%,v |
| 182 | %:: RCS/% |
| 183 | %:: s.% |
| 184 | %:: SCCS/s.% |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 185 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 186 | ###################################################################### |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 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 | ###################################################################### |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 195 | # Standard library variables |
| 196 | ###################################################################### |
| 197 | |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 198 | STDLIB_CRATE := $(S)src/libstd/std.rc |
| 199 | STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \ |
| 200 | std.rc *.rs */*.rs)) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 201 | |
| 202 | ###################################################################### |
| 203 | # rustc crate variables |
| 204 | ###################################################################### |
| 205 | |
Graydon Hoare | 87c14f1 | 2012-02-29 19:46:23 | [diff] [blame] | 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/, \ |
Niko Matsakis | 28d0ce9 | 2012-05-19 17:31:48 | [diff] [blame] | 209 | rustc.rc *.rs */*.rs */*/*.rs */*/*/*.rs))) |
Haitao Li | bc95ccb | 2011-12-20 10:17:13 | [diff] [blame] | 210 | |
Kevin Cantu | 7dcbaed | 2012-05-30 04:35:12 | [diff] [blame] | 211 | LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rc |
| 212 | LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \ |
| 213 | syntax.rc *.rs */*.rs */*/*.rs)) |
Brian Anderson | a0ed1fb | 2012-03-22 22:27:35 | [diff] [blame] | 214 | |
Graydon Hoare | 87c14f1 | 2012-02-29 19:46:23 | [diff] [blame] | 215 | RUSTC_INPUTS := $(S)src/rustc/driver/rustc.rs |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 216 | |
| 217 | ###################################################################### |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 218 | # LLVM macros |
| 219 | ###################################################################### |
| 220 | |
Brian Anderson | a92218e | 2011-11-27 06:38:36 | [diff] [blame] | 221 | # FIXME: x86-ism |
Zack Corr | d7aa991 | 2012-08-25 04:54:30 | [diff] [blame] | 222 | LLVM_COMPONENTS=x86 ipo bitreader bitwriter linker asmparser jit mcjit \ |
| 223 | interpreter |
Brian Anderson | a92218e | 2011-11-27 06:38:36 | [diff] [blame] | 224 | |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 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))) |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 230 | |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 231 | # Any rules that depend on LLVM should depend on LLVM_CONFIG |
Brian Anderson | 283cf35 | 2011-12-14 06:43:32 | [diff] [blame] | 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) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 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) |
Brian Anderson | a92218e | 2011-11-27 06:38:36 | [diff] [blame] | 238 | LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS)) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 239 | LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags) |
Jyun-Yan You | 5e250b6 | 2012-01-26 09:13:57 | [diff] [blame] | 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)) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 243 | LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target) |
| 244 | |
Brian Anderson | ecdeffb | 2011-12-14 03:03:43 | [diff] [blame] | 245 | LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X) |
| 246 | LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 247 | |
| 248 | endef |
| 249 | |
| 250 | $(foreach target,$(CFG_TARGET_TRIPLES), \ |
| 251 | $(eval $(call DEF_LLVM_VARS,$(target)))) |
| 252 | |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 253 | ###################################################################### |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 254 | # Exports for sub-utilities |
| 255 | ###################################################################### |
| 256 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 257 | # Note that any variable that re-configure should pick up needs to be |
| 258 | # exported |
| 259 | |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 260 | export CFG_SRC_DIR |
Graydon Hoare | ad954fc | 2011-07-23 19:26:47 | [diff] [blame] | 261 | export CFG_BUILD_DIR |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 262 | export CFG_VERSION |
Brian Anderson | 6306c81 | 2011-09-29 19:21:58 | [diff] [blame] | 263 | export CFG_HOST_TRIPLE |
Graydon Hoare | 6a4a85f | 2011-05-18 19:00:26 | [diff] [blame] | 264 | export CFG_LLVM_ROOT |
Graydon Hoare | 0dc2aa3 | 2011-06-28 18:18:25 | [diff] [blame] | 265 | export CFG_ENABLE_MINGW_CROSS |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 266 | export CFG_PREFIX |
Brian Anderson | 9e40e43 | 2012-01-11 01:45:03 | [diff] [blame] | 267 | export CFG_LIBDIR |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 268 | |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 269 | ###################################################################### |
| 270 | # Subprograms |
| 271 | ###################################################################### |
| 272 | |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 273 | ###################################################################### |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 274 | # Per-stage targets and runner |
| 275 | ###################################################################### |
| 276 | |
| 277 | define SREQ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 278 | # $(1) is the stage number |
| 279 | # $(2) is the target triple |
Graydon Hoare | 766e29c | 2011-11-30 03:28:15 | [diff] [blame] | 280 | # $(3) is the host triple |
Brian Anderson | ed106dd | 2011-09-30 19:08:51 | [diff] [blame] | 281 | |
Brian Anderson | 38c67a4 | 2011-09-30 19:24:28 | [diff] [blame] | 282 | # Destinations of artifacts for the host compiler |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 283 | HROOT$(1)_H_$(3) = $(3)/stage$(1) |
| 284 | HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin |
Brian Anderson | 9e40e43 | 2012-01-11 01:45:03 | [diff] [blame] | 285 | HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR) |
Brian Anderson | 38c67a4 | 2011-09-30 19:24:28 | [diff] [blame] | 286 | |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 287 | # Destinations of artifacts for target architectures |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 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 |
Brian Anderson | 9e40e43 | 2012-01-11 01:45:03 | [diff] [blame] | 290 | TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR) |
Brian Anderson | ed106dd | 2011-09-30 19:08:51 | [diff] [blame] | 291 | |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 292 | # The name of the core and standard libraries used by rustc |
Rafael Ávila de Espíndola | 88894b6 | 2011-07-20 20:02:36 | [diff] [blame] | 293 | ifdef CFG_DISABLE_SHAREDSTD |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 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 |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 298 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 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 |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 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 |
Brian Anderson | f634eb2 | 2011-09-30 23:11:47 | [diff] [blame] | 308 | else |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 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) |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 313 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 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) |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 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) |
Brian Anderson | f634eb2 | 2011-09-30 23:11:47 | [diff] [blame] | 323 | endif |
| 324 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 325 | # Preqrequisites for using the stageN compiler |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 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) \ |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 330 | $$(HCORELIB_DEFAULT$(1)_H_$(3)) \ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 331 | $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \ |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 332 | $$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \ |
Niko Matsakis | 5ce33ce | 2011-11-29 20:42:05 | [diff] [blame] | 333 | $$(MKFILE_DEPS) |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 334 | |
| 335 | # Prerequisites for using the stageN compiler to build target artifacts |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 336 | TSREQ$(1)_T_$(2)_H_$(3) = \ |
| 337 | $$(HSREQ$(1)_H_$(3)) \ |
Brian Anderson | 8f0bd18 | 2012-06-02 04:46:10 | [diff] [blame] | 338 | $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME) \ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 339 | $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 340 | |
| 341 | # Prerequisites for complete stageN targets |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 342 | SREQ$(1)_T_$(2)_H_$(3) = \ |
| 343 | $$(TSREQ$(1)_T_$(2)_H_$(3)) \ |
Graydon Hoare | 447414f | 2011-12-06 00:46:37 | [diff] [blame] | 344 | $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \ |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 345 | $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB) \ |
| 346 | $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC) |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 347 | |
Brian Anderson | e3d3aaa | 2011-08-26 18:11:49 | [diff] [blame] | 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 | |
Brian Anderson | c88ab58 | 2012-06-27 23:01:19 | [diff] [blame] | 355 | # Add RUSTFLAGS_STAGEN values to the build command |
| 356 | EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1)) |
| 357 | |
Brian Anderson | cb34138 | 2012-09-23 21:05:44 | [diff] [blame] | 358 | CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1) |
| 359 | |
Graydon Hoare | e7b8388 | 2012-09-26 21:57:35 | [diff] [blame^] | 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 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 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) \ |
Brian Anderson | cb34138 | 2012-09-23 21:05:44 | [diff] [blame] | 373 | --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \ |
Brian Anderson | c88ab58 | 2012-06-27 23:01:19 | [diff] [blame] | 374 | $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) |
Brian Anderson | 7dbce10 | 2011-09-29 19:06:37 | [diff] [blame] | 375 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 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) \ |
Brian Anderson | cb34138 | 2012-09-23 21:05:44 | [diff] [blame] | 380 | --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \ |
Brian Anderson | c88ab58 | 2012-06-27 23:01:19 | [diff] [blame] | 381 | $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) |
Brian Anderson | 7dbce10 | 2011-09-29 19:06:37 | [diff] [blame] | 382 | |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 383 | endef |
| 384 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 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)))))))) |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 389 | |
| 390 | ###################################################################### |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 391 | # rustc-H-targets |
| 392 | # |
| 393 | # Builds a functional Rustc for the given host. |
| 394 | ###################################################################### |
| 395 | |
Niko Matsakis | 15d6032 | 2011-12-06 22:02:03 | [diff] [blame] | 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 | |
Niko Matsakis | c28ada0 | 2011-12-09 16:16:04 | [diff] [blame] | 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 | |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 414 | define DEF_RUSTC_TARGET |
| 415 | # $(1) == architecture |
| 416 | |
Haitao Li | 394a80c | 2012-01-16 05:42:03 | [diff] [blame] | 417 | rustc-H-$(1): rustc-stage2-H-$(1) |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 418 | endef |
| 419 | |
| 420 | $(foreach host,$(CFG_TARGET_TRIPLES), \ |
| 421 | $(eval $(call DEF_RUSTC_TARGET,$(host)))) |
| 422 | |
Niko Matsakis | 68c6272 | 2011-12-13 04:28:35 | [diff] [blame] | 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 | |
Niko Matsakis | 4934929 | 2011-12-03 00:11:35 | [diff] [blame] | 428 | rustc-H-all: $(foreach host,$(CFG_TARGET_TRIPLES),rustc-H-$(host)) |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 429 | |
| 430 | ###################################################################### |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 431 | # Entrypoint rule |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 432 | ###################################################################### |
| 433 | |
Brian Anderson | c9b14cc | 2011-12-13 20:02:17 | [diff] [blame] | 434 | .DEFAULT_GOAL := all |
| 435 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 436 | ifneq ($(CFG_IN_TRANSITION),) |
| 437 | |
Graydon Hoare | 9ac2948 | 2011-05-16 22:14:58 | [diff] [blame] | 438 | CFG_INFO := $(info cfg:) |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 439 | CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***) |
| 440 | CFG_INFO := $(info cfg: *** stage2 and later will not be built ***) |
Graydon Hoare | 9ac2948 | 2011-05-16 22:14:58 | [diff] [blame] | 441 | CFG_INFO := $(info cfg:) |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 442 | |
Graydon Hoare | 193279d | 2012-01-18 22:14:28 | [diff] [blame] | 443 | all: $(SREQ1$(CFG_HOST_TRIPLE)) $(GENERATED) docs |
Brian Anderson | b056096 | 2011-09-30 23:15:02 | [diff] [blame] | 444 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 445 | else |
Brian Anderson | 86ed905 | 2011-09-30 03:27:28 | [diff] [blame] | 446 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 447 | TSREQS := \ |
| 448 | $(foreach target,$(CFG_TARGET_TRIPLES), \ |
| 449 | $(SREQ3_T_$(target)_H_$(CFG_HOST_TRIPLE))) |
Erick Tryzelaar | e849311 | 2012-06-06 04:40:57 | [diff] [blame] | 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) |
Brian Anderson | 86ed905 | 2011-09-30 03:27:28 | [diff] [blame] | 453 | |
Niko Matsakis | d365ec5 | 2012-03-15 14:39:57 | [diff] [blame] | 454 | all: rustc $(GENERATED) docs $(FUZZ) $(CARGO) $(RUSTDOC) |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 455 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 456 | endif |
| 457 | |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 458 | |
| 459 | ###################################################################### |
| 460 | # Re-configuration |
| 461 | ###################################################################### |
| 462 | |
Brian Anderson | 8d7863f | 2011-11-29 01:50:23 | [diff] [blame] | 463 | ifndef CFG_DISABLE_MANAGE_SUBMODULES |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 464 | # This is a pretty expensive operation but I don't see any way to avoid it |
Brian Anderson | 143f878 | 2011-11-26 04:00:48 | [diff] [blame] | 465 | NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)') |
Brian Anderson | 8d7863f | 2011-11-29 01:50:23 | [diff] [blame] | 466 | else |
| 467 | NEED_GIT_RECONFIG=0 |
| 468 | endif |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 469 | |
| 470 | ifeq ($(NEED_GIT_RECONFIG),0) |
| 471 | else |
| 472 | # If the submodules have changed then always execute config.mk |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 473 | .PHONY: config.stamp |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 474 | endif |
| 475 | |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 476 | Makefile config.mk: config.stamp |
| 477 | |
| 478 | config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 479 | @$(call E, cfg: reconfiguring) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 480 | $(Q)$(S)configure $(CFG_CONFIGURE_ARGS) |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 481 | |
| 482 | |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 483 | ###################################################################### |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 484 | # Primary-target makefiles |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 485 | ###################################################################### |
| 486 | |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 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 |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 492 | include $(CFG_SRC_DIR)mk/tools.mk |
| 493 | include $(CFG_SRC_DIR)mk/docs.mk |
| 494 | include $(CFG_SRC_DIR)mk/llvm.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 495 | |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 496 | ###################################################################### |
| 497 | # Secondary makefiles, conditionalized for speed |
| 498 | ###################################################################### |
| 499 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 500 | ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \ |
| 501 | $(findstring check,$(MAKECMDGOALS)) \ |
| 502 | $(findstring test,$(MAKECMDGOALS)) \ |
Graydon Hoare | 39151f2 | 2011-07-13 22:44:09 | [diff] [blame] | 503 | $(findstring tidy,$(MAKECMDGOALS)) \ |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 504 | $(findstring clean,$(MAKECMDGOALS))),) |
| 505 | CFG_INFO := $(info cfg: including dist rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 506 | include $(CFG_SRC_DIR)mk/dist.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 507 | endif |
| 508 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 509 | ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \ |
| 510 | $(findstring clean,$(MAKECMDGOALS))),) |
| 511 | CFG_INFO := $(info cfg: including snap rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 512 | include $(CFG_SRC_DIR)mk/snap.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 513 | endif |
| 514 | |
| 515 | ifneq ($(findstring reformat,$(MAKECMDGOALS)),) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 516 | CFG_INFO := $(info cfg: including reformat rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 517 | include $(CFG_SRC_DIR)mk/pp.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 518 | endif |
| 519 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 520 | ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \ |
| 521 | $(findstring test,$(MAKECMDGOALS)) \ |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 522 | $(findstring perf,$(MAKECMDGOALS)) \ |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 523 | $(findstring tidy,$(MAKECMDGOALS))),) |
| 524 | CFG_INFO := $(info cfg: including test rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 525 | include $(CFG_SRC_DIR)mk/tests.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 526 | endif |
| 527 | |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 528 | ifneq ($(findstring perf,$(MAKECMDGOALS)),) |
| 529 | CFG_INFO := $(info cfg: including perf rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 530 | include $(CFG_SRC_DIR)mk/perf.mk |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 531 | endif |
| 532 | |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 533 | ifneq ($(findstring clean,$(MAKECMDGOALS)),) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 534 | CFG_INFO := $(info cfg: including clean rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 535 | include $(CFG_SRC_DIR)mk/clean.mk |
Michael Sullivan | b01ecb1 | 2011-07-21 18:58:01 | [diff] [blame] | 536 | endif |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 537 | |
| 538 | ifneq ($(findstring install,$(MAKECMDGOALS)),) |
Kevin Cantu | c9d53ca | 2012-01-20 12:17:32 | [diff] [blame] | 539 | ifdef DESTDIR |
| 540 | CFG_INFO := $(info cfg: setting CFG_PREFIX via DESTDIR, $(DESTDIR)) |
| 541 | CFG_PREFIX:=$(DESTDIR) |
| 542 | export CFG_PREFIX |
| 543 | endif |
| 544 | |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 545 | CFG_INFO := $(info cfg: including install rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 546 | include $(CFG_SRC_DIR)mk/install.mk |
Niko Matsakis | e1c470c | 2011-10-12 19:10:21 | [diff] [blame] | 547 | endif |
| 548 | |
| 549 | ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \ |
| 550 | $(findstring TAGS.vi,$(MAKECMDGOALS))),) |
| 551 | CFG_INFO := $(info cfg: including ctags rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 552 | include $(CFG_SRC_DIR)mk/ctags.mk |
Niko Matsakis | e1c470c | 2011-10-12 19:10:21 | [diff] [blame] | 553 | endif |
Michael Sullivan | f99f2e8 | 2012-06-14 18:07:19 | [diff] [blame] | 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) |