TIVI-153: add as dependency for iputils
[profile/ivi/docbook-utils.git] / backends / ps
1 # Backend to convert something into PostScript
2 # Send any comments to Eric Bischoff <eric@caldera.de>
3 # This program is under GPL license. See LICENSE file for details.
4
5 TEXINPUTS="$(dirname "${SGML_FILE}"):${TEXINPUTS}"
6 export TEXINPUTS
7
8 # Convert to TeX
9 $SGML_JADE -t tex -o ${SGML_FILE_NAME}.tex $SGML_ARGUMENTS
10 if [ $? -ne 0 ]
11 then exit 1
12 fi
13
14 # Convert from TeX to DVI
15 jadetex ${SGML_FILE_NAME}.tex >${SGML_FILE_NAME}.tmp
16 if [ $? -ne 0 ]
17 then
18   cat ${SGML_FILE_NAME}.tmp
19   rm ${SGML_FILE_NAME}.tmp
20   rm ${SGML_FILE_NAME}.tex
21   exit 2
22 fi
23 rm ${SGML_FILE_NAME}.tmp
24
25 # If there are unresolved references, re-run jadetex, twice 
26 if egrep '^LaTeX Warning: There were undefined references.$' ${SGML_FILE_NAME}.log >/dev/null 2>&1
27 then
28     jadetex ${SGML_FILE_NAME}.tex >/dev/null
29     jadetex ${SGML_FILE_NAME}.tex >/dev/null
30 fi
31 rm -f ${SGML_FILE_NAME}.log ${SGML_FILE_NAME}.aux \
32         ${SGML_FILE_NAME}.tex ${SGML_FILE_NAME}.out
33
34 # Convert from DVI to PostScript
35 PAPERSIZE="-t letter"
36 if echo x$SGML_ARGUMENTS | grep -- '-V paper-type=A4'
37 then
38   PAPERSIZE="-t a4"
39 fi
40
41 dvips -R -q $PAPERSIZE ${SGML_FILE_NAME}.dvi -o ${SGML_FILE_NAME}.ps
42 if [ $? -ne 0 ]
43 then
44   rm ${SGML_FILE_NAME}.dvi
45   exit 3
46 fi
47 rm ${SGML_FILE_NAME}.dvi
48
49 exit 0