#!/usr/bin/make -f # -*- makefile -*- # Copyright © 2010-2019 Stephen Kitt # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation, either version 2.1 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # 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 upstream_gdbserver_dir := $(upstream_gdb_dir)/gdb/gdbserver build_gdb_dir := $(top_dir)/build-gdb build_gdbserver_dir := $(top_dir)/build-gdbserver 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-mingw-w64 targets := i686-w64-mingw32 x86_64-w64-mingw32 # Full hardening for Debian-targeted builds dpkg_buildflags_arch = DEB_BUILD_MAINT_OPTIONS="hardening=+all" dpkg-buildflags # Windows targets don't support stackprotector, relro, bindnow or pie # We disable PE timestamps to build reproducibly # We disable format because the gdb build tries to do so (partially) # anyway, and breaks the build with -Werror=format-security as a result # We link libstdc++ and libgcc statically to avoid needing the DLLs dpkg_buildflags_indep = DEB_BUILD_MAINT_OPTIONS="hardening=-stackprotector,-relro,-bindnow,-pie,-format" DEB_LDFLAGS_MAINT_APPEND="-Xlinker --no-insert-timestamp -static-libstdc++ -static-libgcc" 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) $(build_gdbserver_dir) $(upstream_gdb_dir) override_dh_auto_configure-arch: unpack-stamp set -e; \ for target in $(targets); do \ mkdir -p $(build_gdb_dir)/$$target; \ cd $(build_gdb_dir)/$$target; \ $(upstream_gdb_dir)/configure \ --build=$(DEB_BUILD_GNU_TYPE) \ --prefix=/usr --enable-lto \ --with-system-readline --with-system-zlib \ --enable-tui --with-expat --with-python=python3 \ --target=$$target --disable-werror \ $(shell $(dpkg_buildflags_arch) --export=cmdline); \ done override_dh_auto_configure-indep: unpack-stamp set -e; \ for target in $(targets); do \ mkdir -p $(build_gdbserver_dir)/$$target; \ cd $(build_gdbserver_dir)/$$target; \ $(upstream_gdbserver_dir)/configure \ --build=$(DEB_BUILD_GNU_TYPE) \ --host=$$target --target=$$target \ --disable-werror \ $(shell $(dpkg_buildflags_indep) --export=cmdline); \ done override_dh_auto_build-arch: set -e; \ for target in $(targets); do \ $(shell $(dpkg_buildflags_arch) --export=sh); \ dh_auto_build --parallel -B$(build_gdb_dir)/$$target -- V=1; \ done override_dh_auto_build-indep: set -e; \ for target in $(targets); do \ $(shell $(dpkg_buildflags_indep) --export=sh); \ dh_auto_build --parallel -B$(build_gdbserver_dir)/$$target -- V=1; \ done override_dh_auto_install: set -e; \ for target in $(targets); do \ dh_auto_install -B$(build_gdb_dir)/$$target; \ done # Drop files which will conflict with other packages 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 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)