# publish — Makefile
#
# Common targets:
#   make             - build the publish binary in the repo
#   make install     - interactive setup: detect OS/GPU, build whisper.cpp
#                      with the right backend, download a model, and link
#                      publish + whisper-cli-<backend> into ~/.local/bin
#   make doctor      - print detected platform/GPU/dependencies and exit
#   make link        - just link the existing publish binary into PREFIX/bin
#   make uninstall   - remove the publish symlink (leaves whisper.cpp alone)
#   make clean       - remove the local publish binary

PREFIX  ?= $(HOME)/.local
BINDIR  := $(PREFIX)/bin

.PHONY: all build link install doctor uninstall clean test help

all: build

build:
	go build -o publish .

link: build
	@mkdir -p "$(BINDIR)"
	@ln -sf "$(CURDIR)/publish" "$(BINDIR)/publish"
	@echo "linked $(BINDIR)/publish -> $(CURDIR)/publish"

install:
	@bash scripts/install.sh

doctor:
	@bash scripts/install.sh --doctor

uninstall:
	@rm -f "$(BINDIR)/publish"
	@echo "removed $(BINDIR)/publish (whisper.cpp checkout and whisper-cli-* symlinks left intact)"

clean:
	rm -f publish

test:
	go test ./...

help:
	@echo "Targets:"
	@echo "  make build      build ./publish"
	@echo "  make link       symlink ./publish into \$$PREFIX/bin (default ~/.local)"
	@echo "  make install    interactive end-to-end setup (deps + whisper + model + publish)"
	@echo "  make doctor     show detected platform/GPU/dependencies"
	@echo "  make uninstall  remove the publish symlink"
	@echo "  make clean      remove the built publish binary"
	@echo "  make test       go test ./..."
