#!/usr/bin/make -f

# Ubuntu 26.04 ships its own yaru-theme-icon, so there this source adds the grey accent
# next to it and never publishes a yaru-theme-icon that could shadow Ubuntu's (BASED-290).
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo yes),yes)
DH_EXCLUDE := -Nyaru-theme-icon
endif

CONFIGURE_FLAGS := \
	-Dgnome-shell-gresource=true \
	-Dgnome-shell-user-themes-support=enabled \
	-Dubuntu-unity=true \
	-Dsessions=false \
	-Dxfwm4=true \
	-Daccent-colors=bark,sage,olive,viridian,prussiangreen,blue,purple,magenta,red,yellow,wartybrown,grey

%:
	dh $@ $(DH_EXCLUDE)

# Upstream commits every accent's bitmaps and only installs an accent whose icons/Yaru-<accent>
# exists at configure time. No release has one for grey, so it is rendered from the accented
# SVGs and meson is configured again to pick it up.
override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS)
	dh_auto_build -- render+symlink-icons-grey
	dh_auto_configure -- $(CONFIGURE_FLAGS) --reconfigure

# With one binary package dh_auto_install would install straight into it, past
# yaru-theme-icon.install, and ship the GTK, shell and sound themes too.
override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

execute_before_dh_install:
	rm -rf debian/tmp/usr/share/themes/*/gtk-2.0

execute_after_dh_install:
	rm -rf debian/yaru-theme-icon/usr/share/icons/Yaru-grey debian/yaru-theme-icon/usr/share/icons/Yaru-grey-dark

execute_after_dh_auto_clean:
	rm -rf icons/Yaru-grey

# The GTK, shell, sound and Unity files are built, because the icon accents are generated
# from the GTK component, and are left out on purpose.
override_dh_missing:
	dh_missing --list-missing
