#!/usr/bin/make -f

# DH_VERBOSE := 1

include /usr/share/dpkg/default.mk


export DEB_BUILD_MAINT_OPTIONS=hardening=+all optimize=-lto
export DEB_CXXFLAGS_MAINT_APPEND=-O3

DEB_CMAKE_EXTRA_FLAGS = -DCMAKE_BUILD_TYPE=Release \
                        -Dspoa_build_executable=ON \
                        -Dspoa_build_tests=ON \
			-Dspoa_use_simde_nonvec=ON \
			-Dspoa_use_simde_openmp=ON \
			-Dspoa_optimize_for_native=OFF \
			-DCMAKE_PREFIX_PATH=/usr/lib/${DEB_HOST_MULTIARCH}/cmake/CpuFeatures

ifneq (,$(filter $(DEB_HOST_ARCH),i386 amd64))
	DEB_CMAKE_EXTRA_FLAGS += -Dspoa_generate_dispatch=ON
endif

%:
	dh $@ --no-parallel

override_dh_auto_configure:
	dh_auto_configure -- $(DEB_CMAKE_EXTRA_FLAGS)

override_dh_install:
	dh_install
	d-shlibmove --commit \
		    --multiarch \
		    --devunversioned \
		    --exclude-la \
		    --exclude-a \
		    --movedev debian/tmp/usr/include/spoa usr/include \
		    --movedev debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}/cmake /usr/lib/${DEB_HOST_MULTIARCH} \
		    debian/tmp/usr/lib/*/*.so

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	`find . -name spoa_test`
	`find . -name spoa | grep bin` test/data/sample.fastq.gz
endif
