+# The pipe below indicates an "order-only dependency" on the aux file.
+# Without it, every compilation of $(PN).tex would produce a new
+# $(PN).aux, and thus $(PN).bbl would be rebuild. This in turn causes
+# $(PN).pdf to appear out-of-date, which leads to a recompilation of
+# $(PN).tex... and so on. The order-only dependency means we won't
+# rebuild $(PN).bbl if $(PN).aux changes.
+#
+# As a side effect, we now need to depend on $(SRCS) here, since we
+# won't pick it up transitively from $(PN).aux.
+#
+# If the $BIBS variable is undefined, we presume that there are no
+# references and create an empty bbl file. Otherwise, we risk trying
+# to run biblatex on an aux file containing no citations.
+#
+$(PN).bbl: $(SRCS) | $(PN).aux
+ifdef BIBS
+ bibtex $(PN).aux
+else
+ echo -n '' > $@
+endif
+
+# Run chktex to find silly mistakes. There is some exit code weirdness
+# (Savannah bug 45979), so we just look for empty output.
+.PHONY: check
+check:
+ @[ -z "$(shell chktex --quiet mjotex.sty)" ]
+