gtk: find the module directory through the GTK runtime again

A module built in the container is installed on a host that has no GTK
development files, and there pkg-config knows nothing: dropping the
runtime query left `doas make install` with nowhere to put the module.
gtk-query-immodules-3.0 answers where GTK looks, so ask it when
pkg-config cannot, as before, and say so in the README.
This commit is contained in:
2026-08-17 14:37:57 +09:00
parent ae7dbae993
commit 544ed835b7
2 changed files with 14 additions and 5 deletions

View File

@@ -183,9 +183,12 @@ export GTK_IM_MODULE=strans
GLFW_IM_MODULE=ibus kitty GLFW_IM_MODULE=ibus kitty
``` ```
Building and installing `gtk/im-strans.so` requires GTK development files; Building `gtk/im-strans.so` requires GTK development files; installing one
the install target uses GTK's own module directory, which packagers and built elsewhere, in the container for instance, does not. The install
cross builds override with `GTK_MODULE_DIR`. target uses `GTK_MODULE_DIR` when it is set, else GTK's pkg-config
variables, else the directory the installed `gtk-query-immodules-3.0`
reports. Packagers and cross builds should set `GTK_MODULE_DIR`, and a
prebuilt module must still match the target architecture and library ABI.
`DESTDIR` staging is supported and deliberately skips the host module-cache `DESTDIR` staging is supported and deliberately skips the host module-cache
update. A native install needs the GTK runtime query utility so it can refresh update. A native install needs the GTK runtime query utility so it can refresh

View File

@@ -7,8 +7,14 @@ GTK_QUERY_IMMODULES ?= gtk-query-immodules-3.0
GTK_LIBDIR ?= $(shell $(PKG_CONFIG) --variable=libdir gtk+-3.0 2>/dev/null) GTK_LIBDIR ?= $(shell $(PKG_CONFIG) --variable=libdir gtk+-3.0 2>/dev/null)
GTK_BINARY_VERSION ?= $(shell $(PKG_CONFIG) \ GTK_BINARY_VERSION ?= $(shell $(PKG_CONFIG) \
--variable=gtk_binary_version gtk+-3.0 2>/dev/null) --variable=gtk_binary_version gtk+-3.0 2>/dev/null)
GTK_MODULE_DIR ?= $(strip $(if $(GTK_BINARY_VERSION),\ # Without GTK development files, ask the runtime where its modules live.
$(GTK_LIBDIR)/gtk-3.0/$(GTK_BINARY_VERSION)/immodules)) GTK_RUNTIME_MODULE_DIR = $(shell GTK_PATH= GTK_IM_MODULE_FILE= \
$(GTK_QUERY_IMMODULES) 2>/dev/null | \
awk -F '"' '/^"\// { sub("/[^/]*$$", "", $$2); print $$2; exit }')
GTK_MODULE_DIR ?= $(strip $(if \
$(and $(strip $(GTK_LIBDIR)),$(strip $(GTK_BINARY_VERSION))),\
$(GTK_LIBDIR)/gtk-3.0/$(GTK_BINARY_VERSION)/immodules,\
$(GTK_RUNTIME_MODULE_DIR)))
all: $(PROG) all: $(PROG)