]> git.proxmox.com Git - rustc.git/blob - mk/dist.mk
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / mk / dist.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 ######################################################################
12 # Distribution
13 ######################################################################
14
15 # Primary targets:
16 #
17 # * dist - make all distribution artifacts
18 # * distcheck - sanity check dist artifacts
19 # * dist-tar-src - source tarballs
20 # * dist-tar-bins - Ad-hoc Unix binary installers
21 # * dist-docs - Stage docs for upload
22
23 PKG_NAME := $(CFG_PACKAGE_NAME)
24 STD_PKG_NAME := rust-std-$(CFG_PACKAGE_VERS)
25 DOC_PKG_NAME := rust-docs-$(CFG_PACKAGE_VERS)
26 MINGW_PKG_NAME := rust-mingw-$(CFG_PACKAGE_VERS)
27
28 # License suitable for displaying in a popup
29 LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
30 cat $^ > $@
31
32
33 ######################################################################
34 # Source tarball
35 ######################################################################
36
37 PKG_TAR = dist/$(PKG_NAME)-src.tar.gz
38
39 PKG_GITMODULES := $(S)src/llvm $(S)src/compiler-rt \
40 $(S)src/rt/hoedown $(S)src/jemalloc
41 PKG_FILES := \
42 $(S)COPYRIGHT \
43 $(S)LICENSE-APACHE \
44 $(S)LICENSE-MIT \
45 $(S)CONTRIBUTING.md \
46 $(S)README.md \
47 $(S)RELEASES.md \
48 $(S)configure $(S)Makefile.in \
49 $(S)man \
50 $(addprefix $(S)src/, \
51 compiletest \
52 doc \
53 driver \
54 etc \
55 error-index-generator \
56 $(foreach crate,$(CRATES),lib$(crate)) \
57 libcollectionstest \
58 libcoretest \
59 libbacktrace \
60 rt \
61 rtstartup \
62 rustllvm \
63 snapshots.txt \
64 rust-installer \
65 rustbook \
66 test) \
67 $(PKG_GITMODULES) \
68 $(filter-out config.stamp, \
69 $(MKFILES_FOR_TARBALL))
70
71 UNROOTED_PKG_FILES := $(patsubst $(S)%,./%,$(PKG_FILES))
72
73 $(PKG_TAR): $(PKG_FILES)
74 @$(call E, making dist dir)
75 $(Q)rm -Rf tmp/dist/$(PKG_NAME)
76 $(Q)mkdir -p tmp/dist/$(PKG_NAME)
77 $(Q)tar \
78 -C $(S) \
79 --exclude-vcs \
80 --exclude=*~ \
81 --exclude=*.pyc \
82 --exclude=*/llvm/test/*/*.ll \
83 --exclude=*/llvm/test/*/*.td \
84 --exclude=*/llvm/test/*/*.s \
85 --exclude=*/llvm/test/*/*/*.ll \
86 --exclude=*/llvm/test/*/*/*.td \
87 --exclude=*/llvm/test/*/*/*.s \
88 -c $(UNROOTED_PKG_FILES) | tar -x -C tmp/dist/$(PKG_NAME)
89 @$(call E, making $@)
90 $(Q)tar -czf $(PKG_TAR) -C tmp/dist $(PKG_NAME)
91 $(Q)rm -Rf tmp/dist/$(PKG_NAME)
92
93 dist-tar-src: $(PKG_TAR)
94
95 distcheck-tar-src: dist-tar-src
96 $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)
97 $(Q)rm -Rf tmp/distcheck/srccheck
98 $(Q)mkdir -p tmp/distcheck
99 @$(call E, unpacking $(PKG_TAR) in tmp/distcheck/$(PKG_NAME))
100 $(Q)cd tmp/distcheck && tar -xzf ../../$(PKG_TAR)
101 @$(call E, configuring in tmp/distcheck/srccheck)
102 $(Q)mkdir -p tmp/distcheck/srccheck
103 $(Q)cd tmp/distcheck/srccheck && ../$(PKG_NAME)/configure
104 @$(call E, making 'check' in tmp/distcheck/srccheck)
105 $(Q)+make -C tmp/distcheck/srccheck check
106 @$(call E, making 'clean' in tmp/distcheck/srccheck)
107 $(Q)+make -C tmp/distcheck/srccheck clean
108 $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)
109 $(Q)rm -Rf tmp/distcheck/srccheck
110
111
112 ######################################################################
113 # Unix binary installer tarballs
114 ######################################################################
115
116 define DEF_START_INSTALLER
117 dist-install-dir-$(1)-%: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
118 dist-install-dir-$(1)-%: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
119 dist-install-dir-$(1)-%: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
120 dist-install-dir-$(1)-%: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
121 dist-install-dir-$(1)-%: PREPARE_CLEAN=true
122
123 $$(eval $$(call DEF_PREPARE,dir-$(1)))
124 endef
125
126 $(foreach target,$(CFG_TARGET),\
127 $(eval $(call DEF_START_INSTALLER,$(target))))
128
129 define DEF_INSTALLER
130
131 dist-install-dir-$(1)-host: PREPARE_HOST=$(1)
132 dist-install-dir-$(1)-host: PREPARE_TARGETS=$(2)
133 dist-install-dir-$(1)-host: PREPARE_DEST_DIR=tmp/dist/$$(PKG_NAME)-$(1)-image
134 dist-install-dir-$(1)-host: prepare-base-dir-$(1)-host docs
135 $$(Q)mkdir -p $$(PREPARE_DEST_DIR)/share/doc/rust
136 $$(Q)$$(PREPARE_MAN_CMD) $$(S)COPYRIGHT $$(PREPARE_DEST_DIR)/share/doc/rust
137 $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR)/share/doc/rust
138 $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR)/share/doc/rust
139 $$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR)/share/doc/rust
140
141 prepare-overlay-$(1):
142 $$(Q)rm -Rf tmp/dist/$$(PKG_NAME)-$(1)-overlay
143 $$(Q)mkdir -p tmp/dist/$$(PKG_NAME)-$(1)-overlay
144 $$(Q)cp $$(S)COPYRIGHT tmp/dist/$$(PKG_NAME)-$(1)-overlay/
145 $$(Q)cp $$(S)LICENSE-APACHE tmp/dist/$$(PKG_NAME)-$(1)-overlay/
146 $$(Q)cp $$(S)LICENSE-MIT tmp/dist/$$(PKG_NAME)-$(1)-overlay/
147 $$(Q)cp $$(S)README.md tmp/dist/$$(PKG_NAME)-$(1)-overlay/
148 # This tiny morsel of metadata is used by rust-packaging
149 $$(Q)echo "$(CFG_VERSION)" > tmp/dist/$$(PKG_NAME)-$(1)-overlay/version
150
151 dist/$$(PKG_NAME)-$(1).tar.gz: dist-install-dir-$(1)-host prepare-overlay-$(1)
152 @$(call E, build: $$@)
153 # On a MinGW target we've got a few runtime DLL dependencies that we need
154 # to include. THe first argument to `make-win-dist` is where to put these DLLs
155 # (the image we're creating) and the second argument is a junk directory to
156 # ignore all the other MinGW stuff the script creates.
157 ifeq ($$(findstring pc-windows-gnu,$(1)),pc-windows-gnu)
158 $$(Q)rm -Rf tmp/dist/win-rust-gcc-$(1)
159 $$(Q)$$(CFG_PYTHON) $$(S)src/etc/make-win-dist.py \
160 tmp/dist/$$(PKG_NAME)-$(1)-image \
161 tmp/dist/win-rust-gcc-$(1) $(1)
162 endif
163 # On 32-bit MinGW we're always including a DLL which needs some extra licenses
164 # to distribute. On 64-bit MinGW we don't actually distribute anything requiring
165 # us to distribute a license but it's likely that the install will *also*
166 # include the rust-mingw package down below, which also need licenses, so to be
167 # safe we just inlude it here in all MinGW packages.
168 ifdef CFG_WINDOWSY_$(1)
169 ifeq ($$(findstring $(1),gnu),gnu)
170 $$(Q)cp -r $$(S)src/etc/third-party \
171 tmp/dist/$$(PKG_NAME)-$(1)-image/share/doc/
172 endif
173 endif
174 $$(Q)$$(S)src/rust-installer/gen-installer.sh \
175 --product-name=Rust \
176 --rel-manifest-dir=rustlib \
177 --success-message=Rust-is-ready-to-roll. \
178 --image-dir=tmp/dist/$$(PKG_NAME)-$(1)-image \
179 --work-dir=tmp/dist \
180 --output-dir=dist \
181 --non-installed-overlay=tmp/dist/$$(PKG_NAME)-$(1)-overlay \
182 --package-name=$$(PKG_NAME)-$(1) \
183 --component-name=rustc \
184 --legacy-manifest-dirs=rustlib,cargo
185 $$(Q)rm -R tmp/dist/$$(PKG_NAME)-$(1)-image
186
187 dist-doc-install-dir-$(1): docs
188 $$(Q)mkdir -p tmp/dist/$$(DOC_PKG_NAME)-$(1)-image/share/doc/rust
189 $$(Q)cp -r doc tmp/dist/$$(DOC_PKG_NAME)-$(1)-image/share/doc/rust/html
190
191 dist/$$(DOC_PKG_NAME)-$(1).tar.gz: dist-doc-install-dir-$(1)
192 @$(call E, build: $$@)
193 $$(Q)$$(S)src/rust-installer/gen-installer.sh \
194 --product-name=Rust-Documentation \
195 --rel-manifest-dir=rustlib \
196 --success-message=Rust-documentation-is-installed. \
197 --image-dir=tmp/dist/$$(DOC_PKG_NAME)-$(1)-image \
198 --work-dir=tmp/dist \
199 --output-dir=dist \
200 --package-name=$$(DOC_PKG_NAME)-$(1) \
201 --component-name=rust-docs \
202 --legacy-manifest-dirs=rustlib,cargo \
203 --bulk-dirs=share/doc/rust/html
204 $$(Q)rm -R tmp/dist/$$(DOC_PKG_NAME)-$(1)-image
205
206 # Creates the rust-mingw package, and the first argument to make-win-dist is a
207 # "temporary directory" which is just thrown away (this contains the runtime
208 # DLLs included in the rustc package above) and the second argument is where to
209 # place all the MinGW components (which is what we want).
210 dist-mingw-install-dir-$(1):
211 $$(Q)mkdir -p tmp/dist/rust-mingw-tmp-$(1)-image
212 $$(Q)rm -Rf tmp/dist/$$(MINGW_PKG_NAME)-$(1)-image
213 $$(Q)$$(CFG_PYTHON) $$(S)src/etc/make-win-dist.py \
214 tmp/dist/rust-mingw-tmp-$(1)-image \
215 tmp/dist/$$(MINGW_PKG_NAME)-$(1)-image $(1)
216
217 dist/$$(MINGW_PKG_NAME)-$(1).tar.gz: dist-mingw-install-dir-$(1)
218 @$(call E, build: $$@)
219 $$(Q)$$(S)src/rust-installer/gen-installer.sh \
220 --product-name=Rust-MinGW \
221 --rel-manifest-dir=rustlib \
222 --success-message=Rust-MinGW-is-installed. \
223 --image-dir=tmp/dist/$$(MINGW_PKG_NAME)-$(1)-image \
224 --work-dir=tmp/dist \
225 --output-dir=dist \
226 --package-name=$$(MINGW_PKG_NAME)-$(1) \
227 --component-name=rust-mingw \
228 --legacy-manifest-dirs=rustlib,cargo
229 $$(Q)rm -R tmp/dist/$$(MINGW_PKG_NAME)-$(1)-image
230
231 endef
232
233 # $(1) - host
234 # $(2) - target
235 define DEF_INSTALLER_TARGETS
236
237 dist-install-dir-$(2)-target: PREPARE_HOST=$(1)
238 dist-install-dir-$(2)-target: PREPARE_TARGETS=$(2)
239 dist-install-dir-$(2)-target: PREPARE_DEST_DIR=tmp/dist/$$(STD_PKG_NAME)-$(2)-image
240 dist-install-dir-$(2)-target: prepare-base-dir-$(2)-target
241
242 dist/$$(STD_PKG_NAME)-$(2).tar.gz: dist-install-dir-$(2)-target
243 @$$(call E, build: $$@)
244 $$(Q)$$(S)src/rust-installer/gen-installer.sh \
245 --product-name=Rust \
246 --rel-manifest-dir=rustlib \
247 --success-message=std-is-standing-at-the-ready. \
248 --image-dir=tmp/dist/$$(STD_PKG_NAME)-$(2)-image \
249 --work-dir=tmp/dist \
250 --output-dir=dist \
251 --package-name=$$(STD_PKG_NAME)-$(2) \
252 --component-name=rust-std-$(2) \
253 --legacy-manifest-dirs=rustlib,cargo
254 $$(Q)rm -R tmp/dist/$$(STD_PKG_NAME)-$(2)-image
255 endef
256
257 $(foreach host,$(CFG_HOST),\
258 $(eval $(call DEF_INSTALLER,$(host))))
259
260 # When generating packages for the standard library, we've actually got a lot of
261 # artifacts to choose from. Each of the CFG_HOST compilers will have a copy of
262 # the standard library for each CFG_TARGET, but we only want to generate one
263 # standard library package. As a result, for each entry in CFG_TARGET we need to
264 # pick a CFG_HOST to get the standard library from.
265 #
266 # In theory it doesn't actually matter what host we choose as it should be the
267 # case that all hosts produce the same set of libraries for a target (regardless
268 # of the host itself). Currently there is a bug in the compiler, however, which
269 # means this is not the case (see #29228 and #29235). To solve the first of
270 # those bugs, we prefer to select a standard library from the host it was
271 # generated from, allowing plugins to work in more situations.
272 #
273 # For all CFG_TARGET entries in CFG_HOST, however, we just pick CFG_BUILD as the
274 # host we slurp up a standard library from.
275 $(foreach host,$(CFG_HOST),\
276 $(eval $(call DEF_INSTALLER_TARGETS,$(host),$(host))))
277 $(foreach target,$(filter-out $(CFG_HOST),$(CFG_TARGET)),\
278 $(eval $(call DEF_INSTALLER_TARGETS,$(CFG_BUILD),$(target))))
279
280 ifdef CFG_WINDOWSY_$(CFG_BUILD)
281 define BUILD_MINGW_TARBALL
282 ifeq ($$(findstring gnu,$(1)),gnu)
283 MAYBE_MINGW_TARBALLS += dist/$(MINGW_PKG_NAME)-$(1).tar.gz
284 endif
285 endef
286
287 $(foreach host,$(CFG_HOST),\
288 $(eval $(call BUILD_MINGW_TARBALL,$(host))))
289 endif
290
291 ifeq ($(CFG_DISABLE_DOCS),)
292 MAYBE_DOC_TARBALLS=$(foreach host,$(CFG_HOST),dist/$(DOC_PKG_NAME)-$(host).tar.gz)
293 endif
294
295 dist-tar-bins: \
296 $(foreach host,$(CFG_HOST),dist/$(PKG_NAME)-$(host).tar.gz) \
297 $(foreach target,$(CFG_TARGET),dist/$(STD_PKG_NAME)-$(target).tar.gz) \
298 $(MAYBE_DOC_TARBALLS) $(MAYBE_MINGW_TARBALLS)
299
300 # Just try to run the compiler for the build host
301 distcheck-tar-bins: dist-tar-bins
302 @$(call E, checking binary tarball)
303 $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)
304 $(Q)rm -Rf tmp/distcheck/tarbininstall
305 $(Q)mkdir -p tmp/distcheck
306 $(Q)cd tmp/distcheck && tar -xzf ../../dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz
307 $(Q)mkdir -p tmp/distcheck/tarbininstall
308 $(Q)sh tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix=tmp/distcheck/tarbininstall
309 $(Q)sh tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix=tmp/distcheck/tarbininstall --uninstall
310 $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)
311 $(Q)rm -Rf tmp/distcheck/tarbininstall
312
313 ######################################################################
314 # Docs
315 ######################################################################
316
317 # Just copy the docs to a folder under dist with the appropriate name
318 # for uploading to S3
319 dist-docs: docs
320 $(Q) rm -Rf dist/doc
321 $(Q) mkdir -p dist/doc/
322 $(Q) cp -r doc dist/doc/$(CFG_PACKAGE_VERS)
323
324 distcheck-docs: dist-docs
325
326 ######################################################################
327 # Primary targets (dist, distcheck)
328 ######################################################################
329
330 MAYBE_DIST_TAR_SRC=dist-tar-src
331 MAYBE_DISTCHECK_TAR_SRC=distcheck-tar-src
332
333 # FIXME #13224: On OS X don't produce tarballs simply because --exclude-vcs don't work.
334 # This is a huge hack because I just don't have time to figure out another solution.
335 ifeq ($(CFG_OSTYPE), apple-darwin)
336 MAYBE_DIST_TAR_SRC=
337 MAYBE_DISTCHECK_TAR_SRC=
338 endif
339
340 # Don't bother with source tarballs on windows just because we historically haven't.
341 ifeq ($(CFG_OSTYPE), pc-windows-gnu)
342 MAYBE_DIST_TAR_SRC=
343 MAYBE_DISTCHECK_TAR_SRC=
344 endif
345
346 ifneq ($(CFG_DISABLE_DOCS),)
347 MAYBE_DIST_DOCS=
348 MAYBE_DISTCHECK_DOCS=
349 else
350 MAYBE_DIST_DOCS=dist-docs
351 MAYBE_DISTCHECK_DOCS=distcheck-docs
352 endif
353
354 dist: $(MAYBE_DIST_TAR_SRC) dist-tar-bins $(MAYBE_DIST_DOCS)
355
356 distcheck: $(MAYBE_DISTCHECK_TAR_SRC) distcheck-tar-bins $(MAYBE_DISTCHECK_DOCS)
357 $(Q)rm -Rf tmp/distcheck
358 @echo
359 @echo -----------------------------------------------
360 @echo "Rust ready for distribution (see ./dist)"
361 @echo -----------------------------------------------
362
363 .PHONY: dist distcheck