#!/usr/bin/make -f

# for d/p/skip-network-tests.patch
export SKIP_NETWORK_TESTS = true

%:
	dh $@ --buildsystem=pybuild

ifeq (,$(filter nodoc, $(DEB_BUILD_OPTIONS)))
execute_after_dh_auto_build: README.html

README.html: README.md
	cmark-gfm $< > $@
endif

# update database files for tests from legacy format
# see https://github.com/davidalber/geneagrapher/pull/31
ifeq (,$(filter nocheck, $(DEB_BUILD_OPTIONS)))
TESTDATA = tests/geneagrapher/testdata
DB_FILES = $(wildcard $(TESTDATA)/*.db)
execute_before_dh_auto_test: $(DB_FILES)

%.db: FORCE
	db_dump185 -f tmp $@
	mv $@ $@.old
	db_load -f tmp $@
	rm tmp

execute_after_dh_auto_test: $(foreach DB_FILE, $(DB_FILES), \
	restore-$(notdir $(DB_FILE)))

restore-%:
	cd $(TESTDATA) && mv $*.old $*

FORCE:
	@true
endif
