PREFIX ?= /usr/local
BUILD = target/release/maman
MANPAGE = man/man1/maman.1
all: build install
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
$(BUILD):
@which cargo > /dev/null || { echo "https://www.rust-lang.org/"; exit 1; }
@cargo build --release
build: $(BUILD)
INSTALL = $(PREFIX)/bin/maman
$(INSTALL):
install -dm755 $(PREFIX)/bin/ $(PREFIX)/share/man/man1/
install -sm755 $(BUILD) $(PREFIX)/bin/
install -m644 $(MANPAGE) $(PREFIX)/share/man/man1/
install: build $(INSTALL)
clean:
rm -rf $(BUILD)
uninstall:
rm $(PREFIX)/bin/maman $(PREFIX)/share/$(MANPAGE)
manpage:
@which a2x > /dev/null || { echo "asciidoc libxml2-utils xmlto docbook-xsl docbook-xml"; exit 1; }
@find doc/ -type f -exec a2x -d manpage -f manpage -D man/man1 {} \;
.PHONY: all install clean uninstall help