#!/usr/bin/make -f

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

override_dh_auto_build: $(DOCS) $(CHANGELOGS)
	dh_auto_build

# link embedded code project to where qmake expects it
override_dh_testdir:
	dh_testdir
	rm -rf submodules
	mkdir -p submodules
	ln -sfT ../Xhsluv submodules/hsluv-c

# rename to avoid clash with GTK image viewer of same name
override_dh_install:
	dh_install
	mv debian/matrix-mirage/usr/share/applications/mirage.desktop \
		debian/matrix-mirage/usr/share/applications/matrix-mirage.desktop
	mv debian/matrix-mirage/usr/share/icons/hicolor/256x256/apps/mirage.png \
		debian/matrix-mirage/usr/share/icons/hicolor/256x256/apps/matrix-mirage.png

override_dh_installdocs:
	dh_installdocs -- $(DOCS)

override_dh_installchangelogs:
	dh_installchangelogs -- $(CHANGELOGS)

override_dh_clean:
	dh_clean -- $(DOCS) $(CHANGELOGS)

%.html: %.md
	pandoc --from gfm-raw_html --to html --standalone --output $@ $<

%.txt: %.md
	pandoc --from gfm-raw_html --to plain --output $@ $<

%:
	dh $@
