]> git.proxmox.com Git - rustc.git/blob - debian/rules
The tests require docs to be built, which requires jquery
[rustc.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 include /usr/share/dpkg/pkg-info.mk
5 include /usr/share/dpkg/architecture.mk
6 include /usr/share/dpkg/buildflags.mk
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))
12 export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
13
14 # Defines DEB_*_RUST_TYPE triples
15 include debian/architecture.mk
16
17 # Uncomment this to turn on verbose mode.
18 #export DH_VERBOSE=1
19
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.
23 unexport SUDO_USER
24
25 # src/rt/miniz.c (incorrectly) triggers -Wmisleading-indentation with
26 # gcc-6. See bug #811573.
27 CFLAGS += -Wno-misleading-indentation
28
29 # Debhelper clears MAKEFLAGS, so we have to do this again for any
30 # target where we call $(MAKE) directly. Boo.
31 DEB_PARALLEL_JOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
32 PMAKE = $(MAKE) $(if $(DEB_PARALLEL_JOBS),-j$(DEB_PARALLEL_JOBS))
33
34 # Release type (one of beta, stable or nightly)
35 RELEASE_CHANNEL := stable
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.
40
41 DEB_DESTDIR := $(CURDIR)/debian/tmp
42
43 RUST_VERSION := $(shell dpkg-parsechangelog --show-field Version | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/')
44 LIBSTD_PKG := libstd-rust-$(RUST_VERSION)
45
46 # These are the normal build flags
47 DEB_CONFIGURE_FLAGS = \
48 --host=$(DEB_HOST_RUST_TYPE) \
49 --target=$(DEB_TARGET_RUST_TYPE) \
50 --disable-manage-submodules \
51 --release-channel=$(RELEASE_CHANNEL) \
52 --prefix=/usr
53
54 # Use system LLVM (comment out to use vendored LLVM)
55 OLD_LLVM_VERSION = 3.8
56 DEB_CONFIGURE_FLAGS += --llvm-root=/usr/lib/llvm-3.9
57
58 # Below we detect how we're supposed to bootstrap the stage0 compiler. See
59 # README.Debian for more details of the cases described below.
60 #
61 # Sed expression that matches the "rustc" we have in our Build-Depends field
62 SED_RUSTC_BUILDDEP := /^Build-Depends:/,/^[^[:space:]\#]/{/\s*rustc.*,/$$action}
63 PRECONFIGURE_CHECK = :
64 ifeq (0,$(shell ls -1 dl/*$(DEB_HOST_RUST_TYPE)* 2>/dev/null | wc -l))
65 # Case A (Building from source): the extracted source tree does not include
66 # a bootstrapping tarball for the current architecture e.g. because the
67 # distro already has a rustc for this arch, or the uploader expects that
68 # this requirement be fulfilled in some other way.
69 #
70 # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
71 # In this case, we use the distro's rustc - either the previous or current version.
72 ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES)))
73 DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/usr
74 # FIXME: Remove for versions after 1.12.1:
75 # Dynamically apply rust-boot-1.12.1-from-1.12.0.diff (or not) depending on
76 # the version of /usr/bin/rustc that you're bootstrapping from. We assume
77 # that it's one of the versions adhering to what's specified by d/control.
78 ifeq (1.12.0,$(shell /usr/bin/rustc --version --verbose | sed -ne 's/^release: //p'))
79 PRECONFIGURE_CHECK = debian/ensure-patch -N debian/patches/rust-boot-1.12.1-from-1.12.0.diff
80 else
81 PRECONFIGURE_CHECK = debian/ensure-patch -R debian/patches/rust-boot-1.12.1-from-1.12.0.diff
82 endif
83 endif
84 #
85 # Case A-2: the builder selected the "dlstage0" build profile.
86 # In this case, the rust build scripts will download a stage0 into dl/ and use that.
87 # We don't need to do anything specific in this build file, so this case is empty.
88 else
89 # Case B (Bootstrapping a new distro): the extracted source tree does
90 # include a bootstrapping tarball for the current architecture; see the
91 # `source_orig-dl` target below on how to build this.
92 #
93 # In this case, we'll bootstrap from the stage0 given in that tarball.
94 # To ensure the uploader of the .dsc didn't make a mistake, we first check
95 # that rustc isn't a Build-Depends for the current architecture.
96 ifneq (,$(shell action=p; sed -ne "$(SED_RUSTC_BUILDDEP)" debian/control))
97 ifeq (,$(shell action=p; sed -ne "$(SED_RUSTC_BUILDDEP)" debian/control | grep '!$(DEB_HOST_ARCH)'))
98 PRECONFIGURE_CHECK = $(error found matches for dl/*$(DEB_HOST_RUST_TYPE)*, \
99 but rustc might be a Build-Depends for $(DEB_HOST_ARCH))
100 endif
101 endif
102 endif
103
104 BUILD_DOCS = 1
105 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
106 DEB_CONFIGURE_FLAGS += --disable-docs
107 BUILD_DOCS =
108 endif
109
110 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
111 DEB_CONFIGURE_FLAGS += --disable-optimize --disable-optimize-cxx --disable-optimize-llvm
112 endif
113
114
115 %:
116 dh $@ --parallel
117
118 # Note: SHELL is not set by dash, but the configure script wants to use it
119 override_dh_auto_configure:
120 # fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
121 ! grep --color=always -i 'll...$(OLD_LLVM_VERSION)' --exclude=changelog -R debian
122 $(PRECONFIGURE_CHECK)
123 SHELL=/bin/sh PATH="$$PWD/debian/bin:$$PATH" DEB_HOST_ARCH="$(DEB_HOST_ARCH)" \
124 ./configure $(DEB_CONFIGURE_FLAGS)
125
126 override_dh_auto_clean:
127 set -e; \
128 if [ -f Makefile ]; then \
129 $(PMAKE) clean-all; \
130 $(RM) Makefile config.stamp config.mk; \
131 fi
132 $(RM) src/rt/hoedown/src/html_blocks.c # clean up after building this ourselves
133 $(RM) src/bootstrap/bootstrap.pyc
134
135 # upstream bundles this in the source, but in Debian we rebuild everything yo
136 generate-sources:
137 $(MAKE) -C src/rt/hoedown src/html_blocks.c
138
139 override_dh_auto_build-arch: generate-sources
140 dh_auto_build -- all-no-docs VERBOSE=1
141
142 # note: this is only for buildds that want to do a separate arch:all build;
143 # there is no point running this yourself "to save time" since it implicitly
144 # depends on build-arch anyways.
145 override_dh_auto_build-indep: generate-sources
146 ifneq (,$(BUILD_DOCS))
147 dh_auto_build -- docs VERBOSE=1
148 endif
149
150 override_dh_auto_install:
151 dh_auto_install --destdir=$(DEB_DESTDIR)
152
153 mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
154 mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
155
156 # Replace duplicated compile-time/run-time dylibs with symlinks
157 @set -e; \
158 for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
159 name=$${f##*/}; \
160 if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
161 echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
162 ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
163 fi; \
164 done
165
166 ifneq (,$(BUILD_DOCS))
167 # Brute force to remove privacy-breach-logo lintian warning.
168 # We could have updated the upstream sources but it would complexify
169 # the rebase
170 @set -e; \
171 find $(DEB_DESTDIR)/usr/share/doc/rust/html -iname '*.html' | \
172 while read file; do \
173 topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
174 sed -i -e "s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
175 -e "s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \
176 done
177 # TODO: replace embedded jquery with symlink to jquery. This should
178 # eventually become part of a dh_rustdoc program.
179 find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete
180 endif
181
182 override_dh_install-arch:
183 dh_install
184 dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/
185
186 chmod -x \
187 debian/rust-gdb/usr/share/rust-gdb/*.py \
188 debian/rust-lldb/usr/share/rust-lldb/*.py
189
190 override_dh_installchangelogs:
191 dh_installchangelogs RELEASES.md
192
193 override_dh_installdocs:
194 dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
195
196 override_dh_compress:
197 dh_compress -X.woff
198
199 override_dh_auto_test:
200 ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
201 RUST_BACKTRACE=1 $(PMAKE) VERBOSE=1 check-notidy
202 endif
203
204 override_dh_makeshlibs:
205 dh_makeshlibs -V
206
207 # dh_makeshlibs doesn't support our "libfoo-version.so" naming
208 # structure, so we have to do this ourselves.
209 install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN
210 LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
211 sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
212 while read name version; do \
213 echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
214 done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
215 chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
216 chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
217
218 override_dh_shlibdeps:
219 dh_shlibdeps -- -x$(LIBSTD_PKG)
220
221 QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi
222 source_orig-dl:
223 QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
224 $(MAKE) -f debian/rules clean
225 debian/make_orig-dl_tarball.sh
226 QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
227 rm -rf .pc