#!/usr/bin/make -f

%:
	dh $@ --parallel

IBASE=src/ibpp/ibase.h

REV_FILE=src/revisioninfo.h

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

override_dh_auto_configure:
	sh debian/mangle-svn-rev.sh
	[ -e config.sub-ORIG ]   || mv config.sub   config.sub-ORIG
	[ -e config.guess-ORIG ] || mv config.guess config.guess-ORIG
	#! [ -e $(IBASE) ]        || mv $(IBASE) $(IBASE)-ORIG
	cp /usr/share/misc/config.sub .
	cp /usr/share/misc/config.guess .
	chmod u+x configure
	dh_auto_configure -- $(shell dpkg-buildflags --export=configure)
	sed -i 's|-Wl,-R/usr/local/lib ||' Makefile
	
	# the build process may change this file. save a copy
	# and restore it in clean
	cp $(REV_FILE) $(REV_FILE)-ORIG

override_dh_auto_build:
	dh_auto_build -O--parallel
	chrpath -d flamerobin

override_dh_auto_clean:
	dh_auto_clean
	if [ -f Makefile ]; then $(MAKE) distclean; fi
	[ ! -e $(REV_FILE)-ORIG ] || mv -f $(REV_FILE)-ORIG $(REV_FILE)
	[ ! -e config.sub-ORIG ]   || mv config.sub-ORIG   config.sub
	[ ! -e config.guess-ORIG ] || mv config.guess-ORIG config.guess
	#[ ! -e $(IBASE)-ORIG ] || [ -e $(IBASE) ] || mv $(IBASE)-ORIG $(IBASE)
	sh debian/unmangle-svn-rev.sh

override_dh_auto_install:
	$(MAKE) install prefix=$(CURDIR)/debian/flamerobin/usr
	cp res/fricon128.png $(CURDIR)/debian/flamerobin/usr/share/pixmaps/flamerobin.png

override_dh_installchangelogs:
	html2text docs/fr_whatsnew.html > upstream-changelog
	dh_installchangelogs upstream-changelog