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 .*,/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 DEB_CONFIGURE_FLAGS
= --enable-llvm-link-shared
--disable-dist-src
--prefix=/usr
43 # Use system LLVM (comment out to use vendored LLVM)
44 OLD_LLVM_VERSION
= 3.8
45 DEB_CONFIGURE_FLAGS
+= --llvm-root
=/usr
/lib
/llvm-3.9
47 RUSTBUILD_FLAGS
= --config debian
/config.toml
-v
50 oldver
=$(shell $(SED_RUSTC_BUILDDEP
) | sed
-ne
's/.*(<= \(.*\)).*/\1/gp' |
$(SED_VERSION_SHORT
)); \
51 newver
=$(RUST_VERSION
); \
52 if
[ $$oldver != $$newver ]; then debian
/update-version.sh
$$oldver $$newver; fi
54 # Below we detect how we're supposed to bootstrap the stage0 compiler. See
55 # README.Debian for more details of the cases described below.
57 PRECONFIGURE_CHECK
= :
58 HAVE_BINARY_TARBALL
:= $(shell ls
-1 stage0
/*/*$(DEB_HOST_RUST_TYPE
)* 2>/dev
/null | wc
-l
)
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
63 ifeq (0,$(HAVE_BINARY_TARBALL
))
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.
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
)))
72 DEB_CONFIGURE_FLAGS
+= --enable-local-rust
--local-rust-root
=/usr
75 # Case A-2: the builder selected the "dlstage0" build profile.
76 # In this case, the rust build scripts will download a stage0 into stage0/ and use that.
77 # We don't need to do anything specific in this build file, so this case is empty.
79 # Case B (Bootstrapping a new distro): the extracted source tree does
80 # include a bootstrapping tarball for the current architecture; see the
81 # `source_orig-stage0` target below on how to build this.
83 # In this case, we'll bootstrap from the stage0 given in that tarball.
84 # To ensure the uploader of the .dsc didn't make a mistake, we first check
85 # that rustc isn't a Build-Depends for the current architecture.
86 ifneq (,$(shell $(SED_RUSTC_BUILDDEP
)))
87 ifeq (,$(shell $(SED_RUSTC_BUILDDEP
) | grep
'!$(DEB_HOST_ARCH)'))
88 PRECONFIGURE_CHECK
= $(error found matches for stage0
/*/*$(DEB_HOST_RUST_TYPE
)*, \
89 but rustc might be a Build-Depends for
$(DEB_HOST_ARCH
))
95 ifneq (,$(findstring nodoc
,$(DEB_BUILD_PROFILES
)))
96 DEB_CONFIGURE_FLAGS
+= --disable-docs
100 ifneq (,$(findstring noopt
,$(DEB_BUILD_OPTIONS
)))
101 DEB_CONFIGURE_FLAGS
+= --disable-optimize
--disable-optimize-cxx
--disable-optimize-llvm
104 # Build products or non-source files in src/, that shouldn't go in rust-src
105 SRC_CLEAN
= src
/rt
/hoedown
/src
/html_blocks.c \
106 src
/bootstrap
/bootstrap.pyc \
116 debian
/config.toml
: debian
/config.toml.in
117 m4
-DDEB_BUILD_RUST_TYPE
="$(DEB_BUILD_RUST_TYPE)" \
118 -DDEB_HOST_RUST_TYPE
="$(DEB_HOST_RUST_TYPE)" \
119 -DDEB_TARGET_RUST_TYPE
="$(DEB_TARGET_RUST_TYPE)" \
120 -DRELEASE_CHANNEL
="$(RELEASE_CHANNEL)" \
123 override_dh_auto_configure
: debian
/config.toml
124 # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
125 ! grep
--color
=always
-i
'll...?$(OLD_LLVM_VERSION)' --exclude
=changelog
-R debian
126 $(PRECONFIGURE_CHECK
)
127 if
[ -d stage0
]; then mkdir
-p build
&& ln
-sfT ..
/stage0 build
/cache
; fi
128 # work around #842634
129 if
test $$(grep
"127.0.0.1\s*localhost" /etc
/hosts | wc
-l
) -gt
1; then \
130 debian
/ensure-patch
-N debian
/patches
/d-host-duplicates.patch
; fi
131 PATH
="$$PWD/debian/bin:$$PATH" \
132 .
/configure
$(DEB_CONFIGURE_FLAGS
)
134 override_dh_auto_clean
:
135 $(RM
) -rf .
/build .
/tmp .
/.cargo config.stamp config.mk Makefile
136 $(RM
) -rf
$(SRC_CLEAN
) debian
/config.toml
138 # upstream bundles this in the source, but in Debian we rebuild everything yo
140 $(MAKE
) -C src
/rt
/hoedown src
/html_blocks.c
142 override_dh_auto_build-arch
: generate-sources
143 $(RUSTBUILD
) build
$(RUSTBUILD_FLAGS
)
145 # note: this is only for buildds that want to do a separate arch:all build;
146 # there is no point running this yourself "to save time" since it implicitly
147 # depends on build-arch anyways.
148 override_dh_auto_build-indep
: generate-sources
149 ifneq (,$(BUILD_DOCS
))
150 # Rust has a weird way of configuring whether to build docs or not
151 sed
-i
-e
's/^docs = false/docs = true/' debian
/config.toml
152 $(RUSTBUILD
) doc
$(RUSTBUILD_FLAGS
)
158 elif
[ $(DEB_VENDOR
) = "Debian" -a
$(DEB_DISTRIBUTION
) != "experimental" ]; then \
160 elif
[ $(DEB_VENDOR
) = "Ubuntu" -a
$(DEB_HOST_ARCH
) != "s390x" ]; then \
163 echo
"====================================================="; \
164 echo
"WARNING: Ignoring test failures in the rust testsuite"; \
165 echo
"====================================================="; \
168 override_dh_auto_test-arch
:
169 ifeq (, $(filter nocheck
,$(DEB_BUILD_OPTIONS
)))
170 $(call RUN_TESTS
,RUST_BACKTRACE
=1 $(RUSTBUILD
) test $(RUSTBUILD_FLAGS
))
173 override_dh_auto_test-indep
:
174 ifneq (,$(BUILD_DOCS
))
175 ifeq (, $(filter nocheck
,$(DEB_BUILD_OPTIONS
)))
176 # Run all rules that test the docs, i.e. in step.rs that depend on default:doc
177 $(call RUN_TESTS
,RUST_BACKTRACE
=1 $(RUSTBUILD
) test src
/tools
/linkchecker
$(RUSTBUILD_FLAGS
))
181 override_dh_auto_install
:
182 DESTDIR
=$(DEB_DESTDIR
) $(RUSTBUILD
) dist $(RUSTBUILD_FLAGS
) --install
184 mkdir
-p
$(DEB_DESTDIR
)/usr
/lib
/$(DEB_HOST_MULTIARCH
)/
185 mv
$(DEB_DESTDIR
)/usr
/lib
/lib
*.so
$(DEB_DESTDIR
)/usr
/lib
/$(DEB_HOST_MULTIARCH
)/
187 # Replace duplicated compile-time/run-time dylibs with symlinks
189 for f in
$(DEB_DESTDIR
)/usr
/lib
/rustlib
/$(DEB_HOST_RUST_TYPE
)/lib
/lib
*.so
; do \
191 if
[ -f
"$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
192 echo
"ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
193 ln
-sf ..
/..
/..
/$(DEB_HOST_MULTIARCH
)/$$name $$f; \
197 ifneq (,$(BUILD_DOCS
))
198 # Brute force to remove privacy-breach-logo lintian warning.
199 # We could have updated the upstream sources but it would complexify
202 find
$(DEB_DESTDIR
)/usr
/share
/doc
/rust
/html
-iname
'*.html' | \
203 while read file
; do \
204 topdir
=$$(echo
"$$file" | sed
's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
205 sed
-i
-e
"s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
206 -e
"s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \
208 find
$(DEB_DESTDIR
) \
( -iname
'*.html' -empty
-o
-name .lock
-o
-name
'*.inc' \
) -delete
;
211 override_dh_install-arch
:
213 dh_install
-p
$(LIBSTD_PKG
) usr
/lib
/$(DEB_HOST_MULTIARCH
)/
215 override_dh_install-indep
:
218 debian
/rust-gdb
/usr
/share
/rust-gdb
/*.py \
219 debian
/rust-lldb
/usr
/share
/rust-lldb
/*.py
220 $(RM
) -rf
$(SRC_CLEAN
:%=debian
/rust-src
/usr
/src
/rust
/%)
221 # Get rid of lintian warnings
222 find debian
/rust-src
/usr
/src
/rust \
223 \
( -name .gitignore \
224 -o
-name
'LICENSE*' \
227 -o
-name
'COPYING*' \
229 cd debian
/rust-src
/usr
/src
/rust
&& chmod
-x \
230 src
/etc
/gdb_rust_pretty_printing.py \
231 src
/etc
/adb_run_wrapper.sh \
232 src
/compiler-rt
/test/builtins
/Unit
/ppc
/test
234 override_dh_installchangelogs
:
235 dh_installchangelogs RELEASES.md
237 override_dh_installdocs
:
238 dh_installdocs
-X.
tex -X.aux
-X.log
-X.out
-X.toc
240 override_dh_compress
:
243 override_dh_makeshlibs
:
246 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
247 # structure, so we have to do this ourselves.
248 install -o
0 -g
0 -d debian
/$(LIBSTD_PKG
)/DEBIAN
249 LC_ALL
=C ls debian
/$(LIBSTD_PKG
)/usr
/lib
/$(DEB_HOST_MULTIARCH
)/lib
*.so | \
250 sed
-n
's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
251 while read name version
; do \
252 echo
"$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
253 done
> debian
/$(LIBSTD_PKG
)/DEBIAN
/shlibs
254 chmod
644 debian
/$(LIBSTD_PKG
)/DEBIAN
/shlibs
255 chown
0:0 debian
/$(LIBSTD_PKG
)/DEBIAN
/shlibs
257 override_dh_shlibdeps
:
258 dh_shlibdeps
-- -x
$(LIBSTD_PKG
)
260 QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE
= x
=$$?
; if
[ $$x = 2 ]; then exit
0; else exit
$$x; fi
262 QUILT_PATCHES
=debian
/patches quilt push
-aq
; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE
)
263 $(MAKE
) -f debian
/rules
clean
264 debian
/make_orig-stage0_tarball.sh
265 QUILT_PATCHES
=debian
/patches quilt pop
-aq
; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE
)