#!/usr/bin/make -f
# -*- makefile -*-

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

SOVERSION := 5-5

# see #963247, #980423
# extract the protobuf API version package and add it to d/control
# Needed because protobuf generated headers are only compatible with that version
protobufapi := $(shell dpkg-query -W -f '$${Provides}' libprotobuf-dev | grep -o 'protobuf-api-[^ ]*')

# virtual package to represent libignition-msgs and protobuf ABI
ignitionprotoabi := libignition-msgs$(SOVERSION)-protobuf$(shell dpkg-query -W -f '$${Depends}' libprotobuf-dev | sed -n 's/.*libprotobuf\([0-9]*\) .*/\1/p')

override_dh_auto_configure:
	dh_auto_configure -- \
                -DUSE_HOST_SSE_FLAGS:BOOL=False \
                -DUSE_IGN_RECOMMENDED_FLAGS:BOOL=False

%:
	dh $@

execute_before_dh_gencontrol:
	echo 'ignition:Provides=$(ignitionprotoabi)' >> debian/libignition-msgs$(SOVERSION).substvars
	echo 'protobuf:API=$(protobufapi)' >> debian/libignition-msgs5-dev.substvars

override_dh_makeshlibs:
	dh_makeshlibs -plibignition-msgs$(SOVERSION) -V '$(ignitionprotoabi)'
	dh_makeshlibs --remaining-packages
