Updated Spanish translation
[gtk-doc.git] / gtkdocize.in
blob06b67a57f857144db1606d90ff327c52861da22f
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 copy=no
15 makefile=gtk-doc.make
16 flavour=legacy
18 # mini help
19 usage="\
20 usage: $progname [ --copy ] [ --docdir DIR ] [ --flavour {legacy|legacy-flat|no-tmpl|no-tmpl-flat} ] [ --srcdir DIR ]"
22 # Find the srcdir early (and ignore a srcdir set in configure).
23 # https://bugzilla.gnome.org/show_bug.cgi?id=707426
24 args="$*"
25 while test $# -gt 0; do
26 case "$1" in
27 --srcdir)
28 shift
29 srcdir="$1"
30 shift ;;
31 --srcdir=*)
32 srcdir=`expr "X$1" : '[^=]*=\(.*\)'`
33 shift ;;
35 shift ;;
36 esac
37 done
38 set - $args
40 # assume working directory if srcdir is not set
41 test "$srcdir" || srcdir=.
42 test "$docdir" || docdir="$srcdir"
44 # detect configure script
45 no_configure_found=0
46 if test -f "$srcdir"/configure.ac; then
47 configure="$srcdir"/configure.ac
48 elif test -f "$srcdir"/configure.in; then
49 configure="$srcdir"/configure.in
50 else
51 no_configure_found=1
54 # check configure script for GTK_DOC_CHECK macro
55 no_gtk_doc_check_found=0
56 if test $no_configure_found -eq 0; then
57 macro=`grep '^GTK_DOC_CHECK' $configure 2>/dev/null`
58 if test $? -eq 0; then
59 # GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
60 params=`echo $macro | sed -e 's/^GTK_DOC_CHECK(\ *\(.*\))/\1/'`
61 if echo $params | grep -q '^.*\,\ *\[\{0,1\}'; then
62 extra_options=`echo $params | sed -e 's/^.*\,\ *\[\{0,1\}\([^]]*\)\]\{0,1\}\ *$/\1/'`
63 #echo >&2 "DEBUG: adding extra options [$extra_options] to [$*]"
64 set - $* $GTKDOCIZE_FLAGS $extra_options
65 else
66 set - $* $GTKDOCIZE_FLAGS
68 else
69 no_gtk_doc_check_found=1;
73 while test $# -gt 0; do
74 #echo >&2 "DEBUG: parsing args [$1]";
75 case "$1" in
76 --help)
77 echo "$usage"
78 exit 0 ;;
79 --version)
80 echo "$PROGRAM ($PACKAGE) $VERSION"
81 exit 0 ;;
82 --copy)
83 copy=yes
84 shift ;;
85 --docdir)
86 shift
87 docdir="$1"
88 shift ;;
89 --docdir=*)
90 docdir=`expr "X$1" : '[^=]*=\(.*\)'`
91 shift ;;
92 --flavour)
93 shift
94 flavour="$1"
95 shift ;;
96 --flavour=*)
97 flavour=`expr "X$1" : '[^=]*=\(.*\)'`
98 shift ;;
99 --srcdir)
100 shift
101 # srcdir was set earlier.
102 shift ;;
103 --srcdir=*)
104 # srcdir was set earlier.
105 shift ;;
107 echo "$progname: unrecognised option '$1'" 1>&2
108 echo "$usage" 1>&2
109 exit 1 ;;
111 echo "$progname: too many arguments" 1>&2
112 echo "$usage" 1>&2
113 exit 1 ;;
114 esac
115 done
117 case "$flavour" in
118 legacy*)
120 legacy-flat*)
121 makefile=gtk-doc.flat.make
123 no-tmpl*)
124 makefile=gtk-doc.notmpl.make
126 no-tmpl-flat*)
127 makefile=gtk-doc.notmpl-flat.make
130 echo "$progname: invalid value for --flavour" 1>&2
131 echo "$usage" 1>&2
132 exit 1 ;;
133 esac
135 if test $no_configure_found -eq 1; then
136 echo "$progname: neither configure.ac nor configure.in exist" 1>&2
137 exit 1
139 if test $no_gtk_doc_check_found -eq 1; then
140 echo "$progname: GTK_DOC_CHECK not called in $configure" 1>&2
141 exit 1
144 # If the AC_CONFIG_MACRO_DIR() macro is used, copy gtk-doc.m4 from our
145 # prefix to that directory. This makes sure that the M4 macro used
146 # matches the the automake fragment.
147 # If AC_CONFIG_MACRO_DIR is not used, the macro won't be copied, and
148 # the correct flags must be passed to aclocal for it to find the macro.
149 m4dir="$srcdir/`cat "$configure" | grep '^AC_CONFIG_MACRO_DIR' | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`"
150 if test -n "$m4dir"; then
151 rm -f $m4dir/gtk-doc.m4
152 if test "$copy" = yes; then
153 cp -f $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
154 exit 1
155 else
156 ln -sf $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
157 cp -f $datadir/aclocal/gtk-doc.m4 $m4dir/ ||
158 exit 1
162 rm -f $docdir/gtk-doc.make
163 if test "$copy" = yes; then
164 cp -f $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
165 exit 1
166 else
167 ln -sf $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
168 cp -f $datadir/gtk-doc/data/$makefile $docdir/gtk-doc.make ||
169 exit 1