#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Through Autoconf we set hardening flags that are actually more aggressive
# than the Ubuntu defaults, but they conflict with same.
export DEB_BUILD_MAINT_OPTIONS = hardening=-stackprotector
-include /usr/share/dpkg/buildflags.mk

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	dh_auto_configure -- \
		--disable-silent-rules \
		--enable-ufw \
		--enable-completion \
		--docdir=/usr/share/doc/goblin-mosh \
		--with-zstd \
		--with-librsync \
		--with-fips-crypto \
		--without-libraptorq \
		--enable-compile-warnings=yes

# A package must pass this policy gate even with DEB_BUILD_OPTIONS=nocheck.
override_dh_auto_build:
	dh_auto_build
	sh packaging/check-prebuilt-fec.sh ./src/moshcp/goblin-moshcp

# Exercise the core protocol, rendering, compression, pacing and file worker
# tests for every release build. Installed-APT integration tests run separately.
override_dh_auto_test:
	mkdir -p debian/test-runtime
	chmod 700 debian/test-runtime
	XDG_RUNTIME_DIR=$(CURDIR)/debian/test-runtime dh_auto_test -- TESTS='ocb-aes encrypt-decrypt fips-crypto base64 nonce-incr fec-codecs bulk-datagram moshcp-protocol bulk-loss-sim transport-compression state-samples osc52-parse kitty-graphics terminal-geometry terminal-display tmux-control control-panel mascot file-transfer link-budget sixel-state terminal-extensions download download-forward udp-relay udp-jump-wrapper.test'

override_dh_strip:
	dh_strip --no-automatic-dbgsym

override_dh_perl:
	# mosh only uses Perl modules in perl-base.
	dh_perl -d
