#!/usr/bin/make -f
# debian/rules for enblend-enfuse
#
# Written by Sebastian Harl <sh@tokkee.org>.
# Andreas Metzler <ametzler@debian.org>

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

#used by  debian/patches/20_reproducible_sig.diff
export DEB_TOP_DIR:=$(CURDIR)

export DEB_CFLAGS_MAINT_APPEND := -Wall
export DEB_CXXFLAGS_MAINT_APPEND := -pipe
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed
export DEB_BUILD_MAINT_OPTIONS := hardening=+all

CONFARGS:=--enable-gpu-support=yes \
		--with-boost-filesystem=yes \
		--with-openexr=yes


get-orig-source:
	dh_testdir
	dh_testroot
	chmod 755 debian/bin/uscan_repack.sh
	uscan --verbose --force-download --rename

override_dh_auto_configure:
	dh_auto_configure --verbose \
		--builddirectory=build-no-mp -- $(CONFARGS) \
		--disable-openmp \
		--enable-image-cache=yes
	dh_auto_configure --verbose \
		--builddirectory=build-tree-mp -- $(CONFARGS) \
		--enable-openmp \
		--disable-image-cache

override_dh_auto_build:
	dh_auto_build --verbose --parallel --builddirectory=build-no-mp
	cd build-no-mp && $(MAKE) pdf
	dh_auto_build --verbose --parallel --builddirectory=build-tree-mp

	sed -i -e "s/manual page for enblend.*/combine images using a multiresolution spline/" \
		build-no-mp/src/enblend.1
	sed -i -e "s/manual page for enfuse.*/poor man's HDR/" \
		build-no-mp/src/enfuse.1

override_dh_auto_install:
	dh_auto_install --verbose --builddirectory=build-no-mp
	install -m755  build-tree-mp/src/enblend \
		$(CURDIR)/debian/tmp/usr/bin/enblend-mp
	install -m755  build-tree-mp/src/enfuse \
		$(CURDIR)/debian/tmp/usr/bin/enfuse-mp

override_dh_compress:
	dh_compress -X.pdf

override_dh_install:
	dh_install --fail-missing

override_dh_installdocs:
	dh_installdocs -A -a NEWS AUTHORS

%:
	dh $@ --with autotools_dev --builddirectory=build-no-mp
