#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic

export QT_SELECT := 5

IMGFILES := $(shell sed 's/^debian\///' debian/source/include-binaries)

%:
	dh $@ --buildsystem=cmake

override_dh_auto_clean:
	dh_auto_clean
	rm -rf libs/hoedown/libhoedown.a libs/hoedown/libhoedown.so \
		libs/hoedown/libhoedown.so.3 libs/hoedown/smartypants
	rm -rf build output obj-x86_64-linux-gnu
	find . -name Makefile -delete
	@for fn in $(IMGFILES); do \
	    if test -n "$${fn##*.png}"; then # safety \
			rm -f $$fn; \
		fi \
    done
	rm -f share/librepcb/fonts/NotoSans-Regular.ttf
	rm -f share/librepcb/fonts/NotoSansMono-Regular.ttf

override_dh_auto_configure:
	for fn in $(IMGFILES); do \
	 cp debian/$$fn $$fn; \
    done
	ln -fs /usr/share/fonts/truetype/noto/NotoSans-Regular.ttf share/librepcb/fonts/NotoSans-Regular.ttf
	ln -fs /usr/share/fonts/truetype/noto/NotoSansMono-Regular.ttf share/librepcb/fonts/NotoSansMono-Regular.ttf
	dh_auto_configure