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 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
58 $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
59 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
60 | $$(TLIB$(1)_T_$(2)_H_$(3))/
61 @$$(call E, compile_and_link: $$@)
62 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
63 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
64 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
65 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
66 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
68 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
69 $$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
70 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
71 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
72 | $$(TLIB$(1)_T_$(2)_H_$(3))/
73 @$$(call E, compile_and_link: $$@)
74 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
75 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
76 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
77 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
78 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
80 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2)): \
81 $$(LIBRUSTUV_CRATE) $$(LIBRUSTUV_INPUTS) \
82 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
83 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
85 $$(UV_SUPPORT_LIB_$(2)) \
86 | $$(TLIB$(1)_T_$(2)_H_$(3))/
87 @$$(call E, compile_and_link: $$@)
88 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
89 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(2)),$$(notdir $$@))
90 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
91 -L $$(UV_SUPPORT_DIR_$(2)) \
92 -L $$(dir $$(LIBUV_LIB_$(2))) \
93 --out-dir $$(@D) $$< && touch $$@
94 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
95 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(2)),$$(notdir $$@))
97 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
98 $$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \
99 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
100 $$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
101 $$(TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3)) \
102 $$(TLIBRUSTUV_DEFAULT$(1)_T_$(2)_H_$(3)) \
103 | $$(TLIB$(1)_T_$(2)_H_$(3))/
104 @$$(call E, compile_and_link: $$@)
105 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
106 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@
107 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
109 # Only build the compiler for host triples
110 ifneq ($$(findstring $(2),$$(CFG_HOST)),)
112 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)): \
113 $(2)/rustllvm/$(CFG_RUSTLLVM_$(3)) \
114 | $$(TLIB$(1)_T_$(2)_H_$(3))/ \
115 $(SNAPSHOT_RUSTC_POST_CLEANUP)
119 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): CFG_COMPILER = $(2)
120 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
121 $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
122 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
123 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)) \
124 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
125 | $$(TLIB$(1)_T_$(2)_H_$(3))/
126 @$$(call E, compile_and_link: $$@)
127 $$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
128 $$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
129 $$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
131 # NOTE: after the next snapshot remove these '-L' flags
132 $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \
134 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
135 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)) \
136 | $$(TBIN$(1)_T_$(2)_H_$(3))/
137 @$$(call E, compile_and_link: $$@)
138 $$(STAGE$(1)_T_$(2)_H_$(3)) --cfg rustc -o $$@ $$< \
139 -L $$(UV_SUPPORT_DIR_$(2)) \
140 -L $$(dir $$(LIBUV_LIB_$(2)))
141 ifdef CFG_ENABLE_PAX_FLAGS
142 @$$(call E, apply PaX flags: $$@)
143 @"$(CFG_PAXCTL)" -cm "$$@"
148 $$(TBIN$(1)_T_$(2)_H_$(3))/:
151 ifneq ($(CFG_LIBDIR),bin)
152 $$(TLIB$(1)_T_$(2)_H_$(3))/:
158 # In principle, each host can build each target:
159 $(foreach source,$(CFG_HOST), \
160 $(foreach target,$(CFG_TARGET), \
161 $(eval $(call TARGET_STAGE_N,0,$(target),$(source))) \
162 $(eval $(call TARGET_STAGE_N,1,$(target),$(source))) \
163 $(eval $(call TARGET_STAGE_N,2,$(target),$(source))) \
164 $(eval $(call TARGET_STAGE_N,3,$(target),$(source)))))