7814
Ta
tiny-c-agent / files
tiny-c-agent / Makefile
2.4 KB
1# tiny-c-agent - config-first agent for the terminal. 2# 3# make build 4# make deps report build dependencies 5# make run build and run 6# make clean remove build/ 7 8CC ?= cc 9STD ?= gnu11 10OPT ?= -O2 -g 11WARN := -Wall -Wextra -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith 12 13BUILD := build 14BIN := $(BUILD)/tiny 15 16PKGS := libcurl yyjson tree-sitter \ 17 tree-sitter-javascript tree-sitter-bash \ 18 tree-sitter-c tree-sitter-python \ 19 tree-sitter-markdown tree-sitter-markdown-inline 20 21SRCS := $(shell find src -name '*.c' | sort) 22OBJS := $(patsubst src/%.c,$(BUILD)/obj/%.o,$(SRCS)) 23DEPS := $(OBJS:.o=.d) 24 25# Grammars with no distro package are vendored and built into the binary. 26VENDOR_SRCS := $(wildcard vendor/make/src/*.c) \ 27 $(wildcard vendor/typescript/typescript/src/*.c) \ 28 $(wildcard vendor/typescript/tsx/src/*.c) 29VENDOR_OBJS := $(patsubst vendor/%.c,$(BUILD)/obj/vendor/%.o,$(VENDOR_SRCS)) 30OBJS += $(VENDOR_OBJS) 31VENDOR_CPPFLAGS := -D_GNU_SOURCE -std=$(STD) $(OPT) -pthread -w -fPIC -MMD -MP \ 32 -Ivendor/make/src \ 33 -Ivendor/typescript/typescript/src \ 34 -Ivendor/typescript/tsx/src 35 36BASE := -std=$(STD) $(OPT) -pthread 37 38CPPFLAGS += -D_GNU_SOURCE -Isrc -Ivendor/make -Ivendor/typescript -MMD -MP 39CFLAGS += $(BASE) $(WARN) $(shell pkg-config --cflags $(PKGS)) 40LDLIBS += $(shell pkg-config --libs $(PKGS)) -pthread 41 42.PHONY: all deps catalog queries run clean 43all: $(BIN) 44 45# Regenerates the committed catalog from models.dev. Run at release time, then 46# commit src/catalog.generated.c. 47catalog: 48 python3 tools/gen_catalog.py 49 50# Regenerates the committed highlight queries from vendor/queries. Run after 51# editing a .scm file, then commit src/queries.generated.c. 52queries: 53 python3 tools/gen_queries.py 54 55$(BIN): $(OBJS) 56 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) 57 58$(BUILD)/obj/%.o: src/%.c 59 @mkdir -p $(dir $@) 60 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< 61 62$(BUILD)/obj/vendor/%.o: vendor/%.c 63 @mkdir -p $(dir $@) 64 $(CC) $(VENDOR_CPPFLAGS) -c -o $@ $< 65 66deps: 67 @for p in $(PKGS); do \ 68 if pkg-config --exists $$p; then \ 69 printf 'ok %s %s\n' "$$p" "$$(pkg-config --modversion $$p)"; \ 70 else \ 71 printf 'MISSING %s\n' "$$p"; \ 72 fi; \ 73 done 74 75run: all 76 ./$(BIN) 77 78clean: 79 rm -rf $(BUILD) 80 81-include $(DEPS)