Skip to content

Commit

Permalink
Run BibTeX if needed
Browse files Browse the repository at this point in the history
Because BibTeX is run from SPEC.aux, i.e., after the first LaTeX
invocation, integrate it into scripts/rerun.sh rather than trying
to construct Makefile rules to run it at the right time.

When making diffs, append to the $BIBINPUTS path so that .bib files
in the main top-level directory can be found.

Specifications that use BibTeX should list their .bib file(s) as
prerequisites, e.g.

    new/SPEC.pdf diff/SPEC.pdf: SPEC.tex new/SPEC.ver references.bib
  • Loading branch information
jmarshall committed Apr 8, 2019
1 parent 685b79f commit 69c2b02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,4 +1,6 @@
*.aux
*.bbl
*.blg
*.log
*.out
*.toc
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -45,7 +45,7 @@ OLD = HEAD
NEW =

diff/%.pdf: %.tex
TEXINPUTS=:..:../new latexdiff-vc --pdf --dir diff --force --git --subtype ONLYCHANGEDPAGE --graphics-markup=none --ignore-warnings --revision $(OLD) $(if $(NEW),--revision $(NEW)) $<
BIBINPUTS=:.. TEXINPUTS=:..:../new latexdiff-vc --pdf --dir diff --force --git --subtype ONLYCHANGEDPAGE --graphics-markup=none --ignore-warnings --revision $(OLD) $(if $(NEW),--revision $(NEW)) $<


show-styles:
Expand Down
10 changes: 9 additions & 1 deletion scripts/rerun.sh
Expand Up @@ -2,6 +2,7 @@
# Usage: rerun.sh FILEBASE LATEXCOMMAND ARGUMENT...
# Runs the LaTeX command as many times as necessary, as measured by
# the state files FILEBASE.aux etc having arrived at a steady state.
# On the first run, also runs BibTeX (via $BIBTEX if set) if needed.

base=$1
shift
Expand All @@ -17,7 +18,7 @@ checksum_state_files() {
for file in $base.*
do
case $file in
*.log|*.pdf|*.ver) ;;
*.blg|*.log|*.pdf|*.ver) ;;
*) cksum $file ;;
esac
done
Expand All @@ -27,6 +28,13 @@ prev=$(checksum_state_files)

"$@" || exit

if grep -q '\\bibdata' $base.aux
then
: ${BIBTEX:=bibtex --terse}
echo '*' Running $BIBTEX $base.aux
$BIBTEX $base.aux || exit
fi

checksum=$(checksum_state_files)

while test "$checksum" != "$prev"
Expand Down

0 comments on commit 69c2b02

Please sign in to comment.