omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / mk / estimation_tools.mk
| 1 | # EST-2/EST-3 replay, fit and evaluation tools (protocol v1). Not part of |
| 2 | # `all` or `test`. Tools may open files and print; est_types.o and est_kf.o |
| 3 | # stay pure (est-purity, unchanged). |
| 4 | ifndef ESTIMATION_TOOLS_MK |
| 5 | ESTIMATION_TOOLS_MK := 1 |
| 6 | include mk/estimation.mk |
| 7 | .PHONY: test-est-tools est-tools-purity est-tools |
| 8 | ESTT_DIR = $(OUT_DIR)/est-tools |
| 9 | ESTT_CFLAGS = $(EST_CFLAGS) -Itools/estimation |
| 10 | ESTT_LIB = tools/estimation/est_replay.c src/estimation/est_mix.c $(EST_KF_SRCS) |
| 11 | ESTT_HDRS = tools/estimation/est_replay.h $(EST_HDRS) |
| 12 | # Tool identity injected at build time: -DTOOL_COMMIT / -DTOOL_DIRTY. The stamp is |
| 13 | # rewritten only when the commit or the dirty flag changes, so est_eval.o rebuilds then. |
| 14 | ESTT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo unknown) |
| 15 | ESTT_DIRTY := $(shell if [ -n "$$(git status --porcelain 2>/dev/null)" ]; then echo 1; else echo 0; fi) |
| 16 | ESTT_ID = -DTOOL_COMMIT='"$(ESTT_COMMIT)"' -DTOOL_DIRTY=$(ESTT_DIRTY) |
| 17 | ESTT_FORBIDDEN = 'rx_|aienos_|argus_|forge_|aegis|mmap|mprotect|fork|exec|dlopen|socket|system' |
| 18 | |
| 19 | $(ESTT_DIR)/est_replay.o: tools/estimation/est_replay.c $(ESTT_HDRS) |
| 20 | @mkdir -p $(ESTT_DIR) |
| 21 | $(CC) $(ESTT_CFLAGS) -c -o $@ $< |
| 22 | $(ESTT_DIR)/est_fit.o: tools/estimation/est_fit.c $(ESTT_HDRS) |
| 23 | @mkdir -p $(ESTT_DIR) |
| 24 | $(CC) $(ESTT_CFLAGS) -c -o $@ $< |
| 25 | .PHONY: est-tools-stamp |
| 26 | est-tools-stamp: |
| 27 | @mkdir -p $(ESTT_DIR) |
| 28 | @echo "$(ESTT_COMMIT) $(ESTT_DIRTY)" > $(ESTT_DIR)/toolid.new; \ |
| 29 | cmp -s $(ESTT_DIR)/toolid.new $(ESTT_DIR)/toolid.stamp || mv $(ESTT_DIR)/toolid.new $(ESTT_DIR)/toolid.stamp; rm -f $(ESTT_DIR)/toolid.new |
| 30 | $(ESTT_DIR)/toolid.stamp: | est-tools-stamp |
| 31 | $(ESTT_DIR)/est_eval.o: tools/estimation/est_eval.c $(ESTT_HDRS) $(ESTT_DIR)/toolid.stamp |
| 32 | @mkdir -p $(ESTT_DIR) |
| 33 | $(CC) $(ESTT_CFLAGS) $(ESTT_ID) -c -o $@ $< |
| 34 | $(ESTT_DIR)/est_fit: $(ESTT_DIR)/est_fit.o $(ESTT_LIB) $(ESTT_HDRS) |
| 35 | $(CC) $(ESTT_CFLAGS) -o $@ $(ESTT_DIR)/est_fit.o $(ESTT_LIB) -lm |
| 36 | $(ESTT_DIR)/est_eval: $(ESTT_DIR)/est_eval.o $(ESTT_LIB) $(ESTT_HDRS) |
| 37 | $(CC) $(ESTT_CFLAGS) -o $@ $(ESTT_DIR)/est_eval.o $(ESTT_LIB) -lm |
| 38 | # est_eval built for tests only: run B identity and the dirty flag come from the environment |
| 39 | $(ESTT_DIR)/est_eval_t: tools/estimation/est_eval.c $(ESTT_LIB) $(ESTT_HDRS) |
| 40 | @mkdir -p $(ESTT_DIR) |
| 41 | $(CC) $(ESTT_CFLAGS) -DEST_TEST_BUILD -DTOOL_COMMIT='"test-build"' -DTOOL_DIRTY=1 -o $@ tools/estimation/est_eval.c $(ESTT_LIB) -lm |
| 42 | ESTT_OMC ?= seed/out/omc |
| 43 | ESTT_OM_LIB = src/estimation/est_defs.om src/estimation/est_math.om src/estimation/est_types.om \ |
| 44 | src/estimation/est_kf.om src/estimation/est_mix.om src/estimation/est_pred.om \ |
| 45 | src/estimation/est_v4.om tools/estimation/est_replay.om |
| 46 | |
| 47 | $(ESTT_DIR)/est_replay: $(ESTT_OM_LIB) tools/estimation/est_replay_main.om $(ESTT_OMC) |
| 48 | @mkdir -p $(ESTT_DIR) |
| 49 | cat $(ESTT_OM_LIB) tools/estimation/est_replay_main.om | $(ESTT_OMC) > $@ && chmod +x $@ |
| 50 | $(ESTT_DIR)/test_est_tools: tools/estimation/test_est_tools.c $(ESTT_LIB) $(ESTT_HDRS) |
| 51 | @mkdir -p $(ESTT_DIR) |
| 52 | $(CC) $(ESTT_CFLAGS) -o $@ tools/estimation/test_est_tools.c $(ESTT_LIB) -lm |
| 53 | |
| 54 | est-tools: $(ESTT_DIR)/est_fit $(ESTT_DIR)/est_eval $(ESTT_DIR)/est_replay |
| 55 | |
| 56 | est-tools-purity: est-purity $(ESTT_DIR)/est_replay.o $(ESTT_DIR)/est_fit.o $(ESTT_DIR)/est_eval.o |
| 57 | @if nm -u $(ESTT_DIR)/est_replay.o $(ESTT_DIR)/est_fit.o $(ESTT_DIR)/est_eval.o | grep -E $(ESTT_FORBIDDEN) ; then \ |
| 58 | echo "estimation tool references an authority, World or process operation"; exit 1; fi |
| 59 | @echo "est-tools-purity: tool objects reference no authority/process symbol; est_types.o and est_kf.o pure" |
| 60 | |
| 61 | test-est-tools: est-tools-purity $(ESTT_DIR)/est_fit $(ESTT_DIR)/est_eval $(ESTT_DIR)/est_eval_t $(ESTT_DIR)/test_est_tools |
| 62 | rm -rf $(ESTT_DIR)/work |
| 63 | ./$(ESTT_DIR)/test_est_tools ./$(ESTT_DIR)/est_fit ./$(ESTT_DIR)/est_eval ./$(ESTT_DIR)/est_eval_t $(ESTT_DIR)/work |
| 64 | @echo "test-est-tools: replay, fit and evaluation tools pass on run A and synthetic data" |
| 65 | endif |