#!/usr/bin/make -f

#export DH_VERBOSE=1
export QT_SELECT=qt5
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

# latex generation seems to be broken
CONFIGURE_FLAGS += --enable-doxygen-man --disable-doxygen-ps --disable-doxygen-pdf
CONFIGURE_FLAGS += --disable-qvidcap

%:
	dh $@

override_dh_autoreconf:
	dh_autoreconf ./bootstrap.sh

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/ir-keytable.install.$(DEB_HOST_ARCH)

override_dh_auto_configure:
	dh_auto_configure -- --disable-silent-rules --with-libv4lconvertsubdir=libv4lconvert0 $(CONFIGURE_FLAGS)

override_dh_auto_build:
	dh_auto_build
	$(MAKE) doxygen-run

override_dh_install:
	# Remove useless autogenreated doxygen files
	rm -f doxygen-doc/html/*.md5

	# this file is only conditionally created (clang availablility, enabled systemd filters)
	cp -f debian/ir-keytable.install debian/ir-keytable.install.$(DEB_HOST_ARCH)
	test ! -f debian/tmp/lib/systemd/system/systemd-udevd.service.d/50-rc_keymap.conf || echo lib/systemd/system/systemd-udevd.service.d/50-rc_keymap.conf >> debian/ir-keytable.install.$(DEB_HOST_ARCH)

	dh_install

override_dh_installchangelogs:
	dh_installchangelogs -Nlibv4l-dev -Nv4l-utils -Nqv4l2 ChangeLog

override_dh_installdocs:
	dh_installdocs -Nlibv4l-dev -Nv4l-utils -Nqv4l2

override_dh_makeshlibs:
	dh_makeshlibs -Xv4l1compat -Xv4l2convert -Xlibv4l-mplane -Xrc_keymaps/protocols

override_dh_shlibdeps:
	dh_shlibdeps -Xrc_keymaps/protocols
