aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile60
1 files changed, 38 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 0cb65a1..481ccc3 100644
--- a/Makefile
+++ b/Makefile
@@ -4,27 +4,32 @@
# This Makefile is self-documenting (via the 'help' target)
# see: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
-CARGO = cargo
-CARGO_OPTS =
-PREFIX=/usr
-
HACKS=exuberantbovines
+
+CARGO ?= cargo
+CARGO_OPTS ?=
+PREFIX ?= /usr
+PANDOC ?= pandoc
+PANDOCFLAGS ?=
+MANSECTION = 6
+MANPAGE.md = $(PANDOC) --standalone $(PANDOCFLAGS) --to man
+MANPAGES = $(foreach HACK, $(HACKS), doc/$(HACK).$(MANSECTION))
+MANPAGEZ = $(foreach HACK, $(HACKS), doc/$(HACK).$(MANSECTION).gz)
+
INSTALL_BIN=$(PREFIX)/lib/xscreensaver
INSTALL_CONFIG=$(PREFIX)/share/xscreensaver/config
-INSTALL_MAN=$(PREFIX)/share/man
+INSTALL_MAN=$(PREFIX)/share/man/man$(MANSECTION)
-all: ## Alias for build
- $(MAKE) build
- $(MAKE) doc
+all: build doc ## Alias for build
build: ## Compiles the default target
- $(CARGO) $(CARGO_OPTS) build
+ @$(CARGO) $(CARGO_OPTS) build
build-debug: ## Compiles for 'debug' target
- $(CARGO) $(CARGO_OPTS) build --debug
+ @$(CARGO) $(CARGO_OPTS) build --debug
build-release: ## Compiles for 'release' target
- $(CARGO) $(CARGO_OPTS) build --release
+ @$(CARGO) $(CARGO_OPTS) build --release
install: build-release doc-release ## Installs everything!
@echo "Installing under $(PREFIX)..."
@@ -32,8 +37,12 @@ install: build-release doc-release ## Installs everything!
sudo mkdir -p $(PREFIX)/share/xscreensaver/config
@for PROG in $(HACKS); do \
sudo install -m 0755 target/release/$$PROG $(INSTALL_BIN); \
- sudo install -m 0644 extra/$$PROG.xml $(INSTALL_CONFIG); \
+ sudo install -m 0644 configs/$$PROG.xml $(INSTALL_CONFIG); \
+ sudo install -m 0644 doc/$$PROG.$(MANSECTION).gz $(INSTALL_MAN); \
done
+ @echo "Updating mandb (this takes a few seconds)..."
+ @sudo mandb -q
+ @echo ""
@echo "IMPORTANT: For the hacks to show up you'll need to add the following lines to ~/.xscreensaver:"
@echo "";
@for PROG in $(HACKS); do \
@@ -43,23 +52,30 @@ install: build-release doc-release ## Installs everything!
@echo "(don't worry about duplicate lines, xscreensaver will clean that up)"
clean: ## Deletes intermediate files (including compiled deps)
- $(CARGO) $(CARGO_OPTS) clean
+ @$(CARGO) $(CARGO_OPTS) clean
+ @rm -f $(MANPAGES) $(MANPAGEZ)
-check: ## Rebuilds and runs tests
- $(MAKE) build
- $(MAKE) test
+check: build test ## Rebuilds and runs tests
test: ## Runs tests (if they exist)
- $(CARGO) $(CARGO_OPTS) test
+ @$(CARGO) $(CARGO_OPTS) test
bench: ## Run benchmarks (if they exist)
- $(CARGO) $(CARGO_OPTS) bench
+ @$(CARGO) $(CARGO_OPTS) bench
+
+docs: doc
+
+doc: $(MANPAGEZ) ## Builds documentation (if there is any) for the default target
+ @$(CARGO) $(CARGO_OPTS) doc --no-deps
+
+doc-release: $(MANPAGEZ) ## Builds documentation (if there is any) for release
+ @$(CARGO) $(CARGO_OPTS) doc --no-deps --release
-doc: ## Builds documentation (if there is any) for the default target
- $(CARGO) $(CARGO_OPTS) doc --no-deps
+$(MANPAGES): %.$(MANSECTION): %.$(MANSECTION).md
+ $(MANPAGE.md) $< -o $@
-doc-release: ## Builds documentation (if there is any) for release
- $(CARGO) $(CARGO_OPTS) doc --no-deps --release
+$(MANPAGEZ): %.$(MANSECTION).gz: %.$(MANSECTION)
+ @gzip --keep --force $<
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'