#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

#%:
#	dh  $@

# Use override_dh_* targets to customize this.
# ---------------------------------------------------

DEB_COMPRESS_EXCLUDE := ".docbook" 

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/cmake.mk
# include /usr/share/cdbs/1/rules/simple-patchsys.mk
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

clean::
	# TODO if makefile...
	# clean QT version
	qmake-qt4 -nocache src-QT4/kdiff3.pro -o src-QT4/Makefile
	make -C src-QT4 distclean
	# remove generated man page
	rm -f debian/kdiff3.1

build/kdiff3::
	# generate man page
	/usr/bin/docbook-to-man debian/kdiff3.sgml > debian/kdiff3.1

build/kdiff3-qt::
	qmake-qt4 -nocache src-QT4/kdiff3.pro -o src-QT4/Makefile
	make -C src-QT4 prefix=$(CURDIR)/debian/kdiff3-qt

install/kdiff3::
	# install man page
	mkdir --parents $(DEB_DESTDIR)usr/share/man/man1
	cp debian/kdiff3.1 $(DEB_DESTDIR)usr/share/man/man1/kdiff3.1
	# update gnome's icon cache
	dh_icons --package kdiff3 --tmpdir=debian/tmp

install/kdiff3-qt::
	mkdir --parents $(CURDIR)/debian/kdiff3-qt
	make INSTALL_ROOT=$(CURDIR)/debian/kdiff3-qt install -C src-QT4 prefix=$(CURDIR)/debian/kdiff3-qt
	cd po && export INSTALL_ROOT=$(CURDIR)/debian/kdiff3-qt && /bin/sh create_qm_files install
	# update gnome's icon cache
	dh_icons --package kdiff3-qt --tmpdir=debian/tmp
	
install/kdiff3-doc::
	# install HTML help
	mkdir --parents $(DEB_DESTDIR)usr/share/doc/kdiff3-doc/html/
	cp doc/en/*.html $(DEB_DESTDIR)usr/share/doc/kdiff3-doc/html/
