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