]> git.proxmox.com Git - rustc.git/blame - debian/rules
bump version to 1.65.0+dfsg1-1~exp2
[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)
e43b5b50
FG
31LLVM_VERSION = 15
32OLD_LLVM_VERSION = 14
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
aca8be47
XL
156ifeq ($(shell test $(VERBOSITY) -ge 3; echo $$?),0)
157 export DH_VERBOSE=1
158endif
159
160ifeq ($(shell test $(VERBOSITY) -le 0; echo $$?),0)
161 export DH_QUIET=1
162.SILENT:
163endif
164
35329365 165# Build products or non-source files in src/, that shouldn't go in rust-src
9a2ab7ea 166SRC_CLEAN = src/bootstrap/bootstrap.pyc \
d35683cb 167 src/bootstrap/__pycache__ \
35329365 168 src/etc/__pycache__/
1c8ac2b0 169
96a6ef5f
XL
170# Try to work around #933045
171ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel))
172 SYSTEM_WORKAROUNDS += export MALLOC_ARENA_MAX=1;
173endif
170f9149 174
be771b38 175%:
170f9149 176 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
be771b38 177
27da05fd
XL
178.PHONY: .dbg-windows
179.dbg-windows:
180 @echo host=$(DEB_BUILD_ARCH) target=$(DEB_HOST_ARCH) BUILD_WINDOWS=$(BUILD_WINDOWS) WINDOWS_ARCH=$(WINDOWS_ARCH)
181
04c12273
XL
182.PHONY: build
183build:
170f9149 184 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
04c12273 185
de1de54b 186override_dh_clean:
cf0b146d
XL
187 # Upstream contains a lot of these
188 dh_clean -XCargo.toml.orig
de1de54b 189
b49766ad
XL
190debian/config.toml: debian/config.toml.in debian/rules
191 u="$(DEB_VERSION_UPSTREAM)"; \
192 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then channel="beta"; \
aca8be47 193 else channel="stable"; fi; \
ec028c2e
XL
194 m4 -DRELEASE_CHANNEL="$$channel" \
195 -DDEB_BUILD_RUST_TYPE="$(DEB_BUILD_RUST_TYPE)" \
01dc6ef4
XL
196 -DDEB_HOST_RUST_TYPE="$(DEB_HOST_RUST_TYPE)" \
197 -DDEB_TARGET_RUST_TYPE="$(DEB_TARGET_RUST_TYPE)" \
ec028c2e
XL
198 -DDEB_BUILD_GNU_TYPE="$(DEB_BUILD_GNU_TYPE)" \
199 -DDEB_HOST_GNU_TYPE="$(DEB_HOST_GNU_TYPE)" \
200 -DDEB_TARGET_GNU_TYPE="$(DEB_TARGET_GNU_TYPE)" \
5861ebac 201 -DMAKE_OPTIMISATIONS="$(MAKE_OPTIMISATIONS)" \
2f6e6584 202 -DVERBOSITY="$(VERBOSITY)" \
2b7c35b5 203 -DLLVM_DESTDIR="$(LLVM_DESTDIR)" \
666f0397 204 -DLLVM_VERSION="$(LLVM_VERSION)" \
5861ebac 205 -DRUST_DESTDIR="$(RUST_DESTDIR)" \
01dc6ef4 206 "$<" > "$@"
7ee10b55
XL
207 if $(DOWNLOAD_BOOTSTRAP) || [ $(HAVE_BINARY_TARBALL) != 0 ]; \
208 then sed -i -e '/^rustc = /d' -e '/^cargo = /d' "$@"; fi
e8cad677 209# Work around low-memory (32-bit) architectures: https://github.com/rust-lang/rust/issues/45854
a3aaf3d3
FG
210# i386 and x32 fail to mmap rustc_driver when building rustdoc in >1.60
211ifneq (,$(filter $(DEB_BUILD_ARCH), armhf armel i386 mips mipsel powerpc powerpcspe x32))
bae0839e 212 sed -i -e 's/^debuginfo-level = .*/debuginfo-level = 0/g' "$@"
8978aae4 213endif
01dc6ef4 214
61fad94a 215check-no-old-llvm:
5617e1bd 216 # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
3aade234 217 ! grep --color=always -i '\(clang\|ll\(..\|d\)\)-\?$(subst .,\.,$(OLD_LLVM_VERSION))' --exclude=changelog --exclude=copyright --exclude='*.patch' --exclude-dir='.debhelper' -R debian
61fad94a
XL
218.PHONY: check-no-old-llvm
219
220debian/dh_auto_configure.stamp: debian/config.toml check-no-old-llvm
c54b4d09
XL
221 # fail the build if we accidentally vendored openssl, indicates we pulled in unnecessary dependencies
222 test ! -e vendor/openssl
e133b084 223 # fail the build if our version contains ~exp and we are not releasing to experimental
b49766ad 224 v="$(DEB_VERSION)"; test "$$v" = "$${v%~exp*}" -o "$(DEB_DISTRIBUTION)" = "experimental" -o "$(DEB_DISTRIBUTION)" = "UNRELEASED"
427dce5b 225 $(PRECONFIGURE_CHECK)
75be2bb3 226 if [ -d stage0 ]; then mkdir -p build && ln -sfT ../stage0 build/cache; fi
3281855a
XL
227 # work around #842634
228 if test $$(grep "127.0.0.1\s*localhost" /etc/hosts | wc -l) -gt 1; then \
6c577aa0 229 debian/ensure-patch -N debian/patches/d-test-host-duplicates.patch; fi
a93d58bc 230 # don't care about lock changes
c91d0412 231 rm -f Cargo.lock src/bootstrap/Cargo.lock src/tools/rust-analyzer/Cargo.lock
98955da7 232 # We patched some crates so have to rm the checksums
94bd9ad3 233 find vendor -name .cargo-checksum.json -execdir "$(CURDIR)/debian/prune-checksums" "{}" +
6b0d97fc 234 # Link against system liblzma, see https://github.com/alexcrichton/xz2-rs/issues/16
f56f18fe 235 echo 'fn main() { println!("cargo:rustc-link-lib=lzma"); }' > vendor/lzma-sys/build.rs
5861ebac
XL
236 # We don't run ./configure because we use debian/config.toml directly
237 ln -sf debian/config.toml config.toml
3bdf427a
XL
238 touch "$@"
239
240override_dh_auto_configure-arch: debian/dh_auto_configure.stamp
241override_dh_auto_configure-indep: debian/dh_auto_configure.stamp
242ifeq (true,$(BUILD_DOCS))
243# Change config.toml now and not later, since that might trigger a rebuild
244 sed -i -e 's/^docs = false/docs = true/' debian/config.toml
245endif
1c8ac2b0 246
11c430be 247override_dh_auto_clean:
94b8d793 248 $(RM) -rf build tmp debian/cargo_home config.stamp config.mk Makefile
b8189452 249 $(RM) -rf $(TEST_LOG) debian/config.toml debian/*.stamp
5b2524c4 250 $(RM) -rf $(SRC_CLEAN) config.toml
11c430be 251
809d6012 252debian/dh_auto_build.stamp:
04c12273 253 $(RUSTBUILD) build $(RUSTBUILD_FLAGS)
ea192313 254
809d6012 255override_dh_auto_build-arch: debian/dh_auto_build.stamp
27da05fd
XL
256ifeq (true,$(BUILD_WINDOWS))
257 $(RUSTBUILD) build $(RUSTBUILD_FLAGS) \
258 --host $(DEB_BUILD_RUST_TYPE) \
259 --target $(WINDOWS_ARCH)-pc-windows-gnu \
830de2ed 260 library/std
27da05fd
XL
261endif
262
809d6012 263override_dh_auto_build-indep: debian/dh_auto_build.stamp
8d2dc69d 264ifeq (true,$(BUILD_WASM))
8978aae4 265 $(RUSTBUILD) build $(RUSTBUILD_FLAGS) \
910f03de
XL
266 --host $(DEB_BUILD_RUST_TYPE) \
267 --target wasm32-unknown-unknown,wasm32-wasi \
830de2ed 268 library/std
8d2dc69d 269endif
5861ebac 270ifeq (true,$(BUILD_DOCS))
04c12273
XL
271 $(RUSTBUILD) doc $(RUSTBUILD_FLAGS)
272endif
273
3a774f0f 274TEST_LOG = debian/rustc-tests.log
356c70ca
XL
275# This is advertised as "5 tests failed" in README.Debian because our counting
276# method is imprecise and in practise we count some failures twice.
0b9f599a 277FAILURES_ALLOWED = 8
94a85be8 278ifneq (,$(filter $(DEB_BUILD_ARCH), armhf))
6404b712 279 FAILURES_ALLOWED = 12
fa6232de 280endif
b4b364c0 281ifneq (,$(filter $(DEB_BUILD_ARCH), armel mips mips64el))
15f51d41 282 FAILURES_ALLOWED = 24
ab330327 283endif
b4b364c0
FG
284# workaround broken gdb 13.1 - revert to 24 once fixed
285# #1031946 / #1032785
286ifneq (,$(filter $(DEB_BUILD_ARCH), mipsel))
287 FAILURED_ALLOWED = 25
288endif
0ceea14c 289ifneq (,$(filter $(DEB_BUILD_ARCH), ppc64 s390x))
fdd627af
XL
290 FAILURES_ALLOWED = 40
291endif
6f423e6e 292ifneq (,$(filter $(DEB_BUILD_ARCH), powerpc powerpcspe riscv64 sparc64 x32))
617a87c6 293 FAILURES_ALLOWED = 180
734d072d 294endif
01620f26 295FAILED_TESTS = grep "FAILED\|^command did not execute successfully" $(TEST_LOG) | grep -v '^test result: FAILED' | grep -v 'FAILED (allowed)'
beb2e50b
XL
296# ignore debuginfo failures on armhf due to regression in GDB 11.2
297# https://sourceware.org/bugzilla/show_bug.cgi?id=29272
298ifneq (,$(filter $(DEB_BUILD_ARCH), armhf))
ec5a277d 299 FAILED_TESTS += | grep -v '^test \[debuginfo-gdb\] src/test/debuginfo/'
beb2e50b 300endif
7958f3db 301override_dh_auto_test-arch:
91d3be64 302 # ensure that rustc_llvm is actually dynamically linked to libLLVM
347f6206
XL
303 set -e; find build/*/stage2/lib/rustlib/* -name '*rustc_llvm*.so' | \
304 while read x; do \
305 stat -c '%s %n' "$$x"; \
306 objdump -p "$$x" | grep -q "NEEDED.*LLVM"; \
307 test "$$(stat -c %s "$$x")" -lt 6000000; \
308 done
68e7eb97 309ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
7958f3db 310ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
8978aae4 311 { $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS); echo $$?; } | tee -a $(TEST_LOG)
91d3be64 312 # test that the log has at least 1 pass, to prevent e.g. #57709
bbceb41b 313 grep -l "^test .* \.\.\. ok$$" $(TEST_LOG)
2c22371f
XL
314 echo "==== Debian rustc test report ===="; \
315 echo "Specific test failures:"; \
3a774f0f 316 $(FAILED_TESTS); \
873d1fa5 317 num_failures=$$($(FAILED_TESTS) | wc -l); \
2c22371f
XL
318 exit_code=$$(tail -n1 $(TEST_LOG)); \
319 echo "Summary: exit code $$exit_code, counted $$num_failures tests failed."; \
320 echo -n "$(FAILURES_ALLOWED) maximum allowed. "; \
321 if test "$$num_failures" -eq 0 -a "$$exit_code" -ne 0; then \
322 echo "Aborting just in case, because we missed counting some test failures."; \
6404b712 323 echo "This could happen if we failed to build the tests, or if the testsuite runner is buggy."; \
2c22371f
XL
324 false; \
325 elif test "$$num_failures" -le $(FAILURES_ALLOWED); then \
3a774f0f
XL
326 echo "Continuing..."; \
327 else \
328 echo "Aborting the build."; \
329 echo "Check the logs further above for details."; \
330 false; \
331 fi
0d3674eb
XL
332# don't continue if RUSTBUILD_TEST_FLAGS is non-empty
333 test -z "$(RUSTBUILD_TEST_FLAGS)"
27da05fd 334# don't run windows tests yet
e408bc2c 335endif
68e7eb97 336endif
becfe001 337
04c12273 338override_dh_auto_test-indep:
68e7eb97 339ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
7958f3db 340ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
8d2dc69d 341ifeq (true,$(BUILD_WASM))
8978aae4 342 # Ignore failures in these tests, but run them so we see what it's like
005427f4 343 -PATH=$(CURDIR)/debian/bin:$(PATH) $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS) \
910f03de
XL
344 --host $(DEB_BUILD_RUST_TYPE) \
345 --target wasm32-unknown-unknown,wasm32-wasi \
830de2ed 346 library/std
8d2dc69d 347endif
aa14b88a 348ifeq (true,$(BUILD_DOCS))
8978aae4
XL
349 # Run all rules that test the docs, i.e. that depend on default:doc
350 $(RUSTBUILD_TEST) $(RUSTBUILD_FLAGS) src/tools/linkchecker
7958f3db 351endif
aa14b88a 352 test -z "$(RUSTBUILD_TEST_FLAGS)"
7958f3db 353endif
68e7eb97 354endif
04c12273 355
bf52bd52
XL
356run_rustbuild:
357 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) $(X_CMD) $(RUSTBUILD_FLAGS) $(X_FLAGS)
358
110dae6c
XL
359override_dh_prep:
360 dh_prep
361 $(RM) -f debian/dh_auto_install.stamp
362
3bdf427a 363debian/dh_auto_install.stamp:
6a9e99e9 364 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS)
525ff0f9
AL
365
366 mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
367 mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
6fce0a99 368
1261b4b3 369 # Replace duplicated compile-time/run-time dylibs with symlinks
525ff0f9
AL
370 @set -e; \
371 for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
372 name=$${f##*/}; \
373 if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
374 echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
375 ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
376 fi; \
1261b4b3
AL
377 done
378
3bdf427a
XL
379 touch "$@"
380
381override_dh_auto_install-arch: debian/dh_auto_install.stamp
27da05fd
XL
382ifeq (true,$(BUILD_WINDOWS))
383 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS) \
384 --host $(DEB_BUILD_RUST_TYPE) \
385 --target $(WINDOWS_ARCH)-pc-windows-gnu \
830de2ed 386 library/std
27da05fd
XL
387endif
388
3bdf427a 389override_dh_auto_install-indep: debian/dh_auto_install.stamp
8d2dc69d 390ifeq (true,$(BUILD_WASM))
453f6ddc 391 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS) \
910f03de
XL
392 --host $(DEB_BUILD_RUST_TYPE) \
393 --target wasm32-unknown-unknown,wasm32-wasi \
830de2ed 394 library/std
8d2dc69d 395endif
5861ebac 396ifeq (true,$(BUILD_DOCS))
6fce0a99
SL
397 # Brute force to remove privacy-breach-logo lintian warning.
398 # We could have updated the upstream sources but it would complexify
399 # the rebase
b556761e 400 @set -e; \
450ac6ae 401 find $(DEB_DESTDIR)/usr/share/doc/*/html -iname '*.html' | \
1add0b94 402 while read file; do \
b556761e 403 topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
450ac6ae
XL
404 sed -i \
405 -e "s,https://\(doc\|www\).rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
a25a1d96 406 -e 's,<img src="https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg[^"]*" alt="\([^"]*\)" />,<span class="deb-privacy-replace--github.com-badge">\1</span>,g' \
450ac6ae 407 -e 's,<img src="https://img.shields.io/[^"]*" alt="\([^"]*\)" />,<span class="deb-privacy-replace--shields-io">\1</span>,g' "$$file"; \
1add0b94 408 done
b125a683
MO
409 find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete;
410endif
411
eede8545 412override_dh_install-indep:
6fce0a99 413 dh_install
b5dfb68c 414 $(RM) -rf $(SRC_CLEAN:%=debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION)/%)
f40dfcc0 415 # Get rid of lintian warnings
b5dfb68c 416 find debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION) \
f40dfcc0
XL
417 \( -name .gitignore \
418 -o -name 'LICENSE*' \
419 -o -name 'LICENCE' \
420 -o -name 'license' \
421 -o -name 'COPYING*' \
b6d33132 422 -o -name '.eslintrc.js' \
f40dfcc0 423 \) -delete
8d3e3cd2 424 # Remove files that autoload remote resources, caught by lintian
f56f18fe
XL
425 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/cssparser/docs/*.html
426 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/kuchiki/docs/*.html
427 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/url/docs/*.html
428 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/xz2/.gitmodules
1c8ac2b0 429
bc0aa84e
AL
430override_dh_installchangelogs:
431 dh_installchangelogs RELEASES.md
432
433override_dh_installdocs:
434 dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
435
eef1f4e3
AL
436override_dh_compress:
437 dh_compress -X.woff
438
b676ddf6
XL
439# The below override is disabled on advice from #debian-devel, because:
440# - only shared libs get the "split dbgsym package" treatment by dh_strip;
441# static libs simply get their debuginfo discarded
442# - strip(1) sometimes breaks wasm libs
443#
444#override_dh_strip:
445# # Work around #35733, #468333
446# find debian/libstd-rust-dev*/ -name '*.rlib' -execdir mv '{}' '{}.a' \;
447# # This is expected to print out lots of "File format unrecognized" warnings about
448# # rust.metadata.bin and *.deflate but the .o files inside the rlibs should be stripped
449# # Some files are still omitted because of #875780 however.
450# dh_strip -v
451# find debian/libstd-rust-dev*/ -name '*.rlib.a' -execdir sh -c 'mv "$$1" "$${1%.a}"' - '{}' \;
d2456730 452
f6fae01b
XL
453override_dh_dwz:
454 # otherwise rustc gets an empty multifile which lintian errors on, causing
455 # FTP auto-reject. this is a work-around, the lintian bug is #955752
456 dh_dwz --no-dwz-multifile
457
525ff0f9
AL
458override_dh_makeshlibs:
459 dh_makeshlibs -V
460
461 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
462 # structure, so we have to do this ourselves.
a508e13b 463 mkdir -p debian/$(LIBSTD_PKG)/DEBIAN
33766656 464 LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
525ff0f9
AL
465 sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
466 while read name version; do \
467 echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
468 done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
525ff0f9
AL
469
470override_dh_shlibdeps:
471 dh_shlibdeps -- -x$(LIBSTD_PKG)
427dce5b
XL
472
473QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi
75be2bb3 474source_orig-stage0:
16dfb283
XL
475 QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
476 $(MAKE) -f debian/rules clean
75be2bb3 477 debian/make_orig-stage0_tarball.sh
16dfb283
XL
478 QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
479 rm -rf .pc
15ab0b38 480
0a1981fb
XL
481get_beta_version = \
482 u="$(DEB_VERSION_UPSTREAM)"; \
483 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then \
484 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2)/e'); \
485 else \
15ab0b38 486 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2+1)/e'); \
0a1981fb
XL
487 fi
488
489debian/watch-beta: debian/watch-beta.in debian/rules
490 set -e; $(get_beta_version); \
15ab0b38
XL
491 m4 -DOLDVER="$$oldver" -DNEWVER="$$newver.0" "$<" > "$@"
492
493source_orig-beta: debian/watch-beta
d377cbf5 494 uscan $(USCAN_OPTS) $(if $(USCAN_DESTDIR),--destdir=$(USCAN_DESTDIR),) --verbose --watchfile "$<"
0a1981fb 495 set -e; $(get_beta_version); \
d377cbf5
XL
496 bd="$(if $(USCAN_DESTDIR),$(USCAN_DESTDIR),..)"; \
497 tar xf $$bd/rustc-$$newver.0-beta.999-src.tar.xz rustc-beta-src/version; \
0a1981fb 498 bv="$$(sed -re 's/[0-9]+.[0-9]+.[0-9]+-beta.([0-9]+) \(.*\)/\1/g' rustc-beta-src/version)"; \
d377cbf5 499 bash -c 'shopt -s nullglob; for i in '"$$bd"'/rustc*beta.999*; do mv $$i $${i/beta.999/beta.'"$$bv"'}; done'; \
3af75deb
XL
500 rm -f rustc-beta-src/version; \
501 rmdir -p rustc-beta-src; \
d377cbf5 502 echo "prepared rustc $$newver.0~beta.$$bv in $$bd"