[project @ 2002-02-13 19:43:46 by sof]
[ghc-hetmet.git] / glafp-utils / docbook / db2pdf.dir / db2pdf.sh
index 2d0b4cc..a5478aa 100644 (file)
@@ -1,4 +1,11 @@
-TMPFN=`echo $1 | sed 's/\.sgml//'`
+if [ ! -f "$DOCBOOK_CATALOG" ] && [ ! -f "$SGML_CATALOG_FILES" ] ; then
+  echo "CATALOG file not set up; see installation guide for details."
+  exit 1
+fi
+
+if [ -f "$DOCBOOK_CATALOG" ] ; then
+  CATALOG_OPTION=-c $DOCBOOK_CATALOG
+fi
 
 # Dave Mason's option to specify a different stylesheet
 case $1 in
@@ -24,18 +31,27 @@ then
   fi
   if echo $1 | egrep -i '\.sgml$|\.sgm$' >/dev/null 2>&1
   then
-    output="`echo $1 | sed 's,\.sgml$,.pdf,;s,\.sgm$,.pdf,'`"
+    output="`echo $1 | sed 's,\.sgml$,,;s,\.sgm$,,'`"
   fi
 fi
 
-$JADE -t tex -d ${DB_STYLESHEET}\#print -o ${TMPFN}.tex $1
+$JADE -t tex -d ${DB_STYLESHEET}\#print -o ${output}.tex $CATALOG_OPTION $1
 
-pdf$JADEtex $TMPFN
+jadetex ${output}
 
+# See if running jadetex twice cures the problem.
 if egrep '^LaTeX Warning: There were undefined references.$' ${TMPFN}.log >/dev/null 2>&1
 then
-  pdfjadetex $TMPFN
-  pdfjadetex $TMPFN
+  jadetex ${output}
+  jadetex ${output}
 fi
 
+dvips ${output}.dvi ${output}.ps
+ps2pdf ${output}.ps ${output}.pdf
+
+# clean out 
+rm -f ${output}.log
+rm -f ${output}.aux
+rm -f ${output}.tex
+
 exit 0