# Makefile for deepseek_fim -- DeepSeek FIM autocomplete for Vim. # # make build bin/ds_fim (C backend, needs gcc + libcurl) # make check offline tests (C selftest, python selftest, # protocol framing, vimscript syntax, ghost regression) # make install install into $(VIMDIR) (default ~/.vim) # make clean remove build output CC ?= gcc CFLAGS ?= -O2 -Wall -Wextra -std=c99 BIN := bin/ds_fim SRC := src/ds_fim.c PY := src/ds_fim.py CURL_CFLAGS := $(shell pkg-config --cflags libcurl 2>/dev/null) CURL_LIBS := $(shell pkg-config --libs libcurl 2>/dev/null) VIMDIR ?= $(HOME)/.vim all: $(BIN) bin: mkdir -p bin $(BIN): $(SRC) | bin $(CC) $(CFLAGS) $(CURL_CFLAGS) -o $@ $< $(CURL_LIBS) chmod +x $@ # If no C toolchain / libcurl is available, the plugin falls back to # src/ds_fim.py (python3, stdlib only) automatically -- nothing to build. check: all @echo '== C backend selftest ==' ./$(BIN) --selftest @echo '== python fallback selftest ==' python3 $(PY) --selftest @echo '== backend --check without key (must exit 3) ==' @if DEEPSEEK_API_KEY= ./$(BIN) --check; then \ echo 'FAIL: --check should reject empty key'; exit 1; \ else \ echo 'ok: --check rejects empty key (exit '$$?')'; \ fi @echo '== protocol framing without network ==' @echo 'not json' | DEEPSEEK_API_KEY=x ./$(BIN) --once @echo '{"id": 9, "prefix": "x"}' | DEEPSEEK_API_KEY=x ./$(BIN) --once @echo '== vimscript syntax ==' vim -u NONE -N -es --cmd 'set rtp+=.' \ -c 'source plugin/deepseek_fim.vim' \ -c 'if deepseek_fim#version() != "1.0.0" | cquit 1 | endif' \ -c 'qa!' @echo '== ghost Tab-accept regression (E565) ==' vim -u NONE -N -es -S test/ghost.vim @echo 'ok: ghost Tab-accept regression' install: all mkdir -p $(VIMDIR)/pack/ai/start/deepseek_fim cp -r plugin autoload doc bin $(VIMDIR)/pack/ai/start/deepseek_fim/ cp src/ds_fim.py $(VIMDIR)/pack/ai/start/deepseek_fim/src_fallback_ds_fim.py 2>/dev/null || \ (mkdir -p $(VIMDIR)/pack/ai/start/deepseek_fim/src && \ cp src/ds_fim.py $(VIMDIR)/pack/ai/start/deepseek_fim/src/) vim -u NONE -N -es \ -c 'helptags $(VIMDIR)/pack/ai/start/deepseek_fim/doc' \ -c 'qa!' || true @echo 'installed to $(VIMDIR)/pack/ai/start/deepseek_fim/' clean: rm -f $(BIN) .PHONY: all check install clean