#! /usr/bin/make -f

export DH_OPTIONS
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

INSTDIR = debian/tmp

%:
	dh $@ -Bbuild -Scmake --with python3

ifeq "" "$(filter %-doc,$(shell dh_listpackages))"
  BUILDDOC = OFF
else
  BUILDDOC = ON
endif

override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_DOCS=$(BUILDDOC) \
		-DCMAKE_BUILD_RPATH_USE_ORIGIN=ON \
		-DPYTHON=ON

override_dh_auto_build-indep:
	dh_auto_build -- docs

override_dh_auto_install-indep:
	dh_auto_install -- -C docs

override_dh_auto_test:

override_dh_install-arch:
	dh_numpy3 --package=python3-imath
	dh_install

override_dh_install-indep:
	rm -f $(INSTDIR)/usr/share/doc/Imath/sphinx/_static/doctools.js
	rm -f $(INSTDIR)/usr/share/doc/Imath/sphinx/_static/jquery.js
	rm -f $(INSTDIR)/usr/share/doc/Imath/sphinx/_static/language_data.js
	rm -f $(INSTDIR)/usr/share/doc/Imath/sphinx/_static/searchtools.js
	rm -f $(INSTDIR)/usr/share/doc/Imath/sphinx/_static/underscore.js
	rm -f $(INSTDIR)/usr/share/doc/Imath/sphinx/.buildinfo
	rm -rf $(INSTDIR)/usr/share/doc/Imath/sphinx/.doctrees
	dh_install
