#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

# Security Hardening
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND = -fPIC
export DEB_LDFLAGS_MAINT_APPEND = -fPIC

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

# Due to: https://github.com/libcheck/check/issues/293
# Workaround from: https://bugs.gentoo.org/736766
override_dh_auto_configure:
	sed -i s:-Werror:-Wextra: CMakeLists.txt
	dh_auto_configure -- \
		-DENABLE_SHARED_EXECUTABLES=YES \
		-DENABLE_SHARED_TESTS=YES \
		-DENABLE_STATIC=NO

override_dh_install:
	rm -f debian/tmp/usr/share/doc/libcork/html/.buildinfo
	sed -i " \
		s%http[s]*://cdn.mathjax.org/mathjax/latest/MathJax.js%file:///usr/share/javascript/mathjax/MathJax.js%; \
		s%https://cdnjs.cloudflare.com/ajax/libs/mathjax/[0-9].[0-9].[0-9]/MathJax.js%file:///usr/share/javascript/mathjax/MathJax.js%; \
		s%https://cdnjs.cloudflare.com/ajax/libs/mathjax/[0-9].[0-9].[0-9]/latest.js%file:///usr/share/javascript/mathjax/unpacked/latest.js%; \
		" debian/tmp/usr/share/doc/libcork/html/*.html
	dh_install

# Upstream supports both autoreconf and cmake
# Here we disable autoreconf so cmake will be used
%:
	dh $@ --with sphinxdoc --without autoreconf
