From 8ea53af6769f41e64842dacb93f76beca2e91bd4 Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Thu, 30 Apr 2026 11:05:21 +0200 Subject: [PATCH] build: use a UTF-8 locale for builtin icon cache generation gtk-update-icon-cache may need to run in a UTF-8 locale when generating gtkbuiltincache.h. Otherwise GLib can fail to convert UTF-8 output in ASCII locales such as 646. Choose a usable UTF-8 locale for this rule, while allowing packagers to override it with GTK_UPDATE_ICON_CACHE_LOCALE. If no known UTF-8 locale is available, fall back to the previous behavior. This is based on the build fix carried by NetBSD pkgsrc for GTK2, but avoids hard-coding en_US.UTF-8 so Debian, Gentoo, Arch and other systems can use their available UTF-8 locale. Ported-from: NetBSD pkgsrc x11/gtk2 patch-gtk_Makefile.in --- gtk/Makefile.am | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 1238d9b6a..f7a23c93b 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1464,10 +1464,25 @@ endif gtkbuiltincache.h: @REBUILD@ stamp-icons $(MAKE) $(AM_MAKEFLAGS) gtk-update-icon-cache$(EXEEXT) - $(gtk_update_icon_cache_program) --force --ignore-theme-index \ - --include-image-data \ - --source builtin_icons stock-icons > gtkbuiltincache.h.tmp && \ - mv gtkbuiltincache.h.tmp gtkbuiltincache.h + { lc_all=$${GTK_UPDATE_ICON_CACHE_LOCALE-}; \ + if test -z "$$lc_all"; then \ + for locale in C.UTF-8 C.utf8 en_US.UTF-8 en_US.utf8; do \ + if LC_ALL=$$locale locale charmap >/dev/null 2>&1; then \ + lc_all=$$locale; \ + break; \ + fi; \ + done; \ + fi; \ + if test -n "$$lc_all"; then \ + LC_ALL=$$lc_all $(gtk_update_icon_cache_program) --force --ignore-theme-index \ + --include-image-data \ + --source builtin_icons stock-icons > gtkbuiltincache.h.tmp; \ + else \ + $(gtk_update_icon_cache_program) --force --ignore-theme-index \ + --include-image-data \ + --source builtin_icons stock-icons > gtkbuiltincache.h.tmp; \ + fi; \ + } && mv gtkbuiltincache.h.tmp gtkbuiltincache.h EXTRA_DIST += \ $(STOCK_ICONS) \