PREFIX ?= /usr/local
_INSTDIR = $(DESTDIR)$(PREFIX)
BINDIR ?= $(_INSTDIR)/bin
MANDIR ?= $(_INSTDIR)/share/man
PHETCH_RELEASE = target/release/phetch
PHETCH_DEBUG = target/debug/phetch
RSFILES = $(wildcard src/*.rs src/**/*.rs)
.PHONY: all release debug clean install manual scdoc
all: release manual
release: $(PHETCH_RELEASE)
debug: $(PHETCH_DEBUG)
./target/debug/phetch
clean:
@rm -rf target
test:
cargo clippy --all-features
cargo test --all-features
$(PHETCH_RELEASE): $(RSFILES)
cargo build --release
$(PHETCH_DEBUG): $(RSFILES)
cargo build --no-default-features
install: all
mkdir -p $(BINDIR) $(MANDIR)/man1
install -m755 $(PHETCH_RELEASE) $(BINDIR)/phetch
install -m644 doc/phetch.1 $(MANDIR)/man1/phetch.1
uninstall:
rm -f $(BINDIR)/phetch $(MANDIR)/man1/phetch.1
manual: doc/phetch.1
doc/phetch.1: doc/phetch.1.md scdoc
scdoc < doc/phetch.1.md > doc/phetch.1
scdoc:
@which scdoc || (echo "scdoc(1) not found."; \
echo "install it: https://repology.org/project/scdoc"; exit 1)