#!/usr/bin/make -f

%:
	dh $@ --with quilt

override_dh_auto_configure:
	dh_auto_configure -- \
	--enable-hdri \
	--enable-reproducible-build \
	--enable-shared \
	--enable-opencl \
	--with-djvu \
	--with-gs-font-dir=/usr/share/fonts/type1/gsfonts \
	--with-gslib=yes \
	--with-heic \
	--with-includearch-dir=/usr/include/$(DEB_HOST_MULTIARCH)/ \
	--with-magick-plus-plus \
	--with-modules \
	--with-openjp2 \
	--without-dps \
	--without-fpx \
	--without-gvc \
	--without-rsvg \
	--with-webp \
	--with-jxl \
	--with-fftw \
	--with-wmf

##	--with-quantum-depth=32 \
##	--docdir=/usr/share/doc/imagemagick-7-common/html \

##	--with-perl \
##	--with-perl-options='INSTALLDIRS=vendor' \

#	exit 1

override_dh_install:
# Don' delete .la files
#	find debian/tmp -name '*.la' -delete

	find $(CURDIR)/debian/tmp/usr/lib -name '*.la' -exec \
	sed -i "s,^dependency_libs=.*,dependency_libs=''," {} \;

	rm debian/tmp/usr/lib/*/libMagickCore-7.Q16HDRI.la
	rm debian/tmp/usr/lib/*/libMagickWand-7.Q16HDRI.la
	rm debian/tmp/usr/lib/*/libMagick++-7.Q16HDRI.la

	-rm -rf debian/tmp/usr/share/doc/ImageMagick-7

	dh_install

#override_dh_auto_install:
#	dh_auto_install -- \
#	pkgdocdir=/usr/share/doc/imagemagick-7-common/html

execute_after_dh_auto_install:

	for basename in compare animate convert composite conjure import identify stream display montage mogrify; do \
                mv "$(CURDIR)/debian/tmp/usr/bin/$$basename" \
                   "$(CURDIR)/debian/tmp/usr/bin/$$basename-7"; \
                mv "$(CURDIR)/debian/tmp/usr/share/man/man1/$$basename.1" \
                   "$(CURDIR)/debian/tmp/usr/share/man/man1/$$basename-7.1" ;\
        done

override_dh_missing:
	dh_missing --fail-missing

override_dh_clean:
	dh_clean PerlMagick/default/MYMETA.json PerlMagick/default/MYMETA.yml \
	PerlMagick/default/Makefile PerlMagick/default/Makefile.old \
	PerlMagick/quantum/MYMETA.json PerlMagick/quantum/MYMETA.yml \
	PerlMagick/quantum/Makefile PerlMagick/quantum/Q16HDRI.c \
	PerlMagick/quantum/Q16HDRI.o

	-find -name *.pc -delete

override_dh_auto_test:
