#!/usr/bin/make -f

export DEB_LDFLAGS_MAINT_APPEND=-Wl,-z,defs -Wl,--as-needed -Wl,-O1
export DEB_BUILD_MAINT_OPTIONS=hardening=+pie,+bindnow

override_dh_auto_configure:
	exo-csource --static --name=`basename xfdesktop-settings-ui.glade .glade | sed -e 's/-/_/g'` \
		 $(CURDIR)/settings/xfdesktop-settings-ui.glade >$(CURDIR)/settings/xfdesktop-settings-ui.h
	NOCONFIGURE=1 xdt-autogen
	find .pc -type f -name '*.c' -exec echo '{}' >> po/POTFILES.skip \;
	dh_auto_configure -- --enable-thunarx --enable-exo \
	 	--docdir=\$${prefix}/share/doc/xfdesktop4-data

override_dh_auto_clean:
	rm -f po/POTFILES.skip
	dh_auto_clean
	rm -f aclocal.m4 config.guess config.sub configure ltmain.sh settings/xfdesktop-settings-ui.h
	rm -f $$(find -name 'Makefile.in*')

override_dh_install:
	chrpath -d -k $(CURDIR)/debian/tmp/usr/bin/*
	
	dh_install --sourcedir=debian/tmp --fail-missing
	# why oh why is this necessary?
	rm -rf $(CURDIR)/debian/xfdesktop4-data/usr/share/man
	# clean up wallpapers, cf. <https://blueprints.launchpad.net/ubuntu/+spec/other-p-xubuntu-cleanthemes>
	rm -f $(CURDIR)/debian/xfdesktop4-data/usr/share/xfce4/backdrops/xfce-in-a-grid.png
	rm -f $(CURDIR)/debian/xfdesktop4-data/usr/share/xfce4/backdrops/xfce-in-the-moon.png
	rm -f $(CURDIR)/debian/xfdesktop4-data/usr/share/xfce4/backdrops/xfce-smoke.png
	rm -f $(CURDIR)/debian/xfdesktop4-data/usr/share/xfce4/backdrops/xfce-stellar-tile.png
	rm -f $(CURDIR)/debian/xfdesktop4-data/usr/share/xfce4/backdrops/xfce-turbulence.png
	rm -f $(CURDIR)/debian/xfdesktop4-data/usr/share/xfce4/backdrops/xfce4gradientcurve.png
	rm -f $(CURDIR)/debian/xfdesktop4-data/usr/share/xfce4/backdrops/xfce4logo.png

override_dh_link:
	rm -rf $(CURDIR)/debian/xfdesktop4/usr/share/doc/xfdesktop4
	ln -s xfdesktop4-data $(CURDIR)/debian/xfdesktop4/usr/share/doc/xfdesktop4
	dh_link

override_dh_strip:
	dh_strip --dbg-package=xfdesktop4-dbg

%:
	dh $@
