#!/usr/bin/make -f

%:
	dh $@ --parallel --sourcedirectory=$(CURDIR)/QGLViewer

override_dh_auto_configure:
	mkdir -p $(CURDIR)/debian/qt4/
	sed -i -- 's/TARGET = QGLViewer/TARGET = QGLViewer-qt4/g' QGLViewer/QGLViewer.pro
	QT_SELECT=qt4 dh_auto_configure
	cd QGLViewer ; $(MAKE) ; mv libQGLViewer-qt4* ../debian/qt4/ ; rm -rf .obj .moc *.prl Makefile ui_ImageInterface.h ui_VRenderInterface.h
	rm debian/*.log
	sed -i -- 's/TARGET = QGLViewer-qt4/TARGET = QGLViewer-qt5/g' QGLViewer/QGLViewer.pro
	QT_SELECT=qt5 dh_auto_configure -- LIB_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_install:
	find . -name '*.vcproj' -print0 | xargs -0 rm -f
	# now apply privacy cleanning rules
	find $(CURDIR)/doc/ \
			 -type f -and -name '*.html' -and -not -empty -print0 \
			 | xargs -r -0 -n 1 sed -i '/script t/,/script>/d'
	dh_auto_install
	mv debian/qt4/* debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(CURDIR)/debian/qt4
	rm -rf $(CURDIR)/debian/qt5

override_dh_auto_build: