#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

DHFLAGS=--parallel
DEB_ATRIL_FLAGS=
ifeq ($(shell dpkg-vendor --is Debian && echo yes),yes)
ifeq ($(shell lsb_release -cs),wheezy)
	DEB_ATRIL_FLAGS=--without-keyring
endif
endif

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


%:
	dh $@ $(DHFLAGS) --with gir --without autoreconf


# dh_make generated override targets.
# This is an example for Cmake (see <https://bugs.debian.org/641051>).
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_missing:
	dh_missing --fail-missing

override_dh_install:
	rm -rfv debian/tmp/usr/lib/*/*.la
	rm -rfv debian/tmp/usr/lib/*/caja/extensions-2.0/*.la
	rm -rfv debian/tmp/usr/lib/*/atril/3/backends/*.la
	mkdir -p debian/tmp/usr/share/doc/atril/
	mv debian/tmp/usr/share/gtk-doc/html/atril debian/tmp/usr/share/doc/atril/html
	mkdir -p debian/tmp/usr/share/doc/libatrilview-dev/
	mv debian/tmp/usr/share/gtk-doc/html/libatrilview-1.5.0 debian/tmp/usr/share/doc/libatrilview-dev/html
	mkdir -p debian/tmp/usr/share/doc/libatrildocument-dev/
	mv debian/tmp/usr/share/gtk-doc/html/libatrildocument-1.5.0 debian/tmp/usr/share/doc/libatrildocument-dev/html
	dh_install

override_dh_auto_test:
	DEB_BUILD_OPTIONS=nocheck dh_auto_test

override_dh_auto_configure:
	# we need libegg from mate-submodules
	cd cut-n-paste/smclient/; tar xvJf /usr/src/mate-submodules-source.tar.xz
	NOCONFIGURE=1 ./autogen.sh
	dh_auto_configure $(DHFLAGS) -- \
		--enable-gtk-doc \
		--enable-djvu \
		--enable-dvi \
		--enable-t1lib \
		--enable-pixbuf \
		--enable-comics \
		--enable-introspection \
		--disable-silent-rules \
		--disable-static \
		--libexecdir=/usr/libexec \
		$(DEB_ATRIL_FLAGS)

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
