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