#!/usr/bin/make -f

#For our custom rules on all mythtv packages
# get-orig-source
# info
include /usr/share/mythtv/mythtv.make

THEMES=$(shell ls --full-time -l --hide "debian" | grep '^d' | awk '{ print $$9 }' )

update-control-files:
	rm -f debian/control debian/*.install
	sed s/#THEMES#/$(shell echo $(THEMES) | tr '[A-Z]' '[a-z]' | sed s/^/mythtv-theme-/ | sed s/\ /,\\\\\ mythtv-theme-/g)/ \
	   debian/control.in > debian/control
	$(foreach theme,$(THEMES),\
	   echo "$(theme) usr/share/mythtv/themes" > debian/mythtv-theme-$(shell echo $(theme) | tr '[A-Z]' '[a-z]').install; \
	   cat debian/theme.stub | sed s/#THEME#/$(shell echo $(theme) | tr '[A-Z]' '[a-z]')/ >> debian/control; \
 	 )

%:
	dh $@

override_dh_fixperms:
	dh_fixperms
	for type in png html txt jpg xml ; do \
		find debian -name "*.$$type" -type f -exec chmod -x {} \; ;\
	done

override_dh_auto_configure:
override_dh_auto_build:
