#!/usr/bin/make -f

pkg=texmaker
data=$(pkg)-data

%:
	dh $@

override_dh_auto_clean:
	[ ! -f Makefile ] || $(MAKE) distclean
	$(RM) .obj/* .moc/* .ui/* 
	dh_auto_clean

override_dh_auto_build:
	qmake-qt4 -unix PREFIX=/usr QMAKE_CFLAGS="$(CPPFLAGS)" QMAKE_CXXFLAGS="$(CXXFLAGS)" QMAKE_LFLAGS="$(LDFLAGS)" texmaker.pro

override_dh_auto_test:
	# do not try testing

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
