#!/usr/bin/make -f

export DH_VERBOSE=1

export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

CFLAGS = -Wall -g
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
    CFLAGS += -O0
else
    CFLAGS += -O2
endif

ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
    confflags += --build $(DEB_HOST_GNU_TYPE)
else
    confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif

%:
	dh $@

override_dh_auto_configure:
	chmod +x ./debian/autogen.sh
	./debian/autogen.sh
	dh_auto_configure -- $(confflags) --with-gpgme

override_dh_auto_build:
	$(MAKE) CFLAGS="$(CFLAGS)"

override_dh_fixperms:
	chmod 600 $(CURDIR)/debian/fwknop-server/etc/fwknop/access.conf
	dh_fixperms --exclude access.conf

override_dh_strip:
	dh_strip --dbg-package=libfko0-dbg
