#!/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
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic -D_REENTRANT
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Variables used by cdbs
DEB_COMPRESS_EXCLUDE = html

%:
	dh $@ --with autoreconf --with autotools-dev --parallel

override_dh_auto_configure:
	dh_auto_configure -- \
	  --with-docdir="\$${prefix}/share/doc/libtiff-doc" \
	  --libdir="\$${prefix}/lib/$(DEB_HOST_MULTIARCH)" \
	  --includedir="\$${prefix}/include/$(DEB_HOST_MULTIARCH)" \
	  --enable-ld-version-script

override_dh_install:
	dh_install --list-missing -X.la
	# tiffgt is in libtiff-opengl so libtiff-tools doesn't have to have
	# all the X and opengl dependencies.
	rm -f debian/libtiff-tools/usr/bin/tiffgt
	rm -f debian/libtiff-tools/usr/share/man/man1/tiffgt.1*
	# removal as CVE-2015-8668 ,CVE-2016-3619 , CVE-2016-3620 ,
	# CVE-2016-3621 and CVE-2016-5319:
	rm -f ./debian/libtiff-doc/usr/share/doc/libtiff-doc/html/man/bmp2tiff.1.html
	rm -f debian/libtiff-tools/usr/bin/bmp2tiff
	rm -f debian/libtiff-tools/usr/share/man/man1/bmp2tiff.1*
	# removal as CVE-2016-3186 and CVE-2016-5102:
	rm -f ./debian/libtiff-doc/usr/share/doc/libtiff-doc/html/man/gif2tiff.1.html
	rm -f debian/libtiff-tools/usr/bin/gif2tiff
	rm -f debian/libtiff-tools/usr/share/man/man1/gif2tiff.1*
	# removal as CVE-2016-3631 , CVE-2016-3632 , CVE-2016-3633 ,
	# CVE-2016-3634 and CVE-2016-8331:
	rm -f debian/libtiff-doc/usr/share/doc/libtiff-doc/html/man/thumbnail.1.html
	rm -f debian/libtiff-tools/usr/bin/thumbnail
	rm -f debian/libtiff-tools/usr/share/man/man1/thumbnail.1*
