Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 1 | #! /depot/gnu/plat/bin/bash |
| 2 | |
| 3 | MYDIR=`dirname $0` |
| 4 | |
| 5 | # DEFAULT_FORMAT must be upper case... |
| 6 | DEFAULT_FORMAT=PDF |
| 7 | USE_DEFAULT_FORMAT=true |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 8 | DISCARD_TEMPS=true |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 9 | |
| 10 | # This is needed to support kpathsea based TeX installations. Others are |
| 11 | # not supported. ;-) |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 12 | TEXINPUTS=`dirname $MYDIR`/texinputs:$TEXINPUTS |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 13 | export TEXINPUTS |
| 14 | |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 15 | LOGFILE=/usr/tmp/mkhowto-$LOGNAME-$$.how |
| 16 | LOGGING='' |
| 17 | |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 18 | usage() { |
| 19 | echo "usage: $0 [options...] file ..." |
| 20 | exit 2 |
| 21 | } |
| 22 | |
| 23 | build_html() { |
| 24 | # This doesn't work; l2hinit.perl uses the current directory, not it's own |
| 25 | # location. Need a workaround for this. |
| 26 | if [ "$ADDRESS" ] ; then |
| 27 | latex2html -init_file $MYDIR/../perl/l2hinit.perl -address "$ADDRESS" \ |
| 28 | $1 || exit $? |
| 29 | else |
| 30 | latex2html -init_file $MYDIR/../perl/l2hinit.perl $1 || exit $? |
| 31 | fi |
| 32 | (cd $FILE; $MYDIR/node2label.pl *.html) || exit $? |
| 33 | } |
| 34 | |
| 35 | build_dvi() { |
| 36 | latex $1 || exit $? |
| 37 | if [ -f $1.idx ] ; then |
| 38 | `dirname $0`/fix_hack $1.idx || exit $? |
| 39 | makeindex $1.idx || exit $? |
| 40 | fi |
| 41 | latex $1 || exit $? |
| 42 | } |
| 43 | |
| 44 | build_ps() { |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 45 | # note weird sequence of redirects is used to get stderr to the old stdout |
| 46 | # and the new stdout goes to a file |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 47 | dvips -N0 -f $1 >$1.ps || exit $? |
| 48 | } |
| 49 | |
| 50 | build_pdf() { |
| 51 | # We really have to do it three times to get all the page numbers right, |
| 52 | # since the length of the ToC makes a real difference. |
| 53 | pdflatex $1 || exit $? |
| 54 | pdflatex $1 || exit $? |
| 55 | `dirname $0`/toc2bkm.py -c section $FILE || exit $? |
| 56 | if [ -f $1.idx ] ; then |
| 57 | `dirname $0`/fix_hack $1.idx || exit $? |
| 58 | makeindex $1.idx || exit $? |
| 59 | fi |
| 60 | pdflatex $1 || exit $? |
| 61 | } |
| 62 | |
| 63 | # figure out what our targets are: |
| 64 | while [ "$1" ] ; do |
| 65 | case "$1" in |
| 66 | --pdf|--pd) |
| 67 | BUILD_PDF=true |
| 68 | USE_DEFAULT_FORMAT=false |
| 69 | shift 1 |
| 70 | ;; |
| 71 | --ps) |
| 72 | BUILD_PS=true |
| 73 | USE_DEFAULT_FORMAT=false |
| 74 | shift 1 |
| 75 | ;; |
| 76 | --dvi|--dv|--d) |
| 77 | BUILD_DVI=true |
| 78 | USE_DEFAULT_FORMAT=false |
| 79 | shift 1 |
| 80 | ;; |
| 81 | --html|--htm|--ht|--h) |
| 82 | BUILD_HTML=true |
| 83 | USE_DEFAULT_FORMAT=false |
| 84 | shift 1 |
| 85 | ;; |
| 86 | -a|--address|--addres|--addre|-addr|--add|--ad|--a) |
| 87 | ADDRESS="$2" |
| 88 | shift 2 |
| 89 | ;; |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 90 | -l|--logging|--loggin|--loggi|--logg|--log|--lo|--l) |
| 91 | LOGGING=true |
| 92 | shift 1 |
| 93 | ;; |
| 94 | -D|--debugging|--debuggin|--debuggi|--debugg|--debug|--debu|--deb|--de) |
| 95 | DEBUGGING=true |
| 96 | shift 1 |
| 97 | ;; |
| 98 | -k|--keep|--kee|--ke|--k) |
| 99 | DISCARD_TEMPS='' |
| 100 | shift 1 |
| 101 | ;; |
Fred Drake | 664b36f | 1998-03-11 15:41:21 +0000 | [diff] [blame^] | 102 | -q|--quiet|__quie|--qui|--qu|--q) |
| 103 | QUIET=true |
| 104 | shift 1 |
| 105 | ;; |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 106 | -*) |
| 107 | usage |
| 108 | ;; |
| 109 | *) |
| 110 | break;; |
| 111 | esac |
| 112 | done |
| 113 | |
| 114 | if [ $# = 0 ] ; then |
| 115 | usage |
| 116 | fi |
| 117 | |
| 118 | if [ $USE_DEFAULT_FORMAT = true ] ; then |
| 119 | eval "BUILD_$DEFAULT_FORMAT=true" |
| 120 | fi |
| 121 | |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 122 | if [ "$DEBUGGING" ] ; then |
| 123 | set -x |
| 124 | fi |
| 125 | |
Fred Drake | 664b36f | 1998-03-11 15:41:21 +0000 | [diff] [blame^] | 126 | if [ "$QUIET" ] ; then |
| 127 | exec >/dev/null |
| 128 | fi |
| 129 | |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 130 | for FILE in $@ ; do |
| 131 | FILE=${FILE%.tex} |
| 132 | if [ "$BUILD_DVI" -o "$BUILD_PS" ] ; then |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 133 | build_dvi $FILE 2>&1 | tee -a $LOGFILE |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 134 | fi |
| 135 | if [ "$BUILD_PDF" ] ; then |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 136 | build_pdf $FILE 2>&1 | tee -a $LOGFILE |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 137 | fi |
| 138 | if [ "$BUILD_PS" ] ; then |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 139 | build_ps $FILE 2>&1 | tee -a $LOGFILE |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 140 | fi |
| 141 | if [ "$BUILD_HTML" ] ; then |
| 142 | if [ ! "$BUILD_DVI" -o ! "$BUILD_PDF" ] ; then |
| 143 | # need to get aux file |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 144 | build_dvi $FILE 2>&1 | tee -a $LOGFILE |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 145 | fi |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 146 | build_html $FILE 2>&1 | tee -a $LOGFILE |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 147 | fi |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 148 | if [ "$DISCARD_TEMPS" ] ; then |
| 149 | rm -f $FILE.aux $FILE.log $FILE.out $FILE.toc $FILE.bkm 2>&1 \ |
| 150 | | tee -a $LOGFILE |
| 151 | if [ ! "$BUILD_DVI" ] ; then |
| 152 | rm -f $FILE.dvi 2>&1 | tee -a $LOGFILE |
| 153 | fi |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 154 | fi |
Fred Drake | dbc879e | 1998-03-11 15:33:44 +0000 | [diff] [blame] | 155 | # the the logfile around |
| 156 | if [ "$LOGGING" ] ; then |
| 157 | cp $LOGFILE $FILE.how |
| 158 | fi |
| 159 | rm -f $LOGFILE |
Fred Drake | e2e904f | 1998-03-10 23:23:05 +0000 | [diff] [blame] | 160 | done |