#!/usr/bin/make -f
# -*- makefile -*-

%:
	dh $@ --with sphinxdoc

override_dh_auto_configure:
	# Remove bundled stuff
	rm -rf deps/curl
	rm -rf deps/googletest/googlemock
	rm -rf deps/googletest/googletest/*
	touch deps/googletest/googletest/CMakeLists.txt
	rm -rf src/libs/rapidjson
	rm -rf test/pywebdav
	rm -rf doc/sphinx/_themes/sphinx_rtd_theme
	# Symlink to system rapidjson
	ln -s /usr/include/rapidjson src/libs/rapidjson
	dh_auto_configure -- -DLIB_SUFFIX:PATH="/$(DEB_HOST_MULTIARCH)" \
		-DEMBEDDED_LIBCURL:BOOL=FALSE \
		-DENABLE_HTML_DOCS:BOOL=TRUE \
		-DENABLE_THIRD_PARTY_COPY:BOOL=TRUE

override_dh_auto_build:
	dh_auto_build -- all doc
	( cd obj-$(DEB_HOST_GNU_TYPE)/doc ; \
	  sphinx-build -q -b html ../../doc/sphinx build/html )

override_dh_auto_install:
	dh_auto_install
	rm debian/tmp/usr/share/doc/davix/LICENSE

override_dh_auto_clean:
	rm -rf src/libs/rapidjson
	rm -f deps/googletest/googletest/CMakeLists.txt
	dh_auto_clean

override_dh_auto_test:
	dh_auto_test -- ARGS+="-V -T Test"
