#!/usr/bin/make -f

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)

ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),amd64 i386))
  CMAKE_HOST_CFLAGS="True"
else
  CMAKE_HOST_CFLAGS="False"
endif

.PHONY: override_dh_auto_configure \
        override_dh_install \
        override_dh_auto_test \
        override_dh_strip

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
      -DUSE_HOST_CFLAGS:BOOL=${CMAKE_HOST_CFLAGS} \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo

override_dh_install:
	dh_install --
	# need to remove files present in components
	$(RM) debian/libignition-transport*-core-dev/usr/include/ignition/transport*/ignition/transport/log.hh
	$(RM) debian/libignition-transport*-core-dev/usr/include/ignition/transport*/gz/transport/log.hh
	$(RM) debian/libignition-transport*-core-dev/usr/include/ignition/transport*/ignition/transport/parameters.hh
	$(RM) debian/libignition-transport*-core-dev/usr/include/ignition/transport*/gz/transport/parameters.hh
	dh_missing --list-missing

override_dh_auto_test:
	# Fix tests. They need special configuration for networking
	true

override_dh_strip:
	dh_strip -a --dbg-package=libignition-transport11-dbg
