]> git.lizzy.rs Git - rust.git/blob - mk/target.mk
2ac8fe73ad30cd3252d08f7429b2ad77d23735e9
[rust.git] / mk / target.mk
1 # TARGET_STAGE_N template: This defines how target artifacts are built
2 # for all stage/target architecture combinations. The arguments:
3 # $(1) is the stage
4 # $(2) is the target triple
5 # $(3) is the host triple
6
7 define TARGET_STAGE_N
8
9 $$(TLIB$(1)_T_$(2)_H_$(3))/intrinsics.ll: \
10                 $$(S)src/rt/intrinsics/intrinsics.$(HOST_$(2)).ll.in
11         @$$(call E, sed: $$@)
12         $$(Q)sed s/@CFG_TARGET_TRIPLE@/$(2)/ $$< > $$@
13
14 $$(TLIB$(1)_T_$(2)_H_$(3))/intrinsics.bc: \
15                 $$(TLIB$(1)_T_$(2)_H_$(3))/intrinsics.ll \
16                 $$(LLVM_CONFIG_$(2))
17         @$$(call E, llvms-as: $$@)
18         $$(Q)$$(LLVM_AS_$(2)) -o $$@ $$<
19
20 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \
21                 rt/$(2)/arch/$$(HOST_$(2))/libmorestack.a
22         @$$(call E, cp: $$@)
23         $$(Q)cp $$< $$@
24
25 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \
26                 $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \
27                 $$(TSREQ$(1)_T_$(2)_H_$(3))
28         @$$(call E, compile_and_link: $$@)
29         $$(STAGE$(1)_T_$(2)_H_$(3)) --no-core --lib -o $$@ $$< && touch $$@
30
31 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \
32                 $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
33         $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \
34                 $$(TSREQ$(1)_T_$(2)_H_$(3))
35         @$$(call E, compile_and_link: $$@)
36         $$(STAGE$(1)_T_$(2)_H_$(3)) --lib -o $$@ $$< && touch $$@
37
38 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \
39                 rt/$(2)/$$(CFG_RUNTIME)
40         @$$(call E, cp: $$@)
41         $$(Q)cp $$< $$@
42
43 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM): \
44                 rustllvm/$(2)/$$(CFG_RUSTLLVM)
45         @$$(call E, cp: $$@)
46         $$(Q)cp $$< $$@
47
48 $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X):                          \
49                 $$(RUSTC_INPUTS)                                \
50                 $$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
51         @$$(call E, compile_and_link: $$@)
52         $$(STAGE$(1)_T_$(2)_H_$(3))  -o $$@ $$<
53
54 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBRUSTC):            \
55                 $$(COMPILER_CRATE) $$(COMPILER_INPUTS)          \
56                 $$(TSREQ$(1)_T_$(2)_H_$(3))                     \
57                 $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUSTLLVM)     \
58                 $$(TCORELIB_DEFAULT$(1)_T_$(2)_H_$(3))      \
59                 $$(TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3))
60         @$$(call E, compile_and_link: $$@)
61         $$(STAGE$(1)_T_$(2)_H_$(3))  --lib -o $$@ $$< && touch $$@
62
63 endef
64
65 # In principle, each host can build each target:
66 $(foreach source,$(CFG_TARGET_TRIPLES),                                         \
67  $(foreach target,$(CFG_TARGET_TRIPLES),                                        \
68   $(eval $(call TARGET_STAGE_N,0,$(source),$(target)))          \
69   $(eval $(call TARGET_STAGE_N,1,$(source),$(target)))          \
70   $(eval $(call TARGET_STAGE_N,2,$(source),$(target)))          \
71   $(eval $(call TARGET_STAGE_N,3,$(source),$(target)))))