# xop — Makefile
#
# Common tasks:
#   make build       — release binary
#   make install     — install to /usr/local/bin (requires sudo)
#   make uninstall   — remove from /usr/local/bin
#   make test        — full test suite
#   make smoke       — banner + dry-run smoke
#   make clean       — cargo clean

PREFIX ?= /usr/local
BINDIR := $(PREFIX)/bin
TARGET := target/release/xop
BIN_NAME := xop

.PHONY: all build install uninstall test smoke clean check fmt clippy

build:
	cargo build --release

install: build
	install -d $(DESTDIR)$(BINDIR)
	install -m 0755 $(TARGET) $(DESTDIR)$(BINDIR)/$(BIN_NAME)
	@echo ""
	@echo "✓ installed $(BIN_NAME) to $(BINDIR)/$(BIN_NAME)"
	@echo "  test: $$($(BINDIR)/$(BIN_NAME) --version)"

uninstall:
	rm -f $(DESTDIR)$(BINDIR)/$(BIN_NAME)
	@echo "✓ removed $(BINDIR)/$(BIN_NAME)"

check:
	cargo check --all-targets

test:
	cargo test --lib
	cargo test --test integration -- --test-threads=1

smoke: build
	./$(TARGET)               # prints banner
	./$(TARGET) help          # prints help
	./$(TARGET) --version     # prints version

fmt:
	cargo fmt --all

clippy:
	cargo clippy --all-targets -- -D warnings

clean:
	cargo clean