One fixed session, born once, kept and compacted forever. The daemon wakes on its own impulse, works on a persistent goal, detects repeated failures, reflects, changes approach, and records everything. It starts as root, builds a debootstrap chroot, then drops to an unprivileged uid and applies Landlock and seccomp. Dashboard, HTTP API and MCP expose the same snapshot; the event log is root-owned and append-only. Offline suites cover the engine, the daemon, both sandbox layers and the dashboard/MCP sockets; a root-only script covers debootstrap, chroot, uid drop and plugin loading.
102 lines
3.3 KiB
Makefile
102 lines
3.3 KiB
Makefile
# krang -- POSIX make.
|
|
#
|
|
# make build krang
|
|
# make check build and run the offline tests (no network, no model)
|
|
# make clean
|
|
#
|
|
# The engine is ../splinter/libsplinter.so. Build it first with
|
|
# `make -C ../splinter`; its headers are not installed by `make install`.
|
|
|
|
CC ?= cc
|
|
SPLINTER ?= ../splinter
|
|
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Werror -D_POSIX_C_SOURCE=200809L
|
|
CPPFLAGS = -Isrc -I$(SPLINTER)/include -I$(SPLINTER)/src/backend \
|
|
-I$(SPLINTER)/vendor/libmcp
|
|
LDFLAGS ?=
|
|
LIBS = -L$(SPLINTER) -lsplinter -lpthread
|
|
RPATH = -Wl,-rpath,'$$ORIGIN/../splinter' -Wl,-rpath,'$$ORIGIN/../lib'
|
|
TEST_RPATH = -Wl,-rpath,'$$ORIGIN/../../splinter' \
|
|
-Wl,-rpath,'$$ORIGIN/../../lib'
|
|
|
|
BIN = krang
|
|
LIB = libkrang.a
|
|
SRC = src/util.c src/config.c src/log.c src/session.c src/birth.c \
|
|
src/stuck.c src/state.c src/chat.c src/journal.c src/daemon.c \
|
|
src/sandbox.c src/httpd.c
|
|
OBJ = $(SRC:.c=.o)
|
|
TESTS = tests/test_krang tests/test_engine tests/test_server \
|
|
tests/test_sandbox tests/test_sandbox_engine tests/test_daemon
|
|
|
|
all: $(BIN)
|
|
|
|
$(BIN): src/main.o $(LIB)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ src/main.o $(LIB) $(LIBS) $(RPATH)
|
|
|
|
$(LIB): $(OBJ)
|
|
rm -f $@
|
|
ar rcs $@ $(OBJ)
|
|
|
|
src/%.o: src/%.c src/krang.h
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
|
|
|
src/main.o: src/main.c src/krang.h
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
|
|
|
tests/test_krang: tests/test_krang.c $(LIB)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_krang.c $(LIB) \
|
|
$(LIBS) $(TEST_RPATH)
|
|
|
|
tests/test_engine: tests/test_engine.c $(LIB)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) \
|
|
-DKRANG_TEST_PLUGIN='"$(abspath $(SPLINTER))/plugins/clock/clock.so"' \
|
|
-o $@ tests/test_engine.c $(LIB) $(LIBS) $(TEST_RPATH)
|
|
|
|
tests/test_server: tests/test_server.c $(LIB)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_server.c $(LIB) \
|
|
$(LIBS) $(TEST_RPATH)
|
|
|
|
tests/test_sandbox: tests/test_sandbox.c $(LIB)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_sandbox.c $(LIB) \
|
|
$(LIBS) $(TEST_RPATH)
|
|
|
|
tests/test_sandbox_engine: tests/test_sandbox_engine.c $(LIB)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_sandbox_engine.c $(LIB) \
|
|
$(LIBS) $(TEST_RPATH)
|
|
|
|
tests/test_daemon: tests/test_daemon.c $(LIB)
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ tests/test_daemon.c $(LIB) \
|
|
$(LIBS) $(TEST_RPATH)
|
|
|
|
check: $(TESTS)
|
|
@echo "== tests/test_krang"; ./tests/test_krang
|
|
@echo "== tests/test_engine"; ./tests/test_engine
|
|
@echo "== tests/test_server"; ./tests/test_server
|
|
@echo "== tests/test_sandbox"; ./tests/test_sandbox
|
|
@echo "== tests/test_sandbox_engine"; ./tests/test_sandbox_engine
|
|
@echo "== tests/test_daemon"; ./tests/test_daemon
|
|
@echo "all tests passed"
|
|
|
|
check-root: $(BIN)
|
|
tests/root-integration.sh
|
|
|
|
check-asan:
|
|
$(MAKE) clean
|
|
$(MAKE) CFLAGS="$(CFLAGS) -g -fsanitize=address,undefined" \
|
|
LDFLAGS="-fsanitize=address,undefined" check
|
|
|
|
install: $(BIN)
|
|
install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib \
|
|
$(DESTDIR)$(PREFIX)/share/krang
|
|
install -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin/krang
|
|
install -m 0644 $(SPLINTER)/libsplinter.so \
|
|
$(DESTDIR)$(PREFIX)/lib/libsplinter.so
|
|
install -m 0644 krang.conf.example \
|
|
$(DESTDIR)$(PREFIX)/share/krang/krang.conf.example
|
|
install -m 0644 share/krang.service \
|
|
$(DESTDIR)$(PREFIX)/share/krang/krang.service
|
|
|
|
clean:
|
|
rm -f $(BIN) $(LIB) $(OBJ) src/main.o $(TESTS)
|
|
|
|
.PHONY: all check check-asan check-root install clean
|