#!/usr/bin/make -f

CONF_OPTIONS := \
	--with-default-io-provider=io-desktop \
	--with-caja \
	--with-nemo \
	--enable-html-manuals \
	--disable-scrollkeeper

ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
	export DH_VERBOSE = 1
else
	CONF_OPTIONS += --quiet
endif


# Disable tests since the XML validation performed by xmllint
# requires remote DTDs.
export DEB_BUILD_OPTIONS += nocheck
export DEB_BUILD_MAINT_OPTIONS = hardening=+all future=+lfs

#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Prevent network connections.
export http_proxy := http://127.0.0.1:9/

%:
	dh $@

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_auto_configure -- $(CONF_OPTIONS)

# Add larger-sized icons to make the package AppStream-ready.
ICON_SIZES := 64 128 256 512

override_dh_auto_install-indep: icons/scalable/filemanager-actions.svg
	dh_auto_install -i
	set -e; \
	for S in $(ICON_SIZES); do \
		D="debian/tmp/usr/share/icons/hicolor/$${S}x$${S}/apps"; \
		install -d "$${D}"; \
		inkscape -z -e "$${D}/filemanager-actions.png" -w $${S} -h $${S} $<; \
	done

override_dh_makeshlibs:
	dh_makeshlibs --no-act

override_dh_shlibdeps:
	dh_shlibdeps -Lfilemanager-actions-libs

override_dh_install:
	dh_install -X.la

override_dh_installdocs-indep:
	dh_installdocs -i
	jdupes -rl debian/filemanager-actions-doc

MAN_PAGES := $(shell cat debian/filemanager-actions-data.manpages)

$(MAN_PAGES): %: %.md
	pandoc -s -t man -o $@ $<

override_dh_installman-indep: $(MAN_PAGES)
	dh_installman -i
