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