Updated Spanish translation
[gtk-doc.git] / gtkdoc-mkpdf.in
blobb4ade2a6ae889155eb3ba0e045ed4bebee50b13b
1 #!/bin/sh
4 usage() {
5 cat <<EOF
6 gtkdoc-mkpdf version @VERSION@ - generate documentation in pdf format
8 --verbose Print extra output while processing
9 --path=SEARCH_PATH Extra source directories
10 --imgdir=DIR Extra image directories
11 MODULE Name of the doc module being parsed
12 DRIVER_FILE File containing the toplevel DocBook file.
13 --version Print the version of this program
14 --help Print this help
15 EOF
18 #echo "args $0\n";
20 cleanexit() {
21 rm -f $module.fo
22 exit $1
25 # parse options, ignore unknown options for future extensions
27 verbose="0"
28 searchpath=
29 uninstalled=no
30 imgdirs=
31 while true; do
32 case "X$1" in
33 X--version) echo "@VERSION@"; exit 0;;
34 X--help) usage; exit 0;;
35 X--uninstalled) uninstalled=yes; shift;;
36 X--verbose) verbose="1"; shift;;
37 X--path=*) searchpath=`echo $1 | sed s/.*=//`; shift;;
38 X--imgdir=*) imgdirs="$imgdirs -I `echo $1 | sed s/.*=//`"; shift;;
39 X--*) shift;;
40 X*) break;;
41 esac
42 done
44 if test $# -lt 2; then
45 usage 1>&2
46 exit 1
49 module=$1
50 shift
51 document=$1
52 shift
54 quiet="1"
55 if test $verbose = "1"; then
56 quiet="0"
59 if test $uninstalled = yes; then
60 # this does not work from buiddir!=srcdir
61 # we could try this
62 # MAKE_SCRDIR=$(abs_srcdir) MAKE_BUILDDIR=$(abs_builddir) gtkdoc-mkpdf ...
63 gtkdocdir=`dirname $0`
64 #echo "uninstalled, gtkdocdir=$gtkdocdir"
65 else
66 # the first two are needed to resolve datadir
67 prefix=@prefix@
68 datarootdir=@datarootdir@
69 gtkdocdir=@datadir@/gtk-doc/data
72 if head -n 1 $document | grep "<?xml" > /dev/null; then
73 is_xml=true
74 path_option='--path'
75 else
76 is_xml=false
77 path_option='--directory'
80 # we could do "$path_option $PWD "
81 # to avoid needing rewriting entities that are copied from the header
82 # into docs under xml
83 if test "X$searchpath" = "X"; then
84 path_arg=
85 else
86 path_arg="$path_option $searchpath"
89 if $is_xml; then
90 if test -n "@DBLATEX@"; then
91 # extra options to consider
92 # -I FIG_PATH
93 # -V is useful for debugging
94 # -T db2latex : different style
95 # -d : keep transient files (for debugging)
96 # -P abc.def=$quiet : once the stylesheets have a quiet mode
97 # xsltproc is already called with --xinclude
98 # does not work: --xslt-opts "$path_arg --nonet $@"
99 dblatex_options="-o $module.pdf $imgdirs $document"
100 #echo "calling: @DBLATEX@ $dblatex_options"
101 if test $verbose = "0"; then
102 @DBLATEX@ 2>&1 --help | grep >/dev/null "\-\-quiet"
103 if test "$?" = "0"; then
104 dblatex_options="--quiet $dblatex_options";
106 @DBLATEX@ 2>&1 >/dev/null $dblatex_options | grep -v 'programlisting or screen'
107 else
108 { @DBLATEX@ 2>&1 >&3 $dblatex_options | grep -v 'programlisting or screen' >&2; } 3>&1
110 else
111 if test -n "@FOP@"; then
112 @XSLTPROC@ $path_arg --nonet --xinclude \
113 --stringparam gtkdoc.bookname $module \
114 --stringparam gtkdoc.version "@VERSION@" \
115 --stringparam chunk.quietly $quiet \
116 --stringparam chunker.output.quiet $quiet \
117 "$@" -o $module.fo $gtkdocdir/gtk-doc-fo.xsl $document || cleanexit $?
118 # fop dies too easily :(
119 # @FOP@ $module.fo $module.pdf
120 else
121 echo "dblatex or fop must be installed to use gtkdoc-mkpdf." >&2
122 cleanexit 1
125 else
126 # not very good output
127 # also for xxx-docs.sgml it will produce xxx-docs.pdf
128 docbook2pdf -e no-valid $document
131 echo "timestamp" > pdf.stamp
132 cleanexit 0