#!/usr/bin/make -f

export CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
export CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
export DEBIAN_LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)
export BUILD_DIR=obj-$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

TARGETS=ping tracepath traceroute6 clockdiff arping
MAN_TARGETS=doc/arping.8 doc/clockdiff.8 \
	   doc/ping.8 doc/tracepath.8 doc/traceroute6.8

%:
	dh $@ --buildsystem=meson+ninja --builddirectory=$(BUILD_DIR)

override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_RARPD=false \
		-DBUILD_RDISC=false \
		-DBUILD_TFTPD=false \
		-DBUILD_NINFOD=false \
		-DBUILD_HTML_MANS=false \
		-DBUILD_TRACEROUTE6=true \
		-DNO_SETCAP_OR_SUID=true \
		-DUSE_GETTEXT=false

override_dh_auto_test:

override_dh_install:
	dh_install
	mv debian/iputils-tracepath/usr/bin/traceroute6 debian/iputils-tracepath/usr/bin/traceroute6.iputils

override_dh_installman:
	dh_installman
	mv debian/iputils-tracepath/usr/share/man/man8/traceroute6.8 debian/iputils-tracepath/usr/share/man/man8/traceroute6.iputils.8