#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)

override_dh_auto_configure:
	dh_testdir
	CONFIG_SHELL=/bin/sh ./configure $(CROSS) --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info \
		--sysconfdir=/etc \
		CFLAGS="$(CFLAGS) $(CPPFLAGS)" \
		LDFLAGS="$(LDFLAGS) -lresolv -Wl,-z,defs -L/usr/lib/libmilter" \
		--enable-filter-tests \
		--with-spf \
		--with-spf2-include=/usr/include/spf2 \
		--with-spf2-lib=/usr/lib \
		--with-sql-backend

override_dh_installdocs:
	dh_installdocs
	mkdir -p $(CURDIR)/debian/opendmarc/usr/share/doc/opendmarc
	cp opendmarc/README $(CURDIR)/debian/opendmarc/usr/share/doc/opendmarc/README.opendmarc

override_dh_installchangelogs:
	dh_installchangelogs RELEASE_NOTES

override_dh_fixperms-arch:
	dh_fixperms
	chmod +x $(CURDIR)/debian/opendmarc/lib/opendmarc/opendmarc.service.generate

