#!/usr/bin/make -f

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

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --parallel

override_dh_auto_configure:
	dh_auto_configure -- \
		--docdir=\$${prefix}/share/doc/thunar-data \
		--disable-silent-rules \
		--enable-dbus --enable-startup-notification --enable-apr-plugin \
		--enable-exif --enable-pcre --enable-sbr-plugin --enable-tpa-plugin \
		--enable-uca-plugin

override_dh_install:
	rm -f $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*.la
	rm -f $(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/*/*.la
	# rpath
	chrpath -d -k $(CURDIR)/debian/tmp/usr/bin/Thunar \
		$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/Thunar/thunar-* \
		$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libthunar*.so.*0 \
		$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/thunarx-2/thunar-apr.so \
		$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/xfce4/panel/plugins/libthunar-tpa.so
	dh_install --fail-missing -X usr/lib/$(DEB_HOST_MULTIARCH)/xfce4/panel/plugins/libthunar-tpa.la

override_dh_installdocs:
	dh_installdocs -p libthunarx-2-dev -p libthunarx-2-0 -p thunar --link-doc=thunar-data
	dh_installdocs --remaining-packages

override_dh_strip:
	dh_strip --dbg-package=thunar-dbg

override_dh_shlibdeps:
	dh_shlibdeps -X debian/thunar/usr/lib/$(DEB_HOST_MULTIARCH)/xfce4/panel/plugins/libthunar-tpa.so -- \
    -dRecommends debian/thunar/usr/lib/$(DEB_HOST_MULTIARCH)/xfce4/panel/plugins/libthunar-tpa.so -dDepends

override_dh_makeshlibs:
	dh_makeshlibs -p libthunarx-2-0 -X debian/libthunarx-2-0/usr/lib/$(DEB_HOST_MULTIARCH)/thunarx-2
