#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS = reproducible=+fixfilepath hardening=+all

# Let timing tests run long in case we're testing on slow hardware
# (like HPPA)

export CMARK_TIMING_SCALE = 10

DEB_HOST_MULTIARCH?=$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

DEB_CMAKE_EXTRA_FLAGS=\
	-DCMAKE_INSTALL_LIBDIR="/usr/lib/$(DEB_HOST_MULTIARCH)" \
	-DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)" \
	-DCMAKE_BUILD_RPATH_USE_ORIGIN=ON \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.0

%:
	dh $@ --buildsystem=cmake

clean: debian/control

execute_after_dh_clean:
	rm -rf test/__pycache__/

override_dh_auto_configure:
	dh_auto_configure -- $(DEB_CMAKE_EXTRA_FLAGS)

debian/control: debian/control-in
	sed 's/%DEB_VERSION_UPSTREAM%/$(DEB_VERSION_UPSTREAM)/g' $< > $@
	echo 'usr/lib/*/libcmark-gfm.so.*' > debian/libcmark-gfm$(DEB_VERSION_UPSTREAM).install
	echo 'usr/lib/*/libcmark-gfm-extensions.so.*' > debian/libcmark-gfm-extensions$(DEB_VERSION_UPSTREAM).install

override_dh_auto_install:
	dh_auto_install
	*/src/cmark-gfm test/spec.txt > debian/tmp/spec.html
