]> git.lizzy.rs Git - rust.git/blob - mk/dist.mk
dist: Tweak the OSX pkg installer
[rust.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-win - Windows exe installers
21 # * dist-osx - OS X .pkg installers
22 # * dist-tar-bins - Ad-hoc Unix binary installers
23 # * dist-docs - Stage docs for upload
24
25 PKG_NAME := $(CFG_PACKAGE_NAME)
26
27 # License suitable for displaying in a popup
28 LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
29         cat $^ > $@
30
31
32 ######################################################################
33 # Source tarball
34 ######################################################################
35
36 PKG_TAR = dist/$(PKG_NAME).tar.gz
37
38 PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt
39 PKG_FILES := \
40     $(S)COPYRIGHT                              \
41     $(S)LICENSE-APACHE                         \
42     $(S)LICENSE-MIT                            \
43     $(S)AUTHORS.txt                            \
44     $(S)CONTRIBUTING.md                        \
45     $(S)README.md                              \
46     $(S)RELEASES.txt                           \
47     $(S)configure $(S)Makefile.in              \
48     $(S)man                                    \
49     $(addprefix $(S)src/,                      \
50       README.md                                \
51       compiletest                              \
52       doc                                      \
53       driver                                   \
54       etc                                      \
55       $(foreach crate,$(CRATES),lib$(crate))   \
56       rt                                       \
57       rustllvm                                 \
58       snapshots.txt                            \
59       test)                                    \
60     $(PKG_GITMODULES)                          \
61     $(filter-out config.stamp, \
62                  $(MKFILES_FOR_TARBALL))
63
64 UNROOTED_PKG_FILES := $(patsubst $(S)%,./%,$(PKG_FILES))
65
66 $(PKG_TAR): $(PKG_FILES)
67         @$(call E, making dist dir)
68         $(Q)rm -Rf tmp/dist/$(PKG_NAME)
69         $(Q)mkdir -p tmp/dist/$(PKG_NAME)
70         $(Q)tar \
71          -C $(S) \
72          --exclude-vcs \
73          --exclude=*~ \
74          --exclude=*/llvm/test/*/*.ll \
75          --exclude=*/llvm/test/*/*.td \
76          --exclude=*/llvm/test/*/*.s \
77          --exclude=*/llvm/test/*/*/*.ll \
78          --exclude=*/llvm/test/*/*/*.td \
79          --exclude=*/llvm/test/*/*/*.s \
80          -c $(UNROOTED_PKG_FILES) | tar -x -C tmp/dist/$(PKG_NAME)
81         $(Q)tar -czf $(PKG_TAR) -C tmp/dist $(PKG_NAME)
82         $(Q)rm -Rf tmp/dist/$(PKG_NAME)
83
84 dist-tar-src: $(PKG_TAR)
85
86 distcheck-tar-src: dist-tar-src
87         $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)
88         $(Q)rm -Rf tmp/distcheck/srccheck
89         $(Q)mkdir -p tmp/distcheck
90         @$(call E, unpacking $(PKG_TAR) in tmp/distcheck/$(PKG_NAME))
91         $(Q)cd tmp/distcheck && tar -xzf ../../$(PKG_TAR)
92         @$(call E, configuring in tmp/distcheck/srccheck)
93         $(Q)mkdir -p tmp/distcheck/srccheck
94         $(Q)cd tmp/distcheck/srccheck && ../$(PKG_NAME)/configure
95         @$(call E, making 'check' in tmp/distcheck/srccheck)
96         $(Q)+make -C tmp/distcheck/srccheck check
97         @$(call E, making 'clean' in tmp/distcheck/srccheck)
98         $(Q)+make -C tmp/distcheck/srccheck clean
99         $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)
100         $(Q)rm -Rf tmp/distcheck/srccheck
101
102
103 ######################################################################
104 # Windows .exe installer
105 ######################################################################
106
107 # FIXME Needs to support all hosts, but making rust.iss compatible looks like a chore
108
109 ifdef CFG_ISCC
110
111 PKG_EXE = dist/$(PKG_NAME)-install.exe
112
113 %.iss: $(S)src/etc/pkg/%.iss
114         cp $< $@
115
116 %.ico: $(S)src/etc/pkg/%.ico
117         cp $< $@
118
119 $(PKG_EXE): rust.iss modpath.iss LICENSE.txt rust-logo.ico \
120             $(CSREQ3_T_$(CFG_BUILD)_H_$(CFG_BUILD)) \
121             dist-prepare-win
122         $(CFG_PYTHON) $(S)src/etc/copy-runtime-deps.py tmp/dist/win/bin
123         @$(call E, ISCC: $@)
124         $(Q)"$(CFG_ISCC)" $<
125
126 $(eval $(call DEF_PREPARE,win))
127
128 dist-prepare-win: PREPARE_HOST=$(CFG_BUILD)
129 dist-prepare-win: PREPARE_TARGETS=$(CFG_BUILD)
130 dist-prepare-win: PREPARE_DEST_DIR=tmp/dist/win
131 dist-prepare-win: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
132 dist-prepare-win: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
133 dist-prepare-win: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
134 dist-prepare-win: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
135 dist-prepare-win: PREPARE_CLEAN=true
136 dist-prepare-win: prepare-base-win
137
138 endif
139
140 dist-win: $(PKG_EXE)
141
142 distcheck-win: dist-win
143
144 ######################################################################
145 # OS X .pkg installer
146 ######################################################################
147
148 ifeq ($(CFG_OSTYPE), apple-darwin)
149
150 define DEF_OSX_PKG
151
152 $$(eval $$(call DEF_PREPARE,osx-$(1)))
153
154 dist-prepare-osx-$(1): PREPARE_HOST=$(1)
155 dist-prepare-osx-$(1): PREPARE_TARGETS=$(1)
156 dist-prepare-osx-$(1): PREPARE_DEST_DIR=tmp/dist/pkgroot-$(1)
157 dist-prepare-osx-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
158 dist-prepare-osx-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
159 dist-prepare-osx-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
160 dist-prepare-osx-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
161 dist-prepare-osx-$(1): prepare-base-osx-$(1)
162
163 dist/$(PKG_NAME)-$(1).pkg: $(S)src/etc/pkg/Distribution.xml LICENSE.txt \
164                 dist-prepare-osx-$(1) \
165                 tmp/dist/pkgres-$(1)/LICENSE.txt \
166                 tmp/dist/pkgres-$(1)/welcome.rtf \
167                 tmp/dist/pkgres-$(1)/rust-logo.png
168         @$$(call E, making OS X pkg)
169         $(Q)pkgbuild --identifier org.rust-lang.rust --root tmp/dist/pkgroot-$(1) rust.pkg
170         $(Q)productbuild --distribution $(S)src/etc/pkg/Distribution.xml \
171               --resources tmp/dist/pkgres-$(1) dist/$(PKG_NAME)-$(1).pkg
172         $(Q)rm -rf tmp rust.pkg
173
174 tmp/dist/pkgres-$(1)/LICENSE.txt: $(S)/LICENSE.txt
175         @$$(call E,pkg resource LICENSE.txt)
176         $(Q)mkdir -p $$(@D)
177         $(Q)cp $$< $$@
178
179 tmp/dist/pkgres-$(1)/%: $(S)src/etc/pkg/%
180         @$$(call E,pkg resource $$*)
181         $(Q)mkdir -p $$(@D)
182         $(Q)cp -r $$< $$@
183
184 endef
185
186 $(foreach host,$(CFG_HOST),$(eval $(call DEF_OSX_PKG,$(host))))
187
188 dist-osx: $(foreach host,$(CFG_HOST),dist/$(PKG_NAME)-$(host).pkg)
189
190 else
191
192 dist-osx:
193
194 endif
195
196 # FIXME should do something
197 distcheck-osx: dist-osx
198
199
200 ######################################################################
201 # Unix binary installer tarballs
202 ######################################################################
203
204 define DEF_INSTALLER
205
206 $$(eval $$(call DEF_PREPARE,dir-$(1)))
207
208 dist-install-dir-$(1): PREPARE_HOST=$(1)
209 dist-install-dir-$(1): PREPARE_TARGETS=$(1)
210 dist-install-dir-$(1): PREPARE_DEST_DIR=tmp/dist/$$(PKG_NAME)-$(1)
211 dist-install-dir-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
212 dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
213 dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
214 dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
215 dist-install-dir-$(1): PREPARE_CLEAN=true
216 dist-install-dir-$(1): prepare-base-dir-$(1)
217         $$(Q)(cd $$(PREPARE_DEST_DIR)/ && find . -type f | sed 's/^\.\///') \
218       > tmp/dist/manifest-$(1).in
219         $$(Q)mv tmp/dist/manifest-$(1).in $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest.in
220 # Add remaining non-installed files
221         $$(Q)$$(PREPARE_MAN_CMD) $$(S)COPYRIGHT $$(PREPARE_DEST_DIR)
222         $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR)
223         $$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR)
224         $$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR)
225         $$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR)
226
227 dist/$$(PKG_NAME)-$(1).tar.gz: dist-install-dir-$(1)
228         @$(call E, build: $$@)
229         $$(Q)tar -czf dist/$$(PKG_NAME)-$(1).tar.gz -C tmp/dist $$(PKG_NAME)-$(1)
230
231 endef
232
233 $(foreach host,$(CFG_HOST),\
234   $(eval $(call DEF_INSTALLER,$(host))))
235
236 dist-install-dirs: $(foreach host,$(CFG_HOST),dist-install-dir-$(host))
237
238 dist-tar-bins: $(foreach host,$(CFG_HOST),dist/$(PKG_NAME)-$(host).tar.gz)
239
240 # Just try to run the compiler for the build host
241 distcheck-tar-bins: dist-tar-bins
242         @$(call E, checking binary tarball)
243         $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)
244         $(Q)rm -Rf tmp/distcheck/tarbininstall
245         $(Q)mkdir -p tmp/distcheck
246         $(Q)cd tmp/distcheck && tar -xzf ../../dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz
247         $(Q)mkdir -p tmp/distcheck/tarbininstall
248         $(Q)sh tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix=tmp/distcheck/tarbininstall
249         $(Q)tmp/distcheck/tarbininstall/bin/rustc --version
250         $(Q)rm -Rf tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)
251         $(Q)rm -Rf tmp/distcheck/tarbininstall
252
253 ######################################################################
254 # Docs
255 ######################################################################
256
257 # Just copy the docs to a folder under dist with the appropriate name
258 # for uploading to S3
259 dist-docs: docs compiler-docs
260         $(Q) rm -Rf dist/doc
261         $(Q) mkdir -p dist/doc/
262         $(Q) cp -r doc dist/doc/$(CFG_PACKAGE_VERS)
263
264 distcheck-docs: dist-docs
265
266 ######################################################################
267 # Primary targets (dist, distcheck)
268 ######################################################################
269
270 ifdef CFG_WINDOWSY_$(CFG_BUILD)
271
272 dist: dist-win
273
274 distcheck: distcheck-win
275         $(Q)rm -Rf tmp/distcheck
276         @echo
277         @echo -----------------------------------------------
278         @echo "Rust ready for distribution (see ./dist)"
279         @echo -----------------------------------------------
280
281 else
282
283 dist: dist-tar-src dist-osx dist-tar-bins dist-docs
284
285 distcheck: distcheck-tar-src distcheck-osx distcheck-tar-bins distcheck-docs
286         $(Q)rm -Rf tmp/distcheck
287         @echo
288         @echo -----------------------------------------------
289         @echo "Rust ready for distribution (see ./dist)"
290         @echo -----------------------------------------------
291
292 endif
293
294 .PHONY: dist distcheck