#!/usr/bin/make -f
# -*- makefile -*-

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

# extract the architecture for setting the library path suffix
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# extract the last section of the changelog version for extra info
DEB_VERSION ?= $(shell dpkg-parsechangelog -S Version)

# use changelog timestamp instead of build timestamp for reproducible builds
DEB_TIMESTAMP ?= $(shell date --date=@$(shell dpkg-parsechangelog -S Timestamp) +%Y-%m-%d)

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_AUTOSET_INSTALL_RPATH=FALSE \
		-DUDEV_RULES_PATH=/lib/udev/rules.d \
		-DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)" \
		-DOVERRIDE_LIME_SUITE_VERSION="$(DEB_VERSION)" \
		-DOVERRIDE_TIMESTAMP="$(DEB_TIMESTAMP)"

override_dh_installdocs:
	dh_installdocs -p soapysdr-module-lms7 \
                --link-doc=soapysdr0.5-2-module-lms7
	dh_installdocs --remaining-packages
