# SPDX-License-Identifier: GPL-3.0-or-later
# pomelo-input — Pomelo 注音輸入法（XIM 伺服器 + libchewing）
PREFIX ?= /usr/local
CFLAGS ?= -Os -pipe -Wall -Wextra -Wno-unused-parameter -Wno-format-truncation
POMELO_CFLAGS ?= $(shell pkg-config --cflags pomelo)
POMELO_LIBS   ?= $(shell pkg-config --libs pomelo)
PKGS = xcb xcb-shape xcb-keysyms xcb-imdkit cairo-xcb chewing
DEP_CFLAGS ?= $(shell pkg-config --cflags $(PKGS))
DEP_LIBS   ?= $(shell pkg-config --libs $(PKGS))
CHEWING_VER ?= $(shell pkg-config --modversion chewing 2>/dev/null || echo ?)
VER_FLAGS = -DCHEWING_VERSION=\"$(CHEWING_VER)\"

all: pomelo-input

pomelo-input: pomelo-input.c
	$(CC) $(CFLAGS) $(VER_FLAGS) $(POMELO_CFLAGS) $(DEP_CFLAGS) -o $@ pomelo-input.c $(POMELO_LIBS) $(DEP_LIBS) -lm $(LDFLAGS)

install: all
	install -Dm755 pomelo-input $(DESTDIR)$(PREFIX)/bin/pomelo-input

clean:
	rm -f pomelo-input

.PHONY: all install clean
