diff --git a/README.md b/README.md index 08c9fd0..bd7e29f 100644 --- a/README.md +++ b/README.md @@ -183,9 +183,12 @@ export GTK_IM_MODULE=strans GLFW_IM_MODULE=ibus kitty ``` -Building and installing `gtk/im-strans.so` requires GTK development files; -the install target uses GTK's own module directory, which packagers and -cross builds override with `GTK_MODULE_DIR`. +Building `gtk/im-strans.so` requires GTK development files; installing one +built elsewhere, in the container for instance, does not. The install +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 update. A native install needs the GTK runtime query utility so it can refresh diff --git a/gtk/Makefile b/gtk/Makefile index f357eec..a9d3277 100644 --- a/gtk/Makefile +++ b/gtk/Makefile @@ -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_BINARY_VERSION ?= $(shell $(PKG_CONFIG) \ --variable=gtk_binary_version gtk+-3.0 2>/dev/null) -GTK_MODULE_DIR ?= $(strip $(if $(GTK_BINARY_VERSION),\ - $(GTK_LIBDIR)/gtk-3.0/$(GTK_BINARY_VERSION)/immodules)) +# Without GTK development files, ask the runtime where its modules live. +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)