Not gettext: this harness is meant to start in ten years, and gettext needs msgfmt at build time and .mo files at runtime. So catalogues are 'key = text' files in share/locale, read once at startup. - language from the config key LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=, else SPLINTER_LOCALE, LC_ALL, LC_MESSAGES, LANG; regional variants are stripped (de_DE.UTF-8 -> de); - catalogue search: $SPLINTER_LOCALE_DIR, the executable's own directory (so works from any cwd), the source tree, /usr/local/share; - a missing key falls back to English, and a key that exists nowhere is shown as itself - an empty label hides a bug, a visible key does not; - UI labels, roles, sidebar headings, status line, command errors and the shell escape all go through sp_t(); plugins can translate theirs the same way. test_i18n loads both catalogues from share/locale, checks lookups, the fallback chain, printf placeholders, and that de.msg covers every key en.msg has - a translation that silently misses half the UI is worse than none. Seventeen test binaries green.
149 lines
6.3 KiB
Makefile
149 lines
6.3 KiB
Makefile
# splinter -- POSIX make for our own code, GNU make only for the vendored curses.
|
|
#
|
|
# make libsplinter.so, the splinter binary, the example plugin
|
|
# make check builds and runs every test binary
|
|
# make curses builds the vendored NetBSD curses explicitly
|
|
# make clean removes generated files only
|
|
#
|
|
# The layout is deliberate: all logic lives in libsplinter.so. The binary and
|
|
# every plugin link against that one library, so there is exactly one copy of
|
|
# each symbol in the process. Two copies would mean two registries.
|
|
|
|
CC ?= cc
|
|
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Werror -D_POSIX_C_SOURCE=200809L \
|
|
-fPIC -Iinclude -Isrc -Ivendor/libmcp -Ivendor/netbsd-curses/libcurses
|
|
LDFLAGS ?=
|
|
LIBS ?= -lpthread
|
|
PREFIX ?= /usr/local
|
|
|
|
CURSES_DIR = vendor/netbsd-curses
|
|
CURSES_A = $(CURSES_DIR)/libcurses/libcurses.a \
|
|
$(CURSES_DIR)/libterminfo/libterminfo.a
|
|
|
|
LIB = libsplinter.so
|
|
LIBOBJ = src/buf.o src/tool.o src/session.o src/conv.o src/transport.o \
|
|
src/json.o src/sse.o src/openai.o src/transport_openai.o src/builtin.o \
|
|
src/agent.o src/theme.o src/palettes.o src/decomp.o src/i18n.o src/config.o src/plugin.o
|
|
BIN = splinter
|
|
BINOBJ = src/main.o src/ui.o
|
|
PLUGIN = plugins/clock/clock.so plugins/lcm/lcm.so plugins/cps/cps.so \
|
|
plugins/cli/cli.so plugins/focus/focus.so
|
|
TESTS = tests/test_buf tests/test_tool tests/test_session tests/test_conv \
|
|
tests/test_transport tests/test_agent tests/test_openai \
|
|
tests/test_theme tests/test_plugin tests/test_ascii tests/test_i18n tests/test_config tests/test_focus tests/test_sse tests/test_cli tests/test_compactor
|
|
|
|
RPATH = -Wl,-rpath,'$$ORIGIN'
|
|
PLUGIN_RPATH = -Wl,-rpath,'$$ORIGIN/../..'
|
|
TEST_RPATH = -Wl,-rpath,'$$ORIGIN/..'
|
|
|
|
all: $(LIB) $(BIN) $(PLUGIN)
|
|
|
|
# The vendored tree ships a GNUmakefile; this is the only place that needs GNU
|
|
# make, and it is why the comment above says so out loud.
|
|
$(CURSES_A):
|
|
cd $(CURSES_DIR) && $(MAKE) -f GNUmakefile libcurses/libcurses.a \
|
|
libterminfo/libterminfo.a
|
|
|
|
curses: $(CURSES_A)
|
|
|
|
$(LIB): $(LIBOBJ) $(CURSES_A)
|
|
$(CC) -shared -o $@ $(LIBOBJ) $(CURSES_A) $(LIBS)
|
|
|
|
# curses belongs to the front end, not to the library: a plugin that drew into
|
|
# a WINDOW would be a plugin holding the UI thread's state.
|
|
$(BIN): $(BINOBJ) $(LIB)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(BINOBJ) -L. -lsplinter $(RPATH) \
|
|
$(CURSES_A) $(LIBS)
|
|
|
|
plugins/clock/clock.so: plugins/clock/clock.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/clock/clock.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/lcm/lcm.so: plugins/lcm/lcm.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/lcm/lcm.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/cli/cli.so: plugins/cli/cli.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/cli/cli.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/focus/focus.so: plugins/focus/focus.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/focus/focus.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/cps/cps.so: plugins/cps/cps.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/cps/cps.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
.c.o:
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
src/agent.o: include/splinter.h
|
|
src/buf.o: include/splinter.h
|
|
src/tool.o: include/splinter.h
|
|
src/session.o: include/splinter.h
|
|
src/transport.o: include/splinter.h
|
|
src/conv.o: include/splinter.h
|
|
src/json.o: vendor/libmcp/mcp.h
|
|
src/sse.o: include/splinter.h vendor/libmcp/mcp.h
|
|
src/openai.o: include/splinter.h vendor/libmcp/mcp.h
|
|
src/transport_openai.o: include/splinter.h
|
|
src/builtin.o: include/splinter.h
|
|
src/theme.o: src/theme.h src/palettes.h include/splinter.h
|
|
src/palettes.o: src/palettes.h
|
|
src/decomp.o: src/decomp.h
|
|
src/i18n.o: src/i18n.h include/splinter.h
|
|
src/config.o: src/config.h include/splinter.h
|
|
src/plugin.o: include/splinter.h include/splinter_plugin.h
|
|
src/ui.o: src/ui.h src/theme.h src/decomp.h src/i18n.h include/splinter.h include/splinter_plugin.h
|
|
src/main.o: include/splinter.h src/config.h src/i18n.h include/splinter_plugin.h src/ui.h src/theme.h
|
|
|
|
tests/test_buf: tests/test_buf.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_buf.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_tool: tests/test_tool.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_tool.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_session: tests/test_session.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_session.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_transport: tests/test_transport.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_transport.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_agent: tests/test_agent.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_agent.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_conv: tests/test_conv.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_conv.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_openai: tests/test_openai.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_openai.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_theme: tests/test_theme.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_theme.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_focus: tests/test_focus.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_focus.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_i18n: tests/test_i18n.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_i18n.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_ascii: tests/test_ascii.c $(LIB) $(BINOBJ)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_ascii.c src/ui.o -L. -lsplinter \
|
|
$(TEST_RPATH) $(CURSES_A) $(LIBS)
|
|
tests/test_config: tests/test_config.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_config.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_sse: tests/test_sse.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_sse.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_cli: tests/test_cli.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_cli.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_compactor: tests/test_compactor.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_compactor.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_plugin: tests/test_plugin.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_plugin.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
check: $(LIB) $(BIN) $(PLUGIN) $(TESTS)
|
|
@set -e; for t in $(TESTS); do echo "== $$t"; ./$$t; done; \
|
|
echo "all tests passed"
|
|
|
|
install: all
|
|
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib
|
|
cp $(BIN) $(DESTDIR)$(PREFIX)/bin/
|
|
cp $(LIB) $(DESTDIR)$(PREFIX)/lib/
|
|
|
|
clean:
|
|
rm -f $(BIN) $(LIB) $(LIBOBJ) $(BINOBJ) $(PLUGIN) $(TESTS)
|
|
|
|
.PHONY: all check curses install clean
|