#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
export CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
export CXXFLAGS:=$(shell dpkg-buildflags --get CXXFLAGS)
export LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

%:
	dh $@ --sourcedirectory=Zerg

.PHONY: override_dh_auto_configure
override_dh_auto_configure:
	dh_auto_configure -- OPTIMIZE="$(CPPFLAGS) $(CFLAGS)" LD="$(shell perl -V::ld:) $(LDFLAGS)"

PERLDIR = $(shell echo $(CURDIR)/debian/libzerg-perl/usr/lib/*/perl*/*)
execute_after_dh_install:
	iconv -f ISO-8859-1 -t UTF-8 \
	< $(PERLDIR)/Zerg/Report.pm \
	> $(PERLDIR)/Zerg/Report.pm.utf8
	mv -vf $(PERLDIR)/Zerg/Report.pm.utf8 \
		$(PERLDIR)/Zerg/Report.pm
