#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

MANPAGES = sludge-engine sludge-compiler sludge-devkit sludge-projectmanager \
	sludge-floormaker sludge-zbuffermaker sludge-spritebankeditor \
	sludge-translationeditor

%:
	dh $@

# With FETCHCONTENT_FULLY_DISCONNECTED, CMake stops instead of downloading
# a library that it does not find on the system.
override_dh_auto_configure:
	dh_auto_configure -- -DSLUDGE_ENGINE=ON -DSLUDGE_DEVKIT=ON -DSLUDGE_DOC=ON \
		-DFETCHCONTENT_FULLY_DISCONNECTED=ON

execute_after_dh_auto_build:
	for page in $(MANPAGES); do \
		xsltproc --nonet \
			--param make.year.ranges 1 \
			--param make.single.year.ranges 1 \
			--param man.charmap.use.subset 0 \
			-o debian/ \
			http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl \
			debian/$$page.1.xml || exit 1; \
	done

# The view test of the Dev Kit compares OpenGL drawings with reference
# images pixel by pixel, which needs Mesa's EGL and depends on its software
# renderer, so we leave it out.
override_dh_auto_test:
	dh_auto_test -- "ARGS+=-E devkit_views"

execute_after_dh_auto_clean:
	rm -f $(foreach page,$(MANPAGES),debian/$(page).1)
