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 | |
| 51 | include config.mk |
Brian Anderson | 4709038 | 2011-10-06 00:41:01 | [diff] [blame] | 52 | OUR_MKFILES := Makefile config.mk $(wildcard $(CFG_SRC_DIR)/mk/*.mk) |
Erick Tryzelaar | ab26558 | 2011-11-08 22:36:19 | [diff] [blame] | 53 | 3RDPARTY_MKFILES := $(CFG_SRC_DIR)/src/libuv/Makefile \ |
| 54 | $(wildcard $(CFG_SRC_DIR)/src/libuv/*.mk) |
Niko Matsakis | 20946e6 | 2011-10-14 00:11:28 | [diff] [blame] | 55 | GEN_MKFILES := $(wildcard $(CFG_SRC_DIR)/mk/libuv/*/*/*) \ |
Erick Tryzelaar | ab26558 | 2011-11-08 22:36:19 | [diff] [blame] | 56 | $(wildcard $(CFG_SRC_DIR)/mk/libuv/mac/src/libuv/*) \ |
| 57 | $(wildcard $(CFG_SRC_DIR)/mk/libuv/mac/src/libuv/*) \ |
| 58 | $(wildcard $(CFG_SRC_DIR)/mk/libuv/mac/src/libuv/*) |
Brian Anderson | 4709038 | 2011-10-06 00:41:01 | [diff] [blame] | 59 | |
| 60 | MKFILES := $(OUR_MKFILES) $(3RDPARTY_MKFILES) $(GEN_MKFILES) |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 61 | |
Niko Matsakis | 8371beb | 2011-11-22 21:04:52 | [diff] [blame^] | 62 | NON_HOST_TRIPLES = $(filter-out $(CFG_HOST_TRIPLE),$(CFG_TARGET_TRIPLES)) |
| 63 | |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 64 | ifneq ($(MAKE_RESTARTS),) |
| 65 | CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS)) |
| 66 | endif |
| 67 | |
Graydon Hoare | 1321580 | 2011-09-21 18:24:59 | [diff] [blame] | 68 | CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE)) |
Niko Matsakis | 8371beb | 2011-11-22 21:04:52 | [diff] [blame^] | 69 | CFG_INFO := $(info cfg: non host triples $(NON_HOST_TRIPLES)) |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 70 | |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 71 | ifdef CFG_DISABLE_OPTIMIZE |
Graydon Hoare | 19ebc0f | 2011-04-08 23:29:19 | [diff] [blame] | 72 | $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) |
Patrick Walton | c52fb52 | 2011-04-29 17:23:07 | [diff] [blame] | 73 | CFG_RUSTC_FLAGS := |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 74 | else |
Patrick Walton | c52fb52 | 2011-04-29 17:23:07 | [diff] [blame] | 75 | CFG_RUSTC_FLAGS := -O |
Graydon Hoare | cae703c | 2011-04-08 22:44:41 | [diff] [blame] | 76 | endif |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 77 | |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 78 | ifdef SAVE_TEMPS |
Marijn Haverbeke | 6b11f6c | 2011-04-26 18:32:08 | [diff] [blame] | 79 | CFG_RUSTC_FLAGS += --save-temps |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 80 | endif |
Patrick Walton | 648c4ae | 2011-04-29 18:55:32 | [diff] [blame] | 81 | ifdef TIME_PASSES |
| 82 | CFG_RUSTC_FLAGS += --time-passes |
| 83 | endif |
Brian Anderson | 2752284 | 2011-06-19 00:26:41 | [diff] [blame] | 84 | ifdef TIME_LLVM_PASSES |
| 85 | CFG_RUSTC_FLAGS += --time-llvm-passes |
| 86 | endif |
Patrick Walton | 404db4d | 2011-05-11 00:48:49 | [diff] [blame] | 87 | ifdef DEBUG |
| 88 | CFG_RUSTC_FLAGS += -g |
| 89 | endif |
Patrick Walton | 3f77e7d | 2011-04-25 21:20:28 | [diff] [blame] | 90 | |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 91 | # platform-specific auto-configuration |
| 92 | include $(CFG_SRC_DIR)/mk/platform.mk |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 93 | |
Brian Anderson | cad8c73 | 2011-05-14 03:20:34 | [diff] [blame] | 94 | # Run the stage1/2 compilers under valgrind |
| 95 | ifdef VALGRIND_COMPILE |
| 96 | CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND) |
| 97 | else |
| 98 | CFG_VALGRIND_COMPILE := |
| 99 | endif |
| 100 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 101 | CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt) |
Graydon Hoare | 7ac885e | 2011-03-22 06:06:42 | [diff] [blame] | 102 | CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm) |
Haitao Li | d1cc00f | 2011-10-30 14:04:32 | [diff] [blame] | 103 | CFG_STDLIB :=$(call CFG_LIB_NAME,ruststd) |
Brian Anderson | 5fb9cad | 2011-07-01 06:16:01 | [diff] [blame] | 104 | CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 105 | |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 106 | # version-string calculation |
| 107 | CFG_GIT_DIR := $(CFG_SRC_DIR).git |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 108 | CFG_VERSION = prerelease |
Graydon Hoare | 0a8f9a3 | 2011-06-13 21:45:26 | [diff] [blame] | 109 | ifneq ($(wildcard $(CFG_GIT)),) |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 110 | ifneq ($(wildcard $(CFG_GIT_DIR)),) |
| 111 | CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \ |
| 112 | --pretty=format:'(%h %ci)') |
| 113 | endif |
Graydon Hoare | 0a8f9a3 | 2011-06-13 21:45:26 | [diff] [blame] | 114 | endif |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 115 | |
Graydon Hoare | 94731fa | 2011-03-30 04:45:09 | [diff] [blame] | 116 | ifdef CFG_DISABLE_VALGRIND |
| 117 | $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND)) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 118 | CFG_VALGRIND := |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 119 | endif |
Patrick Walton | 518e2d2 | 2011-05-06 01:11:40 | [diff] [blame] | 120 | ifdef CFG_BAD_VALGRIND |
| 121 | $(info cfg: disabling valgrind due to its unreliability on this platform) |
| 122 | CFG_VALGRIND := |
| 123 | endif |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 124 | |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 125 | DOCS := |
| 126 | ifeq ($(CFG_MAKEINFO),) |
| 127 | $(info cfg: no makeinfo found, omitting doc/rust.html) |
| 128 | else |
| 129 | DOCS += doc/rust.html |
| 130 | endif |
| 131 | |
| 132 | ifeq ($(CFG_TEXI2PDF),) |
| 133 | $(info cfg: no texi2pdf found, omitting doc/rust.pdf) |
| 134 | else |
Graydon Hoare | f740747 | 2011-03-23 20:31:51 | [diff] [blame] | 135 | ifeq ($(CFG_TEX),) |
| 136 | $(info cfg: no tex found, omitting doc/rust.pdf) |
| 137 | else |
| 138 | DOCS += doc/rust.pdf |
| 139 | endif |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 140 | endif |
| 141 | |
Brian Anderson | 0c62007 | 2011-10-27 21:59:22 | [diff] [blame] | 142 | ifeq ($(CFG_NATURALDOCS),) |
Brian Anderson | 33f2f22 | 2011-10-27 22:04:29 | [diff] [blame] | 143 | $(info cfg: no naturaldocs found, omitting doc/std/index.html) |
Brian Anderson | 0c62007 | 2011-10-27 21:59:22 | [diff] [blame] | 144 | else |
| 145 | DOCS += doc/std/index.html |
| 146 | endif |
| 147 | |
Graydon Hoare | 94731fa | 2011-03-30 04:45:09 | [diff] [blame] | 148 | ifdef CFG_DISABLE_DOCS |
| 149 | $(info cfg: disabling doc build (CFG_DISABLE_DOCS)) |
| 150 | DOCS := |
| 151 | endif |
Graydon Hoare | 28a4e77 | 2011-03-23 17:37:35 | [diff] [blame] | 152 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 153 | ###################################################################### |
| 154 | # Target-and-rule "utility variables" |
| 155 | ###################################################################### |
| 156 | |
| 157 | ifdef VERBOSE |
| 158 | Q := |
| 159 | E = |
| 160 | else |
| 161 | Q := @ |
| 162 | E = echo $(1) |
| 163 | endif |
| 164 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 165 | S := $(CFG_SRC_DIR) |
| 166 | X := $(CFG_EXE_SUFFIX) |
| 167 | |
| 168 | # Look in doc and src dirs. |
| 169 | VPATH := $(S)doc $(S)src |
| 170 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 171 | # "Source" files we generate in builddir along the way. |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 172 | GENERATED := |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 173 | |
| 174 | # Delete the built-in rules. |
| 175 | .SUFFIXES: |
| 176 | %:: %,v |
| 177 | %:: RCS/%,v |
| 178 | %:: RCS/% |
| 179 | %:: s.% |
| 180 | %:: SCCS/s.% |
Graydon Hoare | 9c6e7e6 | 2011-03-16 16:17:32 | [diff] [blame] | 181 | |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 182 | ###################################################################### |
| 183 | # Standard library variables |
| 184 | ###################################################################### |
| 185 | |
Graydon Hoare | 6597439 | 2011-03-21 20:42:29 | [diff] [blame] | 186 | STDLIB_CRATE := $(S)src/lib/std.rc |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 187 | STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rc *.rs */*.rs)) |
| 188 | |
| 189 | ###################################################################### |
| 190 | # rustc crate variables |
| 191 | ###################################################################### |
| 192 | |
Graydon Hoare | 6597439 | 2011-03-21 20:42:29 | [diff] [blame] | 193 | COMPILER_CRATE := $(S)src/comp/rustc.rc |
Graydon Hoare | 874a7bf | 2011-03-19 00:30:06 | [diff] [blame] | 194 | COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \ |
Tim Chevalier | 60399ed | 2011-05-18 22:34:52 | [diff] [blame] | 195 | rustc.rc *.rs */*.rs */*/*.rs)) |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 196 | |
| 197 | ###################################################################### |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 198 | # LLVM macros |
| 199 | ###################################################################### |
| 200 | |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 201 | define DEF_LLVM_VARS |
| 202 | # The configure script defines these variables with the target triples |
| 203 | # separated by Z. This defines new ones with the expected format. |
| 204 | CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1))) |
| 205 | CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1))) |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 206 | |
Brian Anderson | 4b6585c | 2011-11-02 23:21:17 | [diff] [blame] | 207 | # Any rules that depend on LLVM should depend on LLVM_CONFIG |
| 208 | LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config |
| 209 | LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version) |
| 210 | LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir) |
| 211 | LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir) |
| 212 | LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir) |
| 213 | LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs) |
| 214 | LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags) |
| 215 | LLVM_CXXFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags) |
| 216 | LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target) |
| 217 | |
| 218 | LLVM_AS_$(1)=$$(LLVM_BINDIR_$(1))/llvm-as$$(X) |
| 219 | LLC_$(1)=$$(LLVM_BINDIR_$(1))/llc$$(X) |
| 220 | |
| 221 | endef |
| 222 | |
| 223 | $(foreach target,$(CFG_TARGET_TRIPLES), \ |
| 224 | $(eval $(call DEF_LLVM_VARS,$(target)))) |
| 225 | |
Brian Anderson | a0ff3db | 2011-11-02 00:09:44 | [diff] [blame] | 226 | ###################################################################### |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 227 | # Exports for sub-utilities |
| 228 | ###################################################################### |
| 229 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 230 | # Note that any variable that re-configure should pick up needs to be |
| 231 | # exported |
| 232 | |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 233 | export CFG_SRC_DIR |
Graydon Hoare | ad954fc | 2011-07-23 19:26:47 | [diff] [blame] | 234 | export CFG_BUILD_DIR |
Graydon Hoare | 1e03f00 | 2011-05-06 18:21:51 | [diff] [blame] | 235 | export CFG_VERSION |
Brian Anderson | 6306c81 | 2011-09-29 19:21:58 | [diff] [blame] | 236 | export CFG_HOST_TRIPLE |
Graydon Hoare | 6a4a85f | 2011-05-18 19:00:26 | [diff] [blame] | 237 | export CFG_LLVM_ROOT |
Graydon Hoare | 0dc2aa3 | 2011-06-28 18:18:25 | [diff] [blame] | 238 | export CFG_ENABLE_MINGW_CROSS |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 239 | export CFG_PREFIX |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 240 | |
Patrick Walton | 04f966f | 2011-05-05 01:28:30 | [diff] [blame] | 241 | ###################################################################### |
| 242 | # Subprograms |
| 243 | ###################################################################### |
| 244 | |
Graydon Hoare | d987b49 | 2011-05-03 06:37:52 | [diff] [blame] | 245 | ###################################################################### |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 246 | # Per-stage targets and runner |
| 247 | ###################################################################### |
| 248 | |
| 249 | define SREQ |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 250 | # $(1) is the stage number |
| 251 | # $(2) is the target triple |
| 252 | # $(3) is the build triple |
Brian Anderson | ed106dd | 2011-09-30 19:08:51 | [diff] [blame] | 253 | |
Brian Anderson | 38c67a4 | 2011-09-30 19:24:28 | [diff] [blame] | 254 | # Destinations of artifacts for the host compiler |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 255 | HROOT$(1)_H_$(3) = $(3)/stage$(1) |
| 256 | HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin |
| 257 | HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib |
Brian Anderson | 38c67a4 | 2011-09-30 19:24:28 | [diff] [blame] | 258 | |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 259 | # Destinations of artifacts for target architectures |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 260 | TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2) |
| 261 | TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin |
| 262 | TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib |
Brian Anderson | ed106dd | 2011-09-30 19:08:51 | [diff] [blame] | 263 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 264 | # The name of the standard library used by rustc |
Rafael Ávila de Espíndola | 88894b6 | 2011-07-20 20:02:36 | [diff] [blame] | 265 | ifdef CFG_DISABLE_SHAREDSTD |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 266 | HSTDLIB_DEFAULT$(1)_H_$(3) = \ |
| 267 | $$(HLIB$(1)_H_$(3))/libstd.rlib |
| 268 | TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \ |
| 269 | $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib |
Brian Anderson | f634eb2 | 2011-09-30 23:11:47 | [diff] [blame] | 270 | else |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 271 | HSTDLIB_DEFAULT$(1)_H_$(3) = \ |
| 272 | $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB) |
| 273 | TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \ |
| 274 | $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB) |
Brian Anderson | f634eb2 | 2011-09-30 23:11:47 | [diff] [blame] | 275 | endif |
| 276 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 277 | # Preqrequisites for using the stageN compiler |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 278 | HSREQ$(1)_H_$(3) = \ |
| 279 | $$(HBIN$(1)_H_$(3))/rustc$$(X) \ |
| 280 | $$(HLIB$(1)_H_$(3))/$$(CFG_RUNTIME) \ |
| 281 | $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLLVM) \ |
| 282 | $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \ |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 283 | $$(MKFILES) |
| 284 | |
| 285 | # Prerequisites for using the stageN compiler to build target artifacts |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 286 | TSREQ$(1)_T_$(2)_H_$(3) = \ |
| 287 | $$(HSREQ$(1)_H_$(3)) \ |
| 288 | $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME) \ |
| 289 | $$(TLIB$(1)_T_$(2)_H_$(3))/intrinsics.bc \ |
| 290 | $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 291 | |
| 292 | # Prerequisites for complete stageN targets |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 293 | SREQ$(1)_T_$(2)_H_$(3) = \ |
| 294 | $$(TSREQ$(1)_T_$(2)_H_$(3)) \ |
| 295 | $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB) |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 296 | |
Brian Anderson | e3d3aaa | 2011-08-26 18:11:49 | [diff] [blame] | 297 | ifeq ($(1),0) |
| 298 | # Don't run the the stage0 compiler under valgrind - that ship has sailed |
| 299 | CFG_VALGRIND_COMPILE$(1) = |
| 300 | else |
| 301 | CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE) |
| 302 | endif |
| 303 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 304 | STAGE$(1)_T_$(2)_H_$(3) := \ |
| 305 | $$(Q)$$(call CFG_RUN_TARG,$(1), \ |
| 306 | $$(CFG_VALGRIND_COMPILE$(1)) \ |
| 307 | $$(HBIN$(1)_H_$(3))/rustc$$(X) \ |
| 308 | $$(CFG_RUSTC_FLAGS) --target=$(2)) |
Brian Anderson | 7dbce10 | 2011-09-29 19:06:37 | [diff] [blame] | 309 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 310 | PERF_STAGE$(1)_T_$(2)_H_$(3) := \ |
| 311 | $$(Q)$$(call CFG_RUN_TARG,$(1), \ |
| 312 | $$(CFG_PERF_TOOL) \ |
| 313 | $$(HBIN$(1)_H_$(3))/rustc$$(X) \ |
| 314 | $$(CFG_RUSTC_FLAGS) --target=$(2)) |
Brian Anderson | 7dbce10 | 2011-09-29 19:06:37 | [diff] [blame] | 315 | |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 316 | endef |
| 317 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 318 | $(foreach build,$(CFG_TARGET_TRIPLES), \ |
| 319 | $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \ |
| 320 | $(eval $(foreach stage,$(STAGES), \ |
| 321 | $(eval $(call SREQ,$(stage),$(target),$(build)))))))) |
Graydon Hoare | fafb42e | 2011-07-15 23:12:41 | [diff] [blame] | 322 | |
| 323 | ###################################################################### |
| 324 | # Entrypoint rule |
Graydon Hoare | 4c2245d | 2011-03-18 06:51:45 | [diff] [blame] | 325 | ###################################################################### |
| 326 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 327 | ifneq ($(CFG_IN_TRANSITION),) |
| 328 | |
Graydon Hoare | 9ac2948 | 2011-05-16 22:14:58 | [diff] [blame] | 329 | CFG_INFO := $(info cfg:) |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 330 | CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***) |
| 331 | CFG_INFO := $(info cfg: *** stage2 and later will not be built ***) |
Graydon Hoare | 9ac2948 | 2011-05-16 22:14:58 | [diff] [blame] | 332 | CFG_INFO := $(info cfg:) |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 333 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 334 | all: $(SREQ1$(CFG_HOST_TRIPLE)) $(GENERATED) $(DOCS) |
Brian Anderson | b056096 | 2011-09-30 23:15:02 | [diff] [blame] | 335 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 336 | else |
Brian Anderson | 86ed905 | 2011-09-30 03:27:28 | [diff] [blame] | 337 | |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 338 | TSREQS := \ |
| 339 | $(foreach target,$(CFG_TARGET_TRIPLES), \ |
| 340 | $(SREQ3_T_$(target)_H_$(CFG_HOST_TRIPLE))) |
| 341 | FUZZ := $(HBIN3_H_$(CFG_HOST_TRIPLE))/fuzzer$(X) |
Brian Anderson | 86ed905 | 2011-09-30 03:27:28 | [diff] [blame] | 342 | |
Niko Matsakis | d088799 | 2011-10-14 21:08:04 | [diff] [blame] | 343 | #all: $(SREQ3$(CFG_HOST_TRIPLE)) $(GENERATED) $(DOCS) $(FUZZ) |
Niko Matsakis | 9c12c7c | 2011-11-21 21:11:40 | [diff] [blame] | 344 | all: $(TSREQS) $(GENERATED) $(DOCS) $(FUZZ) |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 345 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 346 | endif |
| 347 | |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 348 | |
| 349 | ###################################################################### |
| 350 | # Re-configuration |
| 351 | ###################################################################### |
| 352 | |
Brian Anderson | 8d7863f | 2011-11-29 01:50:23 | [diff] [blame] | 353 | ifndef CFG_DISABLE_MANAGE_SUBMODULES |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 354 | # 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] | 355 | 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] | 356 | else |
| 357 | NEED_GIT_RECONFIG=0 |
| 358 | endif |
Brian Anderson | 0e15011 | 2011-11-01 01:19:40 | [diff] [blame] | 359 | |
| 360 | ifeq ($(NEED_GIT_RECONFIG),0) |
| 361 | else |
| 362 | # If the submodules have changed then always execute config.mk |
| 363 | .PHONY: config.mk |
| 364 | endif |
| 365 | |
Graydon Hoare | ae784df | 2011-05-14 00:00:43 | [diff] [blame] | 366 | config.mk: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 367 | @$(call E, cfg: reconfiguring) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 368 | $(Q)$(S)configure $(CFG_CONFIGURE_ARGS) |
Graydon Hoare | 10f3360 | 2011-03-25 17:29:45 | [diff] [blame] | 369 | |
| 370 | |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 371 | ###################################################################### |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 372 | # Primary-target makefiles |
Graydon Hoare | e961f53 | 2011-03-21 18:23:19 | [diff] [blame] | 373 | ###################################################################### |
| 374 | |
Brian Anderson | 6e65456 | 2011-10-02 03:12:08 | [diff] [blame] | 375 | include $(CFG_SRC_DIR)/mk/target.mk |
| 376 | include $(CFG_SRC_DIR)/mk/host.mk |
Michael Sullivan | b01ecb1 | 2011-07-21 18:58:01 | [diff] [blame] | 377 | include $(CFG_SRC_DIR)/mk/stage0.mk |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 378 | include $(CFG_SRC_DIR)/mk/rt.mk |
| 379 | include $(CFG_SRC_DIR)/mk/rustllvm.mk |
Graydon Hoare | 40624e3 | 2011-05-01 20:18:52 | [diff] [blame] | 380 | include $(CFG_SRC_DIR)/mk/autodep.mk |
Brian Anderson | 3a6f3cf | 2011-10-03 00:28:59 | [diff] [blame] | 381 | include $(CFG_SRC_DIR)/mk/tools.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 382 | include $(CFG_SRC_DIR)/mk/docs.mk |
Brian Anderson | f96f169 | 2011-11-01 00:34:31 | [diff] [blame] | 383 | include $(CFG_SRC_DIR)/mk/llvm.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 384 | |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 385 | ###################################################################### |
| 386 | # Secondary makefiles, conditionalized for speed |
| 387 | ###################################################################### |
| 388 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 389 | ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \ |
| 390 | $(findstring check,$(MAKECMDGOALS)) \ |
| 391 | $(findstring test,$(MAKECMDGOALS)) \ |
Graydon Hoare | 39151f2 | 2011-07-13 22:44:09 | [diff] [blame] | 392 | $(findstring tidy,$(MAKECMDGOALS)) \ |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 393 | $(findstring clean,$(MAKECMDGOALS))),) |
| 394 | CFG_INFO := $(info cfg: including dist rules) |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 395 | include $(CFG_SRC_DIR)/mk/dist.mk |
| 396 | endif |
| 397 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 398 | ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \ |
| 399 | $(findstring clean,$(MAKECMDGOALS))),) |
| 400 | CFG_INFO := $(info cfg: including snap rules) |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 401 | include $(CFG_SRC_DIR)/mk/snap.mk |
| 402 | endif |
| 403 | |
| 404 | ifneq ($(findstring reformat,$(MAKECMDGOALS)),) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 405 | CFG_INFO := $(info cfg: including reformat rules) |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 406 | include $(CFG_SRC_DIR)/mk/pp.mk |
| 407 | endif |
| 408 | |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 409 | ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \ |
| 410 | $(findstring test,$(MAKECMDGOALS)) \ |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 411 | $(findstring perf,$(MAKECMDGOALS)) \ |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 412 | $(findstring tidy,$(MAKECMDGOALS))),) |
| 413 | CFG_INFO := $(info cfg: including test rules) |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 414 | include $(CFG_SRC_DIR)/mk/tests.mk |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 415 | endif |
| 416 | |
Graydon Hoare | d5b2d62 | 2011-09-13 22:06:21 | [diff] [blame] | 417 | ifneq ($(findstring perf,$(MAKECMDGOALS)),) |
| 418 | CFG_INFO := $(info cfg: including perf rules) |
| 419 | include $(CFG_SRC_DIR)/mk/perf.mk |
| 420 | endif |
| 421 | |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 422 | ifneq ($(findstring clean,$(MAKECMDGOALS)),) |
Graydon Hoare | df8161d | 2011-06-30 20:41:20 | [diff] [blame] | 423 | CFG_INFO := $(info cfg: including clean rules) |
Graydon Hoare | 79ba315 | 2011-06-25 19:23:27 | [diff] [blame] | 424 | include $(CFG_SRC_DIR)/mk/clean.mk |
Michael Sullivan | b01ecb1 | 2011-07-21 18:58:01 | [diff] [blame] | 425 | endif |
Brian Anderson | 9563c17 | 2011-10-01 02:00:19 | [diff] [blame] | 426 | |
| 427 | ifneq ($(findstring install,$(MAKECMDGOALS)),) |
| 428 | CFG_INFO := $(info cfg: including install rules) |
| 429 | include $(CFG_SRC_DIR)/mk/install.mk |
Niko Matsakis | e1c470c | 2011-10-12 19:10:21 | [diff] [blame] | 430 | endif |
| 431 | |
| 432 | ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \ |
| 433 | $(findstring TAGS.vi,$(MAKECMDGOALS))),) |
| 434 | CFG_INFO := $(info cfg: including ctags rules) |
| 435 | include $(CFG_SRC_DIR)/mk/ctags.mk |
| 436 | endif |