#!/usr/bin/make -f

DEB_BUILD_MAINT_OPTIONS=hardening=+bindnow
DPKG_EXPORT_BUILDFLAGS=1
include /usr/share/dpkg/buildflags.mk

SOURCEDIR = $(CURDIR)/linux
DESTDIR = $(CURDIR)/debian/tmp

export PREFIX = /usr
export LIBDIR = /usr/lib/spectrwm
export SYSCONFDIR = /etc

%:
	dh $@

# Build, install and clean.
#
# The Makefile we need to use is in the linux/ directory, so we need
# to override the usual dh_auto_* commands to prevent them from using
# the top-level Makefile, which only works on OpenBSD.
#
# We also move some files after installation, to make things easier
# for the tools that are going to move them into the Debian package.
override_dh_auto_build:
	dh_auto_build --sourcedir=$(SOURCEDIR)

override_dh_auto_install:
	dh_auto_install --sourcedir=$(SOURCEDIR) --destdir=$(DESTDIR)
	mv $(DESTDIR)/usr/share/doc/spectrwm/CHANGELOG.md \
	   $(DESTDIR)/usr/share/doc/spectrwm/NEWS

override_dh_auto_clean:
	dh_auto_clean --sourcedir=$(SOURCEDIR)

# Prevent CHANGELOG.md from being installed.
#
# Despite the name, we don't want it to end up being installed as
# changelog.gz, as doing so would go against Policy.
override_dh_installchangelogs:
	dh_installchangelogs --exclude=CHANGELOG.md

# Don't try to run tests.
#
# spectrwm doesn't have a test suite, but the OpenBSD Makefile in the
# top-level directory confuses dh_auto_test's detection and tricks it
# into thinking one exists.
override_dh_auto_test:

# Don't create shlibs files.
#
# libswmhack.so is not a proper shared library, and it should not be
# treated as such.
override_dh_makeshlibs:
