#!/usr/bin/make -f
#
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
DH_ALWAYS_EXCLUDE:=CVS:.svn:.svnignore:.git:.gitignore

export CC  = gcc-4.8
export CXX = g++-4.8

# Optimize with O3 to make the computationally expensive higher levels faster.
export DEB_CXXFLAGS_MAINT_STRIP  = -O2
export DEB_CXXFLAGS_MAINT_APPEND = -O3
# Link “as needed” to minimize the dependencies of the KDE thumbnailer on
# KDE libraries it doesn’t actually use.
export DEB_LDFLAGS_MAINT_APPEND  = -Wl,--as-needed

define \n


endef

pngs := $(subst .svg,.png,$(wildcard src/pentobi/icons/*.svg) \
		$(wildcard src/libboardgame_gui/icons/*.svg))

override_dh_auto_configure:
	rm -f $(pngs)
	dh_auto_configure -- -DCMAKE_INSTALL_BINDIR=/usr/games \
			-DCMAKE_INSTALL_DATADIR=/usr/share/games \
			-DPENTOBI_BUILD_KDE_THUMBNAILER=ON \
			-DPENTOBI_BUILD_TESTS=ON

override_dh_auto_build:
	$(foreach png,$(pngs),inkscape -e $(png) $(subst .png,.svg,$(png)) $(\n))
	convert src/pentobi/icons/pentobi-32.png src/pentobi/icons/pentobi.xpm
	dh_auto_build

override_dh_install:
	rm -f debian/tmp/usr/share/doc/pentobi/COPYING
	mv debian/tmp/usr/share/doc/pentobi/NEWS \
			debian/tmp/usr/share/doc/pentobi/changelog
	dh_install
	# Replace duplicate files of en_CA and en_GB manuals with symlinks.
	rdfind -outputname /dev/null -makesymlinks true \
			debian/pentobi/usr/share/doc/pentobi/manual
	symlinks -r -s -c debian/pentobi/usr/share/doc/pentobi/manual

override_dh_makeshlibs:
	dh_makeshlibs -Xusr/lib/kde4/pentobi-thumbnail.so

%:
	dh $@ --parallel
