SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
RM := rm -f
RMDIR := rm -rf
BINS := tcslog-dump tcslog-dumphdr
.PHONY: help
help:
@echo "Makefile for tcslog-tools"
@echo ""
@echo "Usage:"
@grep -hE '^[a-zA-Z_-]+:.*## ' $(MAKEFILE_LIST) \
| sed 's/:.*## /|/' \
| awk -F'|' '{printf " make %-14s - %s\n", $$1, $$2}'
.PHONY: test
test:
@echo "Running tests..."
cargo test
@echo "[OK] Tests complete"
.PHONY: clean
clean:
@echo "Cleaning build artifacts..."
-cargo clean
@echo "[OK] Clean complete"
.PHONY: distclean
distclean: clean
@echo "Removing all generated files..."
$(RMDIR) target
@echo "[OK] Project reset"
PREFIX ?= $(HOME)
DESTDIR ?=
.PHONY: install
install:
@echo "Installing $(BINS) to $(DESTDIR)$(PREFIX)/bin..."
cargo install --path . --root $(DESTDIR)$(PREFIX)
@echo "[OK] Installed to $(DESTDIR)$(PREFIX)/bin/"
.PHONY: uninstall
uninstall:
@echo "Removing $(BINS) from $(DESTDIR)$(PREFIX)/bin..."
$(RM) $(addprefix $(DESTDIR)$(PREFIX)/bin/,$(BINS))
@echo "[OK] Uninstalled from $(DESTDIR)$(PREFIX)/bin/"
.PHONY: check
check:
@echo "Running cargo check..."
cargo check --all-targets
cargo clippy --all-targets -- -D warnings
cargo fmt -- --check
.PHONY: format
format:
cargo fmt
.PHONY: release
release: test
@echo "Creating release build..."
cargo build --release
@echo "[OK] Release binaries are in target/release/"