# in a makefile?
#
# At the start of this target, we call $(LATEX) to compile $(PN).tex.
-# The first step is to check for the existence of a "previous"
-# file. If there isn't one, this is the first time that we've tried to
-# build the PDF. In that case, take the PDF that we've just built and
-# make *that* the previous file. Then start all over. If there is a
-# previous file, then this is the second (or more) time that we've
-# tried to build the PDF. We diff the PDF file that we've just built
-# against the previous file; if they're the same, then we've succeeded
-# and stop. Otherwise, we make the new PDF the previous file, and
-# start all over. The end result is that we will loop until the
-# newly-created PDF and the previous file are identical.
+# Afterwards, we check for the existence of a "previous" file. If
+# there isn't one, then this is the first time that we've built the
+# PDF. In that case, we take the PDF that we've just built and make it
+# the "previous" file before starting all over. If, on the other hand,
+# there already *was* a "previous" file, then this is the second (or
+# third...) time that we've built the PDF. We diff the newly-built PDF
+# against the "previous" file; if they're the same, then we've
+# succeeded and stop. Otherwise, we make the new PDF the "previous"
+# one, and start all over. The end result is that we will loop until
+# the newly-created PDF and the "previous" one are identical.
#
$(PN).pdf: $(SRCS) $(PN).bbl $(INDEX_DSTS)
$(LATEX) $(PN).tex
- if [ ! -f $@.previous ]; then \
- mv $@ $@.previous; \
- $(MAKE) $@; \
- fi;
-
- if cmp -s $@ $@.previous; then \
+ if [ -f $@.previous ] && cmp -s $@ $@.previous; then \
rm $@.previous; \
else \
mv $@ $@.previous; \