#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/hardening-includes/hardening.make

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

export CFLAGS LDFLAGS

DEB_CONFIGURE_EXTRA_FLAGS := --disable-gnome-thumbnailers --enable-dbus --enable-startup-notification

makebuilddir/libthunar-vfs-1-2:: debian/compat
	# Some systems don't have POSIX_MADV* but have MADV* defined with
	# the same values anyway.
	grep -q POSIX_MADV foo || sed -i -e 's/POSIX_MADV/MADV/' \
		$(CURDIR)/thunar-vfs/*.c
	

install/libthunar-vfs-1-2::
	rm -f $(CURDIR)/debian/tmp/usr/lib/*.la 
	rm -f $(CURDIR)/debian/tmp/usr/lib/*/*.la 
	chrpath -d -k $(CURDIR)/debian/tmp/usr/lib/libthunar*.so.*2

install/libthunar-vfs-1-common::
	cd $(CURDIR)/debian/tmp/usr/share/doc/ && mv thunar-vfs libthunar-vfs-1-common

# The symlinks below aren't enough for dpkg to replace a directory with a
# symlink but they mean it's part of the package.

binary-post-install/libthunar-vfs-1-2::
	cd $(CURDIR)/debian/libthunar-vfs-1-2/usr/share/doc/ && \
		rm -rf libthunar-vfs-1-2 && \
		ln  -sf libthunar-vfs-1-common libthunar-vfs-1-2

binary-post-install/libthunar-vfs-1-dev::
	cd $(CURDIR)/debian/libthunar-vfs-1-dev/usr/share/doc/ && \
		rm -rf libthunar-vfs-1-dev && \
		ln  -sf libthunar-vfs-1-common libthunar-vfs-1-dev
