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

export DEB_BUILD_MAINT_OPTIONS=hardening=+all reproducible=+all future=+lfs

include /usr/share/dpkg/architecture.mk

# We ignore test failures on architectures not supported by upstream
# for now. This is probably not the best idea though...
supported_archs = amd64
ignore_tests = $(if $(filter-out $(supported_archs),$(DEB_HOST_ARCH)),-,)

# Test to avoid memory problems in mipsel
ifeq ($(DEB_HOST_ARCH),$(filter $(DEB_HOST_ARCH),mipsel))
	export DEB_BUILD_MAINT_OPTIONS=parallel=1 hardening=+all reproducible=+all future=+lfs
	CMAKE_FLAGS = -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,--no-map-whole-files -Wl,--no-keep-memory -Wl,--no-keep-files-mapped" \
	            -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=gold -Wl,--no-map-whole-files -Wl,--no-keep-memory -Wl,--no-keep-files-mapped" \
		    -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-Wa,--reduce-memory-overheads
	no_dbssym = --no-automatic-dbgsym
endif


%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure --  \
	    -DBUILD_TESTING=ON \
	    -DFCL_NO_DEFAULT_RPATH=OFF \
	    -DFCL_USE_X64_SSE=OFF \
	    $(CMAKE_FLAGS)

override_dh_auto_test:
	$(ignore_tests)dh_auto_test

override_dh_strip:
	dh_strip $(no_dbssym)
