]> git.lizzy.rs Git - rust.git/blob - mk/host.mk
Rollup merge of #38299 - achanda:ctrl-c, r=brson
[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 ifeq ($$(ONLY_RLIB_$(5)),)
22 $$(HLIB$(2)_H_$(4))/stamp.$(5): \
23         $$(TLIB$(1)_T_$(3)_H_$(4))/stamp.$(5) \
24         $$(RUST_DEPS_$(5)_T_$(3):%=$$(HLIB$(2)_H_$(4))/stamp.%) \
25         | $$(HLIB$(2)_H_$(4))/
26         @$$(call E, cp: $$(@D)/lib$(5))
27         $$(call REMOVE_ALL_OLD_GLOB_MATCHES, \
28             $$(dir $$@)$$(call CFG_LIB_GLOB_$(3),$(5)))
29         $$(Q)cp $$< $$@
30         $$(Q)cp -R $$(TLIB$(1)_T_$(3)_H_$(4))/$$(call CFG_LIB_GLOB_$(3),$(5)) \
31                 $$(HLIB$(2)_H_$(4))
32         $$(call LIST_ALL_OLD_GLOB_MATCHES, \
33             $$(dir $$@)$$(call CFG_LIB_GLOB_$(3),$(5)))
34 else
35 $$(HLIB$(2)_H_$(4))/stamp.$(5):
36         $$(Q)touch $$@
37 endif
38
39 endef
40
41 # Same as the above macro, but for tools instead of crates
42 define CP_HOST_STAGE_N_TOOL
43
44 $$(HBIN$(2)_H_$(4))/$(5)$$(X_$(3)): \
45         $$(TBIN$(1)_T_$(3)_H_$(4))/$(5)$$(X_$(3)) \
46         $$(TOOL_DEPS_$(5):%=$$(HLIB$(2)_H_$(4))/stamp.%) \
47         | $$(HBIN$(2)_H_$(4))/
48         @$$(call E, cp: $$@)
49         $$(Q)cp $$< $$@
50
51 endef
52
53
54 # Miscellaneous rules for just making a few directories.
55 #
56 # $(1) - the stage to copy from
57 # $(2) - the stage to copy to
58 # $(3) - the target triple
59 # $(4) - the host triple (same as $(3))
60 define CP_HOST_STAGE_N
61
62 ifneq ($(CFG_LIBDIR_RELATIVE),bin)
63 $$(HLIB$(2)_H_$(4))/:
64         @mkdir -p $$@
65 endif
66
67 endef
68
69 $(foreach t,$(CFG_HOST), \
70         $(eval $(call CP_HOST_STAGE_N,0,1,$(t),$(t))) \
71         $(eval $(call CP_HOST_STAGE_N,1,2,$(t),$(t))) \
72         $(eval $(call CP_HOST_STAGE_N,2,3,$(t),$(t))))
73
74 $(foreach crate,$(CRATES), \
75  $(foreach t,$(CFG_HOST), \
76   $(eval $(call CP_HOST_STAGE_N_CRATE,0,1,$(t),$(t),$(crate))) \
77   $(eval $(call CP_HOST_STAGE_N_CRATE,1,2,$(t),$(t),$(crate))) \
78   $(eval $(call CP_HOST_STAGE_N_CRATE,2,3,$(t),$(t),$(crate)))))
79
80 $(foreach tool,$(TOOLS), \
81  $(foreach t,$(CFG_HOST), \
82   $(eval $(call CP_HOST_STAGE_N_TOOL,0,1,$(t),$(t),$(tool))) \
83   $(eval $(call CP_HOST_STAGE_N_TOOL,1,2,$(t),$(t),$(tool))) \
84   $(eval $(call CP_HOST_STAGE_N_TOOL,2,3,$(t),$(t),$(tool)))))