#!/usr/bin/make -f

pkg := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')

%:
	dh $@ --with quilt

override_dh_auto_configure:
	lrelease global_resources/translations/*.ts
	qmake-qt4 -r -config release "CONFIG+=LINUX_INTEGRATED" "INSTALL_ROOT_PATH=$(CURDIR)/debian/tmp/usr/" LOWERED_APPNAME="$(pkg)" $(pkg).pro

# Upstream does not seem to provide a proper clean target - clean up here
override_dh_auto_clean:
	rm -rf bin/plugins/* bin/$(pkg)
	find build -type d -name "\.*" -exec rm -rf \{\} \; 2> /dev/null || true
	rm -rf contrib/quazip/libz.a
	rm -f global_resources/translations/[a-ps-z]*.qm
	dh_auto_clean

override_dh_auto_install:
	make install

override_dh_install:
	# Remove those Links to dynamic libraries which have no version number (this should only
	# be provided in -dev packages.  But some *.so files are real files without version number
	# FIXME
	# find $(CURDIR)/debian/tmp/usr/lib/$(pkg) -type l -name "*.so" -exec rm -f \{\} \;
	
	# remove doc files from /usr/bin
	rm -f debian/tmp/usr/bin/[CR]*

	dh_install

override_dh_shlibdeps::
	LD_LIBRARY_PATH=debian/tmp/usr/lib/$(pkg) dh_shlibdeps -l/usr/lib/$(pkg)

override_dh_installdeb:
	# remove extra license file
	rm -f $(CURDIR)/debian/$(pkg)/usr/share/freediams/textfiles/COPYING.txt
	dh_installdeb
