rustc/debian/rules

229 lines
8.9 KiB
Makefile
Executable File

#!/usr/bin/make -f
# -*- makefile -*-
include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildflags.mk
#RUSTFLAGS = -C link-args="$(LDFLAGS)"
# temporary workaround for https://github.com/rust-lang/rust/issues/31529
# this will FAIL if LDFLAGS itself contains shell-interpreted chars beyond
# unquoted spaces (that addprefix works around the failure of)
RUSTFLAGS = $(addprefix -C link-args=,$(LDFLAGS))
export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS
# see https://github.com/rust-lang/rust/issues/37320
# it should be possible to remove this in the next Debian release
export MALLOC_CONF = lg_dirty_mult:-1
# Defines DEB_*_RUST_TYPE triples
include debian/architecture.mk
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# When using sudo pbuilder, this will cause mk/install.mk to run sudo,
# but we don't need sudo as a build-dep for the package if we unexport
# the SUDO_USER variable.
unexport SUDO_USER
# src/rt/miniz.c (incorrectly) triggers -Wmisleading-indentation with
# gcc-6. See bug #811573.
CFLAGS += -Wno-misleading-indentation
# Debhelper clears MAKEFLAGS, so we have to do this again for any
# target where we call $(MAKE) directly. Boo.
DEB_PARALLEL_JOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
PMAKE = $(MAKE) $(if $(DEB_PARALLEL_JOBS),-j$(DEB_PARALLEL_JOBS))
# Release type (one of beta, stable or nightly)
RELEASE_CHANNEL := stable
# See also ./build-preview-dsc.sh for a script that builds a beta/nightly .dsc
# out of this packaging. Furthermore, if the build breaks after importing a new
# upstream stable release, check the do_temporary_fixup function in that file
# to see if we already know what fix to make.
DEB_DESTDIR := $(CURDIR)/debian/tmp
RUST_VERSION := $(shell dpkg-parsechangelog --show-field Version | sed -re 's/([^.]+)\.([^.]+)\..*/\1.\2/')
LIBSTD_PKG := libstd-rust-$(RUST_VERSION)
# These are the normal build flags
DEB_CONFIGURE_FLAGS = \
--host=$(DEB_HOST_RUST_TYPE) \
--target=$(DEB_TARGET_RUST_TYPE) \
--disable-manage-submodules \
--release-channel=$(RELEASE_CHANNEL) \
--prefix=/usr
# Use system LLVM (comment out to use vendored LLVM)
OLD_LLVM_VERSION = 3.8
DEB_CONFIGURE_FLAGS += --llvm-root=/usr/lib/llvm-3.9
# Below we detect how we're supposed to bootstrap the stage0 compiler. See
# README.Debian for more details of the cases described below.
#
# Sed expression that matches the "rustc" we have in our Build-Depends field
SED_RUSTC_BUILDDEP := /^Build-Depends:/,/^[^[:space:]\#]/{/\s*rustc.*,/$$action}
PRECONFIGURE_CHECK = :
ifeq (0,$(shell ls -1 dl/*$(DEB_HOST_RUST_TYPE)* 2>/dev/null | wc -l))
# Case A (Building from source): the extracted source tree does not include
# a bootstrapping tarball for the current architecture e.g. because the
# distro already has a rustc for this arch, or the uploader expects that
# this requirement be fulfilled in some other way.
#
# Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
# In this case, we use the distro's rustc - either the previous or current version.
ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES)))
DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/usr
endif
#
# Case A-2: the builder selected the "dlstage0" build profile.
# In this case, the rust build scripts will download a stage0 into dl/ and use that.
# We don't need to do anything specific in this build file, so this case is empty.
else
# Case B (Bootstrapping a new distro): the extracted source tree does
# include a bootstrapping tarball for the current architecture; see the
# `source_orig-dl` target below on how to build this.
#
# In this case, we'll bootstrap from the stage0 given in that tarball.
# To ensure the uploader of the .dsc didn't make a mistake, we first check
# that rustc isn't a Build-Depends for the current architecture.
ifneq (,$(shell action=p; sed -ne "$(SED_RUSTC_BUILDDEP)" debian/control))
ifeq (,$(shell action=p; sed -ne "$(SED_RUSTC_BUILDDEP)" debian/control | grep '!$(DEB_HOST_ARCH)'))
PRECONFIGURE_CHECK = $(error found matches for dl/*$(DEB_HOST_RUST_TYPE)*, \
but rustc might be a Build-Depends for $(DEB_HOST_ARCH))
endif
endif
endif
BUILD_DOCS = 1
ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
DEB_CONFIGURE_FLAGS += --disable-docs
BUILD_DOCS =
endif
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
DEB_CONFIGURE_FLAGS += --disable-optimize --disable-optimize-cxx --disable-optimize-llvm
endif
%:
dh $@ --parallel
# Note: SHELL is not set by dash, but the configure script wants to use it
override_dh_auto_configure:
# fail the build if we have any instances of OLD_LLVM_VERSION in debian, except for debian/changelog
! grep --color=always -i 'll...$(OLD_LLVM_VERSION)' --exclude=changelog -R debian
$(PRECONFIGURE_CHECK)
SHELL=/bin/sh PATH="$$PWD/debian/bin:$$PATH" DEB_HOST_ARCH="$(DEB_HOST_ARCH)" \
./configure $(DEB_CONFIGURE_FLAGS)
override_dh_auto_clean:
set -e; \
if [ -f Makefile ]; then \
$(PMAKE) clean-all; \
$(RM) Makefile config.stamp config.mk; \
fi
$(RM) src/rt/hoedown/src/html_blocks.c # clean up after building this ourselves
$(RM) src/bootstrap/bootstrap.pyc
# upstream bundles this in the source, but in Debian we rebuild everything yo
generate-sources:
$(MAKE) -C src/rt/hoedown src/html_blocks.c
override_dh_auto_build-arch: generate-sources
dh_auto_build -- all-no-docs VERBOSE=1
# note: this is only for buildds that want to do a separate arch:all build;
# there is no point running this yourself "to save time" since it implicitly
# depends on build-arch anyways.
override_dh_auto_build-indep: generate-sources
ifneq (,$(BUILD_DOCS))
dh_auto_build -- docs VERBOSE=1
endif
override_dh_auto_install:
dh_auto_install --destdir=$(DEB_DESTDIR)
mkdir -p $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
mv $(DEB_DESTDIR)/usr/lib/lib*.so $(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/
# Replace duplicated compile-time/run-time dylibs with symlinks
@set -e; \
for f in $(DEB_DESTDIR)/usr/lib/rustlib/$(DEB_HOST_RUST_TYPE)/lib/lib*.so; do \
name=$${f##*/}; \
if [ -f "$(DEB_DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/$$name" ]; then \
echo "ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f"; \
ln -sf ../../../$(DEB_HOST_MULTIARCH)/$$name $$f; \
fi; \
done
ifneq (,$(BUILD_DOCS))
# Brute force to remove privacy-breach-logo lintian warning.
# We could have updated the upstream sources but it would complexify
# the rebase
@set -e; \
find $(DEB_DESTDIR)/usr/share/doc/rust/html -iname '*.html' | \
while read file; do \
topdir=$$(echo "$$file" | sed 's,^$(DEB_DESTDIR)/usr/share/doc/rust/html/,,; s,/[^/]*$$,/,; s,^[^/]*$$,,; s,[^/]\+/,../,g'); \
sed -i -e "s,https://doc.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," \
-e "s,https://www.rust-lang.org/\(favicon.ico\|logos/rust-logo-32x32-blk.png\),$${topdir}rust-logo-32x32-blk.png," "$$file"; \
done
find $(DEB_DESTDIR) \( -iname '*.html' -empty -o -name .lock -o -name '*.inc' \) -delete
endif
override_dh_install-arch:
dh_install
dh_install -p$(LIBSTD_PKG) usr/lib/$(DEB_HOST_MULTIARCH)/
override_dh_install-indep:
dh_install
chmod -x \
debian/rust-gdb/usr/share/rust-gdb/*.py \
debian/rust-lldb/usr/share/rust-lldb/*.py
override_dh_installchangelogs:
dh_installchangelogs RELEASES.md
override_dh_installdocs:
dh_installdocs -X.tex -X.aux -X.log -X.out -X.toc
override_dh_compress:
dh_compress -X.woff
override_dh_auto_test-arch:
ifeq (, $(filter nocheck,$(DEB_BUILD_OPTIONS)))
RUST_BACKTRACE=1 $(PMAKE) VERBOSE=1 check-notidy
endif
# No tests are applicable when only building arch:all packages.
# More specifically: when we do an arch-all build, some crates are not built.
# This makes some arch-dependent tests fail, so don't run them here.
override_dh_auto_test-indep:
true
override_dh_makeshlibs:
dh_makeshlibs -V
# dh_makeshlibs doesn't support our "libfoo-version.so" naming
# structure, so we have to do this ourselves.
install -o 0 -g 0 -d debian/$(LIBSTD_PKG)/DEBIAN
LC_ALL=C ls debian/$(LIBSTD_PKG)/usr/lib/$(DEB_HOST_MULTIARCH)/lib*.so | \
sed -n 's,^.*/\(lib.*\)-\(.\+\)\.so$$,\1 \2,p' | \
while read name version; do \
echo "$$name $$version $(LIBSTD_PKG) (>= $(DEB_VERSION_UPSTREAM))"; \
done > debian/$(LIBSTD_PKG)/DEBIAN/shlibs
chmod 644 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
chown 0:0 debian/$(LIBSTD_PKG)/DEBIAN/shlibs
override_dh_shlibdeps:
dh_shlibdeps -- -x$(LIBSTD_PKG)
QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE = x=$$?; if [ $$x = 2 ]; then exit 0; else exit $$x; fi
source_orig-dl:
QUILT_PATCHES=debian/patches quilt push -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
$(MAKE) -f debian/rules clean
debian/make_orig-dl_tarball.sh
QUILT_PATCHES=debian/patches quilt pop -aq; $(QUILT_SPECIAL_SNOWFLAKE_RETURN_CODE)
rm -rf .pc