| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | #! /depot/gnu/plat/bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | MYDIR=`dirname $0` | 
					
						
							| 
									
										
										
										
											1998-03-24 17:48:20 +00:00
										 |  |  | WORKDIR=`pwd` | 
					
						
							|  |  |  | cd $MYDIR | 
					
						
							|  |  |  | MYDIR=`pwd` | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | cd .. | 
					
						
							|  |  |  | TOPDIR=`pwd` | 
					
						
							| 
									
										
										
										
											1998-03-24 17:48:20 +00:00
										 |  |  | cd $WORKDIR | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | # DEFAULT_FORMAT must be upper case... | 
					
						
							|  |  |  | DEFAULT_FORMAT=PDF | 
					
						
							|  |  |  | USE_DEFAULT_FORMAT=true | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | DISCARD_TEMPS=true | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-17 20:06:16 +00:00
										 |  |  | HTML_SPLIT_LEVEL=0 | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | L2H_INIT_FILE=$TOPDIR/perl/l2hinit.perl | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | # This is needed to support kpathsea based TeX installations.  Others are | 
					
						
							|  |  |  | # not supported.  ;-) | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | TEXINPUTS=`dirname $MYDIR`/texinputs:$TEXINPUTS | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | export TEXINPUTS | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | LOGFILE=/usr/tmp/mkhowto-$LOGNAME-$$.how | 
					
						
							|  |  |  | LOGGING='' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | usage() { | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  |     MYNAME=`basename $0` | 
					
						
							|  |  |  |     echo "usage: $MYNAME [options...] file ..." | 
					
						
							|  |  |  |     cat <<EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Options specifying formats to build: | 
					
						
							|  |  |  |     --html		HyperText Markup Language | 
					
						
							|  |  |  |     --pdf		Portable Document Format (default) | 
					
						
							|  |  |  |     --ps		PostScript | 
					
						
							|  |  |  |     --dvi		"DeVice Indepentent" format from TeX | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     More than one output format may be specified. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HTML options: | 
					
						
							|  |  |  |     --address, -a	Specify an address for page footers. | 
					
						
							|  |  |  |     --split, -s		Specify a section level for page splitting. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Other options: | 
					
						
							|  |  |  |     --help, -H		Show this text. | 
					
						
							|  |  |  |     --logging, -l	Log stdout and stderr to a file (*.how). | 
					
						
							|  |  |  |     --debugging, -D	Echo commands as they are executed. | 
					
						
							|  |  |  |     --keep, -k		Keep temporary files around. | 
					
						
							|  |  |  |     --quiet, -q		Do not print command output to stdout. | 
					
						
							|  |  |  | 			(stderr is also lost,  sorry; see *.how for errors) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     exit $1 | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build_html() { | 
					
						
							| 
									
										
										
										
											1998-04-17 20:06:16 +00:00
										 |  |  |     if [ "$HTML_SPLIT_LEVEL" -gt 0 ] ; then | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	if [ "$ADDRESS" ] ; then | 
					
						
							|  |  |  | 	    latex2html -init_file $L2H_INIT_FILE \
 | 
					
						
							|  |  |  | 	     -address "$ADDRESS" \
 | 
					
						
							|  |  |  | 	     -split $HTML_SPLIT_LEVEL \
 | 
					
						
							|  |  |  | 	     $1 || exit $? | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	    latex2html -init_file $L2H_INIT_FILE \
 | 
					
						
							|  |  |  | 	     -split $HTML_SPLIT_LEVEL \
 | 
					
						
							|  |  |  | 	     $1 || exit $? | 
					
						
							|  |  |  | 	fi | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	if [ "$ADDRESS" ] ; then | 
					
						
							|  |  |  | 	    latex2html -init_file $L2H_INIT_FILE \
 | 
					
						
							|  |  |  | 	     -address "$ADDRESS" \
 | 
					
						
							|  |  |  | 	     $1 || exit $? | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	    latex2html -init_file $L2H_INIT_FILE \
 | 
					
						
							|  |  |  | 	     $1 || exit $? | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											1998-04-17 20:06:16 +00:00
										 |  |  |     if [ "$HTML_SPLIT_LEVEL" -ne 1 ] ; then | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	(cd $FILE; $MYDIR/node2label.pl *.html) || exit $? | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  | use_latex() { | 
					
						
							|  |  |  |     # two args:  <file> <latextype> | 
					
						
							|  |  |  |     MYFILE=$1 | 
					
						
							|  |  |  |     MYLATEX=$2 | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # We really have to do it three times to get all the page numbers right, | 
					
						
							|  |  |  |     # since the length of the ToC makes a real difference. | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     $MYDIR/newind.py >$MYFILE.ind | 
					
						
							|  |  |  |     $MYDIR/newind.py modindex >mod$MYFILE.ind | 
					
						
							|  |  |  |     $MYLATEX $MYFILE || exit $? | 
					
						
							|  |  |  |     if [ -f mod$MYFILE.idx ] ; then | 
					
						
							|  |  |  | 	makeindex mod$MYFILE.idx | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     if [ -f $MYFILE.idx ] ; then | 
					
						
							|  |  |  | 	$MYDIR/fix_hack $MYFILE.idx | 
					
						
							|  |  |  | 	makeindex $MYFILE.idx | 
					
						
							|  |  |  | 	$MYDIR/indfix.py $MYFILE.ind | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     $MYLATEX $MYFILE || exit $? | 
					
						
							|  |  |  |     if [ -f mod$MYFILE.idx ] ; then | 
					
						
							|  |  |  | 	makeindex mod$MYFILE.idx | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  |     if [ -f $MYFILE.idx ] ; then | 
					
						
							|  |  |  | 	$MYDIR/fix_hack $MYFILE.idx || exit $? | 
					
						
							|  |  |  | 	makeindex -s $TOPDIR/texinputs/myindex.ist $MYFILE.idx || exit $? | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     if [ -f $MYFILE.toc ] ; then | 
					
						
							|  |  |  | 	$MYDIR/toc2bkm.py -c section $MYFILE | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     $MYLATEX $MYFILE || exit $? | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  | build_dvi() { | 
					
						
							|  |  |  |     use_latex $1 latex | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build_pdf() { | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  |     use_latex $1 pdflatex | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build_ps() { | 
					
						
							| 
									
										
										
										
											1998-04-17 20:06:16 +00:00
										 |  |  |     dvips -N0 -o $1.ps $1 || exit $? | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cleanup() { | 
					
						
							| 
									
										
										
										
											1998-04-17 20:25:55 +00:00
										 |  |  |     rm -f $1.aux $1.log $1.out $1.toc $1.bkm $1.idx $1.ind mod$1.ind | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  |     if [ ! "$BUILD_DVI" ] ; then | 
					
						
							|  |  |  | 	rm -f $FILE.dvi | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # figure out what our targets are: | 
					
						
							|  |  |  | while [ "$1" ] ; do | 
					
						
							|  |  |  |     case "$1" in | 
					
						
							|  |  |  | 	--pdf|--pd) | 
					
						
							|  |  |  | 	    BUILD_PDF=true | 
					
						
							|  |  |  | 	    USE_DEFAULT_FORMAT=false | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							|  |  |  | 	--ps) | 
					
						
							|  |  |  | 	    BUILD_PS=true | 
					
						
							|  |  |  | 	    USE_DEFAULT_FORMAT=false | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							|  |  |  | 	--dvi|--dv|--d) | 
					
						
							|  |  |  | 	    BUILD_DVI=true | 
					
						
							|  |  |  | 	    USE_DEFAULT_FORMAT=false | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	--html|--htm|--ht) | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | 	    BUILD_HTML=true | 
					
						
							|  |  |  | 	    USE_DEFAULT_FORMAT=false | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	-H|--help|--hel|--he) | 
					
						
							|  |  |  | 	    usage 0 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | 	-a|--address|--addres|--addre|-addr|--add|--ad|--a) | 
					
						
							|  |  |  | 	    ADDRESS="$2" | 
					
						
							|  |  |  | 	    shift 2 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	-s|--split|--spli|--spl|--sp|--s) | 
					
						
							|  |  |  | 	    HTML_SPLIT_LEVEL="$2" | 
					
						
							|  |  |  | 	    shift 2 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | 	-l|--logging|--loggin|--loggi|--logg|--log|--lo|--l) | 
					
						
							|  |  |  | 	    LOGGING=true | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							|  |  |  | 	-D|--debugging|--debuggin|--debuggi|--debugg|--debug|--debu|--deb|--de) | 
					
						
							|  |  |  | 	    DEBUGGING=true | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							|  |  |  | 	-k|--keep|--kee|--ke|--k) | 
					
						
							|  |  |  | 	    DISCARD_TEMPS='' | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	-q|--quiet|--quie|--qui|--qu|--q) | 
					
						
							| 
									
										
										
										
											1998-03-11 15:41:21 +00:00
										 |  |  | 	    QUIET=true | 
					
						
							|  |  |  | 	    shift 1 | 
					
						
							|  |  |  | 	    ;; | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | 	-*) | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  | 	    usage 2 | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | 	    ;; | 
					
						
							|  |  |  | 	*) | 
					
						
							|  |  |  | 	    break;; | 
					
						
							|  |  |  |     esac | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ $# = 0 ] ; then | 
					
						
							| 
									
										
										
										
											1998-04-02 15:37:13 +00:00
										 |  |  |     usage 2 | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ $USE_DEFAULT_FORMAT = true ] ; then | 
					
						
							|  |  |  |     eval "BUILD_$DEFAULT_FORMAT=true" | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | if [ "$DEBUGGING" ] ; then | 
					
						
							|  |  |  |     set -x | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-11 15:41:21 +00:00
										 |  |  | if [ "$QUIET" ] ; then | 
					
						
							|  |  |  |     exec >/dev/null | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | for FILE in $@ ; do | 
					
						
							|  |  |  |     FILE=${FILE%.tex} | 
					
						
							|  |  |  |     if [ "$BUILD_DVI" -o "$BUILD_PS" ] ; then | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | 	build_dvi $FILE 2>&1 | tee -a $LOGFILE | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  |     if [ "$BUILD_PDF" ] ; then | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | 	build_pdf $FILE 2>&1 | tee -a $LOGFILE | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  |     if [ "$BUILD_PS" ] ; then | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | 	build_ps $FILE 2>&1 | tee -a $LOGFILE | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							|  |  |  |     if [ "$BUILD_HTML" ] ; then | 
					
						
							|  |  |  | 	if [ ! "$BUILD_DVI" -o ! "$BUILD_PDF" ] ; then | 
					
						
							|  |  |  | 	    # need to get aux file | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  | 	    build_dvi $FILE 2>&1 | tee -a $LOGFILE | 
					
						
							|  |  |  | 	fi | 
					
						
							|  |  |  | 	build_html $FILE 2>&1 | tee -a $LOGFILE | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     if [ "$DISCARD_TEMPS" ] ; then | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  | 	cleanup $FILE 2>&1 | tee -a $LOGFILE | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											1998-04-17 02:52:12 +00:00
										 |  |  |     # keep the logfile around | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  |     if [ "$LOGGING" ] ; then | 
					
						
							|  |  |  | 	cp $LOGFILE $FILE.how | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											1998-03-11 15:33:44 +00:00
										 |  |  |     rm -f $LOGFILE | 
					
						
							| 
									
										
										
										
											1998-03-10 23:23:05 +00:00
										 |  |  | done |