| 12
 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
# -*- makefile -*-
# Copyright © 2010-2019 Stephen Kitt <steve@sk2.org>
# Copyright © 2020 Matthias Klose <doko@debian.org>
# Disable package mangling in Launchpad; it currently fails to parse
# Built-Using, which results in build failures
export NO_PKG_MANGLE=1
include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/architecture.mk
top_dir := $(shell pwd)
gdb_dir := /usr/src
upstream_gdb_dir := $(top_dir)/upstream
build_gdb_dir := $(top_dir)/build-gdb
source_version := $(shell dpkg-query -W -f="\$${Version}\n" gdb-source)
deb_version := $(source_version)+$(DEB_VERSION)
deb_upstream_version := $(shell echo $(deb_version) | cut -d- -f1)
gnu_upstream_version := $(shell echo $(deb_upstream_version) | cut -d. -f1-3)
package := gdb-bpf
target := bpf
# Full hardening for Debian-targeted builds
dpkg_buildflags_arch = DEB_BUILD_MAINT_OPTIONS="hardening=+all,-format" dpkg-buildflags
spelling = grep -rl "$(1)" $(upstream_gdb_dir) | xargs -r sed -i "s/$(1)/$(2)/g"
%:
	dh $@
unpack-stamp:
	tar xf $(gdb_dir)/gdb.tar.*
	rm -rf $(upstream_gdb_dir)
	mv gdb $(upstream_gdb_dir)
	$(call spelling,occurences,occurrences)
	$(call spelling,Unkown,Unknown)
	$(call spelling,vaild,valid)
	touch $@
override_dh_auto_clean:
	dh_auto_clean
	rm -rf *-stamp $(build_gdb_dir) $(upstream_gdb_dir)
override_dh_auto_configure: unpack-stamp
	mkdir -p $(build_gdb_dir)
	cd $(build_gdb_dir) && \
	$(upstream_gdb_dir)/configure \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--prefix=/usr \
		--disable-werror \
		--with-system-readline --with-system-zlib \
		--enable-tui --with-expat --with-python=python3 \
		--target=$(target) --disable-werror \
		$(shell $(dpkg_buildflags_arch) --export=cmdline)
override_dh_auto_build:
	$(shell $(dpkg_buildflags_arch) --export=sh); \
	    dh_auto_build --parallel -B$(build_gdb_dir) -- V=1
override_dh_auto_install:
	dh_auto_install -B$(build_gdb_dir)
# Drop files which will conflict with other packages
	rm -rf debian/$(package)/usr/include
	rm -rf debian/$(package)/usr/lib
	rm -rf debian/$(package)/usr/share/gdb
	rm -rf debian/$(package)/usr/share/info
	rm -rf debian/$(package)/usr/share/locale
	rm -f debian/gdb-bpf/usr/share/man/man1/bpf-gdbserver*
override_dh_installchangelogs:
	dh_installchangelogs $(upstream_gdb_dir)/ChangeLog
override_dh_gencontrol:
	dh_gencontrol -- -v$(deb_version) -Vlocal:Version=$(deb_upstream_version) -Vgdb:Version=$(source_version)
 |