#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/architecture.mk

ifeq ($(DEB_BUILD_ARCH_OS),hurd)
HURD_LIBPTHREAD += -lpthread
endif

%:
	dh $@

override_dh_auto_configure:
	CXX="c++ $(HURD_LIBPTHREAD) -Wl,--as-needed -Wl,-O1" dh_auto_configure

override_dh_auto_build:
	cd doc && latex2man -M -t pstoedit.trans pstoedit.tex pstoedit.1
	cd doc && latex2man -H -t pstoedit.trans pstoedit.tex pstoedit.htm
	dh_auto_build

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/buildinfo
	rm -rf autom4te.cache
	rm -f doc/pstoedit.1 doc/pstoedit.htm

override_dh_auto_install:
	dh_auto_install
	@echo "Clearing .la files dependency_libs fields per Debian policy"	
	sed --in-place "/dependency_libs/ s/'.*'/''/" $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pstoedit/*.la

override_dh_installchangelogs:
	dh_installchangelogs doc/changelog.htm
