PROG = im-strans.so
CFLAGS = -Wall -O2 -I.. $(shell pkg-config --cflags gtk+-3.0)
LDFLAGS = $(shell pkg-config --libs gtk+-3.0)
DSTDIR ?= $(shell find /usr/lib* -type d \
	-path "*/gtk-3.0/*/immodules" 2>/dev/null | head -1)

all: $(PROG)

$(PROG): main.c ../ipc.c ../ipc.h
	$(CC) -shared -fPIC $(CFLAGS) -o $@ main.c ../ipc.c $(LDFLAGS)

install: $(PROG)
	test -n "$(DSTDIR)"
	mkdir -p "$(DSTDIR)"
	cp $(PROG) "$(DSTDIR)/"
	gtk-query-immodules-3.0 --update-cache

uninstall:
	test -n "$(DSTDIR)"
	rm -f "$(DSTDIR)/$(PROG)"
	gtk-query-immodules-3.0 --update-cache

clean:
	rm -f $(PROG)

.PHONY: all install uninstall clean
