The install target guessed the module directory from whichever immodule was already installed when pkg-config had nothing to say — a guess that finds nothing on a fresh system and needed seven lines of README to explain. It uses GTK's own pkg-config variables now, or the GTK_MODULE_DIR a packager sets. The README also loses a negation about a font argument that no longer exists and two paragraphs that repeat the dependency list.
38 lines
1.2 KiB
Makefile
38 lines
1.2 KiB
Makefile
PROG = im-strans.so
|
|
PKG_CONFIG ?= pkg-config
|
|
CFLAGS ?= -O2
|
|
GTK_CFLAGS = $(shell $(PKG_CONFIG) --cflags gtk+-3.0)
|
|
GTK_LIBS = $(shell $(PKG_CONFIG) --libs gtk+-3.0)
|
|
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))
|
|
|
|
all: $(PROG)
|
|
|
|
$(PROG): main.c ../ipc.c ../ipc.h
|
|
$(CC) $(CPPFLAGS) -I.. $(GTK_CFLAGS) -Wall $(CFLAGS) $(LDFLAGS) \
|
|
-shared -fPIC -o $@ main.c ../ipc.c $(GTK_LIBS) $(LDLIBS)
|
|
|
|
CHECKDIR = test -n "$$module_dir" || { \
|
|
echo "cannot find GTK 3 module directory; set GTK_MODULE_DIR" >&2; \
|
|
exit 1; }
|
|
REFRESH = test -n "$(DESTDIR)" || { \
|
|
unset GTK_PATH GTK_IM_MODULE_FILE; $(GTK_QUERY_IMMODULES) --update-cache; }
|
|
|
|
install: $(PROG)
|
|
module_dir="$(GTK_MODULE_DIR)"; $(CHECKDIR); \
|
|
mkdir -p "$(DESTDIR)$$module_dir" && \
|
|
cp "$(PROG)" "$(DESTDIR)$$module_dir/" && $(REFRESH)
|
|
|
|
uninstall:
|
|
module_dir="$(GTK_MODULE_DIR)"; $(CHECKDIR); \
|
|
rm -f "$(DESTDIR)$$module_dir/$(PROG)" && $(REFRESH)
|
|
|
|
clean:
|
|
rm -f $(PROG)
|
|
|
|
.PHONY: all install uninstall clean
|