mkdb: ignore empty image sections
[gtk-doc.git] / gtkdocize.in
blob36837bcbcf5aae12271d184de3036db2556ed73d
1 #!/bin/sh
3 progname=`echo "$0" | sed 's%^.*/%%'`
5 PROGRAM=gtkdocize
6 PACKAGE=@PACKAGE@
7 VERSION=@VERSION@
9 prefix=@prefix@
10 datarootdir=@datarootdir@
11 datadir=@datadir@
13 # options
14 docdir=.
15 copy=no
16 makefile=gtk-doc.make
17 flavour=legacy
19 # mini help
20 usage="\
21 usage: $progname [ --copy ] [ --docdir DIR ] [ --flavour {legacy|no-tmpl} ]"
23 # detect configure script
24 no_configure_found=0
25 if test -f configure.ac; then
26 configure=configure.ac
27 elif test -f configure.in; then
28 configure=configure.in
29 else
30 no_configure_found=1
33 # check configure script for GTK_DOC_CHECK macro
34 no_gtk_doc_check_found=0
35 if test $no_configure_found -eq 0; then
36 macro=`grep '^GTK_DOC_CHECK' $configure 2>/dev/null`
37 if test $? -eq 0; then
38 # GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
39 params=`echo $macro | sed -e 's/^GTK_DOC_CHECK(\ *\(.*\))/\1/'`
40 if echo $params | grep -q '^.*\,\ *\[\{0,1\}'; then
41 extra_options=`echo $params | sed -e 's/^.*\,\ *\[\{0,1\}\([^]]*\)\]\{0,1\}\ *$/\1/'`
42 #echo >&2 "DEBUG: adding extra options [$extra_options] to [$*]"
43 set - $* $GTKDOCIZE_FLAGS $extra_options
44 else
45 set - $* $GTKDOCIZE_FLAGS
47 else
48 no_gtk_doc_check_found=1;
52 while test $# -gt 0; do
53 #echo >&2 "DEBUG: parsing args [$1]";
54 case "$1" in
55 --help)
56 echo "$usage"
57 exit 0 ;;
58 --version)
59 echo "$PROGRAM ($PACKAGE) $VERSION"
60 exit 0 ;;
61 --copy)
62 copy=yes
63 shift ;;
64 --docdir)
65 shift
66 docdir="$1"
67 shift ;;
68 --docdir=*)
69 docdir=`expr "X$1" : '[^=]*=\(.*\)'`
70 shift ;;
71 --flavour)
72 shift
73 flavour="$1"
74 shift ;;
75 --flavour=*)
76 flavour=`expr "X$1" : '[^=]*=\(.*\)'`
77 shift ;;
78 -*)
79 echo "$progname: unrecognised option '$1'" 1>&2
80 echo "$usage" 1>&2
81 exit 1 ;;
83 echo "$progname: too many arguments" 1>&2
84 echo "$usage" 1>&2
85 exit 1 ;;
86 esac
87 done
89 case "$flavour" in
90 legacy)
92 no-tmpl)
93 makefile=gtk-doc.notmpl.make
96 echo "$progname: invalid value for --flavour" 1>&2
97 echo "$usage" 1>&2
98 exit 1 ;;
99 esac
101 if test $no_configure_found -eq 1; then
102 echo "$progname: neither configure.ac nor configure.in exist" 1>&2
103 exit 1
105 if test $no_gtk_doc_check_found -eq 1; then
106 echo "$progname: GTK_DOC_CHECK not called in $configure" 1>&2
107 exit 1
110 # If the AC_CONFIG_MACRO_DIR() macro is used, copy gtk-doc.m4 from our
111 # prefix to that directory. This makes sure that the M4 macro used
112 # matches the the automake fragment.
113 # If AC_CONFIG_MACRO_DIR is not used, the macro won't be copied, and
114 # the correct flags must be passed to aclocal for it to find the macro.
115 m4dir=`cat "$configure" | grep '^AC_CONFIG_MACRO_DIR' | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
116 if test -n "$m4dir"; then
117 rm -f $m4dir/gtk-doc.m4
118 if test "$copy" = yes; then
119 cp -f $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
120 exit 1
121 else
122 ln -sf $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
123 cp -f $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
124 exit 1
128 rm -f $docdir/gtk-doc.make
129 if test "$copy" = yes; then
130 cp -f $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
131 exit 1
132 else
133 ln -sf $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
134 cp -f $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
135 exit 1