#!/usr/bin/make -f
# -*- makefile -*-
# Debhelper build instructions for timelimit.

# Aim for the top, adapt if anything should break on the buildds.
DEB_BUILD_MAINT_OPTIONS=	hardening=+all
export DEB_BUILD_MAINT_OPTIONS

DEB_CFLAGS_MAINT_APPEND=	-pipe -Wall -W -pedantic -Wbad-function-cast \
		-Wcast-align -Wcast-qual -Wchar-subscripts -Winline \
		-Wmissing-prototypes -Wnested-externs -Wpointer-arith \
		-Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings
ifneq (,$(filter werror,$(DEB_BUILD_OPTIONS)))
DEB_CFLAGS_MAINT_APPEND+=	-Werror
endif
export DEB_CFLAGS_MAINT_APPEND

export TIMELIMIT_FLAVOR=rust

include /usr/share/dpkg/default.mk

execute_before_dh_auto_build:
	[ -d .cargo ] || install -d -m 755 .cargo
	install -m 644 -- debian/cargo-config.toml .cargo/config.toml
ifneq (,$(filter pkg_timelimit_depcheck,$(DEB_BUILD_OPTIONS)))
	debian/depcheck
	NO_DEV_DEPENDENCIES=1 debian/depcheck
endif

execute_before_dh_auto_test:
	cargo test --release

override_dh_auto_install:
	dh_auto_install --destdir '$(CURDIR)/debian/timelimit' -- \
		PREFIX=/usr MANDIR=/usr/share/man/man \
		INSTALL_PROGRAM='install -m 755' INSTALL_DATA='install -m 644'

override_dh_installchangelogs:
	dh_installchangelogs -X changes.md
	install -m 644 docs/changes.md debian/timelimit/usr/share/doc/timelimit/NEWS.md

%:
	dh '$@'
