#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

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

DESTDIR = $(CURDIR)/debian/tmp

override_dh_auto_test:
	LD_LIBRARY_PATH=$(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE)/libvips dh_auto_test -- --timeout-multiplier=10

override_dh_auto_configure:
	dh_auto_configure -- \
		-Dcpp-docs=$(if $(filter libvips-doc,$(shell dh_listpackages)),true,false) \
		-Ddocs=$(if $(filter libvips-doc,$(shell dh_listpackages)),true,false)

execute_after_dh_auto_install-indep:
ifneq (,$(filter libvips-doc,$(shell dh_listpackages)))
	install -d -m0755 $(DESTDIR)/usr/share/gtk-doc/html/
	mv $(DESTDIR)/usr/share/doc/vips/ \
		$(DESTDIR)/usr/share/gtk-doc/html/libvips/
	install -d -m0755 $(DESTDIR)/usr/share/doc/libvips-doc/
	mv $(DESTDIR)/usr/share/doc/vips-cpp/html/ \
		$(DESTDIR)/usr/share/doc/libvips-doc/
endif

execute_after_dh_auto_install-arch:
	perl $(CURDIR)/debian/scripts/create_missing_manual_pages

%:
	dh $@ --buildsystem=meson --with gir

.PHONY: override_dh_auto_configure override_dh_auto_test \
	execute_after_dh_auto_install-arch execute_after_dh_auto_install-indep
