BINARY_NAME := ralph
INSTALL_ROOT ?= /usr/local
INSTALL_BIN := $(INSTALL_ROOT)/bin
CARGO := cargo
CARGO_FLAGS :=
RELEASE_FLAGS := --release
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PLATFORM := macos
else ifeq ($(UNAME_S),Linux)
PLATFORM := linux
else
PLATFORM := unknown
endif
.PHONY: all build release test clean install uninstall check fmt lint help
all: build
build:
$(CARGO) build $(CARGO_FLAGS)
echo "Debug build complete: target/debug/$(BINARY_NAME)"
release:
$(CARGO) build $(RELEASE_FLAGS)
echo "Release build complete: target/release/$(BINARY_NAME)"
test:
$(CARGO) test $(CARGO_FLAGS)
echo "All tests passed"
test-verbose:
$(CARGO) test $(CARGO_FLAGS) -- --nocapture
clean:
$(CARGO) clean
echo "Build artifacts cleaned"
install: release
echo "Installing $(BINARY_NAME) to $(INSTALL_BIN)..."
mkdir -p $(INSTALL_BIN)
install -m 755 target/release/$(BINARY_NAME) $(INSTALL_BIN)/$(BINARY_NAME)
echo "Installed: $(INSTALL_BIN)/$(BINARY_NAME)"
echo ""
echo "Installation complete! Run 'ralph --help' to get started."
install-local:
$(MAKE) install INSTALL_ROOT=$(HOME)/.local
uninstall:
echo "Removing $(INSTALL_BIN)/$(BINARY_NAME)..."
rm -f $(INSTALL_BIN)/$(BINARY_NAME)
echo "Uninstalled"
check:
$(CARGO) check $(CARGO_FLAGS)
echo "Type check passed"
fmt:
$(CARGO) fmt
echo "Code formatted"
fmt-check:
$(CARGO) fmt -- --check
echo "Format check passed"
lint:
$(CARGO) clippy $(CARGO_FLAGS) --all-targets -- -D warnings
echo "Lint check passed"
ci: fmt-check lint test
echo "All CI checks passed"
doc:
$(CARGO) doc --no-deps --open
version:
echo "Ralph build configuration:"
echo " Binary: $(BINARY_NAME)"
echo " Platform: $(PLATFORM)"
echo " Install path: $(INSTALL_BIN)/$(BINARY_NAME)"
$(CARGO) --version
rustc --version
help:
echo "Ralph Makefile targets:"
echo ""
echo " build Build debug version"
echo " release Build optimized release version"
echo " test Run all tests"
echo " test-verbose Run tests with output"
echo " clean Remove build artifacts"
echo " install Install to $(INSTALL_BIN) (may need sudo)"
echo " install-local Install to ~/.local/bin (no sudo needed)"
echo " uninstall Remove installed binary"
echo " check Run type checks"
echo " fmt Format source code"
echo " lint Run clippy lints"
echo " ci Run all CI checks"
echo " doc Build and open documentation"
echo " version Print version information"
echo " help Show this help"
echo ""
echo "Environment variables:"
echo " INSTALL_ROOT Installation prefix (default: /usr/local)"
echo ""
echo "Examples:"
echo " make release && sudo make install"
echo " make install-local"
echo " INSTALL_ROOT=/opt make install"