#! /usr/bin/make -f

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

#export DEB_BUILD_MAINT_OPTIONS := hardening=+bindnow

%:
	dh $@

override_dh_auto_install:
	dh_auto_install $(DH_BUILD_OPTS) --destdir=debian/tmp
	cp -v repl/repl.js debian/tmp/usr/share/guile-hoot/*/repl/

override_dh_shlibdeps:
	dh_shlibdeps --exclude=.go

execute_after_dh_clean:
	rm -fv doc/hoot.info

# Only run complete tests on speedy archs like amd64/arm64.
#
# Other archs needs 2-4 hours to complete, and FAIL:
#
# ppc64el: https://codeberg.org/spritely/hoot/issues/898
# s390x: https://codeberg.org/spritely/hoot/issues/899
# loong64: https://codeberg.org/spritely/hoot/issues/900
ifeq (,$(filter $(DEB_TARGET_ARCH),amd64 arm64))
override_dh_auto_test:
	dh_auto_test $(DH_BUILD_OPTS) -- \
	 TESTS="test/test-disassemble.scm test/test-char-prelude.scm"
endif

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

ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
execute_before_dh_installman-arch:
	mkdir -pv $(M)
	env GUILE_LOAD_PATH=$(CURDIR)/debian/guile-hoot/usr/share/guile/site/3.0 \
	help2man --version-string="$(DEB_VERSION)" \
		--name="Hoot WebAssembly toolkit" \
		--output $(M)/hoot.1 \
		$(B)/hoot
endif
