1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#!/usr/bin/make -f
export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
targets=\
aarch64-none-elf \
arm-none-eabi \
riscv64-unknown-elf
binutils_dir=/usr/src/binutils
stampdir=debian/stamp
unpack_stamp=$(stampdir)/unpack
tar_stamp=$(stampdir)/tar
override_stamp=$(stampdir)/override
cpu_count = $(shell cat /proc/cpuinfo | grep -c '^processor')
source_version := $(shell dpkg-query -W -f="\$${Version}\n" binutils-source)
deb_version := $(source_version)+$(shell dpkg-parsechangelog | sed -ne "s/^Version: \(.*\)/\1/p")
deb_upstream_version := $(shell echo $(deb_version) | cut -d- -f1)
base_version := $(shell echo $(deb_version) | sed -e 's/\([1-9]\.[0-9]\).*-.*/\1/')
buildflags=$(shell dpkg-buildflags --export=configure)
BUILT_USING := $(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W binutils-source)
export MAKEFLAGS = -j$(cpu_count) -l$(cpu_count)
configure_flags = \
--target=$${target} \
--prefix=/usr \
--sysconfdir=/etc \
--libdir=/usr/$${target}/lib \
--infodir=/usr/share/doc/binutils-$${target}/info \
--htmldir=/usr/share/doc/binutils-$${target}/html \
--pdfdir=/usr/share/doc/binutils-$${target}/pdf \
--mandir=/usr/share/man \
--enable-deterministic-archives \
--disable-nls \
--disable-sim \
--disable-werror \
--enable-plugins \
--enable-interwork \
--with-system-zlib \
"--with-pkgversion=$(deb_version)" \
$(buildflags)
%:
dh $@ -Dbinutils-source
$(override_stamp):
for target in $(targets); do \
sed "s/%TARGET%/$${target}/g" debian/template.lintian-overrides > debian/binutils-$${target}.lintian-overrides; \
done
$(tar_stamp): $(override_stamp)
mkdir -p binutils-source
tar xf $(binutils_dir)/binutils-*.tar.* -C binutils-source --strip-components=1
cp /usr/share/doc/binutils-source/copyright debian/copyright
mkdir -p $(stampdir)
touch $@
$(unpack_stamp): $(tar_stamp)
set -ex; \
cd binutils-source; \
if [ -d ../debian/patches ]; then \
for patch in ../debian/patches/*.patch; do \
echo Applying patch "$$patch"; \
patch -p1 < "$$patch"; \
done; \
fi
mkdir -p $(stampdir)
touch $@
override_dh_autoreconf: $(unpack_stamp)
autoreconf2.69 -f -i binutils-source
override_dh_auto_configure: $(unpack_stamp)
for target in $(targets); do \
dh_auto_configure -Dbinutils-source -Bbuild-$${target} -- $(configure_flags); \
done
override_dh_auto_build:
for target in $(targets); do \
dh_auto_build -Bbuild-$${target} --parallel & \
done; wait
# Replace hard links in /usr/<target>/bin with symlinks to ../../bin/<target>-prog
override_dh_auto_install:
for target in $(targets); do \
dh_auto_install -Bbuild-$${target} --destdir=debian/binutils-$${target}; \
for fullprog in debian/binutils-$${target}/usr/$${target}/bin/*; do \
baseprog=$$(basename $${fullprog}); \
if [ -f "debian/binutils-$${target}/usr/bin/$${target}-$${baseprog}" ]; then \
rm $${fullprog} && ln -sr ../../../bin/$${target}-$${baseprog} $${fullprog}; \
fi; \
done; \
done
override_dh_gencontrol:
dh_gencontrol -a -- -v$(deb_version) -Vlocal:Version=$(deb_upstream_version) -Vbinutils:Version=$(source_version) -VBuilt-Using="$(BUILT_USING)"
override_dh_auto_clean:
rm -rf binutils-source $(stampdir)
for target in $(targets); do \
rm -rf build-$${target} debian/binutils-$${target} debian/binutils-$${target}.lintian-overrides; \
done
override_dh_installchangelogs:
dh_installchangelogs binutils-source/ChangeLog
override_dh_auto_test:
|