summaryrefslogtreecommitdiff
path: root/web/pwebmac/makeall
diff options
context:
space:
mode:
Diffstat (limited to 'web/pwebmac/makeall')
-rwxr-xr-xweb/pwebmac/makeall176
1 files changed, 79 insertions, 97 deletions
diff --git a/web/pwebmac/makeall b/web/pwebmac/makeall
index 602f2377c5..b5b53ff72e 100755
--- a/web/pwebmac/makeall
+++ b/web/pwebmac/makeall
@@ -86,60 +86,48 @@ do
esac
done
-CWEAVE="cweave -f +lX"
-CTWILL="ctwill -f +lpdf"
+CWEAVE="cweave -f +lX +bph"
+CTWILL="ctwill -f +lpdf +bph"
+HITEX="hitex --compress"
PAX="pax -wvzf"
-SED_I="sed -i" # non-GNU-sed requires an extra '' argument for '-i' option.
PDF=pdf # default extension for 'knuth-pdf'
-HITEX="hitex --compress"
+SED_I="sed -i" # non-GNU-sed requires an extra '' argument for '-i' option.
+WEAVE="weave"
-# HINT format
-if [ hitex = "$TEX" ]
-then
- CTWILL="$CTWILL +P"
- TEX="$HITEX"
- PDF=hnt # default extension for 'knuth-hint'
- PDFTOCFRONT=false # use 'hintview -h' to start with TOC page
- VALID=false # HiTeX has no command-line option '--shell-escape'
-fi
+case "$TEX" in
+ hitex ) # HINT format
+ CTWILL="$CTWILL +P"
+ TEX="$HITEX"
+ PDF=hnt # default extension for 'knuth-hint'
+ PDFTOCFRONT=false # use 'hintview -h' to start with TOC page
+ VALID=false ;; # HiTeX has no command-line option '--shell-escape'
+
+ pdftex | luatex ) # actually only necessary for 'pwebmac.tex'
+ VALID=true ;;
+
+ * ) VALID=false ;; # plain TeX and XeTeX use different approach
+esac
# Valid PDF output from 'pdftex' and 'luatex': In 'pwebmac.tex' set '\countD'
# to the actual number of @<named modules@>, not the number of all sections.
-if ( $VALID )
+if $VALID
then
+ NEW=true # PDF output requires 'pwebmac.tex'
TEX="$TEX --shell-escape"
fi
+# Use alternative TeX macros more suited for PDF output.
+if $NEW
+then WEAVE="$WEAVE -p"
+fi
+
# WEB and CWEB programs we want to get formatted
for f in $FILES
do
f=$(basename $f .web)
- if [ ctwill = $f ]
- then
- # apply tons of editorial changes to 'ctwill.w'
- if [ "$HITEX" = "$TEX" ]
- then ctie -m $f.w cweave.w $f-w2c.ch $f-hint.ch
- else ctie -m $f.w cweave.w $f-w2c.ch $f-mini.ch
- fi
- cp -an $KNUTHWARE/cwebdir/*.bux .
- $CTWILL $f # prime the pump
- $CTWILL $f # get decent answers
-
- elif [ twill = $f ]
- then
- tie -m $f.web weave.web weave.ch weav-$f.ch
- weave $f
-
- elif [ glue = $f ]
- then
- weave $f # no 'glue.ch' at this time
-
- elif [ hitex = $f ]
- then
- cweave $f # no 'hitex.ch' at this time
-
- elif $CHANGES
+ if $CHANGES && echo $f | grep -v -q -E 'twill|glue|hitex'
+ # These are changes in and of themselves
then
case $f in
# CWEB programs have individual changefiles
@@ -153,49 +141,48 @@ do
# main WEB programs have complex change files
tex | mf | pdftex | xetex )
WEBINPUTS=$KNUTHWARE/../../Work//:$WEBINPUTS: \
- weave $f $f-final ;;
-
- # TWILL is a change in and of itself
- twill ) ;;
+ $WEAVE $f $f-final
- # HiTeX is a stand-alone version of TeX
- hitex ) ;;
+ # FIX: XeTeX uses '\pdfTeX' from section 114,
+ # which is not changed and thus 'disappears';
+ # repeat in preamble.
+ if [ xetex = $f ]
+ then $SED_I -e "s/\(\\\\let\\\\maybe\)/\\\\def\\\\pdfTeX{pdf\\\\TeX}\n\1/" $f.tex
+ fi ;;
# all other WEB codes have singular changefiles
- * ) weave $f $f ;;
+ * ) $WEAVE $f $f ;;
esac
- # FIX: XeTeX uses '\pdfTeX' from section 114, which is not
- # changed and thus 'disappears'; repeat in preamble.
- if [ xetex = $f ]
- then
- $SED_I -e "s/\(\\\\let\\\\maybe\)/\\\\def\\\\pdfTeX{pdf\\\\TeX}\n\1/" \
- $f.tex
- fi
-
# only document changed modules/sections
$SED_I -e "s/\(\\\\let\\\\maybe=\)\\\\iftrue/\1\\\\iffalse/" \
$f.tex
else
case $f in
+ ctwill )
+ # apply tons of editorial changes to 'ctwill.w'
+ if [ "$HITEX" = "$TEX" ]
+ then ctie -m $f.w cweave.w $f-w2c.ch $f-hint.ch
+ else ctie -m $f.w cweave.w $f-w2c.ch $f-mini.ch
+ fi
+ $CTWILL $f # prime the pump
+ $CTWILL $f ;; # get decent answers
+
c* | refsort | twinx | tie | hitex ) $CWEAVE $f ;;
- * ) weave $f ;;
+
+ twill )
+ tie -m $f.web weave.web weave.ch weav-$f.ch
+ $WEAVE $f ;;
+
+ * ) $WEAVE $f ;;
esac
fi
- if $NEW
+ # 'pwebmac' is for WEB only; do nothing for CWEB programs
+ if $NEW && echo $f | grep -v -q -E '^c|refsort|twinx|tie|hitex'
then
- # use extended WEB macros for TeX Live PDF documentation
- $SED_I -e "1 s/\\\\input webmac/\\\\input pwebmac/" $f.tex
-
# timestamp on table-of-contents page or the first page
case $f in
- # do nothing for CWEB programs
- c* | refsort | twinx | tie ) ;;
-
- hitex )
- $SED_I -e "s/\(\\\\def\\\\topofcontents\)/\\\\datethis\n\\\\emergencystretch=.1\\\\hsize\n\1/" $f.tex ;;
-
bibtex | patgen | tangle | weave )
$SED_I -e "s/\(\\\\def\\\\title\)/\\\\datecontentspage\n\1/" $f.tex ;;
@@ -247,8 +234,7 @@ FI
# FIX: don't wait for Oren Patashnik.
bibtex ) $SED_I -e "s/\\\\def\\\\titlepage{F}/\\\\titletrue/" $f.tex
if ! $CHANGES
- then
- $SED_I -e "71,78d" $f.tex
+ then $SED_I -e "71,78d" $f.tex
fi ;;
# FIX: 'glue.web' obviously uses an old 'webmac.tex'.
@@ -259,29 +245,27 @@ FI
# appear correctly in the bookmarks, too.
pdftex )
if $NEW && [ tex != "$TEX" ] && [ "$HITEX" != "$TEX" ]
- then
- $SED_I -e "s/\(\\\\def\\\\pdfTeX{pdf\\\\TeX}\)/\1 \\\\sanitizecommand\\\\pdfTeX{pdfTeX}\\\\sanitizecommand\\\\eTeX{e-TeX}/" \
- $f.tex
+ then $SED_I -e "s/\(\\\\def\\\\pdfTeX{pdf\\\\TeX}\)/\1 \\\\sanitizecommand\\\\pdfTeX{pdfTeX}\\\\sanitizecommand\\\\eTeX{e-TeX}/" $f.tex
fi ;;
# FIX: weave uses '\max' in name of module 173; this should
# appear correctly in the bookmarks, too.
weave )
if $NEW && [ tex != "$TEX" ] && [ "$HITEX" != "$TEX" ]
- then
- $SED_I -e "s/\(\\\\def\\\\({}\)/\\\\sanitizecommand\\\\max{max}\n\1/" \
- $f.tex
+ then $SED_I -e "s/\(\\\\def\\\\({}\)/\\\\sanitizecommand\\\\max{max}\n\1/" $f.tex
fi ;;
# FIX: purge obsolete macros from XeTeX.
xetex ) $SED_I -e "/\\\\input xewebmac/d" $f.tex ;;
+
+ # timestamp on table-of-contents page or the first page
+ hitex ) $SED_I -e "s/\(\\\\def\\\\topofcontents\)/\\\\datethis\n\\\\emergencystretch=.1\\\\hsize\n\1/" $f.tex ;;
esac
# shift table-of-contents pages to the front in PDF
- if $PDFTOCFRONT && [ ctwill != $f ] && [ hitex != $f ]
+ if $PDFTOCFRONT && echo $f | grep -v -q -E 'ctwill|hitex'
then
- $SED_I -e "0,/\\\\N[1{]/s/\(\\\\N[1{]\)/\\\\input pdfwebtocfront\n\n\1/" \
- $f.tex
+ $SED_I -e "0,/\\\\N[1{]/s/\(\\\\N[1{]\)/\\\\input pdfwebtocfront\n\n\1/" $f.tex
# only XeTeX can process XETEX.WEB
if [ xetex = $f ]
@@ -295,24 +279,24 @@ FI
fi
fi
- if [ xetex = $f ] # only XeTeX can process XETEX.WEB
- then $f $f
- elif [ ctwill = $f ] # gives two different outcomes
- then
- # sort mini-indexes
- if [ "$HITEX" = "$TEX" ]
- then # directly in the TeX file
- proofsort $f.tex > $f-sorted.tex
- mv $f-sorted.tex $f.tex
- else # in the TeX-created .ref file
- $TEX $f
- ctwill-refsort < $f.ref > $f.sref
- fi
- $TEX $f
- elif [ refsort = $f ]
- then $TEX -interaction nonstopmode $f
- else $TEX $f
- fi
+ case $f in
+ xetex ) $f $f ;; # only XeTeX can process XETEX.WEB
+
+ ctwill ) # gives two different outcomes
+ if [ "$HITEX" = "$TEX" ] # sort mini-indexes
+ then # directly in the TeX file
+ ctwill-proofsort < $f.tex > $f-sorted.tex
+ mv $f-sorted.tex $f.tex
+ else # in the TeX-created .ref file
+ $TEX $f
+ ctwill-refsort < $f.ref > $f.sref
+ fi
+ $TEX $f ;;
+
+ refsort ) $TEX -interaction nonstopmode $f ;;
+
+ * ) $TEX $f ;;
+ esac
done
if ( $PDFTOCFRONT || [ "$HITEX" = "$TEX" ] ) && ! $FILESELECT
@@ -385,9 +369,7 @@ then
f=$(kpsewhich -engine tex cwebman)
tie -m $(basename $f) $f $(basename $f .tex)-w2c.ch
if [ "$HITEX" = "$TEX" ]
- then
- $SED_I -e "s/\(\\\\input cwebmac\)/\1\n\\\\input hiplainpage/" \
- cwebman.tex
+ then $SED_I -e "s/\(\\\\input cwebmac\)/\1\n\\\\input hiplainpage/" cwebman.tex
fi
touch pages.tex # let 'manmac' produce output at all