#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/architecture.mk

%:
	dh $@ --with gir --buildsystem=cmake --no-parallel

CONFIGURE_FLAGS = -DGOBJECT_INTROSPECTION=true -DICAL_GLIB_VAPI=true

override_dh_auto_configure:
ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
	dh_auto_configure -- $(CONFIGURE_FLAGS)
else
	dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_configure --reload-all-buildenv-variables
	dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_build --reload-all-buildenv-variables
	dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_install --reload-all-buildenv-variables --destdir=debian/nativetmp
	dh_auto_configure -- $(CONFIGURE_FLAGS) -DIMPORT_ICAL_GLIB_SRC_GENERATOR=$(CURDIR)/debian/nativetmp/usr/lib/$(DEB_BUILD_MULTIARCH)/cmake/LibIcal/IcalGlibSrcGenerator.cmake
endif

override_dh_missing:
	dh_missing --list-missing

ifneq (,$(filter $(DEB_HOST_ARCH), kfreebsd-amd64 kfreebsd-i386))
override_dh_auto_test:
	: # the tests hang on the buildds, don't run them
	: -dh_auto_test
endif

ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
execute_after_dh_auto_clean:
	dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_clean

execute_after_debian_clean:
	rm -Rf debian/nativetmp
endif
