summaryrefslogtreecommitdiffstats
path: root/utilities
diff options
context:
space:
mode:
authorAkira Yokosawa <akiysw@gmail.com>2016-04-24 09:02:50 +0900
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>2016-04-23 22:00:52 -0700
commit4038e781ed56949e864ee03695534a60e7e02b03 (patch)
tree61681b98c0ac553b4045a91425574f6d3a0cfc80 /utilities
parentb086d0241459afd97c735a156140d3951d82f063 (diff)
downloadperfbook-4038e781ed56949e864ee03695534a60e7e02b03.tar.gz
Improve behavior of build scripts
This commit takes care of the possible increase of pdflatex iterations introduced by the previous commit ("qqz: Improve accuracy of cross-links") that would cause 'make' to terminate prematurely. The same issue seems to have been observed since commit 33b93f8258f5 ("qqz: Cross-link questions and answers"). However, no one has attempted to fix it because a final PDF can be obtained by just repeating 'make' again. To fix the issue, this commit refactors 'runlinux.sh' into 3 parts. 1) bibtex related part is moved to 'Makefile' as rules for targets such as 'perfbook.bbl'. It also adds necessary rules which support the '.bbl' rules. 2) 'runfirstlatex.sh' is separated so that it can be invoked in rules for '.aux' targets which support '.bbl' rules. 3) 'runlatex.sh' is intensively modified. The first while loop watches the 'LaTeX Warning: There were undefined references' message and the second one watches the 'LaTeX Warning: Label(s) may have changed' message. The loops watch the variation in 'LaTeX Warning:" lines in $basename.log and when they find no change, they will give up. Note that in early rounds of the loop, there may be cases when there is no change in 'LaTeX Warning' messages while there is still room for improvement. To accommodate this, giving-up will fire only after a certain number of iterations for each loop. Since the minimum iteration numbers are chosen after trial and error, they might need to be changed in the future. For each round of the loop, a message representing which warning is being watched is displayed. When the giving-up logic kicks in, grep of the remaining warnings is also displayed. '$basename-first.log', '$basename-warning.log' and '$basename-warning-prev.log' files are used to track things. They are removed when the build succeeds. This commit also updates the copyright notices in the scripts. Signed-off-by: Akira Yokosawa <akiysw@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Diffstat (limited to 'utilities')
-rw-r--r--utilities/runfirstlatex.sh46
-rw-r--r--utilities/runlatex.sh85
2 files changed, 112 insertions, 19 deletions
diff --git a/utilities/runfirstlatex.sh b/utilities/runfirstlatex.sh
new file mode 100644
index 00000000..9111308f
--- /dev/null
+++ b/utilities/runfirstlatex.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Run the first round of pdflatex.
+# It is assumed to be used together with runlatex.sh and invoked from
+# 'make' command.
+#
+# Usage: sh runfirstlatex.sh file[.tex]
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, you can access it online at
+# http://www.gnu.org/licenses/gpl-2.0.html.
+#
+# Copyright (C) IBM Corporation, 2012
+# Copyright (C) Akira Yokosawa, 2016
+#
+# Authors: Paul E. McKenney <paulmck@us.ibm.com>
+# Akira Yokosawa <akiyks@gmail.com>
+
+if test -z "$1"
+then
+ echo No latex file specified, aborting.
+ exit 1
+fi
+
+basename=`echo $1 | sed -e 's/\.tex$//'`
+
+echo "pdflatex 1"
+pdflatex $basename > /dev/null 2>&1 < /dev/null || :
+if grep -q '! Emergency stop.' $basename.log
+then
+ echo "----- Fatal latex error, see $basename.log for details. -----"
+ exit 1
+fi
+grep 'Latex Warning:' $basename.log > $basename-warning.log
+touch $basename-first.log
+exit 0
diff --git a/utilities/runlatex.sh b/utilities/runlatex.sh
index 8d2d77a8..61acf528 100644
--- a/utilities/runlatex.sh
+++ b/utilities/runlatex.sh
@@ -1,9 +1,12 @@
#!/bin/sh
#
-# Run latex on the specified file and bibliography directory.
+# Run pdflatex on the specified file.
# Attempt to avoid useless repeats.
+# This version is heavily customized to be used for perfbook.
+# It is assumed to be used together with runfirstlatex.sh
+# and Makefile of perfbook.
#
-# Usage: runlatex.sh file.tex [ bibdir ]
+# Usage: sh runlatex.sh file[.tex]
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,47 +23,91 @@
# http://www.gnu.org/licenses/gpl-2.0.html.
#
# Copyright (C) IBM Corporation, 2012
+# Copyright (C) Akira Yokosawa, 2016
#
# Authors: Paul E. McKenney <paulmck@us.ibm.com>
+# Akira Yokosawa <akiyks@gmail.com>
if test -z "$1"
then
- echo No latex file, aborting.
+ echo No latex file specified, aborting.
exit 1
fi
basename=`echo $1 | sed -e 's/\.tex$//'`
iter=1
-echo "pdflatex $iter"
-pdflatex $basename > /dev/null 2>&1 < /dev/null || :
-if grep -q '! Emergency stop.' $basename.log
+if ! test -r $basename-first.log
then
- echo "----- Fatal latex error, see $basename.log for details. -----"
-fi
-if grep -q 'LaTeX Warning: There were undefined references' $basename.log
-then
- if test -d "$2"
+ echo "pdflatex 1"
+ pdflatex $basename > /dev/null 2>&1 < /dev/null || :
+ if grep -q '! Emergency stop.' $basename.log
then
- bibtex $basename || :
- else
- echo "No bibliography directory, skipping bibtex."
+ echo "----- Fatal latex error, see $basename.log for details. -----"
+ exit 1
fi
+ grep 'LaTex Warning:' $basename.log > $basename-warning.log
fi
-while grep -q 'LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.' $basename.log
+rm -f $basename-first.log
+while grep -q 'LaTeX Warning: There were undefined references' $basename.log
do
+ if test -r $basename-warning-prev.log
+ then
+ if test "$iter" -gt 2 && diff -q $basename-warning.log $basename-warning-prev.log >/dev/null
+ then
+ echo "No more improvement is expected, giving up."
+ break
+ else
+ echo "Some improvements are observed, continuing."
+ fi
+ fi
iter=`expr $iter + 1`
- echo "pdflatex $iter"
+ echo "pdflatex $iter # remaining undefined refs"
pdflatex $basename > /dev/null 2>&1 < /dev/null || :
if grep -q '! Emergency stop.' $basename.log
then
echo "----- Fatal latex error, see $basename.log for details. -----"
+ exit 1
+ fi
+ if test -r $basename-warning.log
+ then
+ mv -f $basename-warning.log $basename-warning-prev.log
+ fi
+ grep 'LaTex Warning:' $basename.log > $basename-warning.log
+done
+while grep -q 'LaTeX Warning: Label(s) may have changed' $basename.log
+do
+ if test -r $basename-warning-prev.log;
+ then
+ if test "$iter" -gt 3 && diff -q $basename-warning.log $basename-warning-prev.log >/dev/null
+ then
+ echo "No more improvement is expected, giving up."
+ break
+ else
+ echo "Some improvements are observed, continuing."
+ fi
fi
- if test "$iter" -eq 4
+ iter=`expr $iter + 1`
+ echo "pdflatex $iter # label(s) may have been changed"
+ pdflatex $basename > /dev/null 2>&1 < /dev/null || :
+ if grep -q '! Emergency stop.' $basename.log
then
- echo "Iteration limit: $iter passes through pdflatex"
+ echo "----- Fatal latex error, see $basename.log for details. -----"
exit 1
fi
+ if test -r $basename-warning.log
+ then
+ mv -f $basename-warning.log $basename-warning-prev.log
+ fi
+ grep 'LaTex Warning:' $basename.log > $basename-warning.log
done
-grep "LaTeX Warning:" $basename.log
+if grep "LaTeX Warning:" $basename.log
+then
+ echo "----- You can see $basename-warning.log for the warnings above. -----"
+ echo "----- If you need to, see $basename.log for details. -----"
+ rm -f $basename-warning-prev.log
+ exit 1
+fi
+rm -f $basename-warning.log $basename-warning-prev.log
+echo "No 'LaTeX Warning' found. '$basename.pdf' is ready."
exit 0