MODULE  := gitea.mynodes.xyz/ilker/llmgw
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -X '$(MODULE)/internal/version.Version=$(VERSION)'

.PHONY: build test race lint fmt clean rename

build:
	go build -ldflags "$(LDFLAGS)" -o bin/llmgw ./cmd/llmgw

test:
	go test ./...

race:
	go test -race ./...

lint:
	golangci-lint run

fmt:
	go fmt ./...
	go vet ./...

clean:
	rm -rf bin dist

# Change the module path:  make rename NEW=git.example.com/team/llmgw
rename:
	@test -n "$(NEW)" || (echo "usage: make rename NEW=<new/module/path>"; exit 1)
	go mod edit -module=$(NEW)
	grep -rl '$(MODULE)' --include='*.go' . | xargs sed -i '' 's|$(MODULE)|$(NEW)|g'
	sed -i '' 's|^MODULE  := .*|MODULE  := $(NEW)|' Makefile
	go build ./...
