]> git.lizzy.rs Git - rust.git/blob - mk/host.mk
auto merge of #11823 : derekchiang/rust/fix-barrier-doc, r=alexcrichton
[rust.git] / mk / host.mk
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.
4 #
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.
10
11 # Generic rule for copying any target crate to a host crate. This rule will also
12 # promote any dependent rust crates up to their host locations as well
13 #
14 # $(1) - the stage to copy from
15 # $(2) - the stage to copy to
16 # $(3) - the host triple
17 # $(4) - the target triple (same as $(3))
18 # $(5) - the name of the crate being processed
19 define CP_HOST_STAGE_N_CRATE
20
21 $$(HLIB$(2)_H_$(4))/stamp.$(5):                                 \
22         $$(TLIB$(1)_T_$(3)_H_$(4))/stamp.$(5)                   \
23         $$(RUST_DEPS_$(5):%=$$(HLIB$(2)_H_$(4))/stamp.%)        \
24         | $$(HLIB$(2)_H_$(4))/
25         @$$(call E, cp: $$(@D)/lib$(5))
26         $$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
27             $$(dir $$@)$$(call CFG_LIB_GLOB_$(3),$(5)))
28         $$(Q)cp $$< $$@
29         $$(Q)cp -R $$(TLIB$(1)_T_$(3)_H_$(4))/$$(call CFG_LIB_GLOB_$(3),$(5)) \
30                 $$(HLIB$(2)_H_$(4))
31         $$(call LIST_ALL_OLD_GLOB_MATCHES,\
32             $$(dir $$@)$$(call CFG_LIB_GLOB_$(3),$(5)))
33
34 endef
35
36 # Same as the above macro, but for tools instead of crates
37 define CP_HOST_STAGE_N_TOOL
38
39 $$(HBIN$(2)_H_$(4))/$(5)$$(X_$(3)): \
40         $$(TBIN$(1)_T_$(3)_H_$(4))/$(5)$$(X_$(3)) \
41         $$(TOOL_DEPS_$(5):%=$$(HLIB$(2)_H_$(4))/stamp.%) \
42         | $$(HBIN$(2)_H_$(4))/
43         @$$(call E, cp: $$@)
44         $$(Q)cp $$< $$@
45
46 endef
47
48
49 # Miscellaneous rules for just making a few directories.
50 #
51 # $(1) - the stage to copy from
52 # $(2) - the stage to copy to
53 # $(3) - the target triple
54 # $(4) - the host triple (same as $(3))
55 define CP_HOST_STAGE_N
56
57 $$(HBIN$(2)_H_$(4))/:
58         @mkdir -p $$@
59
60 ifneq ($(CFG_LIBDIR_RELATIVE),bin)
61 $$(HLIB$(2)_H_$(4))/:
62         @mkdir -p $$@
63 endif
64
65 endef
66
67 $(foreach t,$(CFG_HOST),                                                    \
68         $(eval $(call CP_HOST_STAGE_N,0,1,$(t),$(t)))                       \
69         $(eval $(call CP_HOST_STAGE_N,1,2,$(t),$(t)))                       \
70         $(eval $(call CP_HOST_STAGE_N,2,3,$(t),$(t))))
71
72 $(foreach crate,$(CRATES),                                                  \
73  $(foreach t,$(CFG_HOST),                                                   \
74   $(eval $(call CP_HOST_STAGE_N_CRATE,0,1,$(t),$(t),$(crate)))              \
75   $(eval $(call CP_HOST_STAGE_N_CRATE,1,2,$(t),$(t),$(crate)))              \
76   $(eval $(call CP_HOST_STAGE_N_CRATE,2,3,$(t),$(t),$(crate)))))
77
78 $(foreach tool,$(TOOLS),                                                    \
79  $(foreach t,$(CFG_HOST),                                                   \
80   $(eval $(call CP_HOST_STAGE_N_TOOL,0,1,$(t),$(t),$(tool)))                \
81   $(eval $(call CP_HOST_STAGE_N_TOOL,1,2,$(t),$(t),$(tool)))                \
82   $(eval $(call CP_HOST_STAGE_N_TOOL,2,3,$(t),$(t),$(tool)))))