#!/usr/bin/make -f
#export DH_VERBOSE = 1

include /usr/share/dpkg/pkg-info.mk

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

CHANGELOG_DATE ?= $(shell LC_ALL=C date -u -d @$(SOURCE_DATE_EPOCH) +"%d %B %Y")
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# workaround since grcc tries to write to the home directory when buildling GNU radio flow graph:
export HOME=/tmp/tmpbuildhome
#

%:
	dh $@ --no-parallel

override_dh_auto_configure:
	dh_auto_configure -- -DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)"
	# workaround since grcc tries to write to the home directory when buildling GNU radio flow graph:
	mkdir -p $(HOME)/.cache/grc_gnuradio

# Disable running tests since they have problems upstream. REMEMBER to check
# again for every new release
override_dh_auto_test:
	#dh_auto_test


override_dh_clean:
	dh_clean
	$(RM) debian/man/*.1


# We do not want to install the development files in this package
override_dh_auto_install:
	dh_auto_install
	$(RM) debian/tmp/usr/lib/python3/dist-packages/grdab/*.pyc
	$(RM) debian/tmp/usr/lib/python3/dist-packages/grdab/*.pyo
	$(RM) debian/tmp/usr/lib/python3/dist-packages/grdab/app/*.pyc
	$(RM) debian/tmp/usr/lib/python3/dist-packages/grdab/app/*.pyo
	sed -i 's/^# Generated:.*$$/#/' debian/tmp/usr/lib/python3/dist-packages/grdab/app/adjustment_gui.py

override_dh_installman:
	cd debian/man ; CHANGELOG_DATE="$(CHANGELOG_DATE)" ./genmanpages.sh
	dh_installman
