#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

DPKG_EXPORT_BUILDFLAGS = 1

DEB_BUILD_MAINT_OPTIONS=hardening=+all
ifeq (sh4,$(DEB_HOST_ARCH))
  # Renesas SH(sh4) need -mieee option.
  # If this option is not effective, fmtspcl test fails.
  DEB_CFLAGS_MAINT_APPEND=-mieee
endif

include /usr/share/dpkg/buildflags.mk

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --libexecdir=/usr/lib
	# Add fake info files (see README.source).
	touch --date="Jan 01 2000" doc/gawk.info doc/gawk.texi \
                           doc/gawkinet.info doc/gawkinet.texi

override_dh_auto_test:
	# Generate locales used in testsuite.
	mkdir tmp-locales
	localedef -i en_US -c -f ISO-8859-1 -A /usr/share/locale/locale.alias \
          tmp-locales/en_US.ISO-8859-1
	localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias \
          tmp-locales/en_US.UTF-8
	localedef -i ja_JP -c -f UTF-8 -A /usr/share/locale/locale.alias \
          tmp-locales/ja_JP.UTF-8
	localedef -i ru_RU -c -f UTF-8 -A /usr/share/locale/locale.alias \
          tmp-locales/ru_RU.UTF-8
	LOCPATH=$(CURDIR)/tmp-locales LC_ALL=C dh_auto_test

override_dh_auto_install:
	dh_auto_install
	# Remove unwanted files: versioned binaries, plain awk and duplicate
	# manpage.
	rm -f debian/gawk/usr/bin/*awk-*
	rm -f debian/gawk/usr/bin/awk
	rm -f debian/gawk/usr/share/man/man1/pgawk.1
	# Remove fake info files (see README.source).
	rm -rf debian/gawk/usr/share/info

override_dh_auto_clean:
	dh_auto_clean
	rm -rf tmp-locales
