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