#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

# generate documentation unless nodoc requested
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
DOCS = README.html README.txt
endif

%:
	dh $@

%.html: %.md
	cmark-gfm $< > $@

%.txt: %.md
	cmark-gfm --to plaintext $< > $@

# use glyphlist.txt shipped with aglfn
# * tell configure to install where aglfn provides it
# * use aglfn file during build (in case it gets embedded somewhere)
override_dh_auto_configure:
	[ -f glyphlist.txt.upstream ] \
		|| cp glyphlist.txt glyphlist.txt.upstream
	cp --force /usr/share/aglfn/glyphlist.txt glyphlist.txt
	dh_auto_configure -- \
		--enable-glyphlistdir /usr/share/aglfn/glyphlist.txt

execute_after_dh_auto_build: $(DOCS)

# use glyphlist.txt shipped with aglfn
# * skip install file provided by aglfn (we recommend aglfn instead)
override_dh_install:
	dh_install -X/usr/share/aglfn/glyphlist.txt

override_dh_installdocs:
	dh_installdocs -- $(DOCS)

# move back upstream shipped glyphlist.txt to please git-buildpackage
override_dh_clean:
	[ ! -f glyphlist.txt.upstream ] \
		|| mv --force glyphlist.txt.upstream glyphlist.txt
	dh_clean
