#!/usr/bin/make -f

BUILDDIR = $(CURDIR)/debian/build

%:
	dh $@ --builddirectory=$(BUILDDIR)

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed,-no-keep-memory

# Check, whether Build-Depends-Indep are installed
BUILD_DOC=$(shell dpkg -s python3-sphinx | grep -q "^Status:.* installed$$" && echo yes)

override_dh_installdocs-indep:
ifeq ($(BUILD_DOC), yes)
	cd $(BUILDDIR) && $(MAKE) doc
	dh_installdocs -i
	dh_sphinxdoc
	find $(CURDIR)/debian/dyssol-doc -type f -print0 | xargs -0 sed -i 's/https:\/\/cdn\.jsdelivr\.net//g'
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(BUILDDIR)
