#!/usr/bin/make -f
# The crate's build.rs writes the man page and the shell completions to
# SPING_ASSETS_DIR (upstream's fixed path for packagers; otherwise they land
# in one OUT_DIR per profile); dh_auto_install below ships them.
export SPING_ASSETS_DIR = $(CURDIR)/target/assets

%:
	dh $@ --buildsystem cargo

# dh-cargo's test step only runs `cargo build` unless it is told `test`. The
# tests that need an ICMP socket pass without one, as in sbuild.
override_dh_auto_test:
	dh_auto_test -- test --all-targets

override_dh_auto_install:
	dh_auto_install
	install -D -m644 target/assets/man/sping.1 debian/sping/usr/share/man/man1/sping.1
	install -D -m644 target/assets/completions/sping.bash debian/sping/usr/share/bash-completion/completions/sping
	install -D -m644 target/assets/completions/_sping debian/sping/usr/share/zsh/vendor-completions/_sping
	install -D -m644 target/assets/completions/sping.fish debian/sping/usr/share/fish/vendor_completions.d/sping.fish
