.POSIX: PREFIX?=/usr/local BINDIR?=$(PREFIX)/bin MANDIR?=$(PREFIX)/share/man SRC!=find src hwcalc_lib -name '*.rs' DOCS:=docs/man/hc.1 all: hc $(DOCS) hc: $(SRC) cargo build --release mv target/release/hc $@ install: hc $(DOCS) mkdir -m755 -p $(DESTDIR)$(BINDIR) install -m755 hc $(DESTDIR)$(BINDIR)/hc mkdir -m755 -p $(DESTDIR)$(MANDIR)/man1 install -m644 docs/man/hc.1 $(DESTDIR)$(MANDIR)/man1/hc.1 uninstall: rm -f $(DESTDIR)$(BINDIR)/hc rm -f $(DESTDIR)$(MANDIR)/man1/hc.1 lint: cargo fmt -- --check cargo clippy check: cargo test --workspace cov: LLVM_COV=llvm-cov LLVM_PROFDATA=llvm-profdata cargo llvm-cov --workspace --html AFL_TARGET?=eval AFL_JOBS?=1 AFL_TARGET_CRASH?=crashes afl: rm -rf test/afl/out (cd test/afl && \ cargo afl build --release --config profile.release.debug-assertions=true && \ (cargo afl fuzz -i in -o out -Mm target/fuzz/${AFL_TARGET} &) && \ for i in $$(seq $$((${AFL_JOBS} - 1))); do \ cargo afl fuzz -i in -o out -Ss$$i target/fuzz/${AFL_TARGET} & \ done) afl_crash: set +e; \ for f in $$(find test/afl/out -path '*/${AFL_TARGET_CRASH}/id*'); do \ echo "cat $$f | cargo run --features=small_max"; \ out=$$(cat $$f | cargo run --features=small_max 2>&1); \ if [ $$? -ne 0 ] && ! echo "$$out" | grep -qE '^error:'; then \ echo; \ echo "FAIL"; \ echo "$$out"; \ exit 1; \ fi; \ done