chiark / gitweb /
fix leftover \land
[topbloke-formulae.git] / Makefile
index 0391a54176f7d05f5e14506c1673f71e8dd2d8c7..88cfc3b873c973fdd36bab1232b5e6de80edb954 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,27 @@
 
-article.ps: article.pdf
-               pdftops article.pdf article.ps
+SRCS := $(wildcard *.tex)
 
-article.pdf: article.tex
-               pdflatex -halt-on-error $< </dev/null
+default: final.pdf
+
+once:          revid.inc
+               pdflatex -halt-on-error article.tex </dev/null
+
+GITDIR:=$(addsuffix /, $(shell git rev-parse --git-dir))
+HEADREF:=$(shell git symbolic-ref HEAD 2>/dev/null)
+HEADDEPS:=$(addprefix $(GITDIR), HEAD $(HEADREF))
+
+revid.inc:     .git-revid $(SRCS) Makefile $(HEADDEPS)
+               ./$< >$@.new
+               cmp $@.new $@ || mv -f $@.new $@
+
+final.pdf: $(SRCS) revid.inc
+               $(MAKE) once
+               $(MAKE) once
+               $(MAKE) once
+               cp article.pdf final.pdf
+
+%.ps: %.pdf
+               pdftops $*.pdf $*.ps
 
 clean:
-       rm -f *.aux *.log *.dvi *.out *.pdf *~
+       rm -f *.aux *.log *.dvi *.out *.pdf *.ps *~