#!/usr/bin/make -f

ACTUAL_PROG	= cdialog

export DEB_BUILD_MAINT_OPTIONS := hardening=+all qa=+bug reproducible=+all

%:
	dh $@

# dh_autoreconf interferes with portability -- skip it
override_dh_autoreconf:
	echo "skip: dh_autoreconf autoreconf-dickey -- -f -i"

override_dh_auto_configure:
	cp -v package/dialog.map package/${ACTUAL_PROG}.map
	dh_auto_configure -- \
		--prefix=/usr \
		--disable-echo \
		--enable-nls \
		--enable-header-subdir \
		--enable-stdnoreturn \
		--enable-widec \
		--with-package=${ACTUAL_PROG} \
		--with-program-prefix=c \
		--with-shared \
		--with-screen=ncursesw6 \
		--with-versioned-syms \
		--disable-rpath-hack

override_dh_auto_install:
	dh_auto_install -- install install-lib

override_dh_install:
	dh_install

override_dh_link:
	sh -c "\
		S=$$(awk '{gsub(":","."); print $$1}' <VERSION); \
		D=$$(awk '{gsub(":","."); print $$2}' <VERSION); \
	sed -i.bak \
		-e \"s/.SRC/.\$$S/\" \
		-e \"s/.DST/.\$$D/\" \
		debian/cdialog.links"
	diff -u debian/cdialog.links.bak debian/cdialog.links || echo OK
	dh_link

override_dh_installdocs:
	dh_installdocs -v README

override_dh_installchangelogs:
	dh_installchangelogs CHANGES
