#!/usr/bin/make -f

export DEB_LDFLAGS_MAINT_APPEND = -Wl,-z,defs -Wl,--as-needed
export QT_SELECT = qt5

include /usr/share/dpkg/default.mk

paths = \
	Project/GNU/CLI/ \
	Project/Qt/

auto_build_cmd =				\
	for path in $(paths); do		\
		$(1) -D"$$path";		\
	done

configure_targets = $(addprefix configure-, $(subst /,_,$(paths)))

%::
	dh $@ --with=autoreconf

# override_dh_autoreconf:
# 	dh_autoreconf --as-needed

override_dh_auto_configure: $(configure_targets)

configure-%:
	dh_auto_configure -D"$(subst _,/,$*)"

configure-Project_Qt_:
	dh_auto_configure -DProject/Qt -- USE_WEBKIT=1

override_dh_auto_build:
	$(call auto_build_cmd,dh_auto_build)

override_dh_auto_install:
	$(call auto_build_cmd,dh_auto_install)

override_dh_auto_clean:
	$(call auto_build_cmd,dh_auto_clean)

override_dh_installman: debian/mediaconch.1 debian/mediaconch-gui.1
	dh_installman

override_dh_installchangelogs:
	dh_installchangelogs -p mediaconch History_CLI.txt
	dh_installchangelogs -p mediaconch-gui History_GUI.txt

clean:
	rm -f debian/*.1
	dh clean --with=autoreconf

%.1: %.pod
	pod2man --center "User Commands" --release=MediaConch\ $(DEB_VERSION_UPSTREAM) $< > $@
