#!/usr/bin/make -f

ARCH := $(shell uname -m)

%:
	dh $@

override_dh_auto_configure:
	mkdir -p build
	CXXF=
	if dpkg-architecture -e armel; then \
	    CXXF="-DCMAKE_CXX_FLAGS=$(CMAKE_CXX_FLAGS) -mfloat-abi=softfp"; \
	fi
	(cd build && cmake .. ${CXXF} -DDEPENDENCY_CONFIG=../cmake-utils/DependenciesFromLocalSystem.cmake -DBUILD_TESTING=ON -DCRYFS_UPDATE_CHECKS=OFF)

override_dh_auto_build:
	(cd build && make)
	./build/test/blobstore/blobstore-test
	./build/test/blockstore/blockstore-test
	# Config Compatibility tests fail on s390x, mipsel, and hppa archs
	./build/test/cryfs/cryfs-test --gtest_filter=-CryConfigCompatibilityTest.*
	./build/test/parallelaccessstore/parallelaccessstore-test
	./build/test/gitversion/gitversion-test
	# Test fails with pbuilder
	./build/test/cpp-utils/cpp-utils-test --gtest_filter=-HomedirTest.HomedirExists
	# ./build/test/cryfs-cli/cryfs-cli-test
	# Test requires root (and fuse)
	# ./build/test/fspp/fspp-test
