#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all reproducible=+fixfilepath
export DPKG_EXPORT_BUILDFLAGS=1
export LC_ALL=C
export LANG=C
export TZ=GMT

include /usr/share/dpkg/buildflags.mk

export CCFLAGS+=$(shell dpkg-buildflags --get CFLAGS)
export CCFLAGS+=$(shell dpkg-buildflags --get CPPFLAGS)
export LDFLAGS+=$(shell dpkg-buildflags --get LDFLAGS)

ARCH = $(shell bin/package)

%:
	dh $@

override_dh_auto_configure:
	@echo "CCFLAGS=$(CCFLAGS)"
	@echo "LDFLAGS=$(LDFLAGS)"

override_dh_auto_build:
	bin/package make strip=0

override_dh_auto_install-arch:
	cp arch/$(ARCH)/bin/ksh debian/ksh93u+m/bin/ksh93
	cp arch/$(ARCH)/bin/shcomp debian/ksh93u+m/usr/bin/shcomp93
	cp arch/$(ARCH)/man/man1/sh.1 debian/ksh93u+m/usr/share/man/man1/ksh93.1
	cp arch/$(ARCH)/fun/* debian/ksh93u+m/usr/share/ksh/functions

override_dh_installchangelogs:
	dh_installchangelogs NEWS

override_dh_gencontrol:
	dh_gencontrol --package=ksh93u+m
	dh_gencontrol --package=ksh -- -v20211217

clean:
	dh_testdir
	dh_clean
