#! /usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk # DEB_VERSION

# Skip the test suite: tests/exporting.org (export-new / sh-export-new) fails
# in the build environment (gash behaves differently from the expected POSIX
# semantics for `export V` on an unset variable), which aborts dh_auto_test.
export DEB_BUILD_OPTIONS := $(DEB_BUILD_OPTIONS) nocheck

%:
	dh $@

# https://bugs.debian.org/1123387
override_dh_auto_test:
	dh_auto_test $(DH_BUILD_OPTS) -- \
		UNIT_TESTS="tests/unit/eval.scm tests/unit/lexer.scm tests/unit/parser.scm tests/unit/shell.scm tests/unit/word.scm"
	-dh_auto_test $(DH_BUILD_OPTS) -- \
		TESTS="tests/unit/pattern.scm"

override_dh_dwz:
	dh_dwz --exclude=.go

override_dh_shlibdeps:
	dh_shlibdeps --exclude=.go

B = $(CURDIR)/debian/gash/usr/bin
M = $(CURDIR)/debian/tmp/usr/share/man/man1

ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
execute_before_dh_installman-arch:
	mkdir -pv $(M)
	help2man --version-string="$(DEB_VERSION)" \
		--no-info \
		--name="Guile As SHell, a POSIX-compatible shell" \
		--output $(M)/gash.1 \
		$(B)/gash
endif
