forked from rust-lang/cargo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
412 lines (346 loc) · 13.9 KB
/
Makefile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
CFG_RELEASE_NUM=0.18.0
CFG_RELEASE_LABEL=
OPENSSL_VERS=1.0.2k
OPENSSL_SHA256=6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
include config.mk
export PATH := $(dir $(CFG_RUSTC)):$(PATH)
ifeq ($(CFG_RELEASE_CHANNEL),stable)
CFG_RELEASE=$(CFG_RELEASE_NUM)
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)
else ifeq ($(CFG_RELEASE_CHANNEL),beta)
CFG_RELEASE=$(CFG_RELEASE_NUM)-beta
CFG_PACKAGE_VERS=beta
else ifeq ($(CFG_RELEASE_CHANNEL),nightly)
CFG_RELEASE=$(CFG_RELEASE_NUM)-nightly
CFG_PACKAGE_VERS=nightly
else ifeq ($(CFG_RELEASE_CHANNEL),dev)
CFG_RELEASE=$(CFG_RELEASE_NUM)-dev
CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev
endif
# allow build systems to use a constant date instead of the current one
CFG_BUILD_DATE = $(shell SOURCE_DATE_EPOCH="$${SOURCE_DATE_EPOCH:-$$(date +%s)}" ; date -u -d "@$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || date -u -r "$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || date -u +%F)
ifneq ($(wildcard $(CFG_SRC_DIR)/.git),)
CFG_COMMIT_DATE = $(shell git --git-dir='$(CFG_SRC_DIR).git' log -1 --date=short --pretty=format:'%cd')
CFG_SHORT_COMMIT_HASH = $(shell git --git-dir='$(CFG_SRC_DIR).git' rev-parse --short HEAD)
CFG_COMMIT_HASH = $(shell git --git-dir='$(CFG_SRC_DIR).git' rev-parse HEAD)
endif
PKG_NAME = cargo-$(CFG_PACKAGE_VERS)
ifdef CFG_DISABLE_VERIFY_INSTALL
MAYBE_DISABLE_VERIFY=--disable-verify
else
MAYBE_DISABLE_VERIFY=
endif
ifdef CFG_DISABLE_OPTIMIZE
OPT_FLAG=
else
OPT_FLAG=--release
endif
ifdef VERBOSE
VERBOSE_FLAG=--verbose
else
VERBOSE_FLAG=
endif
ifdef CFG_CUSTOM_BUILD_DIR
export CARGO_TARGET_DIR := $(CFG_CUSTOM_BUILD_DIR)
endif
S := $(CFG_SRC_DIR)/
CFG_RELEASE_PARTS := $(subst ., ,$(CFG_RELEASE_NUM))
CFG_VERSION_MAJOR := $(word 1,$(CFG_RELEASE_PARTS))
CFG_VERSION_MINOR := $(word 2,$(CFG_RELEASE_PARTS))
CFG_VERSION_PATCH := $(word 3,$(CFG_RELEASE_PARTS))
# This is output to the 'version' file during packaging
CFG_VERSION=$(CFG_RELEASE)
ifneq ($(CFG_COMMIT_HASH),)
CFG_VERSION=$(CFG_RELEASE) ($(CFG_SHORT_COMMIT_HASH) $(CFG_COMMIT_DATE))
endif
export CFG_VERSION_MAJOR
export CFG_VERSION_MINOR
export CFG_VERSION_PATCH
ifneq ($(CFG_COMMIT_HASH),)
export CFG_COMMIT_HASH
export CFG_COMMIT_DATE
export CFG_SHORT_COMMIT_HASH
endif
export CFG_BUILD_DATE
export CFG_RELEASE_CHANNEL
export CFG_DISABLE_CROSS_TESTS
ifeq ($(OS),Windows_NT)
X = .exe
endif
TARGET_ROOT = target
BIN_TARGETS := cargo
BIN_TARGETS := $(BIN_TARGETS:src/bin/%.rs=%)
BIN_TARGETS := $(filter-out cargo,$(BIN_TARGETS))
define DIST_TARGET
ifdef CFG_DISABLE_OPTIMIZE
TARGET_$(1) = $$(TARGET_ROOT)/$(1)/debug
else
TARGET_$(1) = $$(TARGET_ROOT)/$(1)/release
endif
DISTDIR_$(1) = $$(TARGET_$(1))/dist
IMGDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)-image
OVERLAYDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)-overlay
PKGDIR_$(1) = $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1)
BIN_TARGETS_$(1) := $$(BIN_TARGETS:%=$$(TARGET_$(1))/%$$(X))
endef
$(foreach target,$(CFG_TARGET),$(eval $(call DIST_TARGET,$(target))))
ifdef CFG_LOCAL_CARGO
CARGO := $(CFG_LOCAL_CARGO)
else
CARGO := $(CFG_CARGO)
endif
all: $(foreach target,$(CFG_TARGET),cargo-$(target))
define CARGO_TARGET
cargo-$(1): target/openssl/$(1).stamp
$$(CFG_RUSTC) -V
$$(CARGO) --version
$$(CARGO) build --target $(1) \
--manifest-path $(S)Cargo.toml \
$$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(ARGS)
test-unit-$(1): target/openssl/$(1).stamp cargo-$(1)
@mkdir -p $$(CFG_BUILD_DIR)/target/$(1)/cit
$$(CARGO) test --target $(1) \
--manifest-path $(S)Cargo.toml \
$$(OPT_FLAG) $$(CARGOFLAGS) $$(VERBOSE_FLAG) $$(only) -- \
--quiet
endef
$(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target))))
# === Tests
test: style no-exes $(foreach target,$(CFG_TARGET),test-unit-$(target))
style:
(cd $(S) && sh tests/check-style.sh)
ifeq ($(CFG_GIT),)
no-exes:
else
no-exes:
(cd $(S) && find $$($(CFG_GIT) ls-files) -type f \
\( -perm -u+x -or -perm -g+x -or -perm -o+x \) \
-not -name configure -not -name '*.sh' -not -name '*.rs' \
-not -name '*.py' -not -wholename "*/rust-installer/*" | \
grep '.*' \
&& exit 1 || exit 0)
endif
# === Misc
Makefile config.mk: config.stamp
config.stamp: $(CFG_SRC_DIR)configure $(CFG_SRC_DIR)Makefile.in
$(CFG_SRC_DIR)configure $(CFG_CONFIGURE_ARGS)
clean-all: clean
clean:
rm -rf $(TARGET_ROOT)
# === Documentation
DOCS := index faq config guide manifest build-script pkgid-spec crates-io \
environment-variables specifying-dependencies source-replacement \
policies machine-readable-output
DOC_DIR := target/doc
DOC_OPTS := --markdown-no-toc \
--markdown-css stylesheets/normalize.css \
--markdown-css stylesheets/all.css \
--markdown-css stylesheets/prism.css \
--html-in-header $(S)src/doc/html-headers.html \
--html-before-content $(S)src/doc/header.html \
--html-after-content $(S)src/doc/footer.html
ASSETS := CNAME images/noise.png images/forkme.png images/Cargo-Logo-Small.png \
stylesheets/all.css stylesheets/normalize.css javascripts/prism.js \
javascripts/all.js stylesheets/prism.css images/circle-with-i.png \
images/search.png images/org-level-acl.png images/auth-level-acl.png \
favicon.ico
doc: $(foreach doc,$(DOCS),target/doc/$(doc).html) \
$(foreach asset,$(ASSETS),target/doc/$(asset)) \
target/doc/cargo/index.html
target/doc/cargo/index.html: target/openssl/$(CFG_BUILD).stamp cargo-$(CFG_BUILD)
$(CARGO) doc --no-deps --target $(CFG_BUILD) \
--manifest-path $(S)Cargo.toml $(OPT_FLAG)
$(DOC_DIR)/%.html: \
$(S)src/doc/%.md \
$(S)src/doc/html-headers.html \
$(S)src/doc/header.html \
$(S)src/doc/footer.html
@mkdir -p $(@D)
$(CFG_RUSTDOC) $< -o $(@D) $(DOC_OPTS)
$(DOC_DIR)/%: $(S)src/doc/%
@mkdir -p $(@D)
cp $< $@
OPENSSL_OS_aarch64-unknown-linux-gnu := linux-aarch64
OPENSSL_OS_arm-unknown-linux-gnueabi := linux-armv4
OPENSSL_OS_arm-unknown-linux-gnueabihf := linux-armv4
OPENSSL_OS_armv7-unknown-linux-gnueabihf := linux-armv4
OPENSSL_OS_i686-apple-darwin := darwin-i386-cc
OPENSSL_OS_i686-unknown-freebsd := BSD-x86-elf
OPENSSL_OS_i686-unknown-linux-gnu := linux-elf
OPENSSL_OS_i686-unknown-linux-musl := linux-elf
OPENSSL_OS_mips-unknown-linux-gnu := linux-mips32
OPENSSL_OS_mips64-unknown-linux-gnuabi64 := linux64-mips64
OPENSSL_OS_mips64el-unknown-linux-gnuabi64 := linux64-mips64
OPENSSL_OS_mipsel-unknown-linux-gnu := linux-mips32
OPENSSL_OS_powerpc-unknown-linux-gnu := linux-ppc
OPENSSL_OS_powerpc64-unknown-linux-gnu := linux-ppc64
OPENSSL_OS_powerpc64le-unknown-linux-gnu := linux-ppc64le
OPENSSL_OS_s390x-unknown-linux-gnu := linux64-s390x
OPENSSL_OS_x86_64-apple-darwin := darwin64-x86_64-cc
OPENSSL_OS_x86_64-unknown-freebsd := BSD-x86_64
OPENSSL_OS_x86_64-unknown-linux-gnu := linux-x86_64
OPENSSL_OS_x86_64-unknown-linux-musl := linux-x86_64
OPENSSL_OS_x86_64-unknown-netbsd := BSD-x86_64
OPENSSL_AR_aarch64-unknown-linux-gnu := aarch64-linux-gnu-ar
OPENSSL_AR_arm-unknown-linux-gnueabi := arm-linux-gnueabi-ar
OPENSSL_AR_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-ar
OPENSSL_AR_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-ar
OPENSSL_AR_i686-apple-darwin := ar
OPENSSL_AR_i686-unknown-freebsd := i686-unknown-freebsd10-ar
OPENSSL_AR_i686-unknown-linux-gnu := ar
OPENSSL_AR_i686-unknown-linux-musl := ar
OPENSSL_AR_mips-unknown-linux-gnu := mips-linux-gnu-ar
OPENSSL_AR_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-ar
OPENSSL_AR_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-ar
OPENSSL_AR_mipsel-unknown-linux-gnu := mipsel-linux-gnu-ar
OPENSSL_AR_powerpc-unknown-linux-gnu := powerpc-linux-gnu-ar
OPENSSL_AR_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-ar
OPENSSL_AR_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-ar
OPENSSL_AR_s390x-unknown-linux-gnu := s390x-linux-gnu-ar
OPENSSL_AR_x86_64-apple-darwin := ar
OPENSSL_AR_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-ar
OPENSSL_AR_x86_64-unknown-linux-gnu := ar
OPENSSL_AR_x86_64-unknown-linux-musl := ar
OPENSSL_AR_x86_64-unknown-netbsd := x86_64-unknown-netbsd-ar
OPENSSL_CC_aarch64-unknown-linux-gnu := aarch64-linux-gnu-gcc
OPENSSL_CC_arm-unknown-linux-gnueabi := arm-linux-gnueabi-gcc
OPENSSL_CC_arm-unknown-linux-gnueabihf := arm-linux-gnueabihf-gcc
OPENSSL_CC_armv7-unknown-linux-gnueabihf := armv7-linux-gnueabihf-gcc
OPENSSL_CC_i686-apple-darwin := clang
OPENSSL_CC_i686-unknown-freebsd := i686-unknown-freebsd10-gcc
OPENSSL_CC_i686-unknown-linux-gnu := gcc
OPENSSL_CC_i686-unknown-linux-musl := musl-gcc
OPENSSL_CC_mips-unknown-linux-gnu := mips-linux-gnu-gcc
OPENSSL_CC_mips64-unknown-linux-gnuabi64 := mips64-linux-gnuabi64-gcc
OPENSSL_CC_mips64el-unknown-linux-gnuabi64 := mips64el-linux-gnuabi64-gcc
OPENSSL_CC_mipsel-unknown-linux-gnu := mipsel-linux-gnu-gcc
OPENSSL_CC_powerpc-unknown-linux-gnu := powerpc-linux-gnu-gcc
OPENSSL_CC_powerpc64-unknown-linux-gnu := powerpc64-linux-gnu-gcc
OPENSSL_CC_powerpc64le-unknown-linux-gnu := powerpc64le-linux-gnu-gcc
OPENSSL_CC_s390x-unknown-linux-gnu := s390x-linux-gnu-gcc
OPENSSL_CC_x86_64-apple-darwin := clang
OPENSSL_CC_x86_64-unknown-freebsd := x86_64-unknown-freebsd10-gcc
OPENSSL_CC_x86_64-unknown-linux-gnu := gcc
OPENSSL_CC_x86_64-unknown-linux-musl := musl-gcc
OPENSSL_CC_x86_64-unknown-netbsd := x86_64-unknown-netbsd-gcc
SETARCH_i686-unknown-linux-gnu := setarch i386
OPENSSL_CFLAGS_i686-apple-darwin := -m32
OPENSSL_CFLAGS_i686-unknown-linux-gnu := -m32
OPENSSL_CFLAGS_i686-unknown-linux-musl := -m32
define BUILD_OPENSSL
ifdef CFG_ENABLE_BUILD_OPENSSL
cargo-$(1): export OPENSSL_STATIC := 1
test-unit-$(1): export OPENSSL_STATIC := 1
OPENSSL_INSTALL_$(1) := $$(CFG_BUILD_DIR)/target/openssl/$(1)-install
ifdef OPENSSL_OS_$(1)
target/openssl/$(1).stamp: target/openssl/openssl-$$(OPENSSL_VERS).tar.gz \
| target/openssl/
rm -rf target/openssl/$(1)
mkdir -p target/openssl/$(1)
tar xf $$< -C target/openssl/$(1) --strip-components 1
(cd target/openssl/$(1) && \
CC=$$(OPENSSL_CC_$(1)) \
AR=$$(OPENSSL_AR_$(1)) \
$$(SETARCH_$(1)) ./Configure --prefix=$$(OPENSSL_INSTALL_$(1)) \
no-dso $$(OPENSSL_OS_$(1)) -fPIC $$(OPENSSL_CFLAGS_$(1))&& \
$(MAKE) -j1 && \
$(MAKE) install)
touch $$@
# variables read by various build scripts to find openssl
cargo-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1))
test-unit-$(1): export OPENSSL_DIR := $$(OPENSSL_INSTALL_$(1))
# build libz statically into the cargo we're producing
cargo-$(1): export LIBZ_SYS_STATIC := 1
else # !OPENSSL_OS_$(1)
target/openssl/$(1).stamp:
endif
else # !CFG_ENABLE_BUILD_OPENSSL
target/openssl/$(1).stamp:
endif
endef
$(foreach target,$(CFG_TARGET),$(eval $(call BUILD_OPENSSL,$(target))))
ifeq ($(shell uname),Darwin)
SHASUM := shasum -a 256
else
SHASUM := sha256sum
endif
target/openssl/openssl-$(OPENSSL_VERS).tar.gz: | target/openssl/
curl -o $(@).tmp https://www.openssl.org/source/openssl-$(OPENSSL_VERS).tar.gz
$(SHASUM) $(@).tmp > $(@).sha256
test $(OPENSSL_SHA256) = `cut -d ' ' -f 1 $(@).sha256`
mv $(@).tmp $(@)
target/openssl/:
mkdir -p $(@)
# === Distribution
define DO_DIST_TARGET
dist-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
# One may wonder why some of the commands here are prefixed with `cd -P .`, and
# that's a good question! On some of the windows bots, PWD has a windows-style
# path, and that ends up choking the installation script in various ways.
# Prefixing commands with this `cd -P .` helps the bots to set the right PWD env
# var.
distcheck-$(1): dist-$(1)
rm -rf $$(TARGET_$(1))/distcheck
mkdir -p $$(TARGET_$(1))/distcheck
(cd $$(TARGET_$(1))/distcheck && tar xf ../dist/$$(PKG_NAME)-$(1).tar.gz)
cd -P . && $$(TARGET_$(1))/distcheck/$$(PKG_NAME)-$(1)/install.sh \
--prefix=$$(TARGET_$(1))/distcheck/install
$$(TARGET_$(1))/distcheck/install/bin/cargo -V > /dev/null
cd -P . && $$(TARGET_$(1))/distcheck/$$(PKG_NAME)-$(1)/install.sh \
--prefix=$$(TARGET_$(1))/distcheck/install --uninstall
[ -f $$(TARGET_$(1))/distcheck/install/bin/cargo$(X) ] && exit 1 || exit 0
prepare-image-$(1):
@[ -f $$(TARGET_$(1))/cargo$$(X) ] || echo 'Please run `make` first'
@[ -f $$(TARGET_$(1))/cargo$$(X) ]
rm -rf $$(IMGDIR_$(1))
mkdir -p $$(IMGDIR_$(1))/bin $$(IMGDIR_$(1))/$(CFG_LIBDIR)/cargo \
$$(IMGDIR_$(1))$(CFG_MANDIR)/man1 \
$$(IMGDIR_$(1))$(CFG_DOCDIR) \
$$(IMGDIR_$(1))$(CFG_DATADIR)/zsh/site-functions \
$$(IMGDIR_$(1))$(CFG_SYSCONFDIR)/bash_completion.d
cp $$(TARGET_$(1))/cargo$$(X) $$(IMGDIR_$(1))/bin
cp $(S)src/etc/man/*.1 $$(IMGDIR_$(1))$(CFG_MANDIR)/man1
cp $(S)src/etc/_cargo $$(IMGDIR_$(1))$(CFG_DATADIR)/zsh/site-functions/_cargo
cp $(S)src/etc/cargo.bashcomp.sh $$(IMGDIR_$(1))$(CFG_SYSCONFDIR)/bash_completion.d/cargo
cp $(S)README.md $(S)LICENSE-MIT $(S)LICENSE-APACHE \
$(S)LICENSE-THIRD-PARTY \
$$(IMGDIR_$(1))$(CFG_DOCDIR)
prepare-overlay-$(1):
rm -Rf $$(OVERLAYDIR_$(1))
mkdir -p $$(OVERLAYDIR_$(1))
cp $(S)README.md $(S)LICENSE-MIT $(S)LICENSE-APACHE \
$(S)LICENSE-THIRD-PARTY \
$$(OVERLAYDIR_$(1))
echo "$(CFG_VERSION)" > $$(OVERLAYDIR_$(1))/version
$$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz: prepare-image-$(1) prepare-overlay-$(1)
sh $(S)src/rust-installer/gen-installer.sh \
--product-name=Rust \
--rel-manifest-dir=rustlib \
--success-message=Rust-is-ready-to-roll. \
--image-dir=$$(IMGDIR_$(1)) \
--work-dir=./$$(DISTDIR_$(1)) \
--output-dir=./$$(DISTDIR_$(1)) \
--non-installed-overlay=$$(OVERLAYDIR_$(1)) \
--package-name=$$(PKG_NAME)-$(1) \
--component-name=cargo \
--legacy-manifest-dirs=rustlib,cargo
rm -Rf $$(IMGDIR_$(1))
install-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
$$(PKGDIR_$(1))/install.sh \
--prefix="$$(CFG_PREFIX)" \
--destdir="$$(DESTDIR)" $$(MAYBE_DISABLE_VERIFY)
uninstall-$(1): $$(DISTDIR_$(1))/$$(PKG_NAME)-$(1).tar.gz
$$(PKGDIR_$(1))/install.sh \
--prefix="$$(CFG_PREFIX)" \
--destdir="$$(DESTDIR)" \
--uninstall
endef
$(foreach target,$(CFG_TARGET),$(eval $(call DO_DIST_TARGET,$(target))))
dist: $(foreach target,$(CFG_TARGET),dist-$(target))
distcheck: $(foreach target,$(CFG_TARGET),distcheck-$(target))
install: $(foreach target,$(CFG_TARGET),install-$(target))
uninstall: $(foreach target,$(CFG_TARGET), uninstall-$(target))
# Setup phony tasks
.PHONY: all clean clean-all dist distcheck install uninstall test test-unit style
# Disable unnecessary built-in rules
.SUFFIXES: