SHELL= /bin/bash
PACKAGE= pandora
GITROOT= $(shell git rev-parse --show-toplevel || pwd)
PROFILE?= release
PREFIX= $(HOME)/.local
BIN_DIR = $(PREFIX)/bin
CARGO?= cargo
INSTALL?= install
CARGOFLAGS?= -j$(shell nproc)
SRC=\
pandora.rs \
Cargo.toml
ifeq ($(PROFILE), debug)
BIN= $(GITROOT)/target/debug/$(PACKAGE)
else
BIN= $(GITROOT)/target/release/$(PACKAGE)
CARGOFLAGS+= --release
endif
all: $(BIN)
fmt:
astyle --indent=tab --style=linux t/*.c
$(CARGO) fmt
lint:
$(CARGO) deny check
$(CARGO) acl -n || true
$(CARGO) clippy $(CARGOFLAGS)
install: $(BIN)
$(INSTALL) -d $(BIN_DIR)
$(INSTALL) -m 755 $(BIN) $(BIN_DIR)
uninstall:
rm -f $(BIN_DIR)/$(PACKAGE)
check:
PANDORA_QUIET=1 $(MAKE) checkverbose
checkverbose: $(BIN)
$(CARGO) test $(CARGOFLAGS) -p pandora_box
cov: clean
source <($(CARGO) llvm-cov show-env --export-prefix 2>/dev/null) && \
$(CARGO) build -p pandora_box $(CARGOFLAGS) && \
PANDORA_QUIET=1 $(CARGO) test $(CARGOFLAGS) -p pandora_box && \
$(CARGO) llvm-cov report --release --ignore-filename-regex='/.cargo/' && \
$(CARGO) llvm-cov report --release --ignore-filename-regex='/.cargo/' --html
@echo "HTML report: $(GITROOT)/target/llvm-cov/html/index.html"
clean:
$(CARGO) clean
$(BIN): $(SRC)
$(CARGO) build $(CARGOFLAGS)
.PHONY: all clean check checkverbose cov test install uninstall fmt lint