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.
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.
11 # This is the compile-time target-triple for the compiler. For the compiler at
12 # runtime, this should be considered the host-triple. More explanation for why
13 # this exists can be found on issue #2400
16 # The standard libraries should be held up to a higher standard than any old
17 # code, make sure that these common warnings are denied by default. These can
18 # be overridden during development temporarily. For stage0, we allow warnings
19 # which may be bugs in stage0 (should be fixed in stage1+)
20 WFLAGS_ST0 = -W warnings
21 WFLAGS_ST1 = -D warnings
22 WFLAGS_ST2 = -D warnings
24 # TARGET_STAGE_N template: This defines how target artifacts are built
25 # for all stage/target architecture combinations. The arguments:
27 # $(2) is the target triple
28 # $(3) is the host triple
30 # Every recipe in TARGET_STAGE_N outputs to $$(TLIB$(1)_T_$(2)_H_$(3),
31 # a directory that can be cleaned out during the middle of a run of
32 # the get-snapshot.py script. Therefore, every recipe needs to have
33 # an order-only dependency either on $(SNAPSHOT_RUSTC_POST_CLEANUP) or
34 # on $$(TSREQ$(1)_T_$(2)_H_$(3)), to ensure that no products will be
35 # put into the target area until after the get-snapshot.py script has
36 # had its chance to clean it out; otherwise the other products will be
37 # inadvertantly included in the clean out.
39 SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD))
43 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \
44 $(2)/rt/stage$(1)/arch/$$(HOST_$(2))/libmorestack.a \
45 | $$(TLIB$(1)_T_$(2)_H_$(3))/ \
46 $(SNAPSHOT_RUSTC_POST_CLEANUP)
50 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)): \
51 $(2)/rt/stage$(1)/$(CFG_RUNTIME_$(2)) \
52 | $$(TLIB$(1)_T_$(2)_H_$(3))/ \
53 $(SNAPSHOT_RUSTC_POST_CLEANUP)
57 # SNAP a5fa1d9 remove this after the stage0 snapshot from rules below
59 ifeq ($(3),$$(findstring $(3),$$(NON_BUILD_HOST)))
60 LFLAGS_$(1)_$(2)_$(3) :=
62 LFLAGS_$(1)_$(2)_$(3) := -L $$(TLIB$(1)_T_$(2)_H_$(3))
65 LFLAGS_$(1)_$(2)_$(3) :=
68 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
69 $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
70 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
71 | $$(TLIB$(1)_T_$(2)_H_$(3))/
72 @$$(call E, compile_and_link: $$@)
73 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
74 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
75 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $$(LFLAGS_$(1)_$(2)_$(3)) \
76 --out-dir $$(@D) $$< && touch $$@
77 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
78 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
80 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
81 $$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
82 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
83 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
84 | $$(TLIB$(1)_T_$(2)_H_$(3))/
85 @$$(call E, compile_and_link: $$@)
86 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
87 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
88 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $$(LFLAGS_$(1)_$(2)_$(3)) \
89 --out-dir $$(@D) $$< && touch $$@
90 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
91 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
93 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2)): \
94 $$(LIBRUSTUV_CRATE) $$(LIBRUSTUV_INPUTS) \
95 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
96 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
98 $$(UV_SUPPORT_LIB_$(2)) \
99 | $$(TLIB$(1)_T_$(2)_H_$(3))/
100 @$$(call E, compile_and_link: $$@)
101 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
102 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(2)),$$(notdir $$@))
103 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
104 -L $$(UV_SUPPORT_DIR_$(2)) \
105 -L $$(dir $$(LIBUV_LIB_$(2))) \
106 $$(LFLAGS_$(1)_$(2)_$(3)) \
107 --out-dir $$(@D) $$< && touch $$@
108 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
109 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(2)),$$(notdir $$@))
111 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBGREEN_$(2)): \
112 $$(LIBGREEN_CRATE) $$(LIBGREEN_INPUTS) \
113 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
114 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
115 | $$(TLIB$(1)_T_$(2)_H_$(3))/
116 @$$(call E, compile_and_link: $$@)
117 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_GLOB_$(2)),$$(notdir $$@))
118 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_RGLOB_$(2)),$$(notdir $$@))
119 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
120 $$(LFLAGS_$(1)_$(2)_$(3)) \
121 --out-dir $$(@D) $$< && touch $$@
122 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_GLOB_$(2)),$$(notdir $$@))
123 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBGREEN_RGLOB_$(2)),$$(notdir $$@))
125 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBNATIVE_$(2)): \
126 $$(LIBNATIVE_CRATE) $$(LIBNATIVE_INPUTS) \
127 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
128 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
129 | $$(TLIB$(1)_T_$(2)_H_$(3))/
130 @$$(call E, compile_and_link: $$@)
131 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_GLOB_$(2)),$$(notdir $$@))
132 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_RGLOB_$(2)),$$(notdir $$@))
133 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
134 $$(LFLAGS_$(1)_$(2)_$(3)) \
135 --out-dir $$(@D) $$< && touch $$@
136 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_GLOB_$(2)),$$(notdir $$@))
137 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBNATIVE_RGLOB_$(2)),$$(notdir $$@))
139 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
140 $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
141 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
142 $$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
143 $$(TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
144 | $$(TLIB$(1)_T_$(2)_H_$(3))/
145 @$$(call E, compile_and_link: $$@)
146 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
147 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_RGLOB_$(2)),$$(notdir $$@))
148 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $(BORROWCK) \
149 $$(LFLAGS_$(1)_$(2)_$(3)) \
150 --out-dir $$(@D) $$< && touch $$@
151 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
152 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_RGLOB_$(2)),$$(notdir $$@))
154 # Only build the compiler for host triples
155 ifneq ($$(findstring $(2),$$(CFG_HOST)),)
157 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)): \
158 $(2)/rustllvm/$(CFG_RUSTLLVM_$(3)) \
159 | $$(TLIB$(1)_T_$(2)_H_$(3))/ \
160 $(SNAPSHOT_RUSTC_POST_CLEANUP)
164 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): CFG_COMPILER = $(2)
165 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
166 $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
167 $(S)src/librustc/lib/llvmdeps.rs \
168 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
169 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)) \
170 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
171 | $$(TLIB$(1)_T_$(2)_H_$(3))/
172 @$$(call E, compile_and_link: $$@)
173 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
174 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_RGLOB_$(2)),$$(notdir $$@))
175 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
176 -L "$$(LLVM_LIBDIR_$(2))" \
177 $$(LFLAGS_$(1)_$(2)_$(3)) \
178 --out-dir $$(@D) $$< && touch $$@
179 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
180 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_RGLOB_$(2)),$$(notdir $$@))
182 $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \
184 $$(SREQ$(1)_T_$(2)_H_$(3)) \
185 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \
186 | $$(TBIN$(1)_T_$(2)_H_$(3))/
187 @$$(call E, compile_and_link: $$@)
188 $$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$< \
189 $$(LFLAGS_$(1)_$(2)_$(3))
190 ifdef CFG_ENABLE_PAX_FLAGS
191 @$$(call E, apply PaX flags: $$@)
192 @"$(CFG_PAXCTL)" -cm "$$@"
197 $$(TBIN$(1)_T_$(2)_H_$(3))/:
200 $$(TLIB$(1)_T_$(2)_H_$(3))/:
205 # In principle, each host can build each target:
206 $(foreach source,$(CFG_HOST), \
207 $(foreach target,$(CFG_TARGET), \
208 $(eval $(call TARGET_STAGE_N,0,$(target),$(source))) \
209 $(eval $(call TARGET_STAGE_N,1,$(target),$(source))) \
210 $(eval $(call TARGET_STAGE_N,2,$(target),$(source))) \
211 $(eval $(call TARGET_STAGE_N,3,$(target),$(source)))))