aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-27 13:14:38 +0100
committereunhhu <[email protected]>2026-09-27 13:14:38 +0100
commit37d3a1e152707d2da587440c4cea8601b9ef0fd2 (patch)
tree1a4cbea9d8ca636deabd8fc24b0d73cdae2bdaef /Makefile
parent5372d03b5968796515966e2cfc89628d6448f0c1 (diff)
downloadpure-37d3a1e152707d2da587440c4cea8601b9ef0fd2.tar.gz
pure-37d3a1e152707d2da587440c4cea8601b9ef0fd2.zip
Lay Pure out as a core with the parts selected around it
The app model, the tree store and the HTTP host lived in prototypes/connections among the earlier document runtime, the store was known only by its format's name, and Vega compiled six Pure sources by path. Now, as the README's principle has it: core/ runtime, flow and the app model (module*.c), with what the core asks of storage (state.h, store.h) store/ the tree store (PURETRE3, PUREREC1) serve/ pure-serve: HTTP host, outbound delivery, JSON in place cli/ pure-run, pure-edit-module A top-level make builds libpure.a (app model and store, for hosts to link) and the hosts; make check runs the store's and the app model's tests. The earlier runtime still builds from prototypes/connections against core/ and store/ (check, check-tree and check-core pass). Design 009 records the rule: parts by role behind libraries; git repositories split by coupling, so the store stays here while its contract moves with the core, and Vega stays apart.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile58
1 files changed, 58 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..50448da
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,58 @@
+CC ?= cc
+AR ?= ar
+CFLAGS ?= -O2 -g
+CFLAGS += -std=c17 -Wall -Wextra -Wpedantic -Werror
+BUILD ?= build
+
+# Pure is a small core with the rest selected around it:
+# core/ execution, ownership, limits and completion (runtime), and the app
+# model: modules verified before they run, events as transactions,
+# states as drafts; state.h and store.h are what it asks of storage.
+# store/ the tree store (one file; commits are one contiguous write and one
+# sync; formats PURETRE3 and PUREREC1).
+# serve/ pure-serve: the HTTP host, outbound delivery, JSON in place.
+# cli/ command-line hosts.
+# libpure.a is the app model with the tree store: what a host embeds (Vega's
+# surfaces link it). prototypes/ keeps the earlier document runtime (000-077).
+INCLUDES = -Icore
+MODEL = core/module.c core/module-list.c core/module-save.c core/module-text.c core/module-store.c core/flow.c
+STORE = store/store-tree.c
+SERVE = serve/serve.c serve/deliver.c serve/message-json.c
+HEADERS = $(wildcard core/*.h) $(wildcard serve/*.h)
+OBJECTS = $(patsubst %.c,$(BUILD)/obj/%.o,$(MODEL) $(STORE))
+
+.PHONY: all check
+all: $(BUILD)/libpure.a $(BUILD)/pure-serve $(BUILD)/pure-run $(BUILD)/pure-edit-module
+
+$(BUILD)/obj/%.o: %.c $(HEADERS)
+ @mkdir -p $(dir $@)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) -c $< -o $@
+
+$(BUILD)/libpure.a: $(OBJECTS)
+ rm -f $@
+ $(AR) rcs $@ $^
+
+# The runtime's tickets and budgets, with effects completed off the owner thread.
+$(BUILD)/pure-serve: $(SERVE) core/runtime.c $(BUILD)/libpure.a $(HEADERS)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) -Iserve -DPURE_ASYNC_EFFECTS $(SERVE) core/runtime.c $(BUILD)/libpure.a \
+ $(LDFLAGS) -lssl -lcrypto -lm -pthread $(LDLIBS) -o $@
+
+$(BUILD)/pure-run: cli/pure-run.c $(BUILD)/libpure.a $(HEADERS)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) cli/pure-run.c $(BUILD)/libpure.a $(LDFLAGS) -lm $(LDLIBS) -o $@
+
+# The document CLI contract, driven by a module on the tree store.
+$(BUILD)/pure-edit-module: cli/edit-module.c $(BUILD)/libpure.a $(HEADERS)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) cli/edit-module.c $(BUILD)/libpure.a $(LDFLAGS) -lm $(LDLIBS) -o $@
+
+# Tests build their own copies: the store's fault hooks exist only under PURE_STORE_TEST.
+$(BUILD)/test-module: core/test-module.c $(MODEL) $(STORE) $(HEADERS)
+ @mkdir -p $(BUILD)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) -DPURE_STORE_TEST core/test-module.c $(MODEL) $(STORE) $(LDFLAGS) -pthread -lm $(LDLIBS) -o $@
+
+$(BUILD)/test-tree-store: store/test-tree-store.c $(STORE) $(HEADERS)
+ @mkdir -p $(BUILD)
+ $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) -DPURE_STORE_TEST store/test-tree-store.c $(STORE) $(LDFLAGS) $(LDLIBS) -o $@
+
+check: all $(BUILD)/test-module $(BUILD)/test-tree-store
+ $(BUILD)/test-tree-store
+ $(BUILD)/test-module