#!/usr/bin/make -f

DEB_BUILD_MAINT_OPTIONS := hardening=+all
DEB_LDFLAGS_MAINT_APPEND := \
  -Wl,--no-undefined \
  -Wl,--no-copy-dt-needed-entries \
  -Wl,--no-allow-shlib-undefined
DPKG_EXPORT_BUILDFLAGS := 1
include /usr/share/dpkg/buildflags.mk
include /usr/share/ada/packaging.mk

%:
	dh $@

project := -Pada_bar_codes.gpr
static := $(project) -XABC_Build_Mode=static
shared := $(project) -XABC_Build_Mode=relocatable \
  -XABC_Library_Version=libada_bar_codes.so.$(ada_bar_codes_SO_VERSION)

override_dh_auto_build:
	gprbuild $(GPRBUILDFLAGS) $(static)
	gprbuild $(GPRBUILDFLAGS) $(shared)

override_dh_auto_test:
 # Build the library a third time, with distinct options, demo and test.
	gprbuild $(GPRBUILDFLAGS) $(project) -XABC_Build_Mode=Debug
 # Write the output in the build directory.
	cd obj && ../bar_codes_demo
	cd obj && ../bar_codes_test

override_dh_auto_install:
	gprinstall $(static) $(static_GPRINSTALLFLAGS)
	gprinstall $(shared) $(call shared_GPRINSTALLFLAGS,ada_bar_codes)
