[project @ 2001-10-25 14:50:00 by rrt]
[ghc-hetmet.git] / glafp-utils / docbook / db2pdf.dir / db2pdf.sh
1 if [ ! -f "$DOCBOOK_CATALOG" ] ; then
2   echo "CATALOG file not set up; see installation guide for details."
3   exit 1
4 fi
5
6 # Dave Mason's option to specify a different stylesheet
7 case $1 in
8     -d) DB_STYLESHEET=$2
9         shift 2
10         ;;
11 esac
12
13 echo "Using stylesheet: \"${DB_STYLESHEET}\""
14
15 if [ $# -gt 2 ]
16 then
17   echo "Usage: `basename $0` [filename.sgml]" >&2
18   exit 1
19 fi
20
21 if [ $# -eq 1 ]
22 then
23   if [ ! -r $1 ]
24   then
25     echo Cannot read \"$1\".  Exiting. >&2
26     exit 1
27   fi
28   if echo $1 | egrep -i '\.sgml$|\.sgm$' >/dev/null 2>&1
29   then
30     output="`echo $1 | sed 's,\.sgml$,,;s,\.sgm$,,'`"
31   fi
32 fi
33
34 $JADE -t tex -d ${DB_STYLESHEET}\#print -o ${output}.tex -c $DOCBOOK_CATALOG $1
35
36 pdfjadetex ${output}
37
38 # See if running pdfjadetex twice cures the problem.
39 if egrep '^LaTeX Warning: There were undefined references.$' ${TMPFN}.log >/dev/null 2>&1
40 then
41   pdfjadetex ${output}
42   pdfjadetex ${output}
43 fi
44
45 # clean out 
46 rm -f ${output}.log
47 rm -f ${output}.aux
48 rm -f ${output}.tex
49
50 exit 0