#!/usr/bin/make -f

export LC_ALL=C.UTF-8

ifeq "$(DEB_BUILD_ARCH)" "riscv64"
        CONFIGURE_OPTS = --disable-mythbrowser
endif

%:
	dh $@ --with quilt

override_dh_auto_configure:
	./configure \
	--compile-type=release \
	--disable-mythnetvision \
	--enable-all \
	--prefix=/usr \
	--qmake=qmake6 \
	$(CONFIGURE_OPTS)

#	exit 1

override_dh_auto_install-arch:
	for plugin in mytharchive mythbrowser \
	mythgame mythmusic mythnews mythweather \
	mythzoneminder; do \
		$(MAKE) -C $$plugin install INSTALL_ROOT=$(CURDIR)/debian/$$plugin; \
	done

	dh_installdirs -pmythmusic etc/mythtv usr/share/mythtv/sql
	dh_installdirs -pmythweather etc/mythtv

	rm -rf debian/mytharchive/usr/share

override_dh_auto_install-indep:
	$(MAKE) -C mytharchive install INSTALL_ROOT=$(CURDIR)/debian/mytharchive-data

	rm -rf debian/mytharchive-data/usr/bin
	rm -rf debian/mytharchive-data/usr/lib

	chmod 0755 debian/mytharchive-data/usr/share/mythtv/mytharchive/scripts/*

override_dh_installdocs:
	dh_installdocs
	dh_installdocs -pmytharchive mytharchive/TODO mytharchive/README mytharchive/AUTHORS
ifneq "$(DEB_BUILD_ARCH)" "riscv64"
	dh_installdocs -pmythbrowser mythbrowser/README mythbrowser/AUTHORS
endif
	dh_installdocs -pmythmusic mythmusic/README mythmusic/AUTHORS
	dh_installdocs -pmythnews mythnews/README mythnews/AUTHORS
	dh_installdocs -pmythweather mythweather/README mythweather/AUTHORS
	dh_installdocs -pmythzoneminder mythzoneminder/AUTHORS mythzoneminder/README

	dh_installdocs -pmytharchive-data  mytharchive/TODO mytharchive/README mytharchive/AUTHORS

override_dh_clean:
	[ ! -f Makefile ] || $(MAKE) distclean

	dh_clean

	find -name moc -delete
	find -name obj -delete

override_dh_install override_dh_auto_test:
