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

#export DH_VERBOSE = 1

export PYBUILD_NAME=scinexus

# on i386 crashed test with OOM killer
# an parallel dont work
ifeq ($(DEB_HOST_ARCH),i386)
export PYBUILD_TEST_ARGS = -m "not internet" \
	-k "not test_mypy_typing \
	and not test_parallel \
	and not test_parallel_mpi \
	"
else
export PYBUILD_TEST_ARGS = -m "not internet"
endif


# HTML output directory
DOC_BUILD = docs/_build/html

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_build:
	mkdir -p $(DOC_BUILD)
	# copy static assets
	cp -r docs/images $(DOC_BUILD)/
	cp -r docs/stylesheets $(DOC_BUILD)/

	# build all markdown files
	find docs -name "*.md" -type f | while read f; do \
		out="$(DOC_BUILD)/$$(echo $$f | sed 's|docs/||; s|\.md$$|.html|')"; \
		mkdir -p $$(dirname $$out); \
		pandoc "$$f" \
			-o "$$out" \
			--standalone \
			--toc \
			--quiet \
			--metadata title="$$(basename $$f .md)"; \
	done

	# ensure main index exists
	pandoc docs/index.md \
		-o $(DOC_BUILD)/index.html \
		--standalone \
		--toc
