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