]> git.proxmox.com Git - rustc.git/blame - debian/rules
Release 1.10.0+dfsg1-1 to Debian unstable.
[rustc.git] / debian / rules
CommitLineData
be771b38
LB
1#!/usr/bin/make -f
2# -*- makefile -*-
3
b59979d9 4include /usr/share/dpkg/pkg-info.mk
d75d48d6 5include /usr/share/dpkg/architecture.mk
7d40d3e1 6include /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)
11RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS))
7d40d3e1 12export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
b59979d9 13
525ff0f9
AL
14# Defines DEB_*_RUST_TYPE triples
15include debian/architecture.mk
16
be771b38
LB
17# Uncomment this to turn on verbose mode.
18#export DH_VERBOSE=1
19
03b69fec
JJ
20# When using sudo pbuilder, this will cause mk/install.mk to run sudo,
21# but we don't need sudo as a build-dep for the package if we unexport
22# the SUDO_USER variable.
23unexport SUDO_USER
24
c2a1d9e3
AL
25# src/rt/miniz.c (incorrectly) triggers -Wmisleading-indentation with
26# gcc-6. See bug #811573.
27CFLAGS += -Wno-misleading-indentation
28
1c8ac2b0
SL
29# Debhelper clears MAKEFLAGS, so we have to do this again for any
30# target where we call $(MAKE) directly. Boo.
31DEB_PARALLEL_JOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
525ff0f9 32PMAKE = $(MAKE) $(if $(DEB_PARALLEL_JOBS),-j$(DEB_PARALLEL_JOBS))
b59979d9 33
d4357a26 34# Release type (one of beta, stable or nightly)
0f9154de 35RELEASE_CHANNEL := stable
6935ded2
XL
36# See also ./build-preview-dsc.sh for a script that builds a beta/nightly .dsc
37# out of this packaging. Furthermore, if the build breaks after importing a new
38# upstream stable release, check the do_temporary_fixup function in that file
39# to see if we already know what fix to make.
d4357a26 40
8354de7a 41DEB_DESTDIR := $(CURDIR)/debian/tmp
525ff0f9 42
1ce0c197 43RUST_VERSION := $(shell dpkg-parsechangelog --show-field Version | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/')
888747f5 44LIBSTD_PKG := libstd-rust-$(RUST_VERSION)
02b74708 45
be771b38 46# These are the normal build flags
525ff0f9
AL
47DEB_CONFIGURE_FLAGS = \
48 --host=$(DEB_HOST_RUST_TYPE) \
49 --target=$(DEB_TARGET_RUST_TYPE) \
be771b38 50 --disable-manage-submodules \
d4357a26 51 --release-channel=$(RELEASE_CHANNEL) \
525ff0f9 52 --prefix=/usr
be771b38 53
525ff0f9 54# Use system LLVM (comment out to use vendored LLVM)
0fbc9e96 55DEB_CONFIGURE_FLAGS += --llvm-root=/usr/lib/llvm-3.7
1c8ac2b0 56
427dce5b
XL
57# Below we detect how we're supposed to bootstrap the stage0 compiler. See
58# README.Debian for more details of the cases described below.
59#
60# Sed expression that matches the "rustc" we have in our Build-Depends field
61SED_RUSTC_BUILDDEP := /^Build-Depends:/,/^[^[:space:]\#]/{/\s*rustc.*,/$$action}
62PRECONFIGURE_CHECK = :
63ifeq (0,$(shell ls -1 dl/ 2>/dev/null | wc -l))
64 # Case A (Building from source): the .dsc did not include an extra orig-dl
65 # tarball e.g. because the distro already has a rustc, or the uploader
66 # expects that this requirement be fulfilled in some other way.
67 #
68 # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
69 # In this case, we use the distro's rustc - either the previous or current version.
70 ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES)))
71 DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/usr
72 endif
73 #
74 # Case A-2: the builder selected the "dlstage0" build profile.
75 # In this case, the rust build scripts will download a stage0 into dl/ and use that.
76else
77 # Case B (Bootstrapping a new distro): the .dsc included an extra orig-dl
78 # tarball; see the `source_orig-dl` target below on how to build this.
79 #
80 # In this case, we'll bootstrap from the stage0 given in that tarball.
81 # To ensure the uploader of the .dsc didn't make a mistake, we first check
82 # that rustc isn't in our Build-Depends.
83 ifneq (,$(shell action=p; sed -ne "$(SED_RUSTC_BUILDDEP)" debian/control))
84 PRECONFIGURE_CHECK = $(error dl/ not empty but rustc in Build-Depends)
85 endif
1c8ac2b0
SL
86endif
87
88BUILD_DOCS = 1
120b4d47 89ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
525ff0f9 90 DEB_CONFIGURE_FLAGS += --disable-docs
2e97839d 91 BUILD_DOCS =
1c8ac2b0
SL
92endif
93
94ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
525ff0f9 95 DEB_CONFIGURE_FLAGS += --disable-optimize --disable-optimize-cxx --disable-optimize-llvm
1c8ac2b0
SL
96endif
97
98
be771b38 99%:
2679d355 100 dh $@ --parallel
be771b38 101
7a06551f 102# Note: SHELL is not set by dash, but the configure script wants to use it
be771b38 103override_dh_auto_configure:
427dce5b 104 $(PRECONFIGURE_CHECK)
9cc3337a 105 SHELL=/bin/sh PATH="$$PWD/debian/bin:$$PATH" \
525ff0f9 106 ./configure $(DEB_CONFIGURE_FLAGS)
1c8ac2b0 107
11c430be 108override_dh_auto_clean:
525ff0f9
AL
109 set -e; \
110 if [ -f Makefile ]; then \
111 $(PMAKE) clean-all; \
34f64947 112 $(RM) Makefile config.stamp config.mk; \
525ff0f9 113 fi
34f64947 114 $(RM) src/bootstrap/bootstrap.pyc
11c430be 115
1c8ac2b0
SL
116override_dh_auto_build-arch:
117 dh_auto_build -- all VERBOSE=1
118
119override_dh_auto_build-indep:
120 $(if $(BUILD_DOCS),dh_auto_build -- docs)
becfe001 121
23d2674b 122override_dh_auto_install:
39a0abff 123 dh_auto_install --destdir=$(DEB_DESTDIR)
525ff0f9
AL
124
125 mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
126 mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
6fce0a99 127
1261b4b3 128 # Replace duplicated compile-time/run-time dylibs with symlinks
525ff0f9
AL
129 @set -e; \
130 for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
131 name=$${f##*/}; \
132 if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
133 echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
134 ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
135 fi; \
1261b4b3
AL
136 done
137
525ff0f9 138ifneq (,$(BUILD_DOCS))
6fce0a99
SL
139 # Brute force to remove privacy-breach-logo lintian warning.
140 # We could have updated the upstream sources but it would complexify
141 # the rebase
b556761e
AL
142 @set -e; \
143 find $(DEB_DESTDIR)/usr/share/doc/rust/html -iname '*.html' | \
1add0b94 144 while read file; do \
b556761e 145 topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
92f6ea48 146 sed -i -e "s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
87a30969 147 -e "s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \
1add0b94 148 done
525ff0f9 149
36a05422 150 find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete
2e97839d 151endif
525ff0f9 152
cf9ecdde 153override_dh_install-arch:
6fce0a99 154 dh_install
525ff0f9
AL
155 dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/
156
157 chmod -x \
158 debian/rust-gdb/usr/share/rust-gdb/*.py \
159 debian/rust-lldb/usr/share/rust-lldb/*.py
1c8ac2b0 160
bc0aa84e
AL
161override_dh_installchangelogs:
162 dh_installchangelogs RELEASES.md
163
164override_dh_installdocs:
165 dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
166
eef1f4e3
AL
167override_dh_compress:
168 dh_compress -X.woff
169
1c8ac2b0 170override_dh_auto_test:
0be7358c 171ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
9cc3337a 172 RUST_BACKTRACE=1 $(PMAKE) VERBOSE=1 check-notidy
0be7358c 173endif
525ff0f9
AL
174
175override_dh_makeshlibs:
176 dh_makeshlibs -V
177
178 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
179 # structure, so we have to do this ourselves.
180 install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN
181 ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
182 sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
183 while read name version; do \
184 echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
185 done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
186 chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
187 chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
188
189override_dh_shlibdeps:
190 dh_shlibdeps -- -x$(LIBSTD_PKG)
427dce5b
XL
191
192QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi
193source_orig-dl: clean
194 QUILT_PATCHES=debian/patches quilt push -a; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
195 debian/make_orig-dl_tarball.sh
196 cp debian/control debian/control.next
197 cp debian/changelog debian/changelog.old
198 dch -l+dl "Upload with extra orig-dl bootstrap tarball."
199 action=d; sed -i -e "$(SED_RUSTC_BUILDDEP)" debian/control
200 dpkg-source -b . # TODO: if this fails, you should restore d/{control,changelog}
201 mv debian/changelog.old debian/changelog
202 mv debian/control.next debian/control
203 QUILT_PATCHES=debian/patches quilt pop -a; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
204 rm -rf .pc dl/