aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-10-25 22:25:57 -0600
committerMelody Horn <melody@boringcactus.com>2020-10-25 22:25:57 -0600
commitc538c09ed612e0ac16ed37f7d79995c6014320c0 (patch)
treea8946f7c057aff01231dc69591910c0370aeb624 /Makefile
parent71a5049a68426665d6c411ba3c00d449f0cf884d (diff)
downloadspec-c538c09ed612e0ac16ed37f7d79995c6014320c0.tar.gz
spec-c538c09ed612e0ac16ed37f7d79995c6014320c0.zip
portable makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile28
1 files changed, 18 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index f5f30d3..258580a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,23 +1,31 @@
+.POSIX:
+.SUFFIXES:
+.SUFFIXES: .md .html
+
+# commands
+GIT = git
+PANDOC = pandoc
+PDFINFO = pdfinfo
+
+# input files
SRC = index.md vs-c.md tagged-unions.md types.md safety.md errors.md syntax.md LICENSE.md
-HTML = $(SRC:%.md=%.html)
+HTML = $(SRC:.md=.html)
spec.pdf: $(HTML)
- if git describe --tags --exact-match 2>/dev/null; \
+ if $(GIT) describe --tags --exact-match 2>/dev/null; \
then \
- metadata="subtitle=$(git describe --tags --exact-match)"; \
+ metadata="subtitle=$$($(GIT) describe --tags --exact-match)"; \
else \
- metadata="version=$(git log -1 --no-decorate --oneline)"; \
+ metadata="version=$$($(GIT) log -1 --no-decorate --oneline)"; \
fi; \
- pandoc --defaults=etc/pdf.yml -M "$$metadata" -o $@ $(HTML)
+ $(PANDOC) --defaults=etc/pdf.yml -M "$$metadata" -o $@ $(HTML)
-%.html: %.md
+.md.html:
offset=`echo $(SRC) | awk '{for (i=1; i<=NF; i++) if ($$i == "$<") print (i-1) }'`; \
- pandoc --defaults=etc/md.yml --number-offset=$$offset -o $@ $<
+ $(PANDOC) --defaults=etc/md.yml --number-offset=$$offset -o $@ $<
clean:
rm -f $(HTML) spec.pdf
check: spec.pdf
- test $$(pdfinfo spec.pdf | grep Pages | awk '{ print $$2 }') -le 200
-
-.PHONY: clean check
+ test $$($(PDFINFO) spec.pdf | grep Pages | awk '{ print $$2 }') -le 200