#!/usr/bin/make -f

export PWD=$(shell pwd)

include /usr/share/hardening-includes/hardening.make

CFLAGS=$(shell dpkg-buildflags --get CFLAGS)
LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)
LDFLAGS+=$(HARDENING_LDFLAGS) -Wl,-z,defs -Wl,--as-needed -Wl,-O1
CFLAGS+=$(HARDENING_CFLAGS)

export CFLAGS LDFLAGS

XFVENDOR=Debian
ifeq ($(shell dpkg-vendor --is Ubuntu && echo yes),yes)
	XFVENDOR=Xubuntu
endif

override_dh_auto_configure:
	find .pc -type f -exec echo '{}' \; >> po/POTFILES.skip
	NOCONFIGURE=1 xdt-autogen
	dh_auto_configure -- --with-vendor-info=$(XFVENDOR) --with-x \
		--with-browser=midori --docdir=\$${prefix}/share/doc/xfce4-utils \
		--disable-xfconf-migration

override_dh_install:
	rm -f `pwd`/debian/xfce4-utils/usr/lib/xfce4/mcs-plugins/*.la
	rm -f `pwd`/debian/xfce4-utils/usr/lib/xfce4/mcs-plugins/*.a

	install -D -m 644 `pwd`/debian/Debian \
		`pwd`/debian/xfce4-utils/usr/share/xfce4/Debian

	chrpath -d -k `pwd`/debian/xfce4-utils/usr/bin/xfrun4 \
		`pwd`/debian/xfce4-utils/usr/bin/xfce4-about
	chmod +x `pwd`/debian/xfce4-utils/etc/xdg/xfce4/xinitrc

override_dh_auto_clean:
	rm -f po/POTFILES.skip
	dh_auto_clean

%:
	dh $@
