#!/usr/bin/make -f
#export DH_VERBOSE=1
include /usr/share/dpkg/pkg-info.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# This is needed to work around arch-specific quirks in the test suite.
DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

# Get the hardening build flags and enable all compiler warnings:
CFLAGS   := $(shell dpkg-buildflags --get CFLAGS) -Wall -D_FILE_OFFSET_BITS=64
CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) -Wall -D_FILE_OFFSET_BITS=64
CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS  := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed

# Enable debug code, if nostrip was given.
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
	DEBUG_OPTS =
else
	DEBUG_OPTS = -DCMAKE_BUILD_TYPE=Debug
endif

CONFIG := -DENABLE_EXTERNAL_MSPACK=ON -DENABLE_UNRAR=ON -DENABLE_EXTERNAL_TOMFASTMATH=ON \
	  -DENABLE_APP=OFF -DENABLE_CLAMONACC=OFF -DENABLE_MAN_PAGES=OFF -DENABLE_SYSTEMD=OFF \
	  -DENABLE_DOXYGEN=OFF -DDO_NOT_SET_RPATH=ON -DENABLE_MILTER=OFF\
	  $(DEBUG_OPTS)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIG)
