]>
Commit | Line | Data |
---|---|---|
be771b38 LB |
1 | #!/usr/bin/make -f |
2 | # -*- makefile -*- | |
3 | ||
b59979d9 | 4 | include /usr/share/dpkg/pkg-info.mk |
6472c211 | 5 | include /usr/share/dpkg/vendor.mk |
d75d48d6 | 6 | include /usr/share/dpkg/architecture.mk |
b5dfb68c XL |
7 | SED_VERSION_SHORT := sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/' |
8 | RUST_VERSION := $(shell echo '$(DEB_VERSION_UPSTREAM)' | $(SED_VERSION_SHORT)) | |
9 | RUST_LONG_VERSION := $(shell echo '$(DEB_VERSION_UPSTREAM)' | sed -re 's/([^+]+).*/\1/') | |
10 | LIBSTD_PKG := libstd-rust-$(RUST_VERSION) | |
11 | # Sed expression that matches the "rustc" we have in our Build-Depends field | |
12 | SED_RUSTC_BUILDDEP := sed -ne "/^Build-Depends:/,/^[^[:space:]\#]/{/^ *rustc:native .*,/p}" debian/control | |
2da5f2f9 XL |
13 | # Version of /usr/bin/rustc |
14 | LOCAL_RUST_VERSION := $(shell rustc --version --verbose | sed -ne 's/^release: //p') | |
b5dfb68c | 15 | |
7d40d3e1 | 16 | include /usr/share/dpkg/buildflags.mk |
4888e768 | 17 | # TODO: more correct to use `[build] rustflags = []` list syntax in Cargo.toml |
9197bf09 | 18 | RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS)) |
dd5b7638 | 19 | RUSTFLAGS += --cap-lints warn --remap-path-prefix=$(CURDIR)=/usr/src/rustc-$(RUST_LONG_VERSION) |
7d40d3e1 | 20 | export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS |
ca38e697 | 21 | export CARGO_HOME = $(CURDIR)/debian/cargo |
ab330327 XL |
22 | ifneq (,$(filter $(DEB_BUILD_ARCH), sparc64)) |
23 | export CARGO_INCREMENTAL = 0 | |
24 | endif | |
b59979d9 | 25 | |
525ff0f9 AL |
26 | # Defines DEB_*_RUST_TYPE triples |
27 | include debian/architecture.mk | |
693daed7 | 28 | export DEB_HOST_RUST_TYPE |
525ff0f9 | 29 | |
be771b38 LB |
30 | # Uncomment this to turn on verbose mode. |
31 | #export DH_VERBOSE=1 | |
32 | ||
8354de7a | 33 | DEB_DESTDIR := $(CURDIR)/debian/tmp |
525ff0f9 | 34 | |
525ff0f9 | 35 | # Use system LLVM (comment out to use vendored LLVM) |
e7dbf345 XL |
36 | LLVM_VERSION = 9 |
37 | OLD_LLVM_VERSION = 8 | |
2b7c35b5 XL |
38 | # Make it easier to test against a custom LLVM |
39 | ifneq (,$(LLVM_DESTDIR)) | |
56548b60 XL |
40 | LLVM_LIBRARY_PATH := $(LLVM_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH):$(LLVM_DESTDIR)/usr/lib |
41 | LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):$(LLVM_LIBRARY_PATH),$(LLVM_LIBRARY_PATH)) | |
2b7c35b5 XL |
42 | export LD_LIBRARY_PATH |
43 | endif | |
2b7c35b5 | 44 | |
5fe59560 | 45 | RUSTBUILD = RUST_BACKTRACE=1 python3 src/bootstrap/bootstrap.py |
33416cd4 | 46 | RUSTBUILD_FLAGS = --config debian/config.toml -vvv --on-fail env |
8978aae4 | 47 | RUSTBUILD_TEST = $(RUSTBUILD) test --no-fail-fast |
0d3674eb XL |
48 | # To run a specific test, run something like: |
49 | # $ debian/rules override_dh_auto_test-arch \ | |
50 | # RUSTBUILD_TEST_FLAGS="src/test/run-make --test-args extern-fn-struct" | |
51 | # See src/bootstrap/README.md for more options. | |
52 | RUSTBUILD_TEST_FLAGS = | |
1c8ac2b0 | 53 | |
25f1c2fe XL |
54 | update-version: |
55 | oldver=$(shell $(SED_RUSTC_BUILDDEP) | sed -ne 's/.*(<= \(.*\)).*/\1/gp' | $(SED_VERSION_SHORT)); \ | |
0bf22a45 XL |
56 | newver=$(RUST_VERSION); \ |
57 | debian/update-version.sh $$oldver $$newver $(RUST_LONG_VERSION) $(CARGO_NEW) | |
25f1c2fe | 58 | |
427dce5b XL |
59 | # Below we detect how we're supposed to bootstrap the stage0 compiler. See |
60 | # README.Debian for more details of the cases described below. | |
61 | # | |
427dce5b | 62 | PRECONFIGURE_CHECK = : |
75be2bb3 | 63 | HAVE_BINARY_TARBALL := $(shell ls -1 stage0/*/*$(DEB_HOST_RUST_TYPE)* 2>/dev/null | wc -l) |
5861ebac | 64 | DOWNLOAD_BOOTSTRAP := false |
571f0d20 MK |
65 | # allow not using the binary tarball although it exists |
66 | #ifneq (,$(filter $(DEB_HOST_ARCH), amd64 arm64 armhf i386 powerpc ppc64el s390x)) | |
67 | # HAVE_BINARY_TARBALL := 0 | |
68 | #endif | |
69 | ifeq (0,$(HAVE_BINARY_TARBALL)) | |
16dfb283 XL |
70 | # Case A (Building from source): the extracted source tree does not include |
71 | # a bootstrapping tarball for the current architecture e.g. because the | |
72 | # distro already has a rustc for this arch, or the uploader expects that | |
73 | # this requirement be fulfilled in some other way. | |
427dce5b XL |
74 | # |
75 | # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile. | |
76 | # In this case, we use the distro's rustc - either the previous or current version. | |
77 | ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES))) | |
56548b60 XL |
78 | # Make it easier to test against a custom rustc |
79 | ifneq (,$(RUST_DESTDIR)) | |
80 | RUST_LIBRARY_PATH := $(RUST_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH):$(RUST_DESTDIR)/usr/lib | |
81 | LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):$(RUST_LIBRARY_PATH),$(RUST_LIBRARY_PATH)) | |
82 | export LD_LIBRARY_PATH | |
83 | endif | |
427dce5b XL |
84 | # |
85 | # Case A-2: the builder selected the "dlstage0" build profile. | |
75be2bb3 | 86 | # In this case, the rust build scripts will download a stage0 into stage0/ and use that. |
b9a40c91 | 87 | # We don't need to do anything specific in this build file, so this case is empty. |
5861ebac XL |
88 | else |
89 | DOWNLOAD_BOOTSTRAP := true | |
90 | endif | |
427dce5b | 91 | else |
16dfb283 XL |
92 | # Case B (Bootstrapping a new distro): the extracted source tree does |
93 | # include a bootstrapping tarball for the current architecture; see the | |
75be2bb3 | 94 | # `source_orig-stage0` target below on how to build this. |
427dce5b XL |
95 | # |
96 | # In this case, we'll bootstrap from the stage0 given in that tarball. | |
97 | # To ensure the uploader of the .dsc didn't make a mistake, we first check | |
16dfb283 | 98 | # that rustc isn't a Build-Depends for the current architecture. |
25f1c2fe XL |
99 | ifneq (,$(shell $(SED_RUSTC_BUILDDEP))) |
100 | ifeq (,$(shell $(SED_RUSTC_BUILDDEP) | grep '!$(DEB_HOST_ARCH)')) | |
75be2bb3 | 101 | PRECONFIGURE_CHECK = $(error found matches for stage0/*/*$(DEB_HOST_RUST_TYPE)*, \ |
16dfb283 XL |
102 | but rustc might be a Build-Depends for $(DEB_HOST_ARCH)) |
103 | endif | |
427dce5b | 104 | endif |
1c8ac2b0 SL |
105 | endif |
106 | ||
5861ebac | 107 | BUILD_DOCS := true |
120b4d47 | 108 | ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES))) |
5861ebac | 109 | BUILD_DOCS := false |
1c8ac2b0 | 110 | endif |
005427f4 XL |
111 | ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS))) |
112 | BUILD_DOCS := false | |
113 | endif | |
1c8ac2b0 | 114 | |
8d2dc69d XL |
115 | BUILD_WASM := true |
116 | ifneq (,$(findstring nowasm,$(DEB_BUILD_PROFILES))) | |
117 | BUILD_WASM := false | |
118 | endif | |
119 | ||
5861ebac | 120 | MAKE_OPTIMISATIONS := true |
1c8ac2b0 | 121 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) |
5861ebac | 122 | MAKE_OPTIMISATIONS := false |
1c8ac2b0 SL |
123 | endif |
124 | ||
35329365 | 125 | # Build products or non-source files in src/, that shouldn't go in rust-src |
9a2ab7ea | 126 | SRC_CLEAN = src/bootstrap/bootstrap.pyc \ |
35329365 | 127 | src/etc/__pycache__/ |
1c8ac2b0 | 128 | |
170f9149 XL |
129 | # Workaround for linux #865549 |
130 | ifeq (0,$(shell test $$(uname -s) = "Linux" -a $$(getconf PAGESIZE) -gt 4096; echo $$?)) | |
131 | SYSTEM_WORKAROUNDS += ulimit -s $$(expr $$(getconf PAGESIZE) / 1024 '*' 256 + 8192); | |
132 | endif | |
96a6ef5f XL |
133 | # Try to work around #933045 |
134 | ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel)) | |
135 | SYSTEM_WORKAROUNDS += export MALLOC_ARENA_MAX=1; | |
136 | endif | |
170f9149 | 137 | |
be771b38 | 138 | %: |
170f9149 | 139 | $(SYSTEM_WORKAROUNDS) dh $@ --parallel |
be771b38 | 140 | |
04c12273 XL |
141 | .PHONY: build |
142 | build: | |
170f9149 | 143 | $(SYSTEM_WORKAROUNDS) dh $@ --parallel |
04c12273 | 144 | |
de1de54b | 145 | override_dh_clean: |
cf0b146d XL |
146 | # Upstream contains a lot of these |
147 | dh_clean -XCargo.toml.orig | |
de1de54b | 148 | |
b49766ad XL |
149 | debian/config.toml: debian/config.toml.in debian/rules |
150 | u="$(DEB_VERSION_UPSTREAM)"; \ | |
151 | if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then channel="beta"; \ | |
152 | else channel="stable"; fi; echo $$channel; \ | |
ec028c2e XL |
153 | m4 -DRELEASE_CHANNEL="$$channel" \ |
154 | -DDEB_BUILD_RUST_TYPE="$(DEB_BUILD_RUST_TYPE)" \ | |
01dc6ef4 XL |
155 | -DDEB_HOST_RUST_TYPE="$(DEB_HOST_RUST_TYPE)" \ |
156 | -DDEB_TARGET_RUST_TYPE="$(DEB_TARGET_RUST_TYPE)" \ | |
ec028c2e XL |
157 | -DDEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \ |
158 | -DDEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \ | |
159 | -DDEB_TARGET_GNU_TYPE="$(DEB_TARGET_GNU_TYPE)" \ | |
5861ebac | 160 | -DMAKE_OPTIMISATIONS="$(MAKE_OPTIMISATIONS)" \ |
2b7c35b5 | 161 | -DLLVM_DESTDIR="$(LLVM_DESTDIR)" \ |
666f0397 | 162 | -DLLVM_VERSION="$(LLVM_VERSION)" \ |
5861ebac | 163 | -DRUST_DESTDIR="$(RUST_DESTDIR)" \ |
01dc6ef4 | 164 | "$<" > "$@" |
7ee10b55 XL |
165 | if $(DOWNLOAD_BOOTSTRAP) || [ $(HAVE_BINARY_TARBALL) != 0 ]; \ |
166 | then sed -i -e '/^rustc = /d' -e '/^cargo = /d' "$@"; fi | |
e8cad677 | 167 | # Work around low-memory (32-bit) architectures: https://github.com/rust-lang/rust/issues/45854 |
8978aae4 | 168 | ifneq (,$(filter $(DEB_BUILD_ARCH), armhf armel mips mipsel powerpc powerpcspe)) |
bae0839e | 169 | sed -i -e 's/^debuginfo-level = .*/debuginfo-level = 0/g' "$@" |
8978aae4 | 170 | endif |
01dc6ef4 | 171 | |
b5dfb68c XL |
172 | debian/rust-src.%: debian/rust-src.%.in |
173 | m4 -DRUST_LONG_VERSION="$(RUST_LONG_VERSION)" \ | |
174 | "$<" > "$@" | |
175 | ||
3bdf427a | 176 | debian/dh_auto_configure.stamp: debian/config.toml |
5617e1bd | 177 | # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog |
e7dbf345 | 178 | ! grep --color=always -i 'll\(..\|d\)-\?$(subst .,\.,$(OLD_LLVM_VERSION))' --exclude=changelog --exclude='*.patch' --exclude-dir='.debhelper' -R debian |
c54b4d09 XL |
179 | # fail the build if we accidentally vendored openssl, indicates we pulled in unnecessary dependencies |
180 | test ! -e vendor/openssl | |
189d24b7 | 181 | # fail the build if we didn't update d-ignore-error-detail-diff.patch |
957ba32a | 182 | ! grep -Ri '\$$SRC_DIR' src/test/ |
e133b084 | 183 | # fail the build if our version contains ~exp and we are not releasing to experimental |
b49766ad | 184 | v="$(DEB_VERSION)"; test "$$v" = "$${v%~exp*}" -o "$(DEB_DISTRIBUTION)" = "experimental" -o "$(DEB_DISTRIBUTION)" = "UNRELEASED" |
427dce5b | 185 | $(PRECONFIGURE_CHECK) |
75be2bb3 | 186 | if [ -d stage0 ]; then mkdir -p build && ln -sfT ../stage0 build/cache; fi |
3281855a XL |
187 | # work around #842634 |
188 | if test $$(grep "127.0.0.1\s*localhost" /etc/hosts | wc -l) -gt 1; then \ | |
ed6f7eed | 189 | debian/ensure-patch -N debian/patches/d-host-duplicates.patch; fi |
c9527bb9 XL |
190 | # work around https://github.com/rust-lang/rust/issues/59264 |
191 | # TODO: remove this in 1.41 and later | |
192 | if dpkg --compare-versions $(LOCAL_RUST_VERSION) '>=' 1.40.0; then \ | |
193 | debian/ensure-patch -N debian/patches/u-compiletest-stage0-bump.patch; \ | |
194 | else \ | |
195 | debian/ensure-patch -R debian/patches/u-compiletest-stage0-bump.patch; \ | |
196 | fi | |
98955da7 | 197 | # We patched some crates so have to rm the checksums |
94bd9ad3 | 198 | find vendor -name .cargo-checksum.json -execdir "$(CURDIR)/debian/prune-checksums" "{}" + |
6b0d97fc | 199 | # Link against system liblzma, see https://github.com/alexcrichton/xz2-rs/issues/16 |
f56f18fe | 200 | echo 'fn main() { println!("cargo:rustc-link-lib=lzma"); }' > vendor/lzma-sys/build.rs |
5861ebac XL |
201 | # We don't run ./configure because we use debian/config.toml directly |
202 | ln -sf debian/config.toml config.toml | |
3bdf427a XL |
203 | touch "$@" |
204 | ||
205 | override_dh_auto_configure-arch: debian/dh_auto_configure.stamp | |
206 | override_dh_auto_configure-indep: debian/dh_auto_configure.stamp | |
207 | ifeq (true,$(BUILD_DOCS)) | |
208 | # Change config.toml now and not later, since that might trigger a rebuild | |
209 | sed -i -e 's/^docs = false/docs = true/' debian/config.toml | |
210 | endif | |
1c8ac2b0 | 211 | |
11c430be | 212 | override_dh_auto_clean: |
ca38e697 | 213 | $(RM) -rf build tmp .cargo debian/cargo_home config.stamp config.mk Makefile |
3bdf427a | 214 | $(RM) -rf $(TEST_LOG) debian/config.toml debian/rust-src.install debian/rust-src.links debian/*.stamp |
5b2524c4 | 215 | $(RM) -rf $(SRC_CLEAN) config.toml |
11c430be | 216 | |
809d6012 | 217 | debian/dh_auto_build.stamp: |
04c12273 | 218 | $(RUSTBUILD) build $(RUSTBUILD_FLAGS) |
ea192313 | 219 | |
809d6012 XL |
220 | override_dh_auto_build-arch: debian/dh_auto_build.stamp |
221 | override_dh_auto_build-indep: debian/dh_auto_build.stamp | |
8d2dc69d | 222 | ifeq (true,$(BUILD_WASM)) |
8978aae4 XL |
223 | $(RUSTBUILD) build $(RUSTBUILD_FLAGS) \ |
224 | --host $(DEB_BUILD_RUST_TYPE) --target wasm32-unknown-unknown src/libstd | |
453f6ddc XL |
225 | $(RUSTBUILD) build $(RUSTBUILD_FLAGS) \ |
226 | --host $(DEB_BUILD_RUST_TYPE) --target wasm32-wasi src/libstd | |
8d2dc69d | 227 | endif |
5861ebac | 228 | ifeq (true,$(BUILD_DOCS)) |
04c12273 XL |
229 | $(RUSTBUILD) doc $(RUSTBUILD_FLAGS) |
230 | endif | |
231 | ||
3a774f0f | 232 | TEST_LOG = debian/rustc-tests.log |
356c70ca XL |
233 | # This is advertised as "5 tests failed" in README.Debian because our counting |
234 | # method is imprecise and in practise we count some failures twice. | |
0b9f599a | 235 | FAILURES_ALLOWED = 8 |
be0ee34e | 236 | ifneq (,$(filter $(DEB_BUILD_ARCH), ppc64 arm64 mips64el i386)) |
6404b712 | 237 | FAILURES_ALLOWED = 12 |
fa6232de | 238 | endif |
41f28e35 | 239 | ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel riscv64 s390x)) |
15f51d41 | 240 | FAILURES_ALLOWED = 24 |
ab330327 | 241 | endif |
41f28e35 | 242 | ifneq (,$(filter $(DEB_BUILD_ARCH), powerpc powerpcspe sparc64 x32)) |
617a87c6 | 243 | FAILURES_ALLOWED = 180 |
734d072d | 244 | endif |
873d1fa5 | 245 | FAILED_TESTS = grep "FAILED\|^command did not execute successfully" $(TEST_LOG) | grep -v '^test result: FAILED' |
7958f3db | 246 | override_dh_auto_test-arch: |
91d3be64 | 247 | # ensure that rustc_llvm is actually dynamically linked to libLLVM |
347f6206 XL |
248 | set -e; find build/*/stage2/lib/rustlib/* -name '*rustc_llvm*.so' | \ |
249 | while read x; do \ | |
250 | stat -c '%s %n' "$$x"; \ | |
251 | objdump -p "$$x" | grep -q "NEEDED.*LLVM"; \ | |
252 | test "$$(stat -c %s "$$x")" -lt 6000000; \ | |
253 | done | |
68e7eb97 | 254 | ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES))) |
7958f3db | 255 | ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS))) |
8978aae4 | 256 | { $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS); echo $$?; } | tee -a $(TEST_LOG) |
91d3be64 | 257 | # test that the log has at least 1 pass, to prevent e.g. #57709 |
bbceb41b | 258 | grep -l "^test .* \.\.\. ok$$" $(TEST_LOG) |
2c22371f XL |
259 | echo "==== Debian rustc test report ===="; \ |
260 | echo "Specific test failures:"; \ | |
3a774f0f | 261 | $(FAILED_TESTS); \ |
873d1fa5 | 262 | num_failures=$$($(FAILED_TESTS) | wc -l); \ |
2c22371f XL |
263 | exit_code=$$(tail -n1 $(TEST_LOG)); \ |
264 | echo "Summary: exit code $$exit_code, counted $$num_failures tests failed."; \ | |
265 | echo -n "$(FAILURES_ALLOWED) maximum allowed. "; \ | |
266 | if test "$$num_failures" -eq 0 -a "$$exit_code" -ne 0; then \ | |
267 | echo "Aborting just in case, because we missed counting some test failures."; \ | |
6404b712 | 268 | echo "This could happen if we failed to build the tests, or if the testsuite runner is buggy."; \ |
2c22371f XL |
269 | false; \ |
270 | elif test "$$num_failures" -le $(FAILURES_ALLOWED); then \ | |
3a774f0f XL |
271 | echo "Continuing..."; \ |
272 | else \ | |
273 | echo "Aborting the build."; \ | |
274 | echo "Check the logs further above for details."; \ | |
275 | false; \ | |
276 | fi | |
0d3674eb XL |
277 | # don't continue if RUSTBUILD_TEST_FLAGS is non-empty |
278 | test -z "$(RUSTBUILD_TEST_FLAGS)" | |
e408bc2c | 279 | endif |
68e7eb97 | 280 | endif |
becfe001 | 281 | |
04c12273 | 282 | override_dh_auto_test-indep: |
68e7eb97 | 283 | ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES))) |
7958f3db | 284 | ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS))) |
8d2dc69d | 285 | ifeq (true,$(BUILD_WASM)) |
8978aae4 | 286 | # Ignore failures in these tests, but run them so we see what it's like |
005427f4 | 287 | -PATH=$(CURDIR)/debian/bin:$(PATH) $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS) \ |
8978aae4 | 288 | --host $(DEB_BUILD_RUST_TYPE) --target wasm32-unknown-unknown src/libstd |
453f6ddc XL |
289 | -PATH=$(CURDIR)/debian/bin:$(PATH) $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS) \ |
290 | --host $(DEB_BUILD_RUST_TYPE) --target wasm32-wasi src/libstd | |
8d2dc69d | 291 | endif |
aa14b88a | 292 | ifeq (true,$(BUILD_DOCS)) |
8978aae4 XL |
293 | # Run all rules that test the docs, i.e. that depend on default:doc |
294 | $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) src/tools/linkchecker | |
7958f3db | 295 | endif |
aa14b88a | 296 | test -z "$(RUSTBUILD_TEST_FLAGS)" |
7958f3db | 297 | endif |
68e7eb97 | 298 | endif |
04c12273 | 299 | |
bf52bd52 XL |
300 | run_rustbuild: |
301 | DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) $(X_CMD) $(RUSTBUILD_FLAGS) $(X_FLAGS) | |
302 | ||
3bdf427a | 303 | debian/dh_auto_install.stamp: |
6a9e99e9 | 304 | DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS) |
525ff0f9 AL |
305 | |
306 | mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/ | |
307 | mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/ | |
6fce0a99 | 308 | |
1261b4b3 | 309 | # Replace duplicated compile-time/run-time dylibs with symlinks |
525ff0f9 AL |
310 | @set -e; \ |
311 | for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \ | |
312 | name=$${f##*/}; \ | |
313 | if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \ | |
314 | echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \ | |
315 | ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \ | |
316 | fi; \ | |
1261b4b3 AL |
317 | done |
318 | ||
3bdf427a XL |
319 | touch "$@" |
320 | ||
321 | override_dh_auto_install-arch: debian/dh_auto_install.stamp | |
322 | override_dh_auto_install-indep: debian/dh_auto_install.stamp | |
8d2dc69d | 323 | ifeq (true,$(BUILD_WASM)) |
453f6ddc XL |
324 | DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS) \ |
325 | --host $(DEB_BUILD_RUST_TYPE) --target wasm32-unknown-unknown src/libstd | |
326 | DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS) \ | |
327 | --host $(DEB_BUILD_RUST_TYPE) --target wasm32-wasi src/libstd | |
8d2dc69d | 328 | endif |
5861ebac | 329 | ifeq (true,$(BUILD_DOCS)) |
6fce0a99 SL |
330 | # Brute force to remove privacy-breach-logo lintian warning. |
331 | # We could have updated the upstream sources but it would complexify | |
332 | # the rebase | |
b556761e | 333 | @set -e; \ |
450ac6ae | 334 | find $(DEB_DESTDIR)/usr/share/doc/*/html -iname '*.html' | \ |
1add0b94 | 335 | while read file; do \ |
b556761e | 336 | topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \ |
450ac6ae XL |
337 | sed -i \ |
338 | -e "s,https://\(doc\|www\).rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \ | |
339 | -e 's,<img src="https://img.shields.io/[^"]*" alt="\([^"]*\)" />,<span class="deb-privacy-replace--shields-io">\1</span>,g' "$$file"; \ | |
1add0b94 | 340 | done |
b125a683 MO |
341 | find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete; |
342 | endif | |
343 | ||
cf9ecdde | 344 | override_dh_install-arch: |
6fce0a99 | 345 | dh_install |
525ff0f9 | 346 | dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/ |
cd17b70a | 347 | dh_install -plibstd-rust-dev usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/ |
b4ca3996 | 348 | dh_install -prustc usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/codegen-backends/ |
525ff0f9 | 349 | |
b5dfb68c | 350 | override_dh_install-indep: debian/rust-src.install debian/rust-src.links |
a0022868 | 351 | dh_install |
8d2dc69d | 352 | ifeq (true,$(BUILD_WASM)) |
809d6012 | 353 | dh_install -plibstd-rust-dev-wasm32-cross usr/lib/rustlib/wasm32-*/lib/ |
8d2dc69d | 354 | endif |
525ff0f9 AL |
355 | chmod -x \ |
356 | debian/rust-gdb/usr/share/rust-gdb/*.py \ | |
357 | debian/rust-lldb/usr/share/rust-lldb/*.py | |
b5dfb68c | 358 | $(RM) -rf $(SRC_CLEAN:%=debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION)/%) |
f40dfcc0 | 359 | # Get rid of lintian warnings |
b5dfb68c | 360 | find debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION) \ |
f40dfcc0 XL |
361 | \( -name .gitignore \ |
362 | -o -name 'LICENSE*' \ | |
363 | -o -name 'LICENCE' \ | |
364 | -o -name 'license' \ | |
365 | -o -name 'COPYING*' \ | |
366 | \) -delete | |
8d3e3cd2 | 367 | # Remove files that autoload remote resources, caught by lintian |
f56f18fe XL |
368 | $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/cssparser/docs/*.html |
369 | $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/kuchiki/docs/*.html | |
370 | $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/url/docs/*.html | |
371 | $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/xz2/.gitmodules | |
1c8ac2b0 | 372 | |
bc0aa84e AL |
373 | override_dh_installchangelogs: |
374 | dh_installchangelogs RELEASES.md | |
375 | ||
376 | override_dh_installdocs: | |
377 | dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc | |
378 | ||
5c515547 XL |
379 | override_dh_missing: |
380 | dh_missing --list-missing | |
381 | ||
eef1f4e3 AL |
382 | override_dh_compress: |
383 | dh_compress -X.woff | |
384 | ||
b676ddf6 XL |
385 | # The below override is disabled on advice from #debian-devel, because: |
386 | # - only shared libs get the "split dbgsym package" treatment by dh_strip; | |
387 | # static libs simply get their debuginfo discarded | |
388 | # - strip(1) sometimes breaks wasm libs | |
389 | # | |
390 | #override_dh_strip: | |
391 | # # Work around #35733, #468333 | |
392 | # find debian/libstd-rust-dev*/ -name '*.rlib' -execdir mv '{}' '{}.a' \; | |
393 | # # This is expected to print out lots of "File format unrecognized" warnings about | |
394 | # # rust.metadata.bin and *.deflate but the .o files inside the rlibs should be stripped | |
395 | # # Some files are still omitted because of #875780 however. | |
396 | # dh_strip -v | |
397 | # find debian/libstd-rust-dev*/ -name '*.rlib.a' -execdir sh -c 'mv "$$1" "$${1%.a}"' - '{}' \; | |
d2456730 | 398 | |
525ff0f9 AL |
399 | override_dh_makeshlibs: |
400 | dh_makeshlibs -V | |
401 | ||
402 | # dh_makeshlibs doesn't support our "libfoo-version.so" naming | |
403 | # structure, so we have to do this ourselves. | |
404 | install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN | |
33766656 | 405 | LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \ |
525ff0f9 AL |
406 | sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \ |
407 | while read name version; do \ | |
408 | echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \ | |
409 | done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs | |
410 | chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs | |
411 | chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs | |
412 | ||
413 | override_dh_shlibdeps: | |
414 | dh_shlibdeps -- -x$(LIBSTD_PKG) | |
427dce5b XL |
415 | |
416 | QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi | |
75be2bb3 | 417 | source_orig-stage0: |
16dfb283 XL |
418 | QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE) |
419 | $(MAKE) -f debian/rules clean | |
75be2bb3 | 420 | debian/make_orig-stage0_tarball.sh |
16dfb283 XL |
421 | QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE) |
422 | rm -rf .pc | |
15ab0b38 | 423 | |
0a1981fb XL |
424 | get_beta_version = \ |
425 | u="$(DEB_VERSION_UPSTREAM)"; \ | |
426 | if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then \ | |
427 | newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2)/e'); \ | |
428 | else \ | |
15ab0b38 | 429 | newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2+1)/e'); \ |
0a1981fb XL |
430 | fi |
431 | ||
432 | debian/watch-beta: debian/watch-beta.in debian/rules | |
433 | set -e; $(get_beta_version); \ | |
15ab0b38 XL |
434 | m4 -DOLDVER="$$oldver" -DNEWVER="$$newver.0" "$<" > "$@" |
435 | ||
436 | source_orig-beta: debian/watch-beta | |
d377cbf5 | 437 | uscan $(USCAN_OPTS) $(if $(USCAN_DESTDIR),--destdir=$(USCAN_DESTDIR),) --verbose --watchfile "$<" |
0a1981fb | 438 | set -e; $(get_beta_version); \ |
d377cbf5 XL |
439 | bd="$(if $(USCAN_DESTDIR),$(USCAN_DESTDIR),..)"; \ |
440 | tar xf $$bd/rustc-$$newver.0-beta.999-src.tar.xz rustc-beta-src/version; \ | |
0a1981fb | 441 | bv="$$(sed -re 's/[0-9]+.[0-9]+.[0-9]+-beta.([0-9]+) \(.*\)/\1/g' rustc-beta-src/version)"; \ |
d377cbf5 | 442 | bash -c 'shopt -s nullglob; for i in '"$$bd"'/rustc*beta.999*; do mv $$i $${i/beta.999/beta.'"$$bv"'}; done'; \ |
3af75deb XL |
443 | rm -f rustc-beta-src/version; \ |
444 | rmdir -p rustc-beta-src; \ | |
d377cbf5 | 445 | echo "prepared rustc $$newver.0~beta.$$bv in $$bd" |