# Simple Makefile for Bifrost prompt-rewriter plugin

PLUGIN_NAME := prompt-rewriter
SO_FILE     := $(PLUGIN_NAME).so
GO_FILES    := main.go

# Default target
.PHONY: all
all: build

# Build the shared object plugin
.PHONY: build
build:
	@echo "Building $(SO_FILE)..."
	go build -buildmode=plugin -o $(SO_FILE) $(GO_FILES)
	@echo "Done → $(SO_FILE)"

# Download / tidy dependencies
.PHONY: deps
deps:
	go mod tidy

# Clean build artifacts
.PHONY: clean
clean:
	rm -f $(SO_FILE)
	@echo "Cleaned"

# Rebuild from scratch
.PHONY: rebuild
rebuild: clean deps build

# Show help
.PHONY: help
help:
	@echo "Usage:"
	@echo "  make          - build the plugin (.so)"
	@echo "  make deps     - download/tidy Go modules"
	@echo "  make clean    - remove the .so file"
	@echo "  make rebuild  - clean + deps + build"
