blob: d32e6116eff48814f2e09c7d2077c29e474c0d58 [file] [log] [blame]
Brian Anderson6e654562011-10-02 03:12:081# 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 Anderson19797df2011-11-03 17:53:4934# by rustc. In general, rust programs, even those compiled for the
Brian Anderson6e654562011-10-02 03:12:0835# 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 Matsakis9c12c7c2011-11-21 21:11:4045STAGES = 0 1 2 3
46
Graydon Hoare9c6e7e62011-03-16 16:17:3247######################################################################
48# Residual auto-configuration
49######################################################################
50
51include config.mk
Graydon Hoare9c6e7e62011-03-16 16:17:3252
Niko Matsakis9c00c622011-11-23 23:20:2853ifdef IGNORE_MKFILES
54 MKFILE_DEPS :=
55else
Niko Matsakis5ce33ce2011-11-29 20:42:0556 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 Matsakis9c00c622011-11-23 23:20:2864endif
65
Niko Matsakis8371beb2011-11-22 21:04:5266NON_HOST_TRIPLES = $(filter-out $(CFG_HOST_TRIPLE),$(CFG_TARGET_TRIPLES))
67
Graydon Hoare9c6e7e62011-03-16 16:17:3268ifneq ($(MAKE_RESTARTS),)
69CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
70endif
71
Graydon Hoare13215802011-09-21 18:24:5972CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE))
Niko Matsakis8371beb2011-11-22 21:04:5273CFG_INFO := $(info cfg: non host triples $(NON_HOST_TRIPLES))
Graydon Hoare9c6e7e62011-03-16 16:17:3274
Graydon Hoarecae703c2011-04-08 22:44:4175ifdef CFG_DISABLE_OPTIMIZE
Graydon Hoare19ebc0f2011-04-08 23:29:1976 $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
Patrick Waltonc52fb522011-04-29 17:23:0777 CFG_RUSTC_FLAGS :=
Graydon Hoarecae703c2011-04-08 22:44:4178else
Patrick Waltonc52fb522011-04-29 17:23:0779 CFG_RUSTC_FLAGS := -O
Graydon Hoarecae703c2011-04-08 22:44:4180endif
Graydon Hoare4c2245d2011-03-18 06:51:4581
Patrick Walton3f77e7d2011-04-25 21:20:2882ifdef SAVE_TEMPS
Marijn Haverbeke6b11f6c2011-04-26 18:32:0883 CFG_RUSTC_FLAGS += --save-temps
Patrick Walton3f77e7d2011-04-25 21:20:2884endif
Patrick Walton648c4ae2011-04-29 18:55:3285ifdef TIME_PASSES
86 CFG_RUSTC_FLAGS += --time-passes
87endif
Brian Anderson27522842011-06-19 00:26:4188ifdef TIME_LLVM_PASSES
89 CFG_RUSTC_FLAGS += --time-llvm-passes
90endif
Patrick Walton404db4d2011-05-11 00:48:4991ifdef DEBUG
92 CFG_RUSTC_FLAGS += -g
93endif
Patrick Walton3f77e7d2011-04-25 21:20:2894
Graydon Hoare40624e32011-05-01 20:18:5295# platform-specific auto-configuration
96include $(CFG_SRC_DIR)/mk/platform.mk
Graydon Hoare4c2245d2011-03-18 06:51:4597
Brian Andersoncad8c732011-05-14 03:20:3498# Run the stage1/2 compilers under valgrind
99ifdef VALGRIND_COMPILE
100 CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
101else
102 CFG_VALGRIND_COMPILE :=
103endif
104
Graydon Hoare4c2245d2011-03-18 06:51:45105CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
Graydon Hoare7ac885e2011-03-22 06:06:42106CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm)
Graydon Hoare447414f2011-12-06 00:46:37107CFG_CORELIB :=$(call CFG_LIB_NAME,core)
Haitao Lib4f450a2011-11-18 08:00:28108CFG_STDLIB :=$(call CFG_LIB_NAME,std)
Brian Anderson5fb9cad2011-07-01 06:16:01109CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
Graydon Hoare4c2245d2011-03-18 06:51:45110
Haitao Li6dbd4c22011-12-02 16:51:59111STDLIB_GLOB :=$(call CFG_LIB_GLOB,std)
112CORELIB_GLOB :=$(call CFG_LIB_GLOB,core)
113LIBRUSTC_GLOB :=$(call CFG_LIB_GLOB,rustc)
114
Graydon Hoare1e03f002011-05-06 18:21:51115# version-string calculation
116CFG_GIT_DIR := $(CFG_SRC_DIR).git
Graydon Hoare79ba3152011-06-25 19:23:27117CFG_VERSION = prerelease
Graydon Hoare0a8f9a32011-06-13 21:45:26118ifneq ($(wildcard $(CFG_GIT)),)
Graydon Hoare1e03f002011-05-06 18:21:51119ifneq ($(wildcard $(CFG_GIT_DIR)),)
120 CFG_VERSION += $(shell git --git-dir=$(CFG_GIT_DIR) log -1 \
121 --pretty=format:'(%h %ci)')
122endif
Graydon Hoare0a8f9a32011-06-13 21:45:26123endif
Graydon Hoare1e03f002011-05-06 18:21:51124
Graydon Hoare94731fa2011-03-30 04:45:09125ifdef CFG_DISABLE_VALGRIND
126 $(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND))
Graydon Hoare4c2245d2011-03-18 06:51:45127 CFG_VALGRIND :=
Graydon Hoare9c6e7e62011-03-16 16:17:32128endif
Patrick Walton518e2d22011-05-06 01:11:40129ifdef CFG_BAD_VALGRIND
130 $(info cfg: disabling valgrind due to its unreliability on this platform)
131 CFG_VALGRIND :=
132endif
Graydon Hoare9c6e7e62011-03-16 16:17:32133
Graydon Hoare28a4e772011-03-23 17:37:35134DOCS :=
135ifeq ($(CFG_MAKEINFO),)
136 $(info cfg: no makeinfo found, omitting doc/rust.html)
137else
138 DOCS += doc/rust.html
139endif
140
141ifeq ($(CFG_TEXI2PDF),)
142 $(info cfg: no texi2pdf found, omitting doc/rust.pdf)
143else
Graydon Hoaref7407472011-03-23 20:31:51144 ifeq ($(CFG_TEX),)
145 $(info cfg: no tex found, omitting doc/rust.pdf)
146 else
147 DOCS += doc/rust.pdf
148 endif
Graydon Hoare28a4e772011-03-23 17:37:35149endif
150
Brian Anderson0c620072011-10-27 21:59:22151ifeq ($(CFG_NATURALDOCS),)
Graydon Hoare447414f2011-12-06 00:46:37152 $(info cfg: no naturaldocs found, omitting library doc build)
Brian Anderson0c620072011-10-27 21:59:22153else
Graydon Hoare447414f2011-12-06 00:46:37154 DOCS += doc/core/index.html doc/std/index.html
Brian Anderson0c620072011-10-27 21:59:22155endif
156
Graydon Hoare94731fa2011-03-30 04:45:09157ifdef CFG_DISABLE_DOCS
158 $(info cfg: disabling doc build (CFG_DISABLE_DOCS))
159 DOCS :=
160endif
Graydon Hoare28a4e772011-03-23 17:37:35161
Graydon Hoare4c2245d2011-03-18 06:51:45162######################################################################
163# Target-and-rule "utility variables"
164######################################################################
165
166ifdef VERBOSE
167 Q :=
168 E =
169else
170 Q := @
171 E = echo $(1)
172endif
173
Graydon Hoare4c2245d2011-03-18 06:51:45174S := $(CFG_SRC_DIR)
175X := $(CFG_EXE_SUFFIX)
176
177# Look in doc and src dirs.
178VPATH := $(S)doc $(S)src
179
Graydon Hoare4c2245d2011-03-18 06:51:45180# "Source" files we generate in builddir along the way.
Graydon Hoare40624e32011-05-01 20:18:52181GENERATED :=
Graydon Hoare4c2245d2011-03-18 06:51:45182
183# Delete the built-in rules.
184.SUFFIXES:
185%:: %,v
186%:: RCS/%,v
187%:: RCS/%
188%:: s.%
189%:: SCCS/s.%
Graydon Hoare9c6e7e62011-03-16 16:17:32190
Graydon Hoare4c2245d2011-03-18 06:51:45191######################################################################
Graydon Hoare447414f2011-12-06 00:46:37192# Core library variables
193######################################################################
194
195CORELIB_CRATE := $(S)src/libcore/core.rc
196CORELIB_INPUTS := $(wildcard $(addprefix $(S)src/libcore/, \
197 core.rc *.rs */*.rs))
198
199######################################################################
Graydon Hoare4c2245d2011-03-18 06:51:45200# Standard library variables
201######################################################################
202
Graydon Hoare447414f2011-12-06 00:46:37203STDLIB_CRATE := $(S)src/libstd/std.rc
204STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
205 std.rc *.rs */*.rs))
Graydon Hoare4c2245d2011-03-18 06:51:45206
207######################################################################
208# rustc crate variables
209######################################################################
210
Graydon Hoare65974392011-03-21 20:42:29211COMPILER_CRATE := $(S)src/comp/rustc.rc
Graydon Hoare874a7bf2011-03-19 00:30:06212COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \
Tim Chevalier60399ed2011-05-18 22:34:52213 rustc.rc *.rs */*.rs */*/*.rs))
Graydon Hoare4c2245d2011-03-18 06:51:45214
215######################################################################
Brian Andersona0ff3db2011-11-02 00:09:44216# LLVM macros
217######################################################################
218
Brian Andersona92218e2011-11-27 06:38:36219# FIXME: x86-ism
220LLVM_COMPONENTS=x86 ipo bitreader bitwriter linker asmparser
221
Brian Anderson4b6585c2011-11-02 23:21:17222define 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.
225CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
226CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
Brian Andersona0ff3db2011-11-02 00:09:44227
Brian Anderson4b6585c2011-11-02 23:21:17228# Any rules that depend on LLVM should depend on LLVM_CONFIG
Brian Anderson283cf352011-12-14 06:43:32229LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X)
230LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X)
Brian Anderson4b6585c2011-11-02 23:21:17231LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
232LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
233LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
234LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
Brian Andersona92218e2011-11-27 06:38:36235LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
Brian Anderson4b6585c2011-11-02 23:21:17236LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
237LLVM_CXXFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags)
238LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
239
Brian Andersonecdeffb2011-12-14 03:03:43240LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X)
241LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X)
Brian Anderson4b6585c2011-11-02 23:21:17242
243endef
244
245$(foreach target,$(CFG_TARGET_TRIPLES), \
246 $(eval $(call DEF_LLVM_VARS,$(target))))
247
Brian Andersona0ff3db2011-11-02 00:09:44248######################################################################
Graydon Hoared987b492011-05-03 06:37:52249# Exports for sub-utilities
250######################################################################
251
Brian Anderson6e654562011-10-02 03:12:08252# Note that any variable that re-configure should pick up needs to be
253# exported
254
Graydon Hoared987b492011-05-03 06:37:52255export CFG_SRC_DIR
Graydon Hoaread954fc2011-07-23 19:26:47256export CFG_BUILD_DIR
Graydon Hoare1e03f002011-05-06 18:21:51257export CFG_VERSION
Brian Anderson6306c812011-09-29 19:21:58258export CFG_HOST_TRIPLE
Graydon Hoare6a4a85f2011-05-18 19:00:26259export CFG_LLVM_ROOT
Graydon Hoare0dc2aa32011-06-28 18:18:25260export CFG_ENABLE_MINGW_CROSS
Brian Anderson6e654562011-10-02 03:12:08261export CFG_PREFIX
Graydon Hoared987b492011-05-03 06:37:52262
Patrick Walton04f966f2011-05-05 01:28:30263######################################################################
264# Subprograms
265######################################################################
266
Graydon Hoared987b492011-05-03 06:37:52267######################################################################
Graydon Hoarefafb42e2011-07-15 23:12:41268# Per-stage targets and runner
269######################################################################
270
271define SREQ
Niko Matsakis9c12c7c2011-11-21 21:11:40272# $(1) is the stage number
273# $(2) is the target triple
Graydon Hoare766e29c2011-11-30 03:28:15274# $(3) is the host triple
Brian Andersoned106dd2011-09-30 19:08:51275
Brian Anderson38c67a42011-09-30 19:24:28276# Destinations of artifacts for the host compiler
Niko Matsakis9c12c7c2011-11-21 21:11:40277HROOT$(1)_H_$(3) = $(3)/stage$(1)
278HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
279HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
Brian Anderson38c67a42011-09-30 19:24:28280
Brian Anderson9563c172011-10-01 02:00:19281# Destinations of artifacts for target architectures
Niko Matsakis9c12c7c2011-11-21 21:11:40282TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
283TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
284TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
Brian Andersoned106dd2011-09-30 19:08:51285
Graydon Hoare447414f2011-12-06 00:46:37286# The name of the core and standard libraries used by rustc
Rafael Ávila de Espíndola88894b62011-07-20 20:02:36287ifdef CFG_DISABLE_SHAREDSTD
Graydon Hoare447414f2011-12-06 00:46:37288 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 Matsakis9c12c7c2011-11-21 21:11:40292 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 Andersonf634eb22011-09-30 23:11:47296else
Graydon Hoare447414f2011-12-06 00:46:37297 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 Matsakis9c12c7c2011-11-21 21:11:40301 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 Andersonf634eb22011-09-30 23:11:47305endif
306
Brian Anderson6e654562011-10-02 03:12:08307# Preqrequisites for using the stageN compiler
Niko Matsakis9c12c7c2011-11-21 21:11:40308HSREQ$(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 Hoare447414f2011-12-06 00:46:37312 $$(HCORELIB_DEFAULT$(1)_H_$(3)) \
Niko Matsakis9c12c7c2011-11-21 21:11:40313 $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
Niko Matsakis5ce33ce2011-11-29 20:42:05314 $$(MKFILE_DEPS)
Brian Anderson6e654562011-10-02 03:12:08315
316# Prerequisites for using the stageN compiler to build target artifacts
Niko Matsakis9c12c7c2011-11-21 21:11:40317TSREQ$(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 Anderson6e654562011-10-02 03:12:08322
323# Prerequisites for complete stageN targets
Niko Matsakis9c12c7c2011-11-21 21:11:40324SREQ$(1)_T_$(2)_H_$(3) = \
325 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
Graydon Hoare447414f2011-12-06 00:46:37326 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
Niko Matsakis9c12c7c2011-11-21 21:11:40327 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB)
Graydon Hoarefafb42e2011-07-15 23:12:41328
Brian Andersone3d3aaa2011-08-26 18:11:49329ifeq ($(1),0)
330# Don't run the the stage0 compiler under valgrind - that ship has sailed
331CFG_VALGRIND_COMPILE$(1) =
332else
333CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
334endif
335
Niko Matsakis9c12c7c2011-11-21 21:11:40336STAGE$(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 Anderson7dbce102011-09-29 19:06:37341
Niko Matsakis9c12c7c2011-11-21 21:11:40342PERF_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 Anderson7dbce102011-09-29 19:06:37347
Graydon Hoarefafb42e2011-07-15 23:12:41348endef
349
Niko Matsakis9c12c7c2011-11-21 21:11:40350$(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 Hoarefafb42e2011-07-15 23:12:41354
355######################################################################
Niko Matsakis3bbfe512011-12-03 00:04:27356# rustc-H-targets
357#
358# Builds a functional Rustc for the given host.
359######################################################################
360
Niko Matsakis15d60322011-12-06 22:02:03361define DEF_RUSTC_STAGE_TARGET
362# $(1) == architecture
363# $(2) == stage
364
365rustc-stage$(2)-H-$(1): \
366 $$(foreach target,$$(CFG_TARGET_TRIPLES), \
367 $$(SREQ$(2)_T_$$(target)_H_$(1)))
368
369endef
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 Matsakisc28ada02011-12-09 16:16:04375rustc-stage1: rustc-stage1-H-$(CFG_HOST_TRIPLE)
376rustc-stage2: rustc-stage2-H-$(CFG_HOST_TRIPLE)
377rustc-stage3: rustc-stage3-H-$(CFG_HOST_TRIPLE)
378
Niko Matsakis3bbfe512011-12-03 00:04:27379define DEF_RUSTC_TARGET
380# $(1) == architecture
381
Niko Matsakis15d60322011-12-06 22:02:03382rustc-H-$(1): rustc-stage3-H-$(1)
Niko Matsakis3bbfe512011-12-03 00:04:27383endef
384
385$(foreach host,$(CFG_TARGET_TRIPLES), \
386 $(eval $(call DEF_RUSTC_TARGET,$(host))))
387
Niko Matsakis68c62722011-12-13 04:28:35388rustc-stage1: rustc-stage1-H-$(CFG_HOST_TRIPLE)
389rustc-stage2: rustc-stage2-H-$(CFG_HOST_TRIPLE)
390rustc-stage3: rustc-stage3-H-$(CFG_HOST_TRIPLE)
391rustc: rustc-H-$(CFG_HOST_TRIPLE)
392
Niko Matsakis49349292011-12-03 00:11:35393rustc-H-all: $(foreach host,$(CFG_TARGET_TRIPLES),rustc-H-$(host))
Niko Matsakis3bbfe512011-12-03 00:04:27394
395######################################################################
Graydon Hoarefafb42e2011-07-15 23:12:41396# Entrypoint rule
Graydon Hoare4c2245d2011-03-18 06:51:45397######################################################################
398
Brian Andersonc9b14cc2011-12-13 20:02:17399.DEFAULT_GOAL := all
400
Graydon Hoareae784df2011-05-14 00:00:43401ifneq ($(CFG_IN_TRANSITION),)
402
Graydon Hoare9ac29482011-05-16 22:14:58403CFG_INFO := $(info cfg:)
Graydon Hoareae784df2011-05-14 00:00:43404CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
405CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
Graydon Hoare9ac29482011-05-16 22:14:58406CFG_INFO := $(info cfg:)
Graydon Hoareae784df2011-05-14 00:00:43407
Brian Anderson6e654562011-10-02 03:12:08408all: $(SREQ1$(CFG_HOST_TRIPLE)) $(GENERATED) $(DOCS)
Brian Andersonb0560962011-09-30 23:15:02409
Graydon Hoareae784df2011-05-14 00:00:43410else
Brian Anderson86ed9052011-09-30 03:27:28411
Niko Matsakis9c12c7c2011-11-21 21:11:40412TSREQS := \
413 $(foreach target,$(CFG_TARGET_TRIPLES), \
414 $(SREQ3_T_$(target)_H_$(CFG_HOST_TRIPLE)))
415FUZZ := $(HBIN3_H_$(CFG_HOST_TRIPLE))/fuzzer$(X)
Graydon Hoared1fd7d42011-12-01 19:31:29416CARGO := $(HBIN3_H_$(CFG_HOST_TRIPLE))/cargo$(X)
Brian Anderson86ed9052011-09-30 03:27:28417
Niko Matsakis68c62722011-12-13 04:28:35418all: rustc $(GENERATED) $(DOCS) $(FUZZ) $(CARGO)
Brian Anderson6e654562011-10-02 03:12:08419
Graydon Hoareae784df2011-05-14 00:00:43420endif
421
Graydon Hoare10f33602011-03-25 17:29:45422
423######################################################################
424# Re-configuration
425######################################################################
426
Brian Anderson8d7863f2011-11-29 01:50:23427ifndef CFG_DISABLE_MANAGE_SUBMODULES
Brian Anderson0e150112011-11-01 01:19:40428# This is a pretty expensive operation but I don't see any way to avoid it
Brian Anderson143f8782011-11-26 04:00:48429NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
Brian Anderson8d7863f2011-11-29 01:50:23430else
431NEED_GIT_RECONFIG=0
432endif
Brian Anderson0e150112011-11-01 01:19:40433
434ifeq ($(NEED_GIT_RECONFIG),0)
435else
436# If the submodules have changed then always execute config.mk
437.PHONY: config.mk
438endif
439
Graydon Hoareae784df2011-05-14 00:00:43440config.mk: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
Graydon Hoare10f33602011-03-25 17:29:45441 @$(call E, cfg: reconfiguring)
Graydon Hoaredf8161d2011-06-30 20:41:20442 $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
Graydon Hoare10f33602011-03-25 17:29:45443
444
Graydon Hoaree961f532011-03-21 18:23:19445######################################################################
Graydon Hoare79ba3152011-06-25 19:23:27446# Primary-target makefiles
Graydon Hoaree961f532011-03-21 18:23:19447######################################################################
448
Brian Anderson6e654562011-10-02 03:12:08449include $(CFG_SRC_DIR)/mk/target.mk
450include $(CFG_SRC_DIR)/mk/host.mk
Michael Sullivanb01ecb12011-07-21 18:58:01451include $(CFG_SRC_DIR)/mk/stage0.mk
Graydon Hoare40624e32011-05-01 20:18:52452include $(CFG_SRC_DIR)/mk/rt.mk
453include $(CFG_SRC_DIR)/mk/rustllvm.mk
Graydon Hoare40624e32011-05-01 20:18:52454include $(CFG_SRC_DIR)/mk/autodep.mk
Brian Anderson3a6f3cf2011-10-03 00:28:59455include $(CFG_SRC_DIR)/mk/tools.mk
Graydon Hoare79ba3152011-06-25 19:23:27456include $(CFG_SRC_DIR)/mk/docs.mk
Brian Andersonf96f1692011-11-01 00:34:31457include $(CFG_SRC_DIR)/mk/llvm.mk
Graydon Hoare79ba3152011-06-25 19:23:27458
Graydon Hoare79ba3152011-06-25 19:23:27459######################################################################
460# Secondary makefiles, conditionalized for speed
461######################################################################
462
Graydon Hoaredf8161d2011-06-30 20:41:20463ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
464 $(findstring check,$(MAKECMDGOALS)) \
465 $(findstring test,$(MAKECMDGOALS)) \
Graydon Hoare39151f22011-07-13 22:44:09466 $(findstring tidy,$(MAKECMDGOALS)) \
Graydon Hoaredf8161d2011-06-30 20:41:20467 $(findstring clean,$(MAKECMDGOALS))),)
468 CFG_INFO := $(info cfg: including dist rules)
Graydon Hoare79ba3152011-06-25 19:23:27469 include $(CFG_SRC_DIR)/mk/dist.mk
470endif
471
Graydon Hoaredf8161d2011-06-30 20:41:20472ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
473 $(findstring clean,$(MAKECMDGOALS))),)
474 CFG_INFO := $(info cfg: including snap rules)
Graydon Hoare79ba3152011-06-25 19:23:27475 include $(CFG_SRC_DIR)/mk/snap.mk
476endif
477
478ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
Graydon Hoaredf8161d2011-06-30 20:41:20479 CFG_INFO := $(info cfg: including reformat rules)
Graydon Hoare79ba3152011-06-25 19:23:27480 include $(CFG_SRC_DIR)/mk/pp.mk
481endif
482
Graydon Hoaredf8161d2011-06-30 20:41:20483ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
484 $(findstring test,$(MAKECMDGOALS)) \
Graydon Hoared5b2d622011-09-13 22:06:21485 $(findstring perf,$(MAKECMDGOALS)) \
Graydon Hoaredf8161d2011-06-30 20:41:20486 $(findstring tidy,$(MAKECMDGOALS))),)
487 CFG_INFO := $(info cfg: including test rules)
Graydon Hoare79ba3152011-06-25 19:23:27488 include $(CFG_SRC_DIR)/mk/tests.mk
Graydon Hoare79ba3152011-06-25 19:23:27489endif
490
Graydon Hoared5b2d622011-09-13 22:06:21491ifneq ($(findstring perf,$(MAKECMDGOALS)),)
492 CFG_INFO := $(info cfg: including perf rules)
493 include $(CFG_SRC_DIR)/mk/perf.mk
494endif
495
Graydon Hoare79ba3152011-06-25 19:23:27496ifneq ($(findstring clean,$(MAKECMDGOALS)),)
Graydon Hoaredf8161d2011-06-30 20:41:20497 CFG_INFO := $(info cfg: including clean rules)
Graydon Hoare79ba3152011-06-25 19:23:27498 include $(CFG_SRC_DIR)/mk/clean.mk
Michael Sullivanb01ecb12011-07-21 18:58:01499endif
Brian Anderson9563c172011-10-01 02:00:19500
501ifneq ($(findstring install,$(MAKECMDGOALS)),)
502 CFG_INFO := $(info cfg: including install rules)
503 include $(CFG_SRC_DIR)/mk/install.mk
Niko Matsakise1c470c2011-10-12 19:10:21504endif
505
506ifneq ($(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
510endif