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.
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.
11 ######################################################################
13 ######################################################################
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
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
)
28 # License suitable for displaying in a popup
29 LICENSE.txt
: $(S
)COPYRIGHT
$(S
)LICENSE-APACHE
$(S
)LICENSE-MIT
33 ######################################################################
35 ######################################################################
37 PKG_TAR
= dist/$(PKG_NAME
)-src.
tar.gz
39 PKG_GITMODULES
:= $(S
)src
/llvm
$(S
)src
/compiler-rt \
40 $(S
)src
/rt
/hoedown
$(S
)src
/jemalloc
48 $(S
)configure
$(S
)Makefile.in \
50 $(addprefix $(S
)src
/, \
57 $(foreach crate
,$(CRATES
),lib
$(crate
)) \
70 $(filter-out config.stamp
, \
71 $(MKFILES_FOR_TARBALL
))
73 UNROOTED_PKG_FILES
:= $(patsubst $(S
)%,.
/%,$(PKG_FILES
))
75 $(PKG_TAR
): $(PKG_FILES
)
76 @
$(call E
, making
dist dir)
77 $(Q
)rm -Rf tmp
/dist/$(PKG_NAME
)
78 $(Q
)mkdir
-p tmp
/dist/$(PKG_NAME
)
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 \
90 -c
$(UNROOTED_PKG_FILES
) |
tar -x
-C tmp
/dist/$(PKG_NAME
)
92 $(Q
)tar -czf
$(PKG_TAR
) -C tmp
/dist $(PKG_NAME
)
93 $(Q
)rm -Rf tmp
/dist/$(PKG_NAME
)
95 dist-tar-src
: $(PKG_TAR
)
97 distcheck-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
114 ######################################################################
115 # Unix binary installer tarballs
116 ######################################################################
118 define DEF_START_INSTALLER
119 dist-install-dir-
$(1)-%: PREPARE_DIR_CMD
=$(DEFAULT_PREPARE_DIR_CMD
)
120 dist-install-dir-
$(1)-%: PREPARE_BIN_CMD
=$(DEFAULT_PREPARE_BIN_CMD
)
121 dist-install-dir-
$(1)-%: PREPARE_LIB_CMD
=$(DEFAULT_PREPARE_LIB_CMD
)
122 dist-install-dir-
$(1)-%: PREPARE_MAN_CMD
=$(DEFAULT_PREPARE_MAN_CMD
)
123 dist-install-dir-
$(1)-%: PREPARE_CLEAN
=true
125 $$(eval
$$(call DEF_PREPARE
,dir-
$(1)))
128 $(foreach target
,$(CFG_TARGET
),\
129 $(eval
$(call DEF_START_INSTALLER
,$(target
))))
133 dist-install-dir-
$(1)-host
: PREPARE_HOST
=$(1)
134 dist-install-dir-
$(1)-host
: PREPARE_TARGETS
=$(2)
135 dist-install-dir-
$(1)-host
: PREPARE_DEST_DIR
=tmp
/dist/$$(PKG_NAME
)-$(1)-image
136 dist-install-dir-
$(1)-host
: prepare-base-dir-
$(1)-host docs
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
143 prepare-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
/
150 # This tiny morsel of metadata is used by rust-packaging
151 $$(Q
)echo
"$(CFG_VERSION)" > tmp
/dist/$$(PKG_NAME
)-$(1)-overlay
/version
153 dist/$$(PKG_NAME
)-$(1).
tar.gz
: dist-install-dir-
$(1)-host prepare-overlay-
$(1)
154 @
$(call E
, build
: $$@
)
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.
159 ifeq ($$(findstring pc-windows-gnu
,$(1)),pc-windows-gnu
)
160 $$(Q
)rm -Rf tmp
/dist/win-rust-gcc-
$(1)
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)
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.
170 ifdef CFG_WINDOWSY_
$(1)
171 ifeq ($$(findstring $(1),gnu
),gnu
)
172 $$(Q
)cp
-r
$$(S
)src
/etc
/third-party \
173 tmp
/dist/$$(PKG_NAME
)-$(1)-image
/share
/doc
/
176 $$(Q
)$$(S
)src
/rust-installer
/gen-installer.sh \
177 --product-name
=Rust \
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 \
183 --non-installed-overlay
=tmp
/dist/$$(PKG_NAME
)-$(1)-overlay \
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
189 dist-doc-install-dir-
$(1): docs
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
193 dist/$$(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 \
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
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).
212 dist-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 \
216 tmp
/dist/rust-mingw-tmp-
$(1)-image \
217 tmp
/dist/$$(MINGW_PKG_NAME
)-$(1)-image
$(1)
219 dist/$$(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 \
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
237 define DEF_INSTALLER_TARGETS
239 dist-install-dir-
$(2)-target
: PREPARE_HOST
=$(1)
240 dist-install-dir-
$(2)-target
: PREPARE_TARGETS
=$(2)
241 dist-install-dir-
$(2)-target
: PREPARE_DEST_DIR
=tmp
/dist/$$(STD_PKG_NAME
)-$(2)-image
242 dist-install-dir-
$(2)-target
: prepare-base-dir-
$(2)-target
244 dist/$$(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 \
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
259 $(foreach host
,$(CFG_HOST
),\
260 $(eval
$(call DEF_INSTALLER
,$(host
))))
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.
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.
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
))))
282 ifdef CFG_WINDOWSY_
$(CFG_BUILD
)
283 define BUILD_MINGW_TARBALL
284 ifeq ($$(findstring gnu
,$(1)),gnu
)
285 MAYBE_MINGW_TARBALLS
+= dist/$(MINGW_PKG_NAME
)-$(1).
tar.gz
289 $(foreach host
,$(CFG_HOST
),\
290 $(eval
$(call BUILD_MINGW_TARBALL
,$(host
))))
293 ifeq ($(CFG_DISABLE_DOCS
),)
294 MAYBE_DOC_TARBALLS
=$(foreach host
,$(CFG_HOST
),dist/$(DOC_PKG_NAME
)-$(host
).
tar.gz
)
298 $(foreach host
,$(CFG_HOST
),dist/$(PKG_NAME
)-$(host
).
tar.gz
) \
299 $(foreach target
,$(CFG_TARGET
),dist/$(STD_PKG_NAME
)-$(target
).
tar.gz
) \
300 $(MAYBE_DOC_TARBALLS
) $(MAYBE_MINGW_TARBALLS
)
302 # Just try to run the compiler for the build host
303 distcheck-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
315 ######################################################################
317 ######################################################################
319 # Just copy the docs to a folder under dist with the appropriate name
320 # for uploading to S3
323 $(Q
) mkdir
-p
dist/doc
/
324 $(Q
) cp
-r doc
dist/doc
/$(CFG_PACKAGE_VERS
)
326 distcheck-docs
: dist-docs
328 ######################################################################
329 # Primary targets (dist, distcheck)
330 ######################################################################
332 MAYBE_DIST_TAR_SRC
=dist-tar-src
333 MAYBE_DISTCHECK_TAR_SRC
=distcheck-tar-src
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.
337 ifeq ($(CFG_OSTYPE
), apple-darwin
)
339 MAYBE_DISTCHECK_TAR_SRC
=
342 # Don't bother with source tarballs on windows just because we historically haven't.
343 ifeq ($(CFG_OSTYPE
), pc-windows-gnu
)
345 MAYBE_DISTCHECK_TAR_SRC
=
348 ifneq ($(CFG_DISABLE_DOCS
),)
350 MAYBE_DISTCHECK_DOCS
=
352 MAYBE_DIST_DOCS
=dist-docs
353 MAYBE_DISTCHECK_DOCS
=distcheck-docs
356 dist: $(MAYBE_DIST_TAR_SRC
) dist-tar-bins
$(MAYBE_DIST_DOCS
)
358 distcheck
: $(MAYBE_DISTCHECK_TAR_SRC
) distcheck-tar-bins
$(MAYBE_DISTCHECK_DOCS
)
359 $(Q
)rm -Rf tmp
/distcheck
361 @echo
-----------------------------------------------
362 @echo
"Rust ready for distribution (see ./dist)"
363 @echo
-----------------------------------------------
365 .PHONY
: dist distcheck