#!/usr/bin/make -f

# export DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# GCC "broken optimization" with GCC 5.3 causes problem
# Remove optimization temporarily
export DEB_CXXFLAGS_MAINT_STRIP = -O2

%:
	dh $@  --with autotools-dev --parallel -B

override_dh_auto_configure:
	cat debian/conffiles.md5 | md5sum -c --status
	@if [ $$? -ne 0 ]; then echo '*** Conffiles updated. Update and fix conffiles.md5'; exit 1; fi

	dh_auto_configure $@ -- \
		--with-dhcp-mysql \
		--with-dhcp-pgsql \
		--with-boost-libs=-lboost_system \
		--enable-generate-docs \
		--disable-static \
		--disable-rpath \
		--enable-generate-parser \
		--disable-dependency-tracking \
		--without-werror

override_dh_auto_make:
	$(MAKE) -C tools system_messages
	dh_auto_make

override_dh_installdocs:
	dh_installdocs -A AUTHORS README

override_dh_auto_test:
	dh_auto_test --no-parallel || /bin/true

override_dh_install:
	dh_install -X.la --list-missing

override_dh_clean:
	dh_clean
	rm -f tools/system_messages
