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