#!/usr/bin/make -f

# TODO: build error with format security
export DEB_BUILD_MAINT_OPTIONS=hardening=+all,-format

%:
	dh $@

# Upstream build system is broken with DESTDIR, we need to set the
# local paths explicitly.
# Watch out for sysconfdir setting CFGFILE to a bogus location breaking
# the resulting binary, this has to be overwritten by explicitly
# passing CFLAGS below
override_dh_auto_configure:
	dh_auto_configure -- --prefix=$(CURDIR)/debian/gnarwl/usr \
	   --mandir=$(CURDIR)/debian/gnarwl/usr/share/man \
	   --sysconfdir=$(CURDIR)/debian/gnarwl/etc \
	   --with-docdir=$(CURDIR)/debian/gnarwl/usr/share/doc/gnarwl \
	   --with-homedir=$(CURDIR)/debian/gnarwl/var/lib/gnarwl \
	   --with-mta=/usr/sbin/sendmail

# Explicitly pass CFLAGS to make, they are not picked up from the env
# - enables hardening buildflags
# - overwrites bogus CFGFILE location
override_dh_auto_build:
	make CFLAGS="$(CFLAGS) -I.."

override_dh_auto_install:
	dh_auto_install
	rm $(CURDIR)/debian/gnarwl/usr/share/doc/gnarwl/INSTALL
	rm $(CURDIR)/debian/gnarwl/usr/share/doc/gnarwl/LICENSE
