| 1 | #!/bin/sh |
| 2 | |
| 3 | # + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |
| 4 | # | Copyright(C) 1997-2005 by F. Bosisio | |
| 5 | # | | |
| 6 | # | This program can be redistributed and/or modified under | |
| 7 | # | the terms of the LaTeX Project Public License, distributed | |
| 8 | # | from CTAN archives in directory macros/latex/base/lppl.txt; | |
| 9 | # | either version 1 of the License, or any later version. | |
| 10 | # | | |
| 11 | # | E-mail: [email protected] | |
| 12 | # | CTAN location: macros/latex/contrib/bosisio/ | |
| 13 | # + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + |
| 14 | |
| 15 | # |
| 16 | # If there isn't a command-line parameter, ask for a filename |
| 17 | # |
| 18 | if test $1 |
| 19 | then |
| 20 | FILE=$1 |
| 21 | else |
| 22 | printf '\tInsert the filename you want to process with makedoc\n' |
| 23 | read FILE |
| 24 | fi |
| 25 | # |
| 26 | # Strip the ".dtx" extension (if present) and check that the file exists |
| 27 | # |
| 28 | FILE=`basename ${FILE} .dtx` |
| 29 | test -f ${FILE}.dtx || exit 1 |
| 30 | # |
| 31 | # Run LaTeX on the ".dtx" file to generate the ".sty" and ".drv" files |
| 32 | # |
| 33 | printf '\n\t\tRunning LaTeX on %s.dtx ...\n\n' "${FILE}" |
| 34 | latex ${FILE}.dtx || exit 2 |
| 35 | # |
| 36 | # Run LaTeX once to generate the ".aux", ".idx" and ".glo" files |
| 37 | # |
| 38 | printf '\n\t\tRunning LaTeX on %s.drv ...\n\n' "${FILE}" |
| 39 | latex ${FILE}.drv || exit 3 |
| 40 | # |
| 41 | # Run BibTeX to generate the bibliography file (".bbl") |
| 42 | # |
| 43 | if grep -q bibdata ${FILE}.aux |
| 44 | then |
| 45 | printf '\n\t\tRunning BibTeX on %s.aux ...\n\n' "${FILE}" |
| 46 | bibtex ${FILE} || exit 4 |
| 47 | rm ${FILE}.blg |
| 48 | fi |
| 49 | # |
| 50 | # Run MakeIndex on the index file |
| 51 | # |
| 52 | if test ${FILE}.idx |
| 53 | then |
| 54 | printf '\n\t\tRunning MakeIndex on %s.idx ...\n\n' "${FILE}" |
| 55 | makeindex -s gind.ist -o ${FILE}.ind ${FILE}.idx || exit 5 |
| 56 | rm ${FILE}.ilg |
| 57 | fi |
| 58 | # |
| 59 | # Run MakeIndex on the glossary file |
| 60 | # |
| 61 | if test ${FILE}.glo |
| 62 | then |
| 63 | printf '\n\t\tRunning MakeIndex on %s.glo ...\n\n' "${FILE}" |
| 64 | makeindex -s gglo.ist -o ${FILE}.gls ${FILE}.glo || exit 6 |
| 65 | rm ${FILE}.ilg |
| 66 | fi |
| 67 | # |
| 68 | # Rerun LaTeX to read the ".bbl", ".ind" and ".gls" files |
| 69 | # |
| 70 | printf '\n\t\tRe-running LaTeX on %s.drv ...\n\n' "${FILE}" |
| 71 | latex ${FILE}.drv |
| 72 | # |
| 73 | # Rerun LaTeX again to get the cross-references right |
| 74 | # |
| 75 | if grep -q 'Rerun to get cross-references right' ${FILE}.log |
| 76 | then |
| 77 | printf '\n\t\tRe-running LaTeX again on %s.drv ...\n\n' "${FILE}" |
| 78 | latex ${FILE}.drv |
| 79 | fi |
| 80 | # |
| 81 | # Remove temporary files |
| 82 | # |
| 83 | rm -f ${FILE}.drv ${FILE}.log ${FILE}.aux ${FILE}.ind ${FILE}.glo \ |
| 84 | ${FILE}.bbl ${FILE}.idx ${FILE}.gls |
| 85 | # |
| 86 | # Show the generated output |
| 87 | # |
| 88 | xdvi ${FILE}.dvi |
| 89 | # |
| 90 | # Run DviPdf to produce the PDF file |
| 91 | # |
| 92 | printf '\n\t\tRunning DviPdf ...\n\n' |
| 93 | dvipdf ${FILE}.dvi |
| 94 | # |
| 95 | # Remove DVI file |
| 96 | # |
| 97 | rm ${FILE}.dvi |