]>
Commit | Line | Data |
---|---|---|
be771b38 LB |
1 | #!/usr/bin/make -f |
2 | # -*- makefile -*- | |
3 | ||
b59979d9 | 4 | include /usr/share/dpkg/pkg-info.mk |
d75d48d6 | 5 | include /usr/share/dpkg/architecture.mk |
7d40d3e1 | 6 | include /usr/share/dpkg/buildflags.mk |
a1140187 XL |
7 | #RUSTFLAGS = -C link-args="$(LDFLAGS)" |
8 | # temporary workaround for https://github.com/rust-lang/rust/issues/31529 | |
9 | # this will FAIL if LDFLAGS itself contains shell-interpreted chars beyond | |
10 | # unquoted spaces (that addprefix works around the failure of) | |
11 | RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS)) | |
7d40d3e1 | 12 | export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS |
b59979d9 | 13 | |
7277ece0 XL |
14 | # see https://github.com/rust-lang/rust/issues/37320 |
15 | # it should be possible to remove this in the next Debian release | |
16 | export MALLOC_CONF = lg_dirty_mult:-1 | |
17 | ||
525ff0f9 AL |
18 | # Defines DEB_*_RUST_TYPE triples |
19 | include debian/architecture.mk | |
20 | ||
be771b38 LB |
21 | # Uncomment this to turn on verbose mode. |
22 | #export DH_VERBOSE=1 | |
23 | ||
03b69fec JJ |
24 | # When using sudo pbuilder, this will cause mk/install.mk to run sudo, |
25 | # but we don't need sudo as a build-dep for the package if we unexport | |
26 | # the SUDO_USER variable. | |
27 | unexport SUDO_USER | |
28 | ||
c2a1d9e3 AL |
29 | # src/rt/miniz.c (incorrectly) triggers -Wmisleading-indentation with |
30 | # gcc-6. See bug #811573. | |
31 | CFLAGS += -Wno-misleading-indentation | |
32 | ||
d4357a26 | 33 | # Release type (one of beta, stable or nightly) |
0f9154de | 34 | RELEASE_CHANNEL := stable |
6935ded2 XL |
35 | # See also ./build-preview-dsc.sh for a script that builds a beta/nightly .dsc |
36 | # out of this packaging. Furthermore, if the build breaks after importing a new | |
37 | # upstream stable release, check the do_temporary_fixup function in that file | |
38 | # to see if we already know what fix to make. | |
d4357a26 | 39 | |
8354de7a | 40 | DEB_DESTDIR := $(CURDIR)/debian/tmp |
525ff0f9 | 41 | |
1ce0c197 | 42 | RUST_VERSION := $(shell dpkg-parsechangelog --show-field Version | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/') |
b125a683 | 43 | RUST_LONG_VERSION := $(shell dpkg-parsechangelog --show-field Version | sed -re 's/([^+]+).*/\1/') |
888747f5 | 44 | LIBSTD_PKG := libstd-rust-$(RUST_VERSION) |
02b74708 | 45 | |
be771b38 | 46 | # These are the normal build flags |
525ff0f9 | 47 | DEB_CONFIGURE_FLAGS = \ |
04c12273 | 48 | --build=$(DEB_BUILD_RUST_TYPE) \ |
525ff0f9 AL |
49 | --host=$(DEB_HOST_RUST_TYPE) \ |
50 | --target=$(DEB_TARGET_RUST_TYPE) \ | |
be771b38 | 51 | --disable-manage-submodules \ |
d4357a26 | 52 | --release-channel=$(RELEASE_CHANNEL) \ |
04c12273 XL |
53 | --prefix=/usr \ |
54 | --enable-vendor --disable-locked-deps \ | |
55 | --enable-llvm-link-shared | |
be771b38 | 56 | |
525ff0f9 | 57 | # Use system LLVM (comment out to use vendored LLVM) |
5617e1bd | 58 | OLD_LLVM_VERSION = 3.8 |
893bf96c | 59 | DEB_CONFIGURE_FLAGS += --llvm-root=/usr/lib/llvm-3.9 |
04c12273 XL |
60 | RUSTBUILD = ./x.py |
61 | RUSTBUILD_FLAGS = -v | |
1c8ac2b0 | 62 | |
427dce5b XL |
63 | # Below we detect how we're supposed to bootstrap the stage0 compiler. See |
64 | # README.Debian for more details of the cases described below. | |
65 | # | |
66 | # Sed expression that matches the "rustc" we have in our Build-Depends field | |
67 | SED_RUSTC_BUILDDEP := /^Build-Depends:/,/^[^[:space:]\#]/{/\s*rustc.*,/$$action} | |
68 | PRECONFIGURE_CHECK = : | |
571f0d20 MK |
69 | HAVE_BINARY_TARBALL := $(shell ls -1 dl/*$(DEB_HOST_RUST_TYPE)* 2>/dev/null | wc -l) |
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 | |
74 | ifeq (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))) | |
83 | DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/usr | |
84 | endif | |
85 | # | |
86 | # Case A-2: the builder selected the "dlstage0" build profile. | |
87 | # In this case, the rust build scripts will download a stage0 into dl/ and use that. | |
b9a40c91 | 88 | # We don't need to do anything specific in this build file, so this case is empty. |
427dce5b | 89 | else |
16dfb283 XL |
90 | # Case B (Bootstrapping a new distro): the extracted source tree does |
91 | # include a bootstrapping tarball for the current architecture; see the | |
92 | # `source_orig-dl` target below on how to build this. | |
427dce5b XL |
93 | # |
94 | # In this case, we'll bootstrap from the stage0 given in that tarball. | |
95 | # To ensure the uploader of the .dsc didn't make a mistake, we first check | |
16dfb283 | 96 | # that rustc isn't a Build-Depends for the current architecture. |
427dce5b | 97 | ifneq (,$(shell action=p; sed -ne "$(SED_RUSTC_BUILDDEP)" debian/control)) |
16dfb283 XL |
98 | ifeq (,$(shell action=p; sed -ne "$(SED_RUSTC_BUILDDEP)" debian/control | grep '!$(DEB_HOST_ARCH)')) |
99 | PRECONFIGURE_CHECK = $(error found matches for dl/*$(DEB_HOST_RUST_TYPE)*, \ | |
100 | but rustc might be a Build-Depends for $(DEB_HOST_ARCH)) | |
101 | endif | |
427dce5b | 102 | endif |
1c8ac2b0 SL |
103 | endif |
104 | ||
105 | BUILD_DOCS = 1 | |
120b4d47 | 106 | ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES))) |
525ff0f9 | 107 | DEB_CONFIGURE_FLAGS += --disable-docs |
2e97839d | 108 | BUILD_DOCS = |
1c8ac2b0 SL |
109 | endif |
110 | ||
b125a683 MO |
111 | BUILD_SRC = 1 |
112 | ifneq (,$(findstring pkg.rust.nosrc,$(DEB_BUILD_PROFILES))) | |
113 | DEB_CONFIGURE_FLAGS += --disable-dist-src | |
114 | BUILD_SRC = | |
115 | endif | |
116 | ||
1c8ac2b0 | 117 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) |
525ff0f9 | 118 | DEB_CONFIGURE_FLAGS += --disable-optimize --disable-optimize-cxx --disable-optimize-llvm |
1c8ac2b0 SL |
119 | endif |
120 | ||
71d68bff | 121 | # Workaround for powerpc64le: no optimization |
2c303438 | 122 | # TODO: can remove when https://github.com/rust-lang/rust/issues/39015 is fixed |
71d68bff EP |
123 | ifneq (,$(findstring powerpc64le,$(DEB_TARGET_RUST_TYPE))) |
124 | DEB_CONFIGURE_FLAGS += --disable-optimize --disable-optimize-cxx --disable-optimize-llvm | |
125 | endif | |
126 | ||
1c8ac2b0 | 127 | |
be771b38 | 128 | %: |
2679d355 | 129 | dh $@ --parallel |
be771b38 | 130 | |
04c12273 XL |
131 | .PHONY: build |
132 | build: | |
133 | dh $@ --parallel | |
134 | ||
7a06551f | 135 | # Note: SHELL is not set by dash, but the configure script wants to use it |
be771b38 | 136 | override_dh_auto_configure: |
5617e1bd XL |
137 | # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog |
138 | ! grep --color=always -i 'll...$(OLD_LLVM_VERSION)' --exclude=changelog -R debian | |
427dce5b | 139 | $(PRECONFIGURE_CHECK) |
04c12273 XL |
140 | cp debian/config.toml src/bootstrap/config.toml |
141 | mkdir cargo # otherwise "install" fails, it's more strict than really needed | |
1b451206 | 142 | SHELL=/bin/sh PATH="$$PWD/debian/bin:$$PATH" DEB_HOST_ARCH="$(DEB_HOST_ARCH)" \ |
525ff0f9 | 143 | ./configure $(DEB_CONFIGURE_FLAGS) |
1c8ac2b0 | 144 | |
11c430be | 145 | override_dh_auto_clean: |
8c87ab10 | 146 | $(RM) -rf ./build ./tmp ./.cargo src/etc/__pycache__/ config.stamp config.mk Makefile ./cargo |
ee41b679 | 147 | $(RM) src/rt/hoedown/src/html_blocks.c # clean up after building this ourselves |
04c12273 | 148 | $(RM) src/bootstrap/bootstrap.pyc src/bootstrap/config.toml |
11c430be | 149 | |
ea192313 XL |
150 | # upstream bundles this in the source, but in Debian we rebuild everything yo |
151 | generate-sources: | |
152 | $(MAKE) -C src/rt/hoedown src/html_blocks.c | |
1c8ac2b0 | 153 | |
ea192313 | 154 | override_dh_auto_build-arch: generate-sources |
04c12273 | 155 | $(RUSTBUILD) build $(RUSTBUILD_FLAGS) |
ea192313 | 156 | |
e408bc2c XL |
157 | # note: this is only for buildds that want to do a separate arch:all build; |
158 | # there is no point running this yourself "to save time" since it implicitly | |
159 | # depends on build-arch anyways. | |
ea192313 | 160 | override_dh_auto_build-indep: generate-sources |
e408bc2c | 161 | ifneq (,$(BUILD_DOCS)) |
04c12273 XL |
162 | $(RUSTBUILD) doc $(RUSTBUILD_FLAGS) |
163 | endif | |
164 | ||
165 | override_dh_auto_test-arch: | |
166 | ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS))) | |
167 | # Use non-parallel $(MAKE) here instead of dh_auto_test, otherwise the upstream | |
168 | # Makefile will try to run N instances of the testrunner each of which will run | |
169 | # N instances of rustc (there is also parallel logic in libtest.rs already). | |
170 | if RUST_BACKTRACE=1 $(RUSTBUILD) test $(RUSTBUILD_FLAGS); then \ | |
171 | : ; \ | |
172 | elif [ $(DEB_DISTRIBUTION) != "experimental" ]; then \ | |
173 | false; \ | |
174 | else \ | |
175 | echo "====================================================="; \ | |
176 | echo "WARNING: Ignoring test failures in the rust testsuite"; \ | |
177 | echo "====================================================="; \ | |
178 | fi | |
e408bc2c | 179 | endif |
becfe001 | 180 | |
04c12273 XL |
181 | # No tests are applicable when only building arch:all packages. |
182 | # More specifically: when we do an arch-all build, some crates are not built. | |
183 | # This makes some arch-dependent tests fail, so don't run them here. | |
184 | override_dh_auto_test-indep: | |
185 | true | |
186 | ||
23d2674b | 187 | override_dh_auto_install: |
04c12273 | 188 | DESTDIR=$(DEB_DESTDIR) $(RUSTBUILD) dist $(RUSTBUILD_FLAGS) --install |
525ff0f9 AL |
189 | |
190 | mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/ | |
191 | mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/ | |
6fce0a99 | 192 | |
1261b4b3 | 193 | # Replace duplicated compile-time/run-time dylibs with symlinks |
525ff0f9 AL |
194 | @set -e; \ |
195 | for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \ | |
196 | name=$${f##*/}; \ | |
197 | if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \ | |
198 | echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \ | |
199 | ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \ | |
200 | fi; \ | |
1261b4b3 AL |
201 | done |
202 | ||
525ff0f9 | 203 | ifneq (,$(BUILD_DOCS)) |
6fce0a99 SL |
204 | # Brute force to remove privacy-breach-logo lintian warning. |
205 | # We could have updated the upstream sources but it would complexify | |
206 | # the rebase | |
b556761e AL |
207 | @set -e; \ |
208 | find $(DEB_DESTDIR)/usr/share/doc/rust/html -iname '*.html' | \ | |
1add0b94 | 209 | while read file; do \ |
b556761e | 210 | topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \ |
92f6ea48 | 211 | sed -i -e "s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \ |
87a30969 | 212 | -e "s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \ |
1add0b94 | 213 | done |
b125a683 MO |
214 | find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete; |
215 | endif | |
216 | ||
217 | ifneq (,$(BUILD_SRC)) | |
218 | # extract library source | |
219 | mkdir -p $(DEB_DESTDIR)/usr/src; | |
220 | tar --strip-components=5 -xzf $(CURDIR)/build/dist/rust-src-$(RUST_LONG_VERSION).tar.gz -C $(DEB_DESTDIR)/usr/src | |
2e97839d | 221 | endif |
525ff0f9 | 222 | |
cf9ecdde | 223 | override_dh_install-arch: |
6fce0a99 | 224 | dh_install |
525ff0f9 AL |
225 | dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/ |
226 | ||
a0022868 XL |
227 | override_dh_install-indep: |
228 | dh_install | |
525ff0f9 AL |
229 | chmod -x \ |
230 | debian/rust-gdb/usr/share/rust-gdb/*.py \ | |
231 | debian/rust-lldb/usr/share/rust-lldb/*.py | |
1c8ac2b0 | 232 | |
bc0aa84e AL |
233 | override_dh_installchangelogs: |
234 | dh_installchangelogs RELEASES.md | |
235 | ||
236 | override_dh_installdocs: | |
237 | dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc | |
238 | ||
eef1f4e3 AL |
239 | override_dh_compress: |
240 | dh_compress -X.woff | |
241 | ||
525ff0f9 AL |
242 | override_dh_makeshlibs: |
243 | dh_makeshlibs -V | |
244 | ||
245 | # dh_makeshlibs doesn't support our "libfoo-version.so" naming | |
246 | # structure, so we have to do this ourselves. | |
247 | install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN | |
33766656 | 248 | LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \ |
525ff0f9 AL |
249 | sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \ |
250 | while read name version; do \ | |
251 | echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \ | |
252 | done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs | |
253 | chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs | |
254 | chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs | |
255 | ||
256 | override_dh_shlibdeps: | |
257 | dh_shlibdeps -- -x$(LIBSTD_PKG) | |
427dce5b XL |
258 | |
259 | QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi | |
16dfb283 XL |
260 | source_orig-dl: |
261 | QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE) | |
262 | $(MAKE) -f debian/rules clean | |
427dce5b | 263 | debian/make_orig-dl_tarball.sh |
16dfb283 XL |
264 | QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE) |
265 | rm -rf .pc |