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