tests: fix typo in returns: statement
[gtk-doc.git] / gtkdoc-mkpdf.in
blob93bc68c8f89effb326a6337b901702429bc455ab
1 #!/bin/sh
4 usage="\
5 Usage: gtkdoc-mkpdf [--path=SEARCH_PATH] MODULE DRIVER_FILE [BACKEND_OPTIONS...]"
7 #echo "args $0\n";
9 # parse options, ignore unknown options for future extensions
11 searchpath=
12 uninstalled=no
13 while true; do
14 case "X$1" in
15 X--version) echo "@VERSION@"; exit 0;;
16 X--help) echo "$usage"; exit 0;;
17 X--uninstalled) uninstalled=yes; shift;;
18 X--path=*) searchpath=`echo $1 | sed s/.*=//`; shift;;
19 X--*) shift;;
20 X*) break;;
21 esac
22 done
24 if test $# -lt 2; then
25 echo "${usage}" 1>&2
26 exit 1
29 module=$1
30 shift
31 document=$1
32 shift
34 if test $uninstalled = yes; then
35 # this does not work from buiddir!=srcdir
36 # we could try this
37 # MAKE_SCRDIR=$(abs_srcdir) MAKE_BUILDDIR=$(abs_builddir) gtkdoc-mkpdf ...
38 gtkdocdir=`dirname $0`
39 #echo "uninstalled, gtkdocdir=$gtkdocdir"
40 else
41 # the first two are needed to resolve datadir
42 prefix=@prefix@
43 datarootdir=@datarootdir@
44 gtkdocdir=@datadir@/gtk-doc/data
47 if head -n 1 $document | grep "<?xml" > /dev/null; then
48 is_xml=true
49 path_option='--path'
50 else
51 is_xml=false
52 path_option='--directory'
55 # we could do "$path_option $PWD "
56 # to avoid needing rewriting entities that are copied from the header
57 # into docs under xml
58 if test "X$searchpath" = "X"; then
59 path_arg=
60 else
61 path_arg="$path_option $searchpath"
64 if $is_xml; then
65 @XSLTPROC@ $path_arg --nonet --xinclude \
66 --stringparam gtkdoc.bookname $module \
67 --stringparam gtkdoc.version "@VERSION@" \
68 "$@" -o $module.fo $gtkdocdir/gtk-doc-fo.xsl $document || exit $?
69 # fop dies too easily :(
70 # @FOP@ $module.fo $module.pdf
71 #rm $module.fo
72 else
73 # not very good output
74 # also for xxx-docs.sgml it will produce xxx-docs.pdf
75 docbook2pdf -e no-valid $document
78 echo "timestamp" > pdf.stamp