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