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