#!/usr/bin/make -f

# we want debug info for stacktrace bugreports
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# extra hardening works on AMD64; but breaks on armel. Be conservative.
CPU_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU)
ifneq (,$(findstring hardening=+all,$(DEB_BUILD_MAINT_OPTIONS)))
ifeq (amd64,$(CPU_ARCH))
export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) -pie
endif
endif

# fpc(1) does not like to be run in parallel
%:
	dh $@ --no-parallel

override_dh_auto_install:
	dh_auto_install -- prefix=/usr libdir=/usr/libexec/ironseed

override_dh_auto_build:
# ppc64el (Bug#978153) does not have working gdc, so skip rebuild of that
ifneq ($(filter ppc64el, $(CPU_ARCH)),)
	touch Data_Generators/makedata/convmake Data_Generators/makedata/logmake
	touch data/titles.dta data/log.dta data/conv*
endif
	dh_auto_build -- prefix=/usr libdir=/usr/libexec/ironseed

override_dh_installdocs:
	rm -f debian/ironseed-data/usr/share/doc/ironseed/*.6*
	dh_installdocs --exclude=.6

.PHONY: override_dh_auto_install override_dh_auto_build override_dh_installdocs
