Files
splinter/Makefile
T
lotherk 36a66ab4f0 self monitor, MCP session tools, junction serving endpoint
- plugins/self: what the session costs the machine - RSS, CPU, threads, fds
  and io of the process itself from /proc/self/*, and the same (count, RSS,
  CPU) for every process whose parent chain reaches it: run calls, MCP
  children, delegates. Widget, /self and the session_usage tool; interval in
  the plugin block (default 2 s).
- MCP server: the session tools. splinter_sessions, splinter_state,
  splinter_models, splinter_agents, splinter_history, splinter_say,
  splinter_open, splinter_model, splinter_agent, splinter_steer,
  splinter_cancel, splinter_approve. Say starts a real turn and returns the
  answer; a turn parked on an approval returns the question instead of
  failing. Mutating tools obey --autonomous. `--daemon --mcp-server-listen`
  runs the MCP server on a thread beside the Telegram daemon.
- the MCP server asks the engine for its registry on every call (a session
  switch replaces it) and copies the tool name out of the parsed JSON before
  freeing it (the first version compared a dangling pointer and answered
  every session call with empty text).
- junction: "serving <endpoint>" - streaming answers carry no
  X-Junction-Endpoint, so the plugin compares the route targets' ok counters
  from /status between samples and names the one that grew, with its
  last_ms. The header is still used when present (non-streaming). The
  X-Junction-Endpoint of the plugin's own /v1/models probe remains a probe
  fact in /junction only.
- transport: X-Junction-Endpoint is parsed from the response headers in both
  the streaming and the non-streaming path and published through
  sp_host_served_by(); sp_reply carries served_by.
- the curl rate guard (--speed-limit/--speed-time) is gone: it cut slow
  router streams with "Less than 1 bytes/sec" even while keepalives arrived.
  The overall -m timeout stays.
- focus: the sidebar shows "recap N, every M turns", and an applied recap
  writes "recap applied (turn N, every M turns)" into the transcript (host
  status messages are now drained during a turn; protocol clients get them
  as entry events too). The initial goal announcement says so as well.
- tests: test_self, test_mcpsession.sh (real socket), test_focus status
  messages, test_junction serving placeholder.

make check: all tests passed.
2026-11-17 19:13:59 +00:00

389 lines
21 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: the backend lives in libsplinter.so (src/backend,
# the engine and everything it owns). The front ends are src/frontend/curses.c
# (the screen), src/frontend/protocol.c (the engine on a socket) and
# src/frontend/client.c (the reference client); src/main.c launches them.
# Every one of them links that single 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/backend -Isrc/frontend -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/backend/buf.o src/backend/tool.o src/backend/session.o src/backend/conv.o src/backend/transport.o \
src/backend/json.o src/backend/sse.o src/backend/openai.o src/backend/transport_openai.o \
src/backend/anthropic.o src/backend/transport_anthropic.o src/backend/builtin.o \
src/backend/agent.o src/backend/theme.o src/backend/palettes.o src/backend/decomp.o src/backend/i18n.o src/backend/delegate.o src/backend/telegram.o src/backend/log.o src/backend/cmdscript.o src/backend/folder.o src/backend/interview.o src/backend/ack.o src/backend/mcpserver.o src/backend/mcpsession.o src/backend/skills.o src/backend/memory.o src/backend/prompt.o src/backend/config.o src/backend/plugin.o src/backend/curl.o src/backend/swarm.o src/backend/provstate.o src/backend/md.o src/backend/tgmd.o src/backend/b64.o src/backend/a2aserver.o src/backend/providers.o src/backend/usage.o src/backend/confblock.o src/backend/agents.o src/backend/engine.o src/backend/http.o src/backend/openai_server.o src/backend/catalogs.o
# buildinfo.o is separate: buildinfo.c is generated from the objects below.
LIBOBJ_ALL = $(LIBOBJ) src/backend/buildinfo.o
BIN = splinter
BINOBJ = src/main.o src/frontend/curses.o src/frontend/protocol.o \
src/frontend/ui_local.o src/frontend/ui_remote.o
CLIENT = splinterctl
CLIENTOBJ = src/frontend/client.o
PLUGIN = plugins/clock/clock.so plugins/lcm/lcm.so plugins/cps/cps.so \
plugins/cli/cli.so plugins/focus/focus.so plugins/mcp/mcp.so \
plugins/ring/ring.so plugins/reminder/reminder.so \
plugins/kids/kids.so plugins/status/status.so plugins/tasks/tasks.so \
plugins/provider/provider.so \
plugins/scheduler/scheduler.so \
plugins/planner/planner.so \
plugins/a2a/a2a.so \
plugins/sysinfo/sysinfo.so \
plugins/tmux/tmux.so \
plugins/junction/junction.so \
plugins/self/self.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_memory tests/test_skills tests/test_telegram tests/test_delegate tests/test_builtin tests/test_ascii tests/test_ack tests/test_i18n tests/test_config tests/test_focus tests/test_sse tests/test_anthropic tests/test_cli tests/test_compactor tests/test_secrets tests/test_mcpclient tests/test_kids tests/test_lifecycle tests/test_md tests/test_tgmd tests/test_providers tests/test_b64 tests/test_pause tests/test_swarm tests/test_provstate tests/test_planner tests/test_tmux tests/test_usage tests/test_agents tests/test_confblock tests/test_jobs tests/test_engine tests/test_self
RPATH = -Wl,-rpath,'$$ORIGIN'
PLUGIN_RPATH = -Wl,-rpath,'$$ORIGIN/../..'
TEST_RPATH = -Wl,-rpath,'$$ORIGIN/..'
all: $(LIB) $(BIN) $(CLIENT) $(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)
src/backend/catalogs.c: share/locale/de.msg share/locale/en.msg share/locale/pt_BR.msg tools/embed_catalogs.sh
sh tools/embed_catalogs.sh share/locale/*.msg > $@
# The build stamp --version prints. It is regenerated only when one of the
# objects it describes is newer, so a no-op make keeps the old stamp: the
# stamp says when this binary was actually built, not when make last ran.
# The revision is included because 0.1.0 does not tell two builds apart.
src/backend/buildinfo.c: $(LIBOBJ) $(BINOBJ)
@{ \
rev=`git rev-parse --short HEAD 2>/dev/null` || rev=unknown; \
if [ -n "`git status --porcelain --untracked-files=no 2>/dev/null | head -n 1`" ]; then \
rev="$$rev-dirty"; \
fi; \
printf '/* generated by make: the build stamp of this binary */\nconst char *sp_build_time = "%s";\nconst char *sp_build_rev = "%s";\n' \
"`date '+%Y-%m-%d %H:%M:%S %Z'`" "$$rev"; \
} > $@
$(LIB): $(LIBOBJ_ALL) $(CURSES_A)
$(CC) -shared -o $@ $(LIBOBJ_ALL) $(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.
# The reference client links the library for the JSON it cannot be bothered to
# write twice, but never the curses code and never the engine's internals.
$(CLIENT): $(CLIENTOBJ) $(LIB)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(CLIENTOBJ) -L. -lsplinter $(RPATH) \
$(LIBS)
$(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/ring/ring.so: plugins/ring/ring.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/ring/ring.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/kids/kids.so: plugins/kids/kids.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/kids/kids.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/tasks/tasks.so: plugins/tasks/tasks.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/tasks/tasks.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/status/status.so: plugins/status/status.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/status/status.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/reminder/reminder.so: plugins/reminder/reminder.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/reminder/reminder.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/mcp/mcp.so: plugins/mcp/mcp.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/mcp/mcp.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 $@ $<
# A cli delegate's child has to find plugins/cli/cli.so. Beside an installed
# binary there is no such file, so the build directory this binary came from is
# compiled in as the last resort (sp_delegate_cli_plugin in src/backend/delegate.c).
src/backend/delegate.o: src/backend/delegate.c
$(CC) $(CFLAGS) -DSPLINTER_PLUGIN_DIR='"$(CURDIR)"' -c -o $@ $<
# POSIX make has no automatic dependencies. Rather than a list that is wrong
# the day somebody adds an #include, every object depends on the headers that
# make up the interface: a change there rebuilds everything that could see it.
HDRS = include/splinter.h include/splinter_engine.h include/splinter_plugin.h \
src/backend/config.h src/backend/ack.h \
src/backend/curl.h src/backend/log.h src/backend/i18n.h src/backend/md.h src/backend/b64.h src/backend/a2aserver.h
$(LIBOBJ) $(BINOBJ): $(HDRS)
$(PLUGIN): $(HDRS)
src/backend/agent.o: include/splinter.h
src/backend/buf.o: include/splinter.h
src/backend/tool.o: include/splinter.h
src/backend/session.o: include/splinter.h
src/backend/transport.o: include/splinter.h
src/backend/conv.o: include/splinter.h
src/backend/json.o: vendor/libmcp/mcp.h
src/backend/sse.o: include/splinter.h vendor/libmcp/mcp.h
src/backend/openai.o: include/splinter.h vendor/libmcp/mcp.h
src/backend/transport_openai.o: include/splinter.h src/backend/curl.h src/backend/log.h
src/backend/anthropic.o: include/splinter.h vendor/libmcp/mcp.h
src/backend/transport_anthropic.o: include/splinter.h src/backend/curl.h src/backend/log.h vendor/libmcp/mcp.h
src/backend/curl.o: src/backend/curl.h include/splinter.h
src/backend/builtin.o: include/splinter.h
src/backend/theme.o: src/backend/theme.h src/backend/palettes.h include/splinter.h
src/backend/palettes.o: src/backend/palettes.h
src/backend/decomp.o: src/backend/decomp.h
src/backend/i18n.o: src/backend/i18n.h include/splinter.h
src/backend/delegate.o: src/backend/config.h include/splinter.h
src/backend/telegram.o: include/splinter.h src/backend/curl.h src/backend/ack.h
src/backend/log.o: src/backend/log.h
src/backend/cmdscript.o: src/backend/cmdscript.h include/splinter.h
src/backend/folder.o: src/backend/folder.h include/splinter.h
src/backend/ack.o: src/backend/ack.h include/splinter.h
src/backend/interview.o: src/backend/interview.h include/splinter.h
src/backend/mcpserver.o: src/backend/mcpserver.h include/splinter.h
src/backend/skills.o: src/backend/skills.h src/backend/config.h include/splinter.h
src/backend/prompt.o: src/backend/prompt.h include/splinter.h
src/backend/memory.o: src/backend/memory.h src/backend/config.h include/splinter.h
src/backend/config.o: src/backend/config.h include/splinter.h
src/backend/plugin.o: include/splinter.h include/splinter_plugin.h
src/frontend/curses.o: src/frontend/ui.h src/frontend/ui_backend.h \
include/splinter_engine.h src/backend/theme.h src/backend/decomp.h src/backend/i18n.h include/splinter.h include/splinter_plugin.h src/backend/md.h
src/backend/md.o: src/backend/md.h include/splinter.h
src/backend/b64.o: src/backend/b64.h include/splinter.h
src/backend/a2aserver.o: src/backend/a2aserver.h include/splinter.h vendor/libmcp/mcp.h
src/frontend/ui_local.o: src/frontend/ui_backend.h include/splinter_engine.h src/frontend/ui.h
src/frontend/ui_remote.o: src/frontend/ui_backend.h src/frontend/protocol.h include/splinter_engine.h vendor/libmcp/mcp.h
src/frontend/client.o: src/frontend/protocol.h include/splinter.h
src/frontend/protocol.o: src/frontend/protocol.h include/splinter_engine.h include/splinter.h src/backend/i18n.h
src/backend/http.o: src/backend/http.h include/splinter.h
src/backend/openai_server.o: src/backend/openai_server.h src/backend/http.h src/backend/config.h include/splinter.h vendor/libmcp/mcp.h
src/backend/engine.o: include/splinter_engine.h src/backend/config.h src/backend/providers.h src/backend/agents.h src/backend/swarm.h src/backend/cmdscript.h src/backend/i18n.h include/splinter_plugin.h
src/backend/providers.o: src/backend/providers.h src/backend/config.h include/splinter.h include/splinter_plugin.h
src/main.o: include/splinter.h include/splinter_engine.h \
src/frontend/ui_backend.h src/backend/config.h src/backend/i18n.h include/splinter_plugin.h src/frontend/ui.h src/backend/theme.h src/backend/a2aserver.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_memory: tests/test_memory.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_memory.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_skills: tests/test_skills.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_skills.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_telegram: tests/test_telegram.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_telegram.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_delegate: tests/test_delegate.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_delegate.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_builtin: tests/test_builtin.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_builtin.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_ack: tests/test_ack.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_ack.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/frontend/curses.o -L. -lsplinter \
$(TEST_RPATH) $(CURSES_A) $(LIBS)
tests/test_md: tests/test_md.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_md.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_tgmd: tests/test_tgmd.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_tgmd.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_providers: tests/test_providers.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_providers.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_b64: tests/test_b64.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_b64.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_pause: tests/test_pause.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_pause.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_swarm: tests/test_swarm.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_swarm.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_provstate: tests/test_provstate.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_provstate.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_planner: tests/test_planner.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_planner.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_agents: tests/test_agents.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_agents.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_confblock: tests/test_confblock.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_confblock.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_engine: tests/test_engine.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_engine.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_junction: tests/test_junction.c $(LIB) plugins/junction/junction.so
$(CC) $(CFLAGS) -o $@ tests/test_junction.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_self: tests/test_self.c $(LIB) plugins/self/self.so
$(CC) $(CFLAGS) -o $@ tests/test_self.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_usage: tests/test_usage.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_usage.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_tmux: tests/test_tmux.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_tmux.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_jobs: tests/test_jobs.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_jobs.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_config: tests/test_config.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_config.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_anthropic: tests/test_anthropic.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_anthropic.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_secrets: tests/test_secrets.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_secrets.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_mcpclient: tests/test_mcpclient.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_mcpclient.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_kids: tests/test_kids.c $(LIB) $(PLUGIN)
$(CC) $(CFLAGS) -o $@ tests/test_kids.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/plugin_lifecycle.so: tests/plugin_lifecycle.c $(LIB) $(HDRS)
$(CC) $(CFLAGS) -shared -o $@ tests/plugin_lifecycle.c -L. -lsplinter \
$(TEST_RPATH) $(LIBS)
tests/test_lifecycle: tests/test_lifecycle.c $(LIB) tests/plugin_lifecycle.so
$(CC) $(CFLAGS) -o $@ tests/test_lifecycle.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) $(CLIENT) $(PLUGIN) $(TESTS) tests/test_junction
@set -e; python3 tools/check_i18n.py; \
export LD_LIBRARY_PATH=.; \
for t in $(TESTS); do echo "== $$t"; ./$$t; done; \
echo "== tests/test_delegate_cli.sh"; sh tests/test_delegate_cli.sh; \
echo "== tests/test_interview.sh"; sh tests/test_interview.sh; \
echo "== tests/test_gateway.sh"; sh tests/test_gateway.sh; \
echo "== tests/test_a2a.sh"; sh tests/test_a2a.sh; \
echo "== tests/test_a2a_ui.sh"; sh tests/test_a2a_ui.sh; \
echo "== tests/test_a2a_server.sh"; sh tests/test_a2a_server.sh; \
echo "== tests/test_a2a_context.sh"; sh tests/test_a2a_context.sh; \
echo "== tests/test_limit_wait.sh"; sh tests/test_limit_wait.sh; \
echo "== tests/test_pools.sh"; sh tests/test_pools.sh; \
echo "== tests/test_anthropic.sh"; sh tests/test_anthropic.sh; \
echo "== tests/test_agents_ui.sh"; sh tests/test_agents_ui.sh; \
echo "== tests/test_a2a_input.sh"; sh tests/test_a2a_input.sh; \
echo "== tests/test_ui.sh"; sh tests/test_ui.sh; \
echo "== tests/test_protocol.sh"; sh tests/test_protocol.sh; \
echo "== tests/test_attach.sh"; sh tests/test_attach.sh; \
echo "== tests/test_gateway_openai.sh"; sh tests/test_gateway_openai.sh; \
echo "== tests/test_reconnect.sh"; sh tests/test_reconnect.sh; \
echo "== tests/test_junction.sh"; sh tests/test_junction.sh; \
echo "== tests/test_mcpsession.sh"; sh tests/test_mcpsession.sh; \
echo "all tests passed"
# The installed binary finds its own library through an rpath relative to itself
# ($ORIGIN), so 'make install PREFIX=$HOME/.local' produces a program that runs
# without a wrapper, without LD_LIBRARY_PATH and without an environment file.
# Install by rename, never in place. A running splinter has these files
# mapped: cp truncates the old inode and writes into pages the process is
# executing, which killed a gateway that was up while make install ran
# (SIGSEGV at a nonsense address). A rename swaps the directory entry and
# leaves the mapped inode alone.
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib \
$(DESTDIR)$(PREFIX)/lib/splinter/plugins
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../lib' \
-o $(DESTDIR)$(PREFIX)/bin/.splinter.new $(BINOBJ) -L. -lsplinter \
$(CURSES_A) $(LIBS)
mv -f $(DESTDIR)$(PREFIX)/bin/.splinter.new \
$(DESTDIR)$(PREFIX)/bin/splinter
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../lib' \
-o $(DESTDIR)$(PREFIX)/bin/.$(CLIENT).new $(CLIENTOBJ) -L. -lsplinter \
$(LIBS)
mv -f $(DESTDIR)$(PREFIX)/bin/.$(CLIENT).new \
$(DESTDIR)$(PREFIX)/bin/$(CLIENT)
cp $(LIB) $(DESTDIR)$(PREFIX)/lib/.$(LIB).new
mv -f $(DESTDIR)$(PREFIX)/lib/.$(LIB).new $(DESTDIR)$(PREFIX)/lib/$(LIB)
for p in $(PLUGIN); do \
cp "$$p" "$(DESTDIR)$(PREFIX)/lib/splinter/plugins/.new.$$$$" && \
mv -f "$(DESTDIR)$(PREFIX)/lib/splinter/plugins/.new.$$$$" \
"$(DESTDIR)$(PREFIX)/lib/splinter/plugins/$${p##*/}" || exit 1; \
done
@echo "installed $(DESTDIR)$(PREFIX)/bin/splinter"
clean:
rm -f src/backend/catalogs.c src/backend/buildinfo.c $(BIN) $(CLIENT) $(LIB) $(LIBOBJ_ALL) $(BINOBJ) \
$(CLIENTOBJ) $(PLUGIN) $(TESTS) tests/plugin_lifecycle.so \
tests/test_junction
.PHONY: all check curses install clean
plugins/provider/provider.so: plugins/provider/provider.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/provider/provider.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/scheduler/scheduler.so: plugins/scheduler/scheduler.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/scheduler/scheduler.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/planner/planner.so: plugins/planner/planner.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/planner/planner.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/tmux/tmux.so: plugins/tmux/tmux.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/tmux/tmux.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/a2a/a2a.so: plugins/a2a/a2a.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/a2a/a2a.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/sysinfo/sysinfo.so: plugins/sysinfo/sysinfo.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/sysinfo/sysinfo.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/junction/junction.so: plugins/junction/junction.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/junction/junction.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)
plugins/self/self.so: plugins/self/self.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/self/self.c -L. -lsplinter \
$(PLUGIN_RPATH) $(LIBS)