#! /usr/bin/make -f

DEBIANDIR = $(shell pwd)/debian

%:
	dh $@

# We want to install the arch-independent headers in /usr/lib
override_dh_auto_configure:
	mkdir -p buildlib
	cd buildlib && cmake ../ \
	    -D CMAKE_INSTALL_PREFIX=$(DEBIANDIR)/librapidfuzz-cpp-dev/usr

override_dh_auto_build:
	: # Dummy to force the target to alway be run
ifeq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
	doxygen
endif

override_dh_auto_install:
	cd buildlib && make install

ifeq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
override_dh_installdocs:
	dh_installdocs -plibrapidfuzz-cpp-doc --doc-main-package=librapidfuzz-cpp-dev
	dh_installdocs --remaining-packages
endif

override_dh_auto_test:
	: # Dummy to force the target to alway be run
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p buildtest
	cd buildtest && cmake ../ -D RAPIDFUZZ_BUILD_TESTING=ON
	cd buildtest && make
	cd buildtest && make test || \
	    make test ARGS="--rerun-failed --output-on-failure"
endif

execute_before_dh_auto_clean:
	rm -rf doxygen build*
