3 # This script may be invoked by naming it directly or via a shell alias,
4 # but NOT through a symbolic link. Perhaps a future version will allow
5 # the use of a symbolic link.
7 # Using a symbolic link will cause the script to not be able to locate
18 # DEFAULT_FORMAT must be upper case...
20 USE_DEFAULT_FORMAT
=true
25 TEMPBASE
=mkhowto-
$LOGNAME-$$
27 L2H_INIT_FILE
=$TOPDIR/perl
/l2hinit.perl
28 L2H_AUX_INIT_FILE
=/usr
/tmp
/$TEMPBASE.perl
30 LOGFILE
=/usr
/tmp
/$TEMPBASE.how
36 usage: $MYNAME [options...] file ...
38 Options specifying formats to build:
39 --html HyperText Markup Language
40 --pdf Portable Document Format (default)
42 --dvi "DeVice Indepentent" format from TeX
43 --text ASCII text (requires lynx)
45 More than one output format may be specified, or --all.
48 --address, -a Specify an address for page footers.
49 --link Specify the number of levels to include on each page.
50 --split, -s Specify a section level for page splitting, default: $MAX_SPLIT_DEPTH.
51 --iconserver, -i Specify location of icons (default: ../).
54 --a4 Format for A4 paper.
55 --letter Format for US letter paper (the default).
56 --help, -H Show this text.
57 --logging, -l Log stdout and stderr to a file (*.how).
58 --debugging, -D Echo commands as they are executed.
59 --keep, -k Keep temporary files around.
60 --quiet, -q Do not print command output to stdout.
61 (stderr is also lost, sorry; see *.how for errors)
71 # These are LaTeX2HTML controls; they reflect l2h variables of the same name.
72 # The values here are the defaults after modification by perl/l2hinit.perl.
79 TEXFILE
=`kpsewhich $1.tex`
80 TEXFILE
="${TEXFILE#./}"
83 -init_file $L2H_INIT_FILE \
84 -init_file $L2H_AUX_INIT_FILE \
85 -dir $BUILDDIR $TEXFILE ||
exit $?
86 if [ "$MAX_SPLIT_DEPTH" -ne 1 ] ; then
87 (cd $BUILDDIR; $MYDIR/node2label.pl
*.html
) ||
exit $?
92 # two args: <file> <latextype>
96 # We really have to do it three times to get all the page numbers right,
97 # since the length of the ToC makes a real difference.
99 $MYDIR/newind.py
>$MYFILE.ind
100 $MYDIR/newind.py modindex
>mod
$MYFILE.ind
101 $MYLATEX $MYFILE ||
exit $?
102 if [ -f mod
$MYFILE.idx
] ; then
103 makeindex mod
$MYFILE.idx
105 if [ -f $MYFILE.idx
] ; then
106 $MYDIR/fix_hack
$MYFILE.idx
107 makeindex
$MYFILE.idx
108 $MYDIR/indfix.py
$MYFILE.ind
110 if [ `grep -c '^\\\\bibdata{' $MYFILE.aux` -ne 0 ] ; then
116 if [ -f $MYFILE.syn
] ; then
117 # This hack is due to a bug with the module synopsis support that
118 # causes the last module synopsis to be written out twice in
119 # howto documents (not present for manuals). Repeated below.
120 uniq $MYFILE.syn
>TEMP.syn
&& mv TEMP.syn
$MYFILE.syn ||
exit $?
122 $MYLATEX $MYFILE ||
exit $?
123 if [ -f mod
$MYFILE.idx
] ; then
124 makeindex mod
$MYFILE.idx
126 if [ -f $MYFILE.idx
] ; then
127 $MYDIR/fix_hack
$MYFILE.idx ||
exit $?
128 makeindex
-s $TOPDIR/texinputs
/python.ist
$MYFILE.idx ||
exit $?
130 if [ -f $MYFILE.toc
-a $MYLATEX = pdflatex
] ; then
131 $MYDIR/toc2bkm.py
-c section
$MYFILE
133 if [ -f $MYFILE.syn
] ; then
134 uniq $MYFILE.syn
>TEMP.syn
&& mv TEMP.syn
$MYFILE.syn ||
exit $?
136 if [ "$USE_BIBTEX" ] ; then
139 $MYLATEX $MYFILE ||
exit $?
147 use_latex
$1 pdflatex
151 dvips
-N0 -o $1.ps
$1 ||
exit $?
155 lynx
-nolist -dump $2/index.html
>$1.txt
160 echo "\$$1 = \"$2\";" >>$L2H_AUX_INIT_FILE
165 rm -f $1.aux
$1.log
$1.out
$1.toc
$1.bkm
$1.idx
$1.ilg
$1.ind
$1.syn
166 rm -f mod
$1.idx mod
$1.ilg mod
$1.ind
167 if [ ! "$BUILD_DVI" ] ; then
171 rm -f $1/IMG
* $1/*.pl
$1/WARNINGS
$1/index.dat
$1/modindex.dat
177 # When using a long option with a parameter separated by '=',
178 # generalize the parsing of the two:
181 STUFF
=`echo "$1" | grep '^--[-a-zA-Z0-9]*='`
182 if [ "$STUFF" ] ; then
183 # This leaves OPTION=--option= and VALUE=value
184 OPTION
=`echo "$STUFF" | sed 's/^\(--[-a-zA-Z0-9]*=\)\(.*\)$/\1/'`
185 VALUE
=`echo "$STUFF" | sed 's/^\(--[-a-zA-Z0-9]*=\)\(.*\)$/\2/'`
189 # figure out what our targets are:
199 USE_DEFAULT_FORMAT
=false
204 USE_DEFAULT_FORMAT
=false
207 --ps|
--postscript|
--postscrip|
--postscri|
--postscr|
--postsc|
--posts|
--post|
--pos|
--po)
209 USE_DEFAULT_FORMAT
=false
214 USE_DEFAULT_FORMAT
=false
219 USE_DEFAULT_FORMAT
=false
222 --text|
--tex|
--te|
--t)
224 USE_DEFAULT_FORMAT
=false
227 -H|
--help|
--hel|
--he)
230 -i|
--iconserver|
--iconserve|
--iconserv|
--iconser|
--iconse|
--icons|
--icon|
--ico|
--ic|
--i)
234 --iconserver=*|
--iconserve=*|
--iconserv=*|
--iconser=*|
--iconse=*|
--icons=*|
--icon=*|
--ico=*|
--ic=*|
--i=*)
238 -a|
--address|
--addres|
--addre|
-addr|
--add|
--ad)
242 --address=*|
--addres=*|
--addre=*|
-addr=*|
--add=*|
--ad=*)
247 TEXINPUTS
=$TOPDIR/paper-a4
:$TEXINPUTS
250 --letter|
--lette|
--lett|
--let|
--le)
257 --link=*|
--lin=*|
--li=*)
261 -s|
--split|
--spli|
--spl|
--sp|
--s)
265 --split=|
--spli=|
--spl=|
--sp=|
--s=)
266 MAX_SPLIT_DEPTH
="$VALUE"
269 -l|
--logging|
--loggin|
--loggi|
--logg|
--log|
--lo)
273 -D|
--debugging|
--debuggin|
--debuggi|
--debugg|
--debug|
--debu|
--deb|
--de)
277 -k|
--keep|
--kee|
--ke|
--k)
281 -q|
--quiet|
--quie|
--qui|
--qu|
--q)
290 usage
2 "Unknown option: ${VALUE%=}"
298 # check for a single .tex file in .
299 COUNT
=`ls -1 *.tex | wc -l | sed 's/[ ]//g'`
300 if [ "$COUNT" -eq 1 ] ; then
302 elif [ "$COUNT" -gt 1 ] ; then
303 usage
2 "Could not deduce which file(s) to process as HOWTO documents."
305 usage
2 "No file to process."
309 if [ $USE_DEFAULT_FORMAT = true
] ; then
310 eval "BUILD_$DEFAULT_FORMAT=true"
313 if [ "$QUIET" ] ; then
317 if [ "$DEBUGGING" ] ; then
321 echo '# auxillary init file for latex2html' >$L2H_AUX_INIT_FILE
322 echo '# generated by mkhowto.sh -- do not edit' >>$L2H_AUX_INIT_FILE
323 if [ "$ICONSERVER" ] ; then
324 ICONSERVER
="${ICONSERVER%/}"
326 l2hoption ICONSERVER
"$ICONSERVER"
327 l2hoption ADDRESS
"$ADDRESS"
328 l2hoption MAX_LINK_DEPTH
"$MAX_LINK_DEPTH"
329 l2hoption MAX_SPLIT_DEPTH
"$MAX_SPLIT_DEPTH"
330 echo '1;' >>$L2H_AUX_INIT_FILE
333 FILEDIR
=`dirname $FILE`
334 FILE
=`basename $FILE .tex`
336 # Put the directory the .tex file is in is also the first directory in
337 # TEXINPUTS, to allow files there to override files in the common area.
339 TEXINPUTS
=$FILEDIR:$TOPDIR/texinputs
:$TEXINPUTS
342 if [ "$BUILD_DVI" -o "$BUILD_PS" ] ; then
343 build_dvi
$FILE 2>&1 |
tee -a $LOGFILE
346 if [ "$BUILD_PDF" ] ; then
347 build_pdf
$FILE 2>&1 |
tee -a $LOGFILE
350 if [ "$BUILD_PS" ] ; then
351 build_ps
$FILE 2>&1 |
tee -a $LOGFILE
353 if [ "$BUILD_HTML" ] ; then
354 if [ ! "$HAVE_TEMPS" ] ; then
355 # need to get aux file
356 build_dvi
$FILE 2>&1 |
tee -a $LOGFILE
359 build_html
$FILE $FILE 2>&1 |
tee -a $LOGFILE
360 if [ "$ICONSERVER" = "." ] ; then
361 cp $TOPDIR/icons
/*.gif
$FILE/
364 if [ "$BUILD_TEXT" ] ; then
365 if [ ! "$HAVE_TEMPS" ] ; then
366 # need to get aux file
367 build_dvi
$FILE 2>&1 |
tee -a $LOGFILE
370 # this is why building text really has to be last:
371 if [ "$MAX_SPLIT_DEPTH" -ne 1 ] ; then
372 echo '# re-hack this file for --text:' >>$L2H_AUX_INIT_FILE
373 l2hoption MAX_SPLIT_DEPTH
1
374 echo '1;' >>$L2H_AUX_INIT_FILE
375 TEMPDIR
=$FILE.temp-html
376 build_html
$FILE $TEMPDIR 2>&1 |
tee -a $LOGFILE
380 build_text
$FILE $TEMPDIR 2>&1 |
tee -a $LOGFILE
383 if [ "$DISCARD_TEMPS" ] ; then
384 cleanup
$FILE 2>&1 |
tee -a $LOGFILE
386 # keep the logfile around
387 if [ "$LOGGING" ] ; then
388 cp $LOGFILE $FILE.how
393 if [ ! "$DEBUGGING" ] ; then
394 rm -f $L2H_AUX_INIT_FILE