#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# reproducibility
LC_ALL=C
LANG=C
TZ=/usr/share/zoneinfo/Etc/GMT
export LC_ALL
export LANG
export TZ

# provide a fake HOME directory to solve test fails
HOME=$(CURDIR)/debian/fakehome
export HOME

%:
	dh $@ --no-parallel

override_dh_auto_install:
	dh_auto_install
	# Rename /usr/bin/ksh93 to /usr/bin/ksh2020 to co-exist with ksh93
	# as well as make use of the alternative system
	mv $(CURDIR)/debian/ksh/usr/bin/ksh $(CURDIR)/debian/ksh/usr/bin/ksh2020
	mv $(CURDIR)/debian/ksh/usr/bin/shcomp $(CURDIR)/debian/ksh/usr/bin/shcomp2020
	# Also rename the man pages
	mv $(CURDIR)/debian/ksh/usr/share/man/man1/ksh.1 \
	        $(CURDIR)/debian/ksh/usr/share/man/man1/ksh2020.1

override_dh_installchangelogs:
	# ChangeLog till 93v is provided in src/cmd/ksh93/RELEASE
	dh_installchangelogs -k CHANGELOG.md

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# Multiple tests fail, skipping for now
	-dh_auto_test
endif
