From 0edc4ca47a037f400f6f3fd59ca0c799e9c75c4f Mon Sep 17 00:00:00 2001 From: Tommaso Negri Date: Sun, 12 Jul 2026 11:14:49 +0200 Subject: [PATCH] add Makefile --- Makefile | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2673813 --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +# Makefile for phbar +# +# Usage: make + +BIN_DIR := $(HOME)/.local/bin +BUILD_DIR := .build/release +BINARIES := phbar + +.PHONY: all build install clean test run + +all: build + +# Build all targets in release mode +build: + swift build -c release + +# Build and install binaries to ~/.local/bin +install: build + @mkdir -p $(BIN_DIR) + @for bin in $(BINARIES); do \ + cp -f $(BUILD_DIR)/$$bin $(BIN_DIR)/; \ + done + @echo "✅ Installed $(BINARIES) to $(BIN_DIR)" + +# Clean build artifacts +clean: + swift package clean + +# Run tests +test: + swift test + +# Quick test: build, install, and verify +run: install + @echo "Verifying installation..." + @for bin in $(BINARIES); do \ + which $$bin > /dev/null && echo "✓ $$bin: $(shell which $$bin)" || echo "✗ $$bin: not found"; \ + done + +# Uninstall binaries from ~/.local/bin +uninstall: + @for bin in $(BINARIES); do \ + rm -f $(BIN_DIR)/$$bin; \ + done + @echo "✅ Uninstalled $(BINARIES) from $(BIN_DIR)" + +# Rebuild and reinstall (clean + install) +reinstall: clean install + +# Show help +help: + @echo "Available targets:" + @echo " make build - Build in release mode" + @echo " make install - Build and install to ~/.local/bin" + @echo " make clean - Clean build artifacts" + @echo " make test - Run tests" + @echo " make run - Build, install, and verify" + @echo " make uninstall - Remove binaries from ~/.local/bin" + @echo " make reinstall - Clean and reinstall"