#!/usr/bin/make -f

pkg=texmaker
data=$(pkg)-data

%:
	dh $@

clean:
	dh clean --before dh_auto_clean
	[ ! -f Makefile ] || $(MAKE) distclean
	$(RM) .obj/* .moc/* .ui/* 
	dh clean --after  dh_auto_clean
build:
	dh build --before dh_auto_build
	# qmake-qt4 -unix PREFIX=/usr CPPFLAGS="$(CPPFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" texmaker.pro
	# this simple means does not help to propagate hardening :-(
	qmake-qt4 -unix PREFIX=/usr texmaker.pro
	dh build --after dh_auto_build --before dh_auto_test
	dh build --after dh_auto_test

override_dh_installchangelogs:
	dh_installchangelogs utilities/CHANGELOG.txt

override_dh_installdocs:
	dh_installdocs
	# Setting symlinks from doc dir to /usr/share/texmaker
	for docfile in `ls $(CURDIR)/debian/$(data)/usr/share/doc/$(pkg)/html/*` ; do \
	    ln -s ../doc/$(pkg)/html/`basename $${docfile}` $(CURDIR)/debian/$(data)/usr/share/$(pkg) ; \
	done

override_dh_install:
	dh_install
	# Rename all hicolor icons to texmaker.png
	[ ! -d $(CURDIR)/debian/$(data)/usr/share/icons/hicolor/ ] || for i in 16 22 32 48 64 128 ; do \
	    mv $(CURDIR)/debian/$(data)/usr/share/icons/hicolor/$${i}x$${i}/apps/$(pkg)$${i}x$${i}.png \
	        $(CURDIR)/debian/$(data)/usr/share/icons/hicolor/$${i}x$${i}/apps/$(pkg).png ; \
	done
