]> git.proxmox.com Git - rustc.git/blame - debian/rules
Delete debian/patches/u-0001-librustc_codegen_llvm-Don-t-eliminate-empty-structs...
[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
4888e768 17# TODO: more correct to use `[build] rustflags = []` list syntax in Cargo.toml
9197bf09 18RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS))
7d40d3e1 19export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
08170615 20RUSTFLAGS += --remap-path-prefix=$(CURDIR)=/usr/src/rustc-$(RUST_LONG_VERSION)
ab330327
XL
21ifneq (,$(filter $(DEB_BUILD_ARCH), sparc64))
22export CARGO_INCREMENTAL = 0
23endif
b59979d9 24
525ff0f9
AL
25# Defines DEB_*_RUST_TYPE triples
26include debian/architecture.mk
693daed7 27export DEB_HOST_RUST_TYPE
525ff0f9 28
be771b38
LB
29# Uncomment this to turn on verbose mode.
30#export DH_VERBOSE=1
31
8354de7a 32DEB_DESTDIR := $(CURDIR)/debian/tmp
525ff0f9 33
525ff0f9 34# Use system LLVM (comment out to use vendored LLVM)
5cb19022
XL
35LLVM_VERSION = 7
36OLD_LLVM_VERSION = 6.0
2b7c35b5
XL
37# Make it easier to test against a custom LLVM
38ifneq (,$(LLVM_DESTDIR))
56548b60
XL
39LLVM_LIBRARY_PATH := $(LLVM_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH):$(LLVM_DESTDIR)/usr/lib
40LD_LIBRARY_PATH := $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):$(LLVM_LIBRARY_PATH),$(LLVM_LIBRARY_PATH))
2b7c35b5
XL
41export LD_LIBRARY_PATH
42endif
2b7c35b5 43
8e396fda 44RUSTBUILD = RUST_BACKTRACE=1 ./x.py
33416cd4 45RUSTBUILD_FLAGS = --config debian/config.toml -vvv --on-fail env
f1b4ffd3
XL
46# TODO: This should simply be "$(RUSTBUILD) test" but unfortunately this causes
47# an insane blow up in the time it takes to run tests. See upstream #37477 for
48# details. Upstream worked around it in #38984 but in Debian we can't take
49# advantage of that work-around, because we want as much debuginfo as possible
50# (so we set debuginfo-lines = true, debuginfo-only-std = false) so we have to
51# work around it instead by disabling backtrace when running tests.
52RUSTBUILD_TEST = ./x.py test
0d3674eb
XL
53# To run a specific test, run something like:
54# $ debian/rules override_dh_auto_test-arch \
55# RUSTBUILD_TEST_FLAGS="src/test/run-make --test-args extern-fn-struct"
56# See src/bootstrap/README.md for more options.
57RUSTBUILD_TEST_FLAGS =
1c8ac2b0 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
SL
115endif
116
5861ebac 117MAKE_OPTIMISATIONS := true
1c8ac2b0 118ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
5861ebac 119 MAKE_OPTIMISATIONS := false
1c8ac2b0
SL
120endif
121
35329365 122# Build products or non-source files in src/, that shouldn't go in rust-src
9a2ab7ea 123SRC_CLEAN = src/bootstrap/bootstrap.pyc \
35329365 124 src/etc/__pycache__/
1c8ac2b0 125
170f9149
XL
126# Workaround for linux #865549
127ifeq (0,$(shell test $$(uname -s) = "Linux" -a $$(getconf PAGESIZE) -gt 4096; echo $$?))
128 SYSTEM_WORKAROUNDS += ulimit -s $$(expr $$(getconf PAGESIZE) / 1024 '*' 256 + 8192);
129endif
130
be771b38 131%:
170f9149 132 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
be771b38 133
04c12273
XL
134.PHONY: build
135build:
170f9149 136 $(SYSTEM_WORKAROUNDS) dh $@ --parallel
04c12273 137
de1de54b 138override_dh_clean:
cf0b146d
XL
139 # Upstream contains a lot of these
140 dh_clean -XCargo.toml.orig
de1de54b 141
b49766ad
XL
142debian/config.toml: debian/config.toml.in debian/rules
143 u="$(DEB_VERSION_UPSTREAM)"; \
144 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then channel="beta"; \
145 else channel="stable"; fi; echo $$channel; \
01dc6ef4
XL
146 m4 -DDEB_BUILD_RUST_TYPE="$(DEB_BUILD_RUST_TYPE)" \
147 -DDEB_HOST_RUST_TYPE="$(DEB_HOST_RUST_TYPE)" \
148 -DDEB_TARGET_RUST_TYPE="$(DEB_TARGET_RUST_TYPE)" \
b49766ad 149 -DRELEASE_CHANNEL="$$channel" \
5861ebac 150 -DMAKE_OPTIMISATIONS="$(MAKE_OPTIMISATIONS)" \
2b7c35b5 151 -DLLVM_DESTDIR="$(LLVM_DESTDIR)" \
666f0397 152 -DLLVM_VERSION="$(LLVM_VERSION)" \
5861ebac 153 -DRUST_DESTDIR="$(RUST_DESTDIR)" \
01dc6ef4 154 "$<" > "$@"
7ee10b55
XL
155 if $(DOWNLOAD_BOOTSTRAP) || [ $(HAVE_BINARY_TARBALL) != 0 ]; \
156 then sed -i -e '/^rustc = /d' -e '/^cargo = /d' "$@"; fi
e8cad677 157# Work around low-memory (32-bit) architectures: https://github.com/rust-lang/rust/issues/45854
3997b412 158ifneq (,$(filter $(DEB_BUILD_ARCH), armhf armel mips mipsel powerpc powerpcspe))
2e2d9bd1
XL
159 sed -i -e '/^debuginfo-only-std = /d' "$@"
160endif
01dc6ef4 161
b5dfb68c
XL
162debian/rust-src.%: debian/rust-src.%.in
163 m4 -DRUST_LONG_VERSION="$(RUST_LONG_VERSION)" \
164 "$<" > "$@"
165
3bdf427a 166debian/dh_auto_configure.stamp: debian/config.toml
5617e1bd 167 # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
e67d3c13 168 ! grep --color=always -i 'll...\?$(subst .,\.,$(OLD_LLVM_VERSION))' --exclude=changelog --exclude='*.patch' -R debian
e133b084 169 # fail the build if our version contains ~exp and we are not releasing to experimental
b49766ad 170 v="$(DEB_VERSION)"; test "$$v" = "$${v%~exp*}" -o "$(DEB_DISTRIBUTION)" = "experimental" -o "$(DEB_DISTRIBUTION)" = "UNRELEASED"
427dce5b 171 $(PRECONFIGURE_CHECK)
75be2bb3 172 if [ -d stage0 ]; then mkdir -p build && ln -sfT ../stage0 build/cache; fi
3281855a
XL
173 # work around #842634
174 if test $$(grep "127.0.0.1\s*localhost" /etc/hosts | wc -l) -gt 1; then \
ed6f7eed 175 debian/ensure-patch -N debian/patches/d-host-duplicates.patch; fi
ec365981
XL
176 # work around https://github.com/rust-lang/rust/issues/59264
177 # TODO: remove this in 1.33 and later
178 if dpkg --compare-versions $(LOCAL_RUST_VERSION) '>=' 1.32.0; then \
179 debian/ensure-patch -N debian/patches/u-compiletest.patch; \
180 else \
181 debian/ensure-patch -R debian/patches/u-compiletest.patch; \
182 fi
98955da7 183 # We patched some crates so have to rm the checksums
f56f18fe 184 find vendor -name .cargo-checksum.json -execdir "$(CURDIR)/debian/prune-checksums" "{}" ";"
6b0d97fc
XL
185 # Unfortunately upstream uses a duplicate copy of libbacktrace and wants to
186 # compile it again for rust-installer, see #43449
f56f18fe 187 ln -rsf src/libbacktrace -t vendor/backtrace-sys/src/
6b0d97fc 188 # Link against system liblzma, see https://github.com/alexcrichton/xz2-rs/issues/16
f56f18fe 189 echo 'fn main() { println!("cargo:rustc-link-lib=lzma"); }' > vendor/lzma-sys/build.rs
5861ebac
XL
190 # We don't run ./configure because we use debian/config.toml directly
191 ln -sf debian/config.toml config.toml
3bdf427a
XL
192 touch "$@"
193
194override_dh_auto_configure-arch: debian/dh_auto_configure.stamp
195override_dh_auto_configure-indep: debian/dh_auto_configure.stamp
196ifeq (true,$(BUILD_DOCS))
197# Change config.toml now and not later, since that might trigger a rebuild
198 sed -i -e 's/^docs = false/docs = true/' debian/config.toml
199endif
1c8ac2b0 200
11c430be 201override_dh_auto_clean:
f40dfcc0 202 $(RM) -rf ./build ./tmp ./.cargo config.stamp config.mk Makefile
3bdf427a 203 $(RM) -rf $(TEST_LOG) debian/config.toml debian/rust-src.install debian/rust-src.links debian/*.stamp
f56f18fe 204 $(RM) -rf $(SRC_CLEAN) config.toml vendor/backtrace-sys/src/libbacktrace
11c430be 205
3bdf427a 206override_dh_auto_build-arch:
04c12273 207 $(RUSTBUILD) build $(RUSTBUILD_FLAGS)
ea192313 208
e408bc2c
XL
209# note: this is only for buildds that want to do a separate arch:all build;
210# there is no point running this yourself "to save time" since it implicitly
211# depends on build-arch anyways.
3bdf427a 212override_dh_auto_build-indep:
5861ebac 213ifeq (true,$(BUILD_DOCS))
04c12273
XL
214 $(RUSTBUILD) doc $(RUSTBUILD_FLAGS)
215endif
216
3a774f0f 217TEST_LOG = debian/rustc-tests.log
356c70ca
XL
218# This is advertised as "5 tests failed" in README.Debian because our counting
219# method is imprecise and in practise we count some failures twice.
0b9f599a 220FAILURES_ALLOWED = 8
e8cad677 221ifneq (,$(filter $(DEB_BUILD_ARCH), ppc64 arm64 mips64el))
6404b712 222 FAILURES_ALLOWED = 12
fa6232de 223endif
e8cad677 224ifneq (,$(filter $(DEB_BUILD_ARCH), mips mipsel s390x))
15f51d41 225 FAILURES_ALLOWED = 24
ab330327 226endif
734d072d 227ifneq (,$(filter $(DEB_BUILD_ARCH), powerpc powerpcspe sparc64 x32))
617a87c6 228 FAILURES_ALLOWED = 180
734d072d 229endif
873d1fa5 230FAILED_TESTS = grep "FAILED\|^command did not execute successfully" $(TEST_LOG) | grep -v '^test result: FAILED'
7958f3db 231override_dh_auto_test-arch:
91d3be64 232 # ensure that rustc_llvm is actually dynamically linked to libLLVM
347f6206
XL
233 set -e; find build/*/stage2/lib/rustlib/* -name '*rustc_llvm*.so' | \
234 while read x; do \
235 stat -c '%s %n' "$$x"; \
236 objdump -p "$$x" | grep -q "NEEDED.*LLVM"; \
237 test "$$(stat -c %s "$$x")" -lt 6000000; \
238 done
68e7eb97 239ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
7958f3db 240ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
2c22371f 241 { $(RUSTBUILD_TEST) --no-fail-fast $(RUSTBUILD_FLAGS) $(RUSTBUILD_TEST_FLAGS); echo $$?; } | tee -a $(TEST_LOG)
91d3be64 242 # test that the log has at least 1 pass, to prevent e.g. #57709
bbceb41b 243 grep -l "^test .* \.\.\. ok$$" $(TEST_LOG)
2c22371f
XL
244 echo "==== Debian rustc test report ===="; \
245 echo "Specific test failures:"; \
3a774f0f 246 $(FAILED_TESTS); \
873d1fa5 247 num_failures=$$($(FAILED_TESTS) | wc -l); \
2c22371f
XL
248 exit_code=$$(tail -n1 $(TEST_LOG)); \
249 echo "Summary: exit code $$exit_code, counted $$num_failures tests failed."; \
250 echo -n "$(FAILURES_ALLOWED) maximum allowed. "; \
251 if test "$$num_failures" -eq 0 -a "$$exit_code" -ne 0; then \
252 echo "Aborting just in case, because we missed counting some test failures."; \
6404b712 253 echo "This could happen if we failed to build the tests, or if the testsuite runner is buggy."; \
2c22371f
XL
254 false; \
255 elif test "$$num_failures" -le $(FAILURES_ALLOWED); then \
3a774f0f
XL
256 echo "Continuing..."; \
257 else \
258 echo "Aborting the build."; \
259 echo "Check the logs further above for details."; \
260 false; \
261 fi
0d3674eb
XL
262# don't continue if RUSTBUILD_TEST_FLAGS is non-empty
263 test -z "$(RUSTBUILD_TEST_FLAGS)"
e408bc2c 264endif
68e7eb97 265endif
becfe001 266
04c12273 267override_dh_auto_test-indep:
5861ebac 268ifeq (true,$(BUILD_DOCS))
68e7eb97 269ifeq (, $(filter nocheck,$(DEB_BUILD_PROFILES)))
7958f3db
XL
270ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
271 # Run all rules that test the docs, i.e. in step.rs that depend on default:doc
3a774f0f 272 $(RUSTBUILD_TEST) --no-fail-fast src/tools/linkchecker $(RUSTBUILD_FLAGS)
7958f3db
XL
273endif
274endif
68e7eb97 275endif
04c12273 276
bf52bd52
XL
277run_rustbuild:
278 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) $(X_CMD) $(RUSTBUILD_FLAGS) $(X_FLAGS)
279
3bdf427a 280debian/dh_auto_install.stamp:
6a9e99e9 281 DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) install $(RUSTBUILD_FLAGS)
525ff0f9
AL
282
283 mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
284 mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
6fce0a99 285
1261b4b3 286 # Replace duplicated compile-time/run-time dylibs with symlinks
525ff0f9
AL
287 @set -e; \
288 for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
289 name=$${f##*/}; \
290 if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
291 echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
292 ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
293 fi; \
1261b4b3
AL
294 done
295
3bdf427a
XL
296 touch "$@"
297
298override_dh_auto_install-arch: debian/dh_auto_install.stamp
299override_dh_auto_install-indep: debian/dh_auto_install.stamp
5861ebac 300ifeq (true,$(BUILD_DOCS))
6fce0a99
SL
301 # Brute force to remove privacy-breach-logo lintian warning.
302 # We could have updated the upstream sources but it would complexify
303 # the rebase
b556761e
AL
304 @set -e; \
305 find $(DEB_DESTDIR)/usr/share/doc/rust/html -iname '*.html' | \
1add0b94 306 while read file; do \
b556761e 307 topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
92f6ea48 308 sed -i -e "s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
87a30969 309 -e "s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \
1add0b94 310 done
b125a683
MO
311 find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete;
312endif
313
cf9ecdde 314override_dh_install-arch:
6fce0a99 315 dh_install
525ff0f9 316 dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/
cd17b70a 317 dh_install -plibstd-rust-dev usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/
b4ca3996 318 dh_install -prustc usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/codegen-backends/
525ff0f9 319
b5dfb68c 320override_dh_install-indep: debian/rust-src.install debian/rust-src.links
a0022868 321 dh_install
525ff0f9
AL
322 chmod -x \
323 debian/rust-gdb/usr/share/rust-gdb/*.py \
324 debian/rust-lldb/usr/share/rust-lldb/*.py
b5dfb68c 325 $(RM) -rf $(SRC_CLEAN:%=debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION)/%)
f40dfcc0 326 # Get rid of lintian warnings
b5dfb68c 327 find debian/rust-src/usr/src/rustc-$(RUST_LONG_VERSION) \
f40dfcc0
XL
328 \( -name .gitignore \
329 -o -name 'LICENSE*' \
330 -o -name 'LICENCE' \
331 -o -name 'license' \
332 -o -name 'COPYING*' \
333 \) -delete
8d3e3cd2 334 # Remove files that autoload remote resources, caught by lintian
f56f18fe
XL
335 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/cssparser/docs/*.html
336 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/kuchiki/docs/*.html
337 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/url/docs/*.html
338 $(RM) -rf debian/rust-src/usr/src/rustc-*/vendor/xz2/.gitmodules
1c8ac2b0 339
bc0aa84e
AL
340override_dh_installchangelogs:
341 dh_installchangelogs RELEASES.md
342
343override_dh_installdocs:
344 dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
345
5c515547
XL
346override_dh_missing:
347 dh_missing --list-missing
348
eef1f4e3
AL
349override_dh_compress:
350 dh_compress -X.woff
351
d2456730
XL
352override_dh_strip:
353 # Work around #35733, #468333
354 find debian/libstd-rust-dev/ -name '*.rlib' -execdir mv '{}' '{}.a' \;
355 # This is expected to print out lots of "File format unrecognized" warnings about
356 # rust.metadata.bin and *.deflate but the .o files inside the rlibs should be stripped
357 # Some files are still omitted because of #875780 however.
358 dh_strip -v
359 find debian/libstd-rust-dev/ -name '*.rlib.a' -execdir sh -c 'mv "$$1" "$${1%.a}"' - '{}' \;
360
525ff0f9
AL
361override_dh_makeshlibs:
362 dh_makeshlibs -V
363
364 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
365 # structure, so we have to do this ourselves.
366 install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN
33766656 367 LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
525ff0f9
AL
368 sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
369 while read name version; do \
370 echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
371 done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
372 chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
373 chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
374
375override_dh_shlibdeps:
376 dh_shlibdeps -- -x$(LIBSTD_PKG)
427dce5b
XL
377
378QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi
75be2bb3 379source_orig-stage0:
16dfb283
XL
380 QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
381 $(MAKE) -f debian/rules clean
75be2bb3 382 debian/make_orig-stage0_tarball.sh
16dfb283
XL
383 QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
384 rm -rf .pc
15ab0b38 385
0a1981fb
XL
386get_beta_version = \
387 u="$(DEB_VERSION_UPSTREAM)"; \
388 if [ "$$u" != "$${u%~beta.*+dfsg*}" ]; then \
389 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2)/e'); \
390 else \
15ab0b38 391 newver=$(shell echo $(RUST_VERSION) | perl -lpe 's/(\d+)\.(\d+)/$$1 . "." . ($$2+1)/e'); \
0a1981fb
XL
392 fi
393
394debian/watch-beta: debian/watch-beta.in debian/rules
395 set -e; $(get_beta_version); \
15ab0b38
XL
396 m4 -DOLDVER="$$oldver" -DNEWVER="$$newver.0" "$<" > "$@"
397
398source_orig-beta: debian/watch-beta
d377cbf5 399 uscan $(USCAN_OPTS) $(if $(USCAN_DESTDIR),--destdir=$(USCAN_DESTDIR),) --verbose --watchfile "$<"
0a1981fb 400 set -e; $(get_beta_version); \
d377cbf5
XL
401 bd="$(if $(USCAN_DESTDIR),$(USCAN_DESTDIR),..)"; \
402 tar xf $$bd/rustc-$$newver.0-beta.999-src.tar.xz rustc-beta-src/version; \
0a1981fb 403 bv="$$(sed -re 's/[0-9]+.[0-9]+.[0-9]+-beta.([0-9]+) \(.*\)/\1/g' rustc-beta-src/version)"; \
d377cbf5 404 bash -c 'shopt -s nullglob; for i in '"$$bd"'/rustc*beta.999*; do mv $$i $${i/beta.999/beta.'"$$bv"'}; done'; \
3af75deb
XL
405 rm -f rustc-beta-src/version; \
406 rmdir -p rustc-beta-src; \
d377cbf5 407 echo "prepared rustc $$newver.0~beta.$$bv in $$bd"