#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Reduce size of debug symbols to fix FTBFS due to the
# 2GB/3GB address space limits on 32bit
DEB_HOST_ARCH_BITS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS)
 ifeq (32,$(DEB_HOST_ARCH_BITS))
 export DEB_CXXFLAGS_MAINT_APPEND = -g1
endif

%:
	dh $@ --with sphinxdoc --buildsystem=cmake --sourcedirectory=src/ --no-parallel

override_dh_auto_build:
	dh_auto_build
ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
	cd doc/sphinx/ ; python3 -m sphinx -b html ./ html
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf doc/sphinx/html

override_dh_sphinxdoc-indep:
	dh_sphinxdoc
	find debian/libsvgpp-doc/ -type f -print0 | xargs -0 sed -i 's/https:\/\/cdn\.mathjax\.org\/mathjax\/latest/\/usr\/share\/javascript\/mathjax/g'
	find debian/libsvgpp-doc/ -type f -print0 | xargs -0 sed -i 's/https:\/\/cdnjs\.cloudflare\.com\/ajax\/libs\/mathjax\/2\.7\.1/\/usr\/share\/javascript\/mathjax\//g'
	find debian/libsvgpp-doc/ -type f -print0 | xargs -0 sed -i 's/http:\/\/www\.w3\.org\/TR\/SVG11\/images\/coords\/Matrix.png//g'
	rm -rf debian/libsvgpp-doc/usr/share/doc/libsvgpp-dev/html/_sources/license.txt