tests: add an empty project where we even regenerate the tester-docs.xml
[gtk-doc.git] / gtkdocize.in
blobf425467e54e6a18d228a8517930f741610f8b61a
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 extra_options=`echo $macro | sed -e 's/^GTK_DOC_CHECK(\ *\(.*\))/\1/' | sed -e 's/^.*\,\ *\[\{0,1\}\([^]]*\)\]\{0,1\}\ *$/\1/'`
40 if test $? -eq 0; then
41 #echo >&2 "DEBUG: adding extra options [$extra_options] to [$*]"
42 set - $* $GTKDOCIZE_FLAGS $extra_options
43 else
44 set - $* $GTKDOCIZE_FLAGS
46 else
47 no_gtk_doc_check_found=1;
51 while test $# -gt 0; do
52 #echo >&2 "DEBUG: parsing args [$1]";
53 case "$1" in
54 --help)
55 echo "$usage"
56 exit 0 ;;
57 --version)
58 echo "$PROGRAM ($PACKAGE) $VERSION"
59 exit 0 ;;
60 --copy)
61 copy=yes
62 shift ;;
63 --docdir)
64 shift
65 docdir="$1"
66 shift ;;
67 --docdir=*)
68 docdir=`expr "X$1" : '[^=]*=\(.*\)'`
69 shift ;;
70 --flavour)
71 shift
72 flavour="$1"
73 shift ;;
74 --flavour=*)
75 flavour=`expr "X$1" : '[^=]*=\(.*\)'`
76 shift ;;
77 -*)
78 echo "$progname: unrecognised option '$1'" 1>&2
79 echo "$usage" 1>&2
80 exit 1 ;;
82 echo "$progname: too many arguments" 1>&2
83 echo "$usage" 1>&2
84 exit 1 ;;
85 esac
86 done
88 case "$flavour" in
89 legacy)
91 no-tmpl)
92 makefile=gtk-doc.notmpl.make
95 echo "$progname: invalid value for --flavour" 1>&2
96 echo "$usage" 1>&2
97 exit 1 ;;
98 esac
100 if test $no_configure_found -eq 1; then
101 echo "$progname: neither configure.ac nor configure.in exist" 1>&2
102 exit 1
104 if test $no_gtk_doc_check_found -eq 1; then
105 echo "$progname: GTK_DOC_CHECK not called in $configure" 1>&2
106 exit 1
109 # If the AC_CONFIG_MACRO_DIR() macro is used, copy gtk-doc.m4 from our
110 # prefix to that directory. This makes sure that the M4 macro used
111 # matches the the automake fragment.
112 # If AC_CONFIG_MACRO_DIR is not used, the macro won't be copied, and
113 # the correct flags must be passed to aclocal for it to find the macro.
114 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`
115 if test -n "$m4dir"; then
116 rm -f $m4dir/gtk-doc.m4
117 if test "$copy" = yes; then
118 cp -f $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
119 exit 1
120 else
121 ln -sf $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
122 cp -f $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
123 exit 1
127 rm -f $docdir/gtk-doc.make
128 if test "$copy" = yes; then
129 cp -f $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
130 exit 1
131 else
132 ln -sf $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
133 cp -f $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
134 exit 1