]> git.lizzy.rs Git - rust.git/blob - mk/prepare.mk
Unignore u128 test for stage 0,1
[rust.git] / mk / prepare.mk
1 # Copyright 2014 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 # Basic support for producing installation images.
12 #
13 # The 'prepare' build target copies all release artifacts from the build
14 # directory to some other location, placing all binaries, libraries, and
15 # docs in their final locations relative to each other.
16 #
17 # It requires the following variables to be set:
18 #
19 #   PREPARE_HOST - the host triple
20 #   PREPARE_TARGETS - the target triples, space separated
21 #   PREPARE_DEST_DIR - the directory to put the image
22
23 PREPARE_STAGE=2
24
25 DEFAULT_PREPARE_DIR_CMD = umask 022 && mkdir -p
26 DEFAULT_PREPARE_BIN_CMD = install -m755
27 DEFAULT_PREPARE_LIB_CMD = install -m644
28 DEFAULT_PREPARE_MAN_CMD = install -m644
29
30 # Create a directory
31 # $(1) is the directory
32 #
33 # XXX: These defines are called to generate make steps.
34 # Adding blank lines means two steps from different defines will not end up on
35 # the same line.
36 define PREPARE_DIR
37
38         @$(call E, prepare: $(1))
39         $(Q)$(PREPARE_DIR_CMD) $(1)
40
41 endef
42
43 # Copy an executable
44 # $(1) is the filename/libname-glob
45 #
46 # See above for an explanation on the surrounding blank lines
47 define PREPARE_BIN
48
49         @$(call E, prepare: $(PREPARE_DEST_BIN_DIR)/$(1))
50         $(Q)$(PREPARE_BIN_CMD) $(PREPARE_SOURCE_BIN_DIR)/$(1) $(PREPARE_DEST_BIN_DIR)/$(1)
51
52 endef
53
54 # Copy a dylib or rlib
55 # $(1) is the filename/libname-glob
56 #
57 # See above for an explanation on the surrounding blank lines
58 define PREPARE_LIB
59
60         @$(call E, prepare: $(PREPARE_WORKING_DEST_LIB_DIR)/$(1))
61         $(Q)LIB_NAME="$(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR)/$(1))))"; \
62         MATCHES="$(filter-out %$(notdir $(lastword $(wildcard $(PREPARE_WORKING_SOURCE_LIB_DIR)/$(1)))), \
63                         $(wildcard $(PREPARE_WORKING_DEST_LIB_DIR)/$(1)))"; \
64         if [ -n "$$MATCHES" ]; then \
65           echo "warning: one or libraries matching Rust library '$(1)'" && \
66           echo "  (other than '$$LIB_NAME' itself) already present"     && \
67           echo "  at destination $(PREPARE_WORKING_DEST_LIB_DIR):"      && \
68           echo $$MATCHES ; \
69         fi
70         $(Q)$(PREPARE_LIB_CMD) `ls -drt1 $(PREPARE_WORKING_SOURCE_LIB_DIR)/$(1)` $(PREPARE_WORKING_DEST_LIB_DIR)/
71
72 endef
73
74 # Copy a man page
75 # $(1) - source dir
76 #
77 # See above for an explanation on the surrounding blank lines
78 define PREPARE_MAN
79
80         @$(call E, prepare: $(PREPARE_DEST_MAN_DIR)/$(1))
81         $(Q)$(PREPARE_MAN_CMD) $(PREPARE_SOURCE_MAN_DIR)/$(1) $(PREPARE_DEST_MAN_DIR)/$(1)
82
83 endef
84
85 PREPARE_TOOLS = $(filter-out compiletest rustbook error_index_generator, $(TOOLS))
86
87
88 # $(1) is tool
89 # $(2) is stage
90 # $(3) is host
91 # $(4) tag
92 define DEF_PREPARE_HOST_TOOL
93 prepare-host-tool-$(1)-$(2)-$(3)-$(4): \
94         PREPARE_SOURCE_BIN_DIR=$$(HBIN$(2)_H_$(3))
95 prepare-host-tool-$(1)-$(2)-$(3)-$(4): prepare-maybe-clean-$(4) \
96                                   $$(foreach dep,$$(TOOL_DEPS_$(1)),prepare-host-lib-$$(dep)-$(2)-$(3)-$(4)) \
97                                   $$(HBIN$(2)_H_$(3))/$(1)$$(X_$(3)) \
98                                   prepare-host-dirs-$(4)
99         $$(if $$(findstring $(2), $$(PREPARE_STAGE)), \
100       $$(if $$(findstring $(3), $$(PREPARE_HOST)), \
101         $$(call PREPARE_BIN,$(1)$$(X_$$(PREPARE_HOST))),),)
102         $$(if $$(findstring $(2), $$(PREPARE_STAGE)), \
103       $$(if $$(findstring $(3), $$(PREPARE_HOST)), \
104         $$(call PREPARE_MAN,$(1).1),),)
105 endef
106
107 # Libraries are compiled using the --libdir provided to configure, but
108 # we store them in the tarball using just "lib" so that the install
109 # script can then rewrite them back to the correct path.
110 PREPARE_TAR_LIB_DIR = $(patsubst $(CFG_LIBDIR_RELATIVE)%,lib%,$(1))
111
112 # For host libraries only install dylibs, not rlibs since the host libs are only
113 # used to support rustc and rustc uses dynamic linking
114 #
115 # $(1) is tool
116 # $(2) is stage
117 # $(3) is host
118 # $(4) tag
119 define DEF_PREPARE_HOST_LIB
120 prepare-host-lib-$(1)-$(2)-$(3)-$(4): \
121         PREPARE_WORKING_SOURCE_LIB_DIR=$$(HLIB$(2)_H_$(3))
122 prepare-host-lib-$(1)-$(2)-$(3)-$(4): \
123         PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_DIR)/$$(call PREPARE_TAR_LIB_DIR,$$(HLIB_RELATIVE$(2)_H_$(3)))
124 prepare-host-lib-$(1)-$(2)-$(3)-$(4): prepare-maybe-clean-$(4) \
125                                  $$(foreach dep,$$(RUST_DEPS_$(1)_T_$(3)),prepare-host-lib-$$(dep)-$(2)-$(3)-$(4)) \
126                                  $$(HLIB$(2)_H_$(3))/stamp.$(1) \
127                                  prepare-host-dirs-$(4)
128         $$(if $$(findstring $(2), $$(PREPARE_STAGE)), \
129       $$(if $$(findstring $(3), $$(PREPARE_HOST)), \
130         $$(if $$(findstring 1,$$(ONLY_RLIB_$(1))),, \
131           $$(call PREPARE_LIB,$$(call CFG_LIB_GLOB_$$(PREPARE_HOST),$(1)))),),)
132 endef
133
134
135 # $(1) is stage
136 # $(2) is target
137 # $(3) is host
138 # $(4) tag
139 define DEF_PREPARE_TARGET_N
140 # Rebind PREPARE_*_LIB_DIR to point to rustlib, then install the libs for the targets
141 prepare-target-$(2)-host-$(3)-$(1)-$(4): \
142         PREPARE_WORKING_SOURCE_LIB_DIR=$$(TLIB$(1)_T_$(2)_H_$(3))
143 prepare-target-$(2)-host-$(3)-$(1)-$(4): \
144         PREPARE_WORKING_DEST_LIB_DIR=$$(PREPARE_DEST_LIB_DIR)/rustlib/$(2)/lib
145 prepare-target-$(2)-host-$(3)-$(1)-$(4): \
146         PREPARE_SOURCE_BIN_DIR=$$(TBIN$(1)_T_$(2)_H_$(3))
147 prepare-target-$(2)-host-$(3)-$(1)-$(4): \
148         PREPARE_DEST_BIN_DIR=$$(PREPARE_DEST_LIB_DIR)/rustlib/$(3)/bin
149 prepare-target-$(2)-host-$(3)-$(1)-$(4): prepare-maybe-clean-$(4) \
150         $$(foreach crate,$$(TARGET_CRATES_$(2)), \
151           $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
152         $$(if $$(findstring $(2),$$(CFG_HOST)), \
153           $$(foreach crate,$$(HOST_CRATES), \
154             $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)),)
155 # Only install if this host and target combo is being prepared. Also be sure to
156 # *not* install the rlibs for host crates because there's no need to statically
157 # link against most of them. They just produce a large amount of extra size
158 # bloat.
159         $$(if $$(findstring $(1), $$(PREPARE_STAGE)), \
160       $$(if $$(findstring $(2), $$(PREPARE_TARGETS)), \
161         $$(if $$(findstring $(3), $$(PREPARE_HOST)), \
162           $$(call PREPARE_DIR,$$(PREPARE_WORKING_DEST_LIB_DIR)) \
163           $$(call PREPARE_DIR,$$(PREPARE_DEST_BIN_DIR)) \
164           $$(foreach crate,$$(TARGET_CRATES_$(2)), \
165             $$(if $$(or $$(findstring 1, $$(ONLY_RLIB_$$(crate))),$$(findstring 1,$$(CFG_INSTALL_ONLY_RLIB_$(2)))),, \
166               $$(call PREPARE_LIB,$$(call CFG_LIB_GLOB_$(2),$$(crate)))) \
167             $$(call PREPARE_LIB,$$(call CFG_RLIB_GLOB,$$(crate)))) \
168           $$(if $$(findstring $(2),$$(CFG_HOST)), \
169             $$(foreach crate,$$(HOST_CRATES), \
170               $$(call PREPARE_LIB,$$(call CFG_LIB_GLOB_$(2),$$(crate)))),) \
171           $$(foreach object,$$(INSTALLED_OBJECTS_$(2)),\
172             $$(call PREPARE_LIB,$$(object))) \
173           $$(foreach bin,$$(INSTALLED_BINS_$(3)),\
174             $$(call PREPARE_BIN,$$(bin))) \
175         ,),),)
176 endef
177
178 define INSTALL_GDB_DEBUGGER_SCRIPTS_COMMANDS
179         $(Q)$(PREPARE_BIN_CMD) $(DEBUGGER_BIN_SCRIPTS_GDB_ABS) $(PREPARE_DEST_BIN_DIR)
180         $(Q)$(PREPARE_LIB_CMD) $(DEBUGGER_RUSTLIB_ETC_SCRIPTS_GDB_ABS) $(PREPARE_DEST_LIB_DIR)/rustlib/etc
181 endef
182
183 define INSTALL_LLDB_DEBUGGER_SCRIPTS_COMMANDS
184         $(Q)$(PREPARE_BIN_CMD) $(DEBUGGER_BIN_SCRIPTS_LLDB_ABS) $(PREPARE_DEST_BIN_DIR)
185         $(Q)$(PREPARE_LIB_CMD) $(DEBUGGER_RUSTLIB_ETC_SCRIPTS_LLDB_ABS) $(PREPARE_DEST_LIB_DIR)/rustlib/etc
186 endef
187
188 define INSTALL_NO_DEBUGGER_SCRIPTS_COMMANDS
189         $(Q)echo "No debugger scripts will be installed for host $(PREPARE_HOST)"
190 endef
191
192 # $(1) is PREPARE_HOST
193 INSTALL_DEBUGGER_SCRIPT_COMMANDS=$(if $(findstring windows,$(1)),\
194                                    $(INSTALL_NO_DEBUGGER_SCRIPTS_COMMANDS),\
195                                    $(if $(findstring darwin,$(1)),\
196                                      $(INSTALL_LLDB_DEBUGGER_SCRIPTS_COMMANDS),\
197                                      $(INSTALL_GDB_DEBUGGER_SCRIPTS_COMMANDS)))
198
199 define DEF_PREPARE
200
201 prepare-base-$(1)-%: PREPARE_SOURCE_MAN_DIR=$$(S)/man
202 prepare-base-$(1)-%: PREPARE_DEST_BIN_DIR=$$(PREPARE_DEST_DIR)/bin
203 prepare-base-$(1)-%: PREPARE_DEST_LIB_DIR=$$(PREPARE_DEST_DIR)/$$(call PREPARE_TAR_LIB_DIR,$$(CFG_LIBDIR_RELATIVE))
204 prepare-base-$(1)-%: PREPARE_DEST_MAN_DIR=$$(PREPARE_DEST_DIR)/share/man/man1
205
206 prepare-base-$(1)-target: prepare-target-$(1)
207 prepare-base-$(1)-host: prepare-host-$(1) prepare-debugger-scripts-$(1)
208
209 prepare-host-$(1): prepare-host-tools-$(1)
210
211 prepare-host-tools-$(1): \
212         $$(foreach tool, $$(PREPARE_TOOLS), \
213           $$(foreach host,$$(CFG_HOST), \
214             prepare-host-tool-$$(tool)-$$(PREPARE_STAGE)-$$(host)-$(1)))
215
216 prepare-host-dirs-$(1): prepare-maybe-clean-$(1)
217         $$(call PREPARE_DIR,$$(PREPARE_DEST_BIN_DIR))
218         $$(call PREPARE_DIR,$$(PREPARE_DEST_LIB_DIR))
219         $$(call PREPARE_DIR,$$(PREPARE_DEST_LIB_DIR)/rustlib/etc)
220         $$(call PREPARE_DIR,$$(PREPARE_DEST_MAN_DIR))
221
222 prepare-debugger-scripts-$(1): prepare-host-dirs-$(1) \
223                                $$(DEBUGGER_BIN_SCRIPTS_ALL_ABS) \
224                                $$(DEBUGGER_RUSTLIB_ETC_SCRIPTS_ALL_ABS)
225         $$(call INSTALL_DEBUGGER_SCRIPT_COMMANDS,$$(PREPARE_HOST))
226
227 $$(foreach tool,$$(PREPARE_TOOLS), \
228   $$(foreach host,$$(CFG_HOST), \
229       $$(eval $$(call DEF_PREPARE_HOST_TOOL,$$(tool),$$(PREPARE_STAGE),$$(host),$(1)))))
230
231 $$(foreach lib,$$(CRATES), \
232   $$(foreach host,$$(CFG_HOST), \
233     $$(eval $$(call DEF_PREPARE_HOST_LIB,$$(lib),$$(PREPARE_STAGE),$$(host),$(1)))))
234
235 prepare-target-$(1): \
236         $$(foreach host,$$(CFG_HOST), \
237            $$(foreach target,$$(CFG_TARGET), \
238              prepare-target-$$(target)-host-$$(host)-$$(PREPARE_STAGE)-$(1)))
239
240 $$(foreach host,$$(CFG_HOST), \
241   $$(foreach target,$$(CFG_TARGET), \
242     $$(eval $$(call DEF_PREPARE_TARGET_N,$$(PREPARE_STAGE),$$(target),$$(host),$(1)))))
243
244 prepare-maybe-clean-$(1):
245         $$(if $$(findstring true,$$(PREPARE_CLEAN)), \
246       @$$(call E, cleaning destination $$(PREPARE_DEST_DIR)),)
247         $$(if $$(findstring true,$$(PREPARE_CLEAN)), \
248       $$(Q)rm -rf $$(PREPARE_DEST_DIR),)
249
250
251 endef