#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=+lto

%:
	dh $@ --with pkgkde_symbolshelper --buildsystem cmake

override_dh_auto_configure:
	dh_auto_configure -- \
	    -DEXIV2_ENABLE_BMFF=ON \
	    -DEXIV2_ENABLE_NLS=ON \
	    -DEXIV2_ENABLE_VIDEO=ON \
	    -DEXIV2_ENABLE_WEBREADY=ON \
	    -DEXIV2_BUILD_UNIT_TESTS=ON \
	    -DEXIV2_BUILD_SAMPLES=OFF \
	    -DEXIV2_BUILD_DOC=$(if $(filter libexiv2-doc, $(shell dh_listpackages)),ON,OFF) \
	    -DCMAKE_INSTALL_DOCDIR=/usr/share/doc/exiv2/html

execute_after_dh_auto_install:
	find $(CURDIR)/debian -type f -name exiv2 | xargs /usr/bin/chrpath -d

execute_after_dh_auto_build-indep:
	dh_auto_build -- doc

override_dh_auto_test:
	# path conflicts between the tests
	dh_auto_test --no-parallel

override_dh_installdocs:
	dh_installdocs -A -Xcmd.txt -XMakefile -Xtemplates -XChangeLog
	find $(CURDIR)/debian -name jquery.js -exec ln -sfv /usr/share/javascript/jquery/jquery.js {} \;
	find $(CURDIR)/debian \( -name '*.map' -o -name '*.md5' \) -delete

override_dh_installchangelogs:
	dh_installchangelogs -A doc/ChangeLog

override_dh_compress:
	dh_compress -X.js -X.xml
