4 include /usr
/share
/dpkg
/pkg-info.mk
5 include /usr
/share
/dpkg
/vendor.mk
6 include /usr
/share
/dpkg
/architecture.mk
7 include /usr
/share
/dpkg
/buildflags.mk
8 # TODO: more correct to use `[build] rustflags = []` list syntax in Cargo.toml
9 RUSTFLAGS
= $(addprefix -C link-args
=,$(LDFLAGS
))
10 export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
12 # Defines DEB_*_RUST_TYPE triples
13 include debian
/architecture.mk
14 export DEB_HOST_RUST_TYPE
16 # Uncomment this to turn on verbose mode.
19 # src/rt/miniz.c (incorrectly) triggers -Wmisleading-indentation with
20 # gcc-6. See bug #811573.
21 CFLAGS
+= -Wno-misleading-indentation
23 # Release type (one of beta, stable or nightly)
24 RELEASE_CHANNEL
:= stable
25 # See also ./build-preview-dsc.sh for a script that builds a beta/nightly .dsc
26 # out of this packaging. Furthermore, if the build breaks after importing a new
27 # upstream stable release, check the do_temporary_fixup function in that file
28 # to see if we already know what fix to make.
30 DEB_DESTDIR
:= $(CURDIR
)/debian
/tmp
32 SED_VERSION_SHORT
:= sed
-re
's/([^.]+)\.([^.]+)\..*/\1.\2/'
33 RUST_VERSION
:= $(shell echo
'$(DEB_VERSION_UPSTREAM)' |
$(SED_VERSION_SHORT
))
34 RUST_LONG_VERSION
:= $(shell echo
'$(DEB_VERSION_UPSTREAM)' | sed
-re
's/([^+]+).*/\1/')
35 LIBSTD_PKG
:= libstd-rust-
$(RUST_VERSION
)
36 # Sed expression that matches the "rustc" we have in our Build-Depends field
37 SED_RUSTC_BUILDDEP
:= sed
-ne
"/^Build-Depends:/,/^[^[:space:]\#]/{/^ *rustc:native .*,/p}" debian
/control
39 # These are the normal build flags. Upstream is moving to debian/config.toml
40 # but at the current version not all of these flags are available in that file.
41 # Certain flags also need to be kept here *as well as* debian/config.toml.in
42 # because of https://github.com/rust-lang/rust/issues/43295
43 DEB_CONFIGURE_FLAGS
= --enable-llvm-link-shared
--disable-dist-src
--prefix=/usr
--release-channel
=$(RELEASE_CHANNEL
) --disable-debuginfo-only-std
45 # Use system LLVM (comment out to use vendored LLVM)
46 OLD_LLVM_VERSION
= 3.8
47 DEB_CONFIGURE_FLAGS
+= --llvm-root
=/usr
/lib
/llvm-3.9
49 RUSTBUILD_FLAGS
= --config debian
/config.toml
-v
--on-fail env
52 oldver
=$(shell $(SED_RUSTC_BUILDDEP
) | sed
-ne
's/.*(<= \(.*\)).*/\1/gp' |
$(SED_VERSION_SHORT
)); \
53 newver
=$(RUST_VERSION
); \
54 if
[ $$oldver != $$newver ]; then debian
/update-version.sh
$$oldver $$newver; fi
56 # Below we detect how we're supposed to bootstrap the stage0 compiler. See
57 # README.Debian for more details of the cases described below.
59 PRECONFIGURE_CHECK
= :
60 HAVE_BINARY_TARBALL
:= $(shell ls
-1 stage0
/*/*$(DEB_HOST_RUST_TYPE
)* 2>/dev
/null | wc
-l
)
61 # allow not using the binary tarball although it exists
62 #ifneq (,$(filter $(DEB_HOST_ARCH), amd64 arm64 armhf i386 powerpc ppc64el s390x))
63 # HAVE_BINARY_TARBALL := 0
65 ifeq (0,$(HAVE_BINARY_TARBALL
))
66 # Case A (Building from source): the extracted source tree does not include
67 # a bootstrapping tarball for the current architecture e.g. because the
68 # distro already has a rustc for this arch, or the uploader expects that
69 # this requirement be fulfilled in some other way.
71 # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
72 # In this case, we use the distro's rustc - either the previous or current version.
73 ifeq (,$(findstring pkg.rustc.dlstage0
,$(DEB_BUILD_PROFILES
)))
74 DEB_CONFIGURE_FLAGS
+= --enable-local-rust
--local-rust-root
=/usr
77 # Case A-2: the builder selected the "dlstage0" build profile.
78 # In this case, the rust build scripts will download a stage0 into stage0/ and use that.
79 # We don't need to do anything specific in this build file, so this case is empty.
81 # Case B (Bootstrapping a new distro): the extracted source tree does
82 # include a bootstrapping tarball for the current architecture; see the
83 # `source_orig-stage0` target below on how to build this.
85 # In this case, we'll bootstrap from the stage0 given in that tarball.
86 # To ensure the uploader of the .dsc didn't make a mistake, we first check
87 # that rustc isn't a Build-Depends for the current architecture.
88 ifneq (,$(shell $(SED_RUSTC_BUILDDEP
)))
89 ifeq (,$(shell $(SED_RUSTC_BUILDDEP
) | grep
'!$(DEB_HOST_ARCH)'))
90 PRECONFIGURE_CHECK
= $(error found matches for stage0
/*/*$(DEB_HOST_RUST_TYPE
)*, \
91 but rustc might be a Build-Depends for
$(DEB_HOST_ARCH
))
97 ifneq (,$(findstring nodoc
,$(DEB_BUILD_PROFILES
)))
98 DEB_CONFIGURE_FLAGS
+= --disable-docs
102 ifneq (,$(findstring noopt
,$(DEB_BUILD_OPTIONS
)))
103 DEB_CONFIGURE_FLAGS
+= --disable-optimize
--disable-optimize-cxx
--disable-optimize-llvm
106 # Build products or non-source files in src/, that shouldn't go in rust-src
107 SRC_CLEAN
= src
/rt
/hoedown
/src
/html_blocks.c \
108 src
/bootstrap
/bootstrap.pyc \
111 # Workaround for linux #865549
112 ifeq (0,$(shell test $$(uname
-s
) = "Linux" -a
$$(getconf PAGESIZE
) -gt
4096; echo
$$?
))
113 SYSTEM_WORKAROUNDS
+= ulimit
-s
$$(expr
$$(getconf PAGESIZE
) / 1024 '*' 256 + 8192);
117 $(SYSTEM_WORKAROUNDS
) dh
$@
--parallel
121 $(SYSTEM_WORKAROUNDS
) dh
$@
--parallel
123 debian
/config.toml
: debian
/config.toml.in
124 m4
-DDEB_BUILD_RUST_TYPE
="$(DEB_BUILD_RUST_TYPE)" \
125 -DDEB_HOST_RUST_TYPE
="$(DEB_HOST_RUST_TYPE)" \
126 -DDEB_TARGET_RUST_TYPE
="$(DEB_TARGET_RUST_TYPE)" \
127 -DRELEASE_CHANNEL
="$(RELEASE_CHANNEL)" \
130 override_dh_auto_configure
: debian
/config.toml
131 # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
132 ! grep
--color
=always
-i
'll...?$(OLD_LLVM_VERSION)' --exclude
=changelog
-R debian
133 $(PRECONFIGURE_CHECK
)
134 if
[ -d stage0
]; then mkdir
-p build
&& ln
-sfT ..
/stage0 build
/cache
; fi
135 # work around #842634
136 if
test $$(grep
"127.0.0.1\s*localhost" /etc
/hosts | wc
-l
) -gt
1; then \
137 debian
/ensure-patch
-N debian
/patches
/d-host-duplicates.patch
; fi
138 PATH
="$$PWD/debian/bin:$$PATH" \
139 .
/configure
$(DEB_CONFIGURE_FLAGS
)
141 override_dh_auto_clean
:
142 $(RM
) -rf .
/build .
/tmp .
/.cargo config.stamp config.mk Makefile
143 $(RM
) -rf
$(SRC_CLEAN
) debian
/config.toml
145 # upstream bundles this in the source, but in Debian we rebuild everything yo
147 $(MAKE
) -C src
/rt
/hoedown src
/html_blocks.c
149 override_dh_auto_build-arch
: generate-sources
150 $(RUSTBUILD
) build
$(RUSTBUILD_FLAGS
)
152 # note: this is only for buildds that want to do a separate arch:all build;
153 # there is no point running this yourself "to save time" since it implicitly
154 # depends on build-arch anyways.
155 override_dh_auto_build-indep
: generate-sources
156 ifneq (,$(BUILD_DOCS
))
157 # Rust has a weird way of configuring whether to build docs or not
158 sed
-i
-e
's/^docs = false/docs = true/' debian
/config.toml
159 $(RUSTBUILD
) doc
$(RUSTBUILD_FLAGS
)
165 elif
[ $(DEB_VENDOR
) = "Debian" -a
$(DEB_DISTRIBUTION
) != "experimental" ]; then \
167 elif
[ $(DEB_VENDOR
) = "Ubuntu" -a
$(DEB_HOST_ARCH
) != "s390x" ]; then \
170 echo
"====================================================="; \
171 echo
"WARNING: Ignoring test failures in the rust testsuite"; \
172 echo
"====================================================="; \
175 override_dh_auto_test-arch
:
176 # ensure that rustc_llvm is actually dynamically linked to libLLVM
177 set
-e
; find build
/*/stage2
/lib
/rustlib
/* -name
'*rustc_llvm*.so' | \
179 stat
-c
'%s %n' "$$x"; \
180 objdump
-p
"$$x" | grep
-q
"NEEDED.*LLVM"; \
181 test "$$(stat -c %s "$$x")" -lt
6000000; \
183 ifeq (, $(filter nocheck
,$(DEB_BUILD_OPTIONS
)))
184 $(call RUN_TESTS
,RUST_BACKTRACE
=1 $(RUSTBUILD
) test --no-fail-fast
$(RUSTBUILD_FLAGS
))
187 override_dh_auto_test-indep
:
188 ifneq (,$(BUILD_DOCS
))
189 ifeq (, $(filter nocheck
,$(DEB_BUILD_OPTIONS
)))
190 # Run all rules that test the docs, i.e. in step.rs that depend on default:doc
191 $(call RUN_TESTS
,RUST_BACKTRACE
=1 $(RUSTBUILD
) test --no-fail-fast src
/tools
/linkchecker
$(RUSTBUILD_FLAGS
))
195 override_dh_auto_install
:
196 DESTDIR
=$(DEB_DESTDIR
) $(RUSTBUILD
) dist $(RUSTBUILD_FLAGS
) --install
198 mkdir
-p
$(DEB_DESTDIR
)/usr
/lib
/$(DEB_HOST_MULTIARCH
)/
199 mv
$(DEB_DESTDIR
)/usr
/lib
/lib
*.so
$(DEB_DESTDIR
)/usr
/lib
/$(DEB_HOST_MULTIARCH
)/
201 # Replace duplicated compile-time/run-time dylibs with symlinks
203 for f in
$(DEB_DESTDIR
)/usr
/lib
/rustlib
/$(DEB_HOST_RUST_TYPE
)/lib
/lib
*.so
; do \
205 if
[ -f
"$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
206 echo
"ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
207 ln
-sf ..
/..
/..
/$(DEB_HOST_MULTIARCH
)/$$name $$f; \
211 ifneq (,$(BUILD_DOCS
))
212 # Brute force to remove privacy-breach-logo lintian warning.
213 # We could have updated the upstream sources but it would complexify
216 find
$(DEB_DESTDIR
)/usr
/share
/doc
/rust
/html
-iname
'*.html' | \
217 while read file
; do \
218 topdir
=$$(echo
"$$file" | sed
's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
219 sed
-i
-e
"s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
220 -e
"s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \
222 find
$(DEB_DESTDIR
) \
( -iname
'*.html' -empty
-o
-name .lock
-o
-name
'*.inc' \
) -delete
;
225 override_dh_install-arch
:
227 dh_install
-p
$(LIBSTD_PKG
) usr
/lib
/$(DEB_HOST_MULTIARCH
)/
229 override_dh_install-indep
:
232 debian
/rust-gdb
/usr
/share
/rust-gdb
/*.py \
233 debian
/rust-lldb
/usr
/share
/rust-lldb
/*.py
234 $(RM
) -rf
$(SRC_CLEAN
:%=debian
/rust-src
/usr
/src
/rust
/%)
235 # Get rid of lintian warnings
236 find debian
/rust-src
/usr
/src
/rust \
237 \
( -name .gitignore \
238 -o
-name
'LICENSE*' \
241 -o
-name
'COPYING*' \
243 cd debian
/rust-src
/usr
/src
/rust
&& chmod
-x \
244 src
/etc
/gdb_rust_pretty_printing.py \
245 src
/etc
/adb_run_wrapper.sh \
246 src
/compiler-rt
/test/builtins
/Unit
/ppc
/test
248 override_dh_installchangelogs
:
249 dh_installchangelogs RELEASES.md
251 override_dh_installdocs
:
252 dh_installdocs
-X.
tex -X.aux
-X.log
-X.out
-X.toc
254 override_dh_compress
:
257 override_dh_makeshlibs
:
260 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
261 # structure, so we have to do this ourselves.
262 install -o
0 -g
0 -d debian
/$(LIBSTD_PKG
)/DEBIAN
263 LC_ALL
=C ls debian
/$(LIBSTD_PKG
)/usr
/lib
/$(DEB_HOST_MULTIARCH
)/lib
*.so | \
264 sed
-n
's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
265 while read name version
; do \
266 echo
"$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
267 done
> debian
/$(LIBSTD_PKG
)/DEBIAN
/shlibs
268 chmod
644 debian
/$(LIBSTD_PKG
)/DEBIAN
/shlibs
269 chown
0:0 debian
/$(LIBSTD_PKG
)/DEBIAN
/shlibs
271 override_dh_shlibdeps
:
272 dh_shlibdeps
-- -x
$(LIBSTD_PKG
)
274 QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE
= x
=$$?
; if
[ $$x = 2 ]; then exit
0; else exit
$$x; fi
276 QUILT_PATCHES
=debian
/patches quilt push
-aq
; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE
)
277 $(MAKE
) -f debian
/rules
clean
278 debian
/make_orig-stage0_tarball.sh
279 QUILT_PATCHES
=debian
/patches quilt pop
-aq
; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE
)