#! /usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
#include /usr/share/hardening-includes/hardening.make
include /usr/share/dpkg/buildflags.mk

CFLAGS		?= $(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS	?= $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS		?= $(shell dpkg-buildflags --get LDFLAGS)
CFLAGS		+= $(HARDENING_CFLAGS)
CFLAGS		+= $(CPPFLAGS)
CPPFLAGS	+= $(HARDENING_CFLAGS)
LDFLAGS		+= $(HARDENING_LDFLAGS)

DESTDIR = $(CURDIR)/debian/tmp/

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	DEBUG = DEBUG=yes
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

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

override_dh_auto_build:
	cd $(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE)/ && \
		$(MAKE) SYSTEM=linux PBKDF_BACKEND=gcrypt $(DEBUG)

# test needs the library, which can't be built ATM
override_dh_auto_test:

# for the rest, use debhelper
%:
	dh $@
