Graydon Hoare | d1affff | 2012-12-11 01:32:48 | [diff] [blame] | 1 | # Copyright 2012 The Rust Project Developers. See the COPYRIGHT |
| 2 | # file at the top-level directory of this distribution and at |
| 3 | # http://rust-lang.org/COPYRIGHT. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | # option. This file may not be copied, modified, or distributed |
| 9 | # except according to those terms. |
| 10 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 11 | # An explanation of how the build is structured: |
| 12 | # |
| 13 | # There are multiple build stages (0-3) needed to verify that the |
| 14 | # compiler is properly self-hosting. Each stage is divided between |
| 15 | # 'host' artifacts and 'target' artifacts, where the stageN host |
| 16 | # compiler builds artifacts for 1 or more stageN target architectures. |
| 17 | # Once the stageN target compiler has been built for the host |
| 18 | # architecture it is promoted (copied) to a stageN+1 host artifact. |
| 19 | # |
| 20 | # The stage3 host compiler is a compiler that successfully builds |
| 21 | # itself and should (in theory) be bitwise identical to the stage2 |
| 22 | # host compiler. The process is bootstrapped using a stage0 host |
| 23 | # compiler downloaded from a previous snapshot. |
| 24 | # |
| 25 | # At no time should stageN artifacts be interacting with artifacts |
| 26 | # from other stages. For consistency, we use the 'promotion' logic |
| 27 | # for all artifacts, even those that don't make sense on non-host |
| 28 | # architectures. |
| 29 | # |
| 30 | # The directory layout for a stage is intended to match the layout |
| 31 | # of the installed compiler, and looks like the following: |
| 32 | # |
| 33 | # stageN - this is the system root, corresponding to, e.g. /usr |
| 34 | # bin - binaries compiled for the host |
| 35 | # lib - libraries used by the host compiler |
| 36 | # 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 Anderson | 19797df | 2011-11-03 17:53:49 | [diff] [blame] | 44 | # by rustc. In general, rust programs, even those compiled for the |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 45 | # host architecture will use libraries from the target |
| 46 | # directories. This gives rust some freedom to experiment with how |
| 47 | # libraries are managed and versioned without polluting the common |
| 48 | # areas of the filesystem. |
| 49 | # |
| 50 | # General rust binaries may stil live in the host bin directory; they |
| 51 | # will just link against the libraries in the target lib directory. |
| 52 | # |
| 53 | # Admittedly this is a little convoluted. |
| 54 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 55 | STAGES = 0 1 2 3 |
| 56 | |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 57 | ###################################################################### |
| 58 | # Residual auto-configuration |
| 59 | ###################################################################### |
| 60 | |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 61 | # Recursive wildcard function |
| 62 | # http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html |
| 63 | rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \ |
| 64 | $(filter $(subst *,%,$2),$d)) |
| 65 | |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 66 | include config.mk |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 67 | |
Michael Sullivan | f99f2e8 | 2012-06-14 18:07:19 | [diff] [blame] | 68 | # We track all of the object files we might build so that we can find |
| 69 | # and include all of the .d files in one fell swoop. |
| 70 | ALL_OBJ_FILES := |
| 71 | |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 72 | MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*) |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 73 | NON_BUILD_HOST_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_HOST_TRIPLES)) |
| 74 | NON_BUILD_TARGET_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_TARGET_TRIPLES)) |
Niko Matsakis | 8371beb | 2011-11-22 21:04:52 | [diff] [blame] | 75 | |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 76 | ifneq ($(MAKE_RESTARTS),) |
| 77 | CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS)) |
| 78 | endif |
| 79 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 80 | CFG_INFO := $(info cfg: build triple $(CFG_BUILD_TRIPLE)) |
| 81 | CFG_INFO := $(info cfg: host triples $(CFG_HOST_TRIPLES)) |
| 82 | CFG_INFO := $(info cfg: target triples $(CFG_TARGET_TRIPLES)) |
Graydon Hoare | f904453 | 2012-03-26 23:05:49 | [diff] [blame] | 83 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 84 | ifneq ($(wildcard $(NON_BUILD_HOST_TRIPLES)),) |
| 85 | CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST_TRIPLES)) |
| 86 | endif |
| 87 | ifneq ($(wildcard $(NON_BUILD_TARGET_TRIPLES)),) |
| 88 | CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET_TRIPLES)) |
Graydon Hoare | f904453 | 2012-03-26 23:05:49 | [diff] [blame] | 89 | endif |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 90 | |
Brian Anderson | c8426d1 | 2012-05-20 01:27:12 | [diff] [blame] | 91 | CFG_RUSTC_FLAGS := $(RUSTFLAGS) |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 92 | CFG_GCCISH_CFLAGS := |
| 93 | CFG_GCCISH_LINK_FLAGS := |
| 94 | |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 95 | ifdef CFG_DISABLE_OPTIMIZE |
Graydon Hoare | 19ebc0f | 2011-04-08 23:29:19 | [diff] [blame] | 96 | $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 97 | CFG_RUSTC_FLAGS += |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 98 | else |
Brian Anderson | 30a7a5b | 2013-08-17 06:14:55 | [diff] [blame] | 99 | # The rtopt cfg turns off runtime sanity checks |
| 100 | CFG_RUSTC_FLAGS += -O --cfg rtopt |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 101 | endif |
| 102 | |
Alex Crichton | 0442764 | 2013-09-21 08:49:38 | [diff] [blame] | 103 | ifdef CFG_DISABLE_DEBUG |
Alex Crichton | 833a64d | 2013-09-18 04:02:11 | [diff] [blame] | 104 | CFG_RUSTC_FLAGS += --cfg ndebug |
Brian Anderson | f452973 | 2012-03-30 02:10:38 | [diff] [blame] | 105 | CFG_GCCISH_CFLAGS += -DRUST_NDEBUG |
Alex Crichton | 0442764 | 2013-09-21 08:49:38 | [diff] [blame] | 106 | else |
| 107 | $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG)) |
| 108 | CFG_RUSTC_FLAGS += --cfg debug |
| 109 | CFG_GCCISH_CFLAGS += -DRUST_DEBUG |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 110 | endif |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 111 | |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 112 | ifdef SAVE_TEMPS |
Marijn Haverbeke | 6b11f6c | 2011-04-26 18:32:08 | [diff] [blame] | 113 | CFG_RUSTC_FLAGS += --save-temps |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 114 | endif |
Niko Matsakis | 989d008 | 2013-05-04 18:29:32 | [diff] [blame] | 115 | ifdef ASM_COMMENTS |
Niko Matsakis | 682bb41 | 2013-06-16 00:15:38 | [diff] [blame] | 116 | CFG_RUSTC_FLAGS += -Z asm-comments |
Niko Matsakis | 989d008 | 2013-05-04 18:29:32 | [diff] [blame] | 117 | endif |
Patrick Walton | 648c4ae | 2011-04-29 18:55:32 | [diff] [blame] | 118 | ifdef TIME_PASSES |
Niko Matsakis | 5be8bf1 | 2012-05-18 04:53:49 | [diff] [blame] | 119 | CFG_RUSTC_FLAGS += -Z time-passes |
Patrick Walton | 648c4ae | 2011-04-29 18:55:32 | [diff] [blame] | 120 | endif |
Brian Anderson | 2752284 | 2011-06-19 00:26:41 | [diff] [blame] | 121 | ifdef TIME_LLVM_PASSES |
Niko Matsakis | 5be8bf1 | 2012-05-18 04:53:49 | [diff] [blame] | 122 | CFG_RUSTC_FLAGS += -Z time-llvm-passes |
Brian Anderson | 2752284 | 2011-06-19 00:26:41 | [diff] [blame] | 123 | endif |
Niko Matsakis | 5e36a99 | 2012-08-28 22:54:45 | [diff] [blame] | 124 | ifdef TRACE |
| 125 | CFG_RUSTC_FLAGS += -Z trace |
| 126 | endif |
Patrick Walton | 08e561a | 2013-05-15 21:01:54 | [diff] [blame] | 127 | ifndef DEBUG_BORROWS |
| 128 | RUSTFLAGS_STAGE1 += -Z no-debug-borrows |
| 129 | RUSTFLAGS_STAGE2 += -Z no-debug-borrows |
| 130 | endif |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 131 | |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 132 | # platform-specific auto-configuration |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 133 | include $(CFG_SRC_DIR)mk/platform.mk |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 134 | |
Brian Anderson | cad8c73 | 2011-05-14 03:20:34 | [diff] [blame] | 135 | # Run the stage1/2 compilers under valgrind |
| 136 | ifdef VALGRIND_COMPILE |
| 137 | CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND) |
| 138 | else |
| 139 | CFG_VALGRIND_COMPILE := |
| 140 | endif |
| 141 | |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 142 | # version-string calculation |
| 143 | CFG_GIT_DIR := $(CFG_SRC_DIR).git |
Brian Anderson | 695cb9f | 2013-09-21 23:25:08 | [diff] [blame] | 144 | CFG_RELEASE = 0.8 |
Graydon Hoare | 80c7bfb | 2012-01-18 00:49:44 | [diff] [blame] | 145 | CFG_VERSION = $(CFG_RELEASE) |
Brian Anderson | 59905d1 | 2013-06-27 22:36:05 | [diff] [blame] | 146 | # windows exe's need numeric versions - don't use anything but |
| 147 | # numbers and dots here |
Brian Anderson | b0a9d81 | 2013-07-08 17:25:45 | [diff] [blame] | 148 | CFG_VERSION_WIN = 0.8 |
Graydon Hoare | 80c7bfb | 2012-01-18 00:49:44 | [diff] [blame] | 149 | |
Graydon Hoare | 0a8f9a3 | 2011-06-13 21:45:26 | [diff] [blame] | 150 | ifneq ($(wildcard $(CFG_GIT)),) |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 151 | ifneq ($(wildcard $(CFG_GIT_DIR)),) |
| 152 | CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \ |
| 153 | --pretty=format:'(%h %ci)') |
Ramkumar Ramachandra | 1a98726 | 2013-06-05 13:44:00 | [diff] [blame] | 154 | CFG_VER_HASH = $(shell git --git-dir=$(CFG_GIT_DIR) rev-parse HEAD) |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 155 | endif |
Graydon Hoare | 0a8f9a3 | 2011-06-13 21:45:26 | [diff] [blame] | 156 | endif |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 157 | |
Brian Anderson | 55d134d | 2012-10-20 21:27:56 | [diff] [blame] | 158 | ifdef CFG_ENABLE_VALGRIND |
| 159 | $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND)) |
| 160 | else |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 161 | CFG_VALGRIND := |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 162 | endif |
Patrick Walton | 518e2d2 | 2011-05-06 01:11:40 | [diff] [blame] | 163 | ifdef CFG_BAD_VALGRIND |
| 164 | $(info cfg: disabling valgrind due to its unreliability on this platform) |
| 165 | CFG_VALGRIND := |
| 166 | endif |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 167 | |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 168 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 169 | ###################################################################### |
| 170 | # Target-and-rule "utility variables" |
| 171 | ###################################################################### |
| 172 | |
| 173 | ifdef VERBOSE |
| 174 | Q := |
| 175 | E = |
| 176 | else |
| 177 | Q := @ |
| 178 | E = echo $(1) |
| 179 | endif |
| 180 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 181 | S := $(CFG_SRC_DIR) |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 182 | |
| 183 | define DEF_X |
| 184 | X_$(1) := $(CFG_EXE_SUFFIX_$(1)) |
| 185 | endef |
| 186 | $(foreach target,$(CFG_TARGET_TRIPLES),\ |
| 187 | $(eval $(call DEF_X,$(target)))) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 188 | |
| 189 | # Look in doc and src dirs. |
| 190 | VPATH := $(S)doc $(S)src |
| 191 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 192 | # "Source" files we generate in builddir along the way. |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 193 | GENERATED := |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 194 | |
| 195 | # Delete the built-in rules. |
| 196 | .SUFFIXES: |
| 197 | %:: %,v |
| 198 | %:: RCS/%,v |
| 199 | %:: RCS/% |
| 200 | %:: s.% |
| 201 | %:: SCCS/s.% |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 202 | |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 203 | |
| 204 | ###################################################################### |
| 205 | # Crates |
| 206 | ###################################################################### |
| 207 | |
| 208 | define DEF_LIBS |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 209 | |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 210 | CFG_RUNTIME_$(1) :=$(call CFG_LIB_NAME_$(1),rustrt) |
| 211 | CFG_RUSTLLVM_$(1) :=$(call CFG_LIB_NAME_$(1),rustllvm) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 212 | CFG_STDLIB_$(1) :=$(call CFG_LIB_NAME_$(1),std) |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 213 | CFG_EXTRALIB_$(1) :=$(call CFG_LIB_NAME_$(1),extra) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 214 | CFG_LIBRUSTC_$(1) :=$(call CFG_LIB_NAME_$(1),rustc) |
| 215 | CFG_LIBSYNTAX_$(1) :=$(call CFG_LIB_NAME_$(1),syntax) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 216 | CFG_LIBRUSTPKG_$(1) :=$(call CFG_LIB_NAME_$(1),rustpkg) |
| 217 | CFG_LIBRUSTDOC_$(1) :=$(call CFG_LIB_NAME_$(1),rustdoc) |
| 218 | CFG_LIBRUSTI_$(1) :=$(call CFG_LIB_NAME_$(1),rusti) |
| 219 | CFG_LIBRUST_$(1) :=$(call CFG_LIB_NAME_$(1),rust) |
| 220 | |
Patrick Walton | f3723cf | 2013-05-17 22:28:44 | [diff] [blame] | 221 | EXTRALIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),extra) |
| 222 | STDLIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),std) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 223 | LIBRUSTC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustc) |
| 224 | LIBSYNTAX_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),syntax) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 225 | LIBRUSTPKG_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustpkg) |
| 226 | LIBRUSTDOC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustdoc) |
| 227 | LIBRUSTI_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rusti) |
| 228 | LIBRUST_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rust) |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 229 | EXTRALIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),extra) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 230 | STDLIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),std) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 231 | LIBRUSTC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustc) |
| 232 | LIBSYNTAX_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),syntax) |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 233 | LIBRUSTPKG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustpkg) |
| 234 | LIBRUSTDOC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc) |
| 235 | LIBRUSTI_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rusti) |
| 236 | LIBRUST_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rust) |
| 237 | |
| 238 | endef |
| 239 | |
Felix S. Klock II | 033ac54 | 2013-07-04 14:51:45 | [diff] [blame] | 240 | # $(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 II | 25f51ee | 2013-07-08 16:35:47 | [diff] [blame] | 244 | # |
| 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 II | 033ac54 | 2013-07-04 14:51:45 | [diff] [blame] | 248 | define CHECK_FOR_OLD_GLOB_MATCHES_EXCEPT |
Felix S. Klock II | 25f51ee | 2013-07-08 16:35:47 | [diff] [blame] | 249 | $(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "Warning: there are previous" \'$(2)\' "libraries:" $$MATCHES; fi |
Felix S. Klock II | 033ac54 | 2013-07-04 14:51:45 | [diff] [blame] | 250 | endef |
| 251 | |
| 252 | # Same interface as above, but deletes rather than just listing the files. |
| 253 | define REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT |
Felix S. Klock II | b6a0138 | 2013-07-18 07:43:19 | [diff] [blame] | 254 | $(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 II | 033ac54 | 2013-07-04 14:51:45 | [diff] [blame] | 255 | endef |
| 256 | |
Felix S. Klock II | 25f51ee | 2013-07-08 16:35:47 | [diff] [blame] | 257 | # 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 II | 033ac54 | 2013-07-04 14:51:45 | [diff] [blame] | 263 | ifdef VERBOSE |
| 264 | define 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 ) |
| 267 | endef |
| 268 | else |
| 269 | define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT |
| 270 | endef |
| 271 | endif |
| 272 | |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 273 | $(foreach target,$(CFG_TARGET_TRIPLES),\ |
| 274 | $(eval $(call DEF_LIBS,$(target)))) |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 275 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 276 | ###################################################################### |
| 277 | # Standard library variables |
| 278 | ###################################################################### |
| 279 | |
Alex Crichton | 42b44b2 | 2013-06-10 20:00:38 | [diff] [blame] | 280 | STDLIB_CRATE := $(S)src/libstd/std.rs |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 281 | STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \ |
Alex Crichton | 42b44b2 | 2013-06-10 20:00:38 | [diff] [blame] | 282 | *.rs */*.rs */*/*rs */*/*/*rs)) |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 283 | |
| 284 | ###################################################################### |
| 285 | # Extra library variables |
| 286 | ###################################################################### |
| 287 | |
Alex Crichton | 42b44b2 | 2013-06-10 20:00:38 | [diff] [blame] | 288 | EXTRALIB_CRATE := $(S)src/libextra/extra.rs |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 289 | EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \ |
Alex Crichton | 42b44b2 | 2013-06-10 20:00:38 | [diff] [blame] | 290 | *.rs */*.rs)) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 291 | |
| 292 | ###################################################################### |
| 293 | # rustc crate variables |
| 294 | ###################################################################### |
| 295 | |
Alex Crichton | 42b44b2 | 2013-06-10 20:00:38 | [diff] [blame] | 296 | COMPILER_CRATE := $(S)src/librustc/rustc.rs |
Brian Anderson | 69a8b4d | 2012-11-07 03:44:58 | [diff] [blame] | 297 | COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \ |
Alex Crichton | 42b44b2 | 2013-06-10 20:00:38 | [diff] [blame] | 298 | *.rs */*.rs */*/*.rs */*/*/*.rs)) |
Haitao Li | bc95ccb | 2011-12-20 10:17:13 | [diff] [blame] | 299 | |
Alex Crichton | 42b44b2 | 2013-06-10 20:00:38 | [diff] [blame] | 300 | LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs |
Kevin Cantu | 7dcbaed | 2012-05-30 04:35:12 | [diff] [blame] | 301 | LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \ |
Huon Wilson | 44acdad | 2013-07-20 14:37:47 | [diff] [blame] | 302 | *.rs */*.rs */*/*.rs */*/*/*.rs)) |
Brian Anderson | a0ed1fb | 2012-03-22 22:27:35 | [diff] [blame] | 303 | |
Brian Anderson | 69a8b4d | 2012-11-07 03:44:58 | [diff] [blame] | 304 | DRIVER_CRATE := $(S)src/driver/driver.rs |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 305 | |
| 306 | ###################################################################### |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 307 | # LLVM macros |
| 308 | ###################################################################### |
| 309 | |
Brian Anderson | a92218e | 2011-11-27 06:38:36 | [diff] [blame] | 310 | # FIXME: x86-ism |
Jyun-Yan You | 5150b98 | 2013-01-29 14:28:08 | [diff] [blame] | 311 | LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \ |
James Miller | d694e28 | 2013-05-27 23:15:31 | [diff] [blame] | 312 | interpreter instrumentation |
Brian Anderson | a92218e | 2011-11-27 06:38:36 | [diff] [blame] | 313 | |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 314 | define 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. |
| 317 | CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1))) |
| 318 | CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1))) |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 319 | |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 320 | # Any rules that depend on LLVM should depend on LLVM_CONFIG |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 321 | LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1)) |
| 322 | LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1)) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 323 | LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version) |
| 324 | LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir) |
| 325 | LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir) |
| 326 | LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir) |
Brian Anderson | a92218e | 2011-11-27 06:38:36 | [diff] [blame] | 327 | LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS)) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 328 | LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags) |
Jyun-Yan You | 5e250b6 | 2012-01-26 09:13:57 | [diff] [blame] | 329 | # 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. |
| 331 | LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags)) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 332 | LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target) |
| 333 | |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 334 | LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1)) |
| 335 | LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1)) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 336 | |
| 337 | endef |
| 338 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 339 | $(foreach host,$(CFG_HOST_TRIPLES), \ |
| 340 | $(eval $(call DEF_LLVM_VARS,$(host)))) |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 341 | |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 342 | ###################################################################### |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 343 | # Exports for sub-utilities |
| 344 | ###################################################################### |
| 345 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 346 | # Note that any variable that re-configure should pick up needs to be |
| 347 | # exported |
| 348 | |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 349 | export CFG_SRC_DIR |
Graydon Hoare | ad954fc | 2011-07-23 19:26:47 | [diff] [blame] | 350 | export CFG_BUILD_DIR |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 351 | export CFG_VERSION |
Brian Anderson | 59905d1 | 2013-06-27 22:36:05 | [diff] [blame] | 352 | export CFG_VERSION_WIN |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 353 | export CFG_BUILD_TRIPLE |
Graydon Hoare | 6a4a85f | 2011-05-18 19:00:26 | [diff] [blame] | 354 | export CFG_LLVM_ROOT |
Graydon Hoare | 0dc2aa3 | 2011-06-28 18:18:25 | [diff] [blame] | 355 | export CFG_ENABLE_MINGW_CROSS |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 356 | export CFG_PREFIX |
Brian Anderson | 9e40e43 | 2012-01-11 01:45:03 | [diff] [blame] | 357 | export CFG_LIBDIR |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 358 | |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 359 | ###################################################################### |
| 360 | # Subprograms |
| 361 | ###################################################################### |
| 362 | |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 363 | ###################################################################### |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 364 | # Per-stage targets and runner |
| 365 | ###################################################################### |
| 366 | |
| 367 | define SREQ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 368 | # $(1) is the stage number |
| 369 | # $(2) is the target triple |
Graydon Hoare | 766e29c | 2011-11-30 03:28:15 | [diff] [blame] | 370 | # $(3) is the host triple |
Brian Anderson | ed106dd | 2011-09-30 19:08:51 | [diff] [blame] | 371 | |
Brian Anderson | 38c67a4 | 2011-09-30 19:24:28 | [diff] [blame] | 372 | # Destinations of artifacts for the host compiler |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 373 | HROOT$(1)_H_$(3) = $(3)/stage$(1) |
| 374 | HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin |
Brian Anderson | 9e40e43 | 2012-01-11 01:45:03 | [diff] [blame] | 375 | HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR) |
Brian Anderson | 38c67a4 | 2011-09-30 19:24:28 | [diff] [blame] | 376 | |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 377 | # Destinations of artifacts for target architectures |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 378 | TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2) |
| 379 | TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin |
Brian Anderson | 9e40e43 | 2012-01-11 01:45:03 | [diff] [blame] | 380 | 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] | 381 | |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 382 | # The name of the standard and extra libraries used by rustc |
Rafael Ávila de Espíndola | 88894b6 | 2011-07-20 20:02:36 | [diff] [blame] | 383 | ifdef CFG_DISABLE_SHAREDSTD |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 384 | 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 Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 388 | |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 389 | 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 Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 394 | 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 Anderson | f634eb2 | 2011-09-30 23:11:47 | [diff] [blame] | 398 | else |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 399 | HSTDLIB_DEFAULT$(1)_H_$(3) = \ |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 400 | $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB_$(3)) |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 401 | TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \ |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 402 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 403 | |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 404 | 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 Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 409 | HLIBRUSTC_DEFAULT$(1)_H_$(3) = \ |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 410 | $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC_$(3)) |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 411 | TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 412 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2)) |
Brian Anderson | f634eb2 | 2011-09-30 23:11:47 | [diff] [blame] | 413 | endif |
| 414 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 415 | # Preqrequisites for using the stageN compiler |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 416 | HSREQ$(1)_H_$(3) = \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 417 | $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 418 | $$(HLIB$(1)_H_$(3))/$(CFG_RUNTIME_$(3)) \ |
| 419 | $$(HLIB$(1)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 420 | $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \ |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 421 | $$(HEXTRALIB_DEFAULT$(1)_H_$(3)) \ |
Brian Anderson | cf002e9 | 2012-11-13 21:32:49 | [diff] [blame] | 422 | $$(HLIBSYNTAX_DEFAULT$(1)_H_$(3)) \ |
Graydon Hoare | 4f826b3 | 2011-12-17 01:21:18 | [diff] [blame] | 423 | $$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \ |
Niko Matsakis | 5ce33ce | 2011-11-29 20:42:05 | [diff] [blame] | 424 | $$(MKFILE_DEPS) |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 425 | |
| 426 | # Prerequisites for using the stageN compiler to build target artifacts |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 427 | TSREQ$(1)_T_$(2)_H_$(3) = \ |
| 428 | $$(HSREQ$(1)_H_$(3)) \ |
Young-il Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 429 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)) \ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 430 | $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 431 | |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 432 | # Prerequisites for a working stageN compiler and libraries, for a specific target |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 433 | SREQ$(1)_T_$(2)_H_$(3) = \ |
| 434 | $$(TSREQ$(1)_T_$(2)_H_$(3)) \ |
Patrick Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 435 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \ |
| 436 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)) |
Brian Anderson | cf002e9 | 2012-11-13 21:32:49 | [diff] [blame] | 437 | |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 438 | # Prerequisites for a working stageN compiler and libraries, for a specific target |
Brian Anderson | cf002e9 | 2012-11-13 21:32:49 | [diff] [blame] | 439 | CSREQ$(1)_T_$(2)_H_$(3) = \ |
| 440 | $$(TSREQ$(1)_T_$(2)_H_$(3)) \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 441 | $$(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 Choi | 26a5dc5 | 2013-02-27 05:53:35 | [diff] [blame] | 445 | $$(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 Walton | 0c820d4 | 2013-05-17 17:45:09 | [diff] [blame] | 449 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \ |
| 450 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)) \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 451 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(2)) \ |
| 452 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2)) \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 453 | $$(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 Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 457 | |
Brian Anderson | e3d3aaa | 2011-08-26 18:11:49 | [diff] [blame] | 458 | ifeq ($(1),0) |
| 459 | # Don't run the the stage0 compiler under valgrind - that ship has sailed |
| 460 | CFG_VALGRIND_COMPILE$(1) = |
| 461 | else |
| 462 | CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE) |
| 463 | endif |
| 464 | |
Brian Anderson | c88ab58 | 2012-06-27 23:01:19 | [diff] [blame] | 465 | # Add RUSTFLAGS_STAGEN values to the build command |
| 466 | EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1)) |
| 467 | |
Brian Anderson | cb34138 | 2012-09-23 21:05:44 | [diff] [blame] | 468 | CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1) |
| 469 | |
Graydon Hoare | e7b8388 | 2012-09-26 21:57:35 | [diff] [blame] | 470 | # 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. |
| 473 | ifeq ($(1),0) |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 474 | ifneq ($(strip $(CFG_BUILD_TRIPLE)),$(strip $(3))) |
Graydon Hoare | e7b8388 | 2012-09-26 21:57:35 | [diff] [blame] | 475 | CFGFLAG$(1)_T_$(2)_H_$(3) = stage1 |
| 476 | endif |
| 477 | endif |
| 478 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 479 | STAGE$(1)_T_$(2)_H_$(3) := \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 480 | $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \ |
Brian Anderson | 55d134d | 2012-10-20 21:27:56 | [diff] [blame] | 481 | $$(CFG_VALGRIND_COMPILE$(1)) \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 482 | $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ |
Brian Anderson | cb34138 | 2012-09-23 21:05:44 | [diff] [blame] | 483 | --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 484 | $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \ |
| 485 | $$(RUSTC_FLAGS_$(2)) |
Brian Anderson | 7dbce10 | 2011-09-29 19:06:37 | [diff] [blame] | 486 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 487 | PERF_STAGE$(1)_T_$(2)_H_$(3) := \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 488 | $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 489 | $$(CFG_PERF_TOOL) \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 490 | $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ |
Brian Anderson | cb34138 | 2012-09-23 21:05:44 | [diff] [blame] | 491 | --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \ |
Young-il Choi | 7714d52 | 2013-03-02 12:25:12 | [diff] [blame] | 492 | $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \ |
| 493 | $$(RUSTC_FLAGS_$(2)) |
Brian Anderson | 7dbce10 | 2011-09-29 19:06:37 | [diff] [blame] | 494 | |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 495 | endef |
| 496 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 497 | $(foreach build,$(CFG_HOST_TRIPLES), \ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 498 | $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \ |
| 499 | $(eval $(foreach stage,$(STAGES), \ |
| 500 | $(eval $(call SREQ,$(stage),$(target),$(build)))))))) |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 501 | |
| 502 | ###################################################################### |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 503 | # rustc-H-targets |
| 504 | # |
| 505 | # Builds a functional Rustc for the given host. |
| 506 | ###################################################################### |
| 507 | |
Niko Matsakis | 15d6032 | 2011-12-06 22:02:03 | [diff] [blame] | 508 | define DEF_RUSTC_STAGE_TARGET |
| 509 | # $(1) == architecture |
| 510 | # $(2) == stage |
| 511 | |
| 512 | rustc-stage$(2)-H-$(1): \ |
| 513 | $$(foreach target,$$(CFG_TARGET_TRIPLES), \ |
| 514 | $$(SREQ$(2)_T_$$(target)_H_$(1))) |
| 515 | |
| 516 | endef |
| 517 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 518 | $(foreach host,$(CFG_HOST_TRIPLES), \ |
Niko Matsakis | 15d6032 | 2011-12-06 22:02:03 | [diff] [blame] | 519 | $(eval $(foreach stage,1 2 3, \ |
| 520 | $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage)))))) |
| 521 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 522 | rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE) |
| 523 | rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE) |
| 524 | rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE) |
Niko Matsakis | c28ada0 | 2011-12-09 16:16:04 | [diff] [blame] | 525 | |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 526 | define DEF_RUSTC_TARGET |
| 527 | # $(1) == architecture |
| 528 | |
Haitao Li | 394a80c | 2012-01-16 05:42:03 | [diff] [blame] | 529 | rustc-H-$(1): rustc-stage2-H-$(1) |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 530 | endef |
| 531 | |
| 532 | $(foreach host,$(CFG_TARGET_TRIPLES), \ |
| 533 | $(eval $(call DEF_RUSTC_TARGET,$(host)))) |
| 534 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 535 | rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE) |
| 536 | rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE) |
| 537 | rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE) |
| 538 | rustc: rustc-H-$(CFG_BUILD_TRIPLE) |
Niko Matsakis | 68c6272 | 2011-12-13 04:28:35 | [diff] [blame] | 539 | |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 540 | rustc-H-all: $(foreach host,$(CFG_HOST_TRIPLES),rustc-H-$(host)) |
Niko Matsakis | 3bbfe51 | 2011-12-03 00:04:27 | [diff] [blame] | 541 | |
| 542 | ###################################################################### |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 543 | # Entrypoint rule |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 544 | ###################################################################### |
| 545 | |
Brian Anderson | c9b14cc | 2011-12-13 20:02:17 | [diff] [blame] | 546 | .DEFAULT_GOAL := all |
| 547 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 548 | ifneq ($(CFG_IN_TRANSITION),) |
| 549 | |
Graydon Hoare | 9ac2948 | 2011-05-16 22:14:58 | [diff] [blame] | 550 | CFG_INFO := $(info cfg:) |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 551 | CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***) |
| 552 | CFG_INFO := $(info cfg: *** stage2 and later will not be built ***) |
Graydon Hoare | 9ac2948 | 2011-05-16 22:14:58 | [diff] [blame] | 553 | CFG_INFO := $(info cfg:) |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 554 | |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 555 | #XXX This is surely busted |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 556 | all: $(SREQ1$(CFG_BUILD_TRIPLE)) $(GENERATED) docs |
Brian Anderson | b056096 | 2011-09-30 23:15:02 | [diff] [blame] | 557 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 558 | else |
Brian Anderson | 86ed905 | 2011-09-30 03:27:28 | [diff] [blame] | 559 | |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 560 | define ALL_TARGET_N |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 561 | ifneq ($$(findstring $(1),$$(CFG_HOST_TRIPLES)),) |
| 562 | # This is a host |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 563 | all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2)) |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 564 | else |
| 565 | # This is a target only |
| 566 | all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2)) |
| 567 | endif |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 568 | endef |
| 569 | |
| 570 | $(foreach target,$(CFG_TARGET_TRIPLES), \ |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 571 | $(foreach host,$(CFG_HOST_TRIPLES), \ |
| 572 | $(eval $(call ALL_TARGET_N,$(target),$(host))))) |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 573 | |
| 574 | ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \ |
Brian Anderson | 15c0c35 | 2013-02-22 00:15:01 | [diff] [blame] | 575 | $(foreach host,$(CFG_HOST_TRIPLES), \ |
| 576 | all-target-$(target)-host-$(host))) |
Brian Anderson | e4c0fad | 2012-11-16 02:13:37 | [diff] [blame] | 577 | |
Alex Crichton | 44be4a4 | 2013-09-04 06:47:13 | [diff] [blame] | 578 | all: $(ALL_TARGET_RULES) $(GENERATED) docs |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 579 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 580 | endif |
| 581 | |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 582 | |
| 583 | ###################################################################### |
| 584 | # Re-configuration |
| 585 | ###################################################################### |
| 586 | |
Brian Anderson | 8d7863f | 2011-11-29 01:50:23 | [diff] [blame] | 587 | ifndef CFG_DISABLE_MANAGE_SUBMODULES |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 588 | # 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] | 589 | 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] | 590 | else |
| 591 | NEED_GIT_RECONFIG=0 |
| 592 | endif |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 593 | |
| 594 | ifeq ($(NEED_GIT_RECONFIG),0) |
| 595 | else |
| 596 | # If the submodules have changed then always execute config.mk |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 597 | .PHONY: config.stamp |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 598 | endif |
| 599 | |
Graydon Hoare | 071dbfc | 2012-03-26 23:04:37 | [diff] [blame] | 600 | Makefile config.mk: config.stamp |
| 601 | |
| 602 | config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 603 | @$(call E, cfg: reconfiguring) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 604 | $(Q)$(S)configure $(CFG_CONFIGURE_ARGS) |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 605 | |
| 606 | |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 607 | ###################################################################### |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 608 | # Primary-target makefiles |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 609 | ###################################################################### |
| 610 | |
Felix S. Klock II | 2835df2 | 2013-09-26 21:56:53 | [diff] [blame^] | 611 | # 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 Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 615 | include $(CFG_SRC_DIR)mk/target.mk |
| 616 | include $(CFG_SRC_DIR)mk/host.mk |
| 617 | include $(CFG_SRC_DIR)mk/stage0.mk |
| 618 | include $(CFG_SRC_DIR)mk/rt.mk |
| 619 | include $(CFG_SRC_DIR)mk/rustllvm.mk |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 620 | include $(CFG_SRC_DIR)mk/tools.mk |
| 621 | include $(CFG_SRC_DIR)mk/docs.mk |
| 622 | include $(CFG_SRC_DIR)mk/llvm.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 623 | |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 624 | ###################################################################### |
| 625 | # Secondary makefiles, conditionalized for speed |
| 626 | ###################################################################### |
| 627 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 628 | ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \ |
| 629 | $(findstring check,$(MAKECMDGOALS)) \ |
| 630 | $(findstring test,$(MAKECMDGOALS)) \ |
Graydon Hoare | 39151f2 | 2011-07-13 22:44:09 | [diff] [blame] | 631 | $(findstring tidy,$(MAKECMDGOALS)) \ |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 632 | $(findstring clean,$(MAKECMDGOALS))),) |
| 633 | CFG_INFO := $(info cfg: including dist rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 634 | include $(CFG_SRC_DIR)mk/dist.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 635 | endif |
| 636 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 637 | ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \ |
| 638 | $(findstring clean,$(MAKECMDGOALS))),) |
| 639 | CFG_INFO := $(info cfg: including snap rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 640 | include $(CFG_SRC_DIR)mk/snap.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 641 | endif |
| 642 | |
| 643 | ifneq ($(findstring reformat,$(MAKECMDGOALS)),) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 644 | CFG_INFO := $(info cfg: including reformat rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 645 | include $(CFG_SRC_DIR)mk/pp.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 646 | endif |
| 647 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 648 | ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \ |
| 649 | $(findstring test,$(MAKECMDGOALS)) \ |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 650 | $(findstring perf,$(MAKECMDGOALS)) \ |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 651 | $(findstring tidy,$(MAKECMDGOALS))),) |
| 652 | CFG_INFO := $(info cfg: including test rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 653 | include $(CFG_SRC_DIR)mk/tests.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 654 | endif |
| 655 | |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 656 | ifneq ($(findstring perf,$(MAKECMDGOALS)),) |
| 657 | CFG_INFO := $(info cfg: including perf rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 658 | include $(CFG_SRC_DIR)mk/perf.mk |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 659 | endif |
| 660 | |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 661 | ifneq ($(findstring clean,$(MAKECMDGOALS)),) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 662 | CFG_INFO := $(info cfg: including clean rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 663 | include $(CFG_SRC_DIR)mk/clean.mk |
Michael Sullivan | b01ecb1 | 2011-07-21 18:58:01 | [diff] [blame] | 664 | endif |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 665 | |
| 666 | ifneq ($(findstring install,$(MAKECMDGOALS)),) |
Kevin Cantu | c9d53ca | 2012-01-20 12:17:32 | [diff] [blame] | 667 | ifdef DESTDIR |
Luca Bruno | 27a984e | 2012-10-01 21:09:56 | [diff] [blame] | 668 | CFG_INFO := $(info cfg: setting CFG_PREFIX via DESTDIR, $(DESTDIR)/$(CFG_PREFIX)) |
| 669 | CFG_PREFIX:=$(DESTDIR)/$(CFG_PREFIX) |
Kevin Cantu | c9d53ca | 2012-01-20 12:17:32 | [diff] [blame] | 670 | export CFG_PREFIX |
| 671 | endif |
| 672 | |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 673 | CFG_INFO := $(info cfg: including install rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 674 | include $(CFG_SRC_DIR)mk/install.mk |
Niko Matsakis | e1c470c | 2011-10-12 19:10:21 | [diff] [blame] | 675 | endif |
| 676 | |
| 677 | ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \ |
| 678 | $(findstring TAGS.vi,$(MAKECMDGOALS))),) |
| 679 | CFG_INFO := $(info cfg: including ctags rules) |
Graydon Hoare | 89dec28 | 2012-03-26 23:05:33 | [diff] [blame] | 680 | include $(CFG_SRC_DIR)mk/ctags.mk |
Niko Matsakis | e1c470c | 2011-10-12 19:10:21 | [diff] [blame] | 681 | endif |
Michael Sullivan | f99f2e8 | 2012-06-14 18:07:19 | [diff] [blame] | 682 | |
| 683 | # Find all of the .d files and include them to add information about |
| 684 | # header file dependencies. |
| 685 | ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d) |
| 686 | -include $(ALL_DEP_FILES) |