#!/usr/bin/make -f

export DH_VERBOSE=1

export DEB_CFLAGS_MAINT_APPEND=-DNCURSES -std=gnu17 -Wno-incompatible-pointer-types -Wno-error=implicit-function-declaration -Wno-error=int-conversion  -Wno-error=old-style-declaration

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

# This is introduced to support cross-building
include /usr/share/dpkg/architecture.mk

%:
	dh $@

# Skip dh_autoreconf: the shipped configure is from autoconf 2.59 and
# autoconf 2.73 generates a broken replacement (ac_fn_c_try_link missing).
override_dh_autoreconf:

# The old Makefile.in only uses $(CFLAGS) and $(LIBS), so we merge
# CPPFLAGS into CFLAGS and LDFLAGS into LIBS for hardening compliance.
override_dh_auto_configure:
	dh_update_autotools_config
	CFLAGS="$$(dpkg-buildflags --get CFLAGS) $$(dpkg-buildflags --get CPPFLAGS)" \
	PRNTCMD=lpr LIBS="-lncurses $$(dpkg-buildflags --get LDFLAGS)" \
	  ./configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
	  --prefix=/usr --mandir=\$${prefix}/share/man \
	  --with-x --x-includes=/usr/include --x-libraries=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_install:
	dh_auto_install -- DESTDIR=$(CURDIR)/debian/xwpe/usr/bin prefix=$(CURDIR)/debian/xwpe/usr
