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
  
     | 
    
      #!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
target != echo $(DEB_SOURCE) | sed s/binutils-//
binutils_dir=/usr/src/binutils
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
deb_upstream_version != dpkg-query -f'$${source:Upstream-Version}' -W binutils-source
# version number for our binary packages
deb_version = $(deb_upstream_version)+$(DEB_VERSION)
unpacked_dir=binutils
%:
	mkdir -p $(unpacked_dir)
	dh $@ -D$(unpacked_dir) -Bbuild
execute_before_dh_update_autotools_config: $(unpacked_dir)/binutils
$(unpacked_dir)/binutils:
	cd $(unpacked_dir) && tar --strip-components=1 -xf $(binutils_dir)/binutils-*.tar.*
	rm -rf $(unpacked_dir)/zlib
override_dh_autoreconf:
# Explicitly adding -I `pwd`/$(unpacked_dir)/config to the autoreconf
# command somehow seems to help with this issue where gcc-plugin.m4
# apparently isn't found:
# https://sourceware.org/pipermail/binutils/2021-August/117733.html
	if ! echo $(DEB_BUILD_OPTIONS) | grep -q terse; \
	then AUTORECONF_OPTS='-v'; \
	fi; \
	AUTORECONF_DIRS=`cd $(unpacked_dir) && find . -name configure.ac -o -name configure.in`; \
	dh_autoreconf autoreconf2.69 -- -f $$AUTORECONF_OPTS -I `pwd`/$(unpacked_dir)/config $$AUTORECONF_DIRS
override_dh_auto_configure:
# Versions of Debhelper newer than 10 by default pass --runstatedir
# to the configure script. The autoconf2.69 package used to have support
# for --runstatedir backported from upstream, but this was dropped in
# 2.69-3 (see #994933), so we set DH_COMPAT=10 to circumvent the issue.
# Hopefully by the time support for DH_COMPAT=10 is removed, Binutils
# will be able to be autoreconf'ed using the latest version.
	DH_COMPAT=10 dh_auto_configure -- \
		--target=$(target) \
		--with-bugurl="https://www.debian.org/Bugs/" \
		--libdir=/usr/lib/$(target) \
		--infodir=/nulldir \
		--htmldir=/nulldir \
		--pdfdir=/nulldir \
		--mandir=/usr/share/man \
		--with-system-zlib \
		--with-pkgversion="$(deb_version)" \
		--enable-deterministic-archives \
execute_before_dh_installdocs: debian/$(DEB_SOURCE).copyright
debian/$(DEB_SOURCE).copyright: debian/copyright /usr/share/doc/binutils-source/copyright
	cp debian/copyright $@
	printf -- "\n-----BEGIN BINUTILS COPYRIGHT INFORMATION-----\n" >> $@
	cat /usr/share/doc/binutils-source/copyright >> $@
	printf -- "-----END BINUTILS COPYRIGHT INFORMATION-----\n" >> $@
BUILT_USING != dpkg-query -f '$${source:Package} (= $${source:Version})' -W binutils-source
override_dh_gencontrol:
	dh_gencontrol -- -v$(deb_version) -VBuilt-Using="$(BUILT_USING)"
execute_after_dh_auto_install:
# Make symbolic links instead of hard links.
	cd debian/$(DEB_SOURCE)/usr/$(target)/bin && \
		for i in *; \
		do rm "$$i" && \
		ln -s ../../bin/$(target)-"$$i" "$$i"; \
		done
# These are provided by binutils-common.
	rm -rf debian/$(DEB_SOURCE)/usr/share/locale debian/$(DEB_SOURCE)/nulldir
# How to run the Binutils test suite in a cross configuration is underdocumented.
# As-is there seem to be numerous failures; it may require a simulator,
# which is probably best provided by a gcc-sh-elf or other package.
# Patches and suggestions are welcome.
override_dh_auto_test:
 
     |