#!/usr/bin/make -f

DHFLAGS=--parallel

ENC_FILES1:=$(wildcard debian/source/desktop-themes/Cartoons/gtk-3.0/*.png)
ENC_FILES2:=$(wildcard debian/source/desktop-themes/Cartoons/gtk-3.0/assets/*.png)
ENC_FILES3:=$(wildcard debian/source/desktop-themes/Cartoons/gtk-3.0/borders/*.png)
ENC_FILES4:=$(wildcard debian/source/desktop-themes/Cartoons/gtk-2.0/assets/*.png)
ENC_FILES5:=$(wildcard debian/source/desktop-themes/Cartoons/gtk-2.0/menubar-toolbar/*.png)
ENC_FILES6:=$(wildcard debian/source/icon-themes/Flat-Remix-Blue/places/symbolic/*.png)

%:
	dh $@ $(DHFLAGS) --without autoreconf

override_dh_install:
	# remove extra-license-file
	rm -rfv debian/mate-themes/usr/share/themes/*/COPYING
	rm -rfv debian/mate-themes/usr/share/themes/TraditionalOk/doc/gpl-3.0*.txt
	# add cursor theme entries
	cp debian/mate-white.theme debian/mate-themes/usr/share/icons/mate/cursor.theme
	cp debian/mate-black.theme debian/mate-themes/usr/share/icons/mate-black/cursor.theme
	dh_install

override_dh_missing:
	dh_missing --fail-missing

override_dh_installchangelogs:
	dh_installchangelogs NEWS

override_dh_auto_configure:
	# upstream tarball is without configure. autogen.sh will create it
	NOCONFIGURE=1 ./autogen.sh
	dh_auto_configure $(DHFLAGS)
	# $(foreach f,$(ENC_FILES1),rm -f debian/source/desktop-themes/Cartoons/gtk-3.0/$(basename $(notdir $(f))).png;)
	# $(foreach f,$(ENC_FILES2),rm -f debian/source/desktop-themes/Cartoons/gtk-3.0/assets/$(basename $(notdir $(f))).png;)
	# $(foreach f,$(ENC_FILES3),rm -f debian/source/desktop-themes/Cartoons/gtk-3.0/borders/$(basename $(notdir $(f))).png;)
	# $(foreach f,$(ENC_FILES4),rm -f debian/source/desktop-themes/Cartoons/gtk-2.0/assets/$(basename $(notdir $(f))).png;)
	# $(foreach f,$(ENC_FILES5),rm -f debian/source/desktop-themes/Cartoons/gtk-2.0/menubar-toolbar/$(basename $(notdir $(f))).png;)
	# $(foreach f,$(ENC_FILES6),rm -f debian/source/icon-themes/Flat-Remix-Blue/places/symbolic/$(basename $(notdir $(f))).png;)
	$(foreach f,$(ENC_FILES1),cp $f desktop-themes/Cartoons/gtk-3.0/;)
	$(foreach f,$(ENC_FILES2),cp $f desktop-themes/Cartoons/gtk-3.0/assets/;)
	$(foreach f,$(ENC_FILES3),cp $f desktop-themes/Cartoons/gtk-3.0/borders/;)
	$(foreach f,$(ENC_FILES4),cp $f desktop-themes/Cartoons/gtk-2.0/assets/;)
	$(foreach f,$(ENC_FILES5),cp $f desktop-themes/Cartoons/gtk-2.0/menubar-toolbar/;)
	$(foreach f,$(ENC_FILES6),cp $f icon-themes/Flat-Remix-Blue/places/symbolic/;)

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
