#!/usr/bin/make -f
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

DEB_BUILD_MAINT_OPTIONS := hardening=+all
include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/buildopts.mk
include /usr/share/ada/debian_packaging.mk

# Compile Ada and C with the same compiler.
CC := gnatgcc

# Upstream Makefile insists on rebuilding everything everytime.
# SOURCE_DATE_EPOCH (set by debhelper) and the -m gnatmake option may
# avoid some unneeded recompilations.
GNATMAKEFLAGS += -m

recursive_make_variables := \
	strip=true \
	"gnatmake_options=$(GNATMAKEFLAGS)" \
	$(foreach v,ADAFLAGS CC CFLAGS CPPFLAGS LDFLAGS,"$(v)=$($(v))")

%:
	dh  $@

.PHONY: override_dh_auto_build
override_dh_auto_build:
	dh_auto_build -- $(recursive_make_variables)

.PHONY: override_dh_auto_install
override_dh_auto_install:
	dh_auto_install -- $(recursive_make_variables)
	# The verbatim GPL would duplicate /usr/share/common-licenses.
	rm -f debian/topal/usr/share/doc/topal/COPYING
	# Let dh_installchangelogs handle an html changelog.
	rm -f debian/topal/usr/share/doc/topal/Changelog.html

.PHONY: override_dh_installchangelogs
override_dh_installchangelogs:
	dh_installchangelogs Changelog.html