Update Enums and Flags with new API
[pygobject.git] / autogen.sh
bloba04bdbff716640deeee8ee48eed2946652fb410b
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
4 srcdir=`dirname $0`
5 test -z "$srcdir" && srcdir=.
6 srcdir=`cd $srcdir && pwd`
8 REQUIRED_AUTOMAKE_VERSION=1.8
10 PKG_NAME="PyGObject"
11 ACLOCAL_FLAGS="-I $srcdir/m4 $ACLOCAL_FLAGS"
13 #name of package
14 PKG_NAME=${PKG_NAME:-Package}
15 srcdir=${srcdir:-.}
17 # default version requirements ...
18 REQUIRED_AUTOCONF_VERSION=${REQUIRED_AUTOCONF_VERSION:-2.53}
19 REQUIRED_AUTOMAKE_VERSION=${REQUIRED_AUTOMAKE_VERSION:-1.4}
20 REQUIRED_LIBTOOL_VERSION=${REQUIRED_LIBTOOL_VERSION:-1.4.3}
21 REQUIRED_GETTEXT_VERSION=${REQUIRED_GETTEXT_VERSION:-0.10.40}
22 REQUIRED_GLIB_GETTEXT_VERSION=${REQUIRED_GLIB_GETTEXT_VERSION:-2.2.0}
23 REQUIRED_INTLTOOL_VERSION=${REQUIRED_INTLTOOL_VERSION:-0.25}
24 REQUIRED_PKG_CONFIG_VERSION=${REQUIRED_PKG_CONFIG_VERSION:-0.14.0}
25 REQUIRED_GTK_DOC_VERSION=${REQUIRED_GTK_DOC_VERSION:-1.0}
26 REQUIRED_DOC_COMMON_VERSION=${REQUIRED_DOC_COMMON_VERSION:-2.3.0}
27 REQUIRED_GNOME_DOC_UTILS_VERSION=${REQUIRED_GNOME_DOC_UTILS_VERSION:-0.3.2}
29 # a list of required m4 macros. Package can set an initial value
30 REQUIRED_M4MACROS=${REQUIRED_M4MACROS:-}
31 FORBIDDEN_M4MACROS=${FORBIDDEN_M4MACROS:-}
33 # Not all echo versions allow -n, so we check what is possible. This test is
34 # based on the one in autoconf.
35 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
36 *c*,-n*) ECHO_N= ;;
37 *c*,* ) ECHO_N=-n ;;
38 *) ECHO_N= ;;
39 esac
41 # some terminal codes ...
42 boldface="`tput bold 2>/dev/null`"
43 normal="`tput sgr0 2>/dev/null`"
44 printbold() {
45 echo $ECHO_N "$boldface"
46 echo "$@"
47 echo $ECHO_N "$normal"
49 printerr() {
50 echo "$@" >&2
53 # Usage:
54 # compare_versions MIN_VERSION ACTUAL_VERSION
55 # returns true if ACTUAL_VERSION >= MIN_VERSION
56 compare_versions() {
57 ch_min_version=$1
58 ch_actual_version=$2
59 ch_status=0
60 IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="."
61 set $ch_actual_version
62 for ch_min in $ch_min_version; do
63 ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
64 if [ -z "$ch_min" ]; then break; fi
65 if [ -z "$ch_cur" ]; then ch_status=1; break; fi
66 if [ $ch_cur -gt $ch_min ]; then break; fi
67 if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
68 done
69 IFS="$ch_save_IFS"
70 return $ch_status
73 # Usage:
74 # version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
75 # checks to see if the package is available
76 version_check() {
77 vc_package=$1
78 vc_variable=$2
79 vc_checkprogs=$3
80 vc_min_version=$4
81 vc_source=$5
82 vc_status=1
84 vc_checkprog=`eval echo "\\$$vc_variable"`
85 if [ -n "$vc_checkprog" ]; then
86 printbold "using $vc_checkprog for $vc_package"
87 return 0
90 if test "x$vc_package" = "xautomake" -a "x$vc_min_version" = "x1.4"; then
91 vc_comparator="="
92 else
93 vc_comparator=">="
95 printbold "checking for $vc_package $vc_comparator $vc_min_version..."
96 for vc_checkprog in $vc_checkprogs; do
97 echo $ECHO_N " testing $vc_checkprog... "
98 if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
99 vc_actual_version=`$vc_checkprog --version | head -n 1 | \
100 sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
101 if compare_versions $vc_min_version $vc_actual_version; then
102 echo "found $vc_actual_version"
103 # set variables
104 eval "$vc_variable=$vc_checkprog; \
105 ${vc_variable}_VERSION=$vc_actual_version"
106 vc_status=0
107 break
108 else
109 echo "too old (found version $vc_actual_version)"
111 else
112 echo "not found."
114 done
115 if [ "$vc_status" != 0 ]; then
116 printerr "***Error***: You must have $vc_package $vc_comparator $vc_min_version installed"
117 printerr " to build $PKG_NAME. Download the appropriate package for"
118 printerr " from your distribution or get the source tarball at"
119 printerr " $vc_source"
120 printerr
122 return $vc_status
125 # Usage:
126 # require_m4macro filename.m4
127 # adds filename.m4 to the list of required macros
128 require_m4macro() {
129 case "$REQUIRED_M4MACROS" in
130 $1\ * | *\ $1\ * | *\ $1) ;;
131 *) REQUIRED_M4MACROS="$REQUIRED_M4MACROS $1" ;;
132 esac
135 forbid_m4macro() {
136 case "$FORBIDDEN_M4MACROS" in
137 $1\ * | *\ $1\ * | *\ $1) ;;
138 *) FORBIDDEN_M4MACROS="$FORBIDDEN_M4MACROS $1" ;;
139 esac
142 # Usage:
143 # add_to_cm_macrodirs dirname
144 # Adds the dir to $cm_macrodirs, if it's not there yet.
145 add_to_cm_macrodirs() {
146 case $cm_macrodirs in
147 "$1 "* | *" $1 "* | *" $1") ;;
148 *) cm_macrodirs="$cm_macrodirs $1";;
149 esac
152 # Usage:
153 # check_m4macros
154 # Checks that all the requested macro files are in the aclocal macro path
155 # Uses REQUIRED_M4MACROS and ACLOCAL variables.
156 check_m4macros() {
157 # construct list of macro directories
158 cm_macrodirs=`$ACLOCAL --print-ac-dir`
159 # aclocal also searches a version specific dir, eg. /usr/share/aclocal-1.9
160 # but it contains only Automake's own macros, so we can ignore it.
162 # Read the dirlist file, supported by Automake >= 1.7.
163 if compare_versions 1.7 $AUTOMAKE_VERSION && [ -s $cm_macrodirs/dirlist ]; then
164 cm_dirlist=`sed 's/[ ]*#.*//;/^$/d' $cm_macrodirs/dirlist`
165 if [ -n "$cm_dirlist" ] ; then
166 for cm_dir in $cm_dirlist; do
167 if [ -d $cm_dir ]; then
168 add_to_cm_macrodirs $cm_dir
170 done
174 # Parse $ACLOCAL_FLAGS
175 set - $ACLOCAL_FLAGS
176 while [ $# -gt 0 ]; do
177 if [ "$1" = "-I" ]; then
178 add_to_cm_macrodirs "$2"
179 shift
181 shift
182 done
184 cm_status=0
185 if [ -n "$REQUIRED_M4MACROS" ]; then
186 printbold "Checking for required M4 macros..."
187 # check that each macro file is in one of the macro dirs
188 for cm_macro in $REQUIRED_M4MACROS; do
189 cm_macrofound=false
190 for cm_dir in $cm_macrodirs; do
191 if [ -f "$cm_dir/$cm_macro" ]; then
192 cm_macrofound=true
193 break
195 # The macro dir in Cygwin environments may contain a file
196 # called dirlist containing other directories to look in.
197 if [ -f "$cm_dir/dirlist" ]; then
198 for cm_otherdir in `cat $cm_dir/dirlist`; do
199 if [ -f "$cm_otherdir/$cm_macro" ]; then
200 cm_macrofound=true
201 break
203 done
205 done
206 if $cm_macrofound; then
208 else
209 printerr " $cm_macro not found"
210 cm_status=1
212 done
214 if [ -n "$FORBIDDEN_M4MACROS" ]; then
215 printbold "Checking for forbidden M4 macros..."
216 # check that each macro file is in one of the macro dirs
217 for cm_macro in $FORBIDDEN_M4MACROS; do
218 cm_macrofound=false
219 for cm_dir in $cm_macrodirs; do
220 if [ -f "$cm_dir/$cm_macro" ]; then
221 cm_macrofound=true
222 break
224 done
225 if $cm_macrofound; then
226 printerr " $cm_macro found (should be cleared from macros dir)"
227 cm_status=1
229 done
231 if [ "$cm_status" != 0 ]; then
232 printerr "***Error***: some autoconf macros required to build $PKG_NAME"
233 printerr " were not found in your aclocal path, or some forbidden"
234 printerr " macros were found. Perhaps you need to adjust your"
235 printerr " ACLOCAL_FLAGS?"
236 printerr
238 return $cm_status
241 # try to catch the case where the macros2/ directory hasn't been cleared out.
242 forbid_m4macro gnome-cxx-check.m4
244 want_libtool=false
245 want_gettext=false
246 want_glib_gettext=false
247 want_intltool=false
248 want_pkg_config=false
249 want_gtk_doc=false
250 want_gnome_doc_utils=false
252 configure_files="`find $srcdir -name '{arch}' -prune -o -name configure.ac -print -o -name configure.in -print`"
253 for configure_ac in $configure_files; do
254 if grep "^A[CM]_PROG_LIBTOOL" $configure_ac >/dev/null ||
255 grep "^LT_INIT" $configure_ac >/dev/null; then
256 want_libtool=true
258 if grep "^AM_GNU_GETTEXT" $configure_ac >/dev/null; then
259 want_gettext=true
261 if grep "^AM_GLIB_GNU_GETTEXT" $configure_ac >/dev/null; then
262 want_glib_gettext=true
264 if grep "^AC_PROG_INTLTOOL" $configure_ac >/dev/null ||
265 grep "^IT_PROG_INTLTOOL" $configure_ac >/dev/null; then
266 want_intltool=true
268 if grep "^PKG_CHECK_MODULES" $configure_ac >/dev/null; then
269 want_pkg_config=true
271 if grep "^GTK_DOC_CHECK" $configure_ac >/dev/null; then
272 want_gtk_doc=true
274 if grep "^GNOME_DOC_INIT" $configure_ac >/dev/null; then
275 want_gnome_doc_utils=true
278 # check to make sure gnome-common macros can be found ...
279 if grep "^GNOME_COMMON_INIT" $configure_ac >/dev/null ||
280 grep "^GNOME_DEBUG_CHECK" $configure_ac >/dev/null ||
281 grep "^GNOME_MAINTAINER_MODE_DEFINES" $configure_ac >/dev/null; then
282 require_m4macro gnome-common.m4
284 if grep "^GNOME_COMPILE_WARNINGS" $configure_ac >/dev/null ||
285 grep "^GNOME_CXX_WARNINGS" $configure_ac >/dev/null; then
286 require_m4macro gnome-compiler-flags.m4
288 done
290 DIE=0
292 #tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13
293 WANT_AUTOCONF_2_5=1
294 export WANT_AUTOCONF_2_5
295 version_check autoconf AUTOCONF 'autoconf2.50 autoconf autoconf-2.53' $REQUIRED_AUTOCONF_VERSION \
296 "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTOCONF_VERSION.tar.gz" || DIE=1
297 AUTOHEADER=`echo $AUTOCONF | sed s/autoconf/autoheader/`
299 case $REQUIRED_AUTOMAKE_VERSION in
300 1.4*) automake_progs="automake-1.4" ;;
301 1.5*) automake_progs="automake-1.5 automake-1.6 automake-1.7 automake-1.8 automake-1.9 automake-1.10 automake-1.11" ;;
302 1.6*) automake_progs="automake-1.6 automake-1.7 automake-1.8 automake-1.9 automake-1.10 automake-1.11" ;;
303 1.7*) automake_progs="automake-1.7 automake-1.8 automake-1.9 automake-1.10 automake-1.11" ;;
304 1.8*) automake_progs="automake-1.8 automake-1.9 automake-1.10 automake-1.11" ;;
305 1.9*) automake_progs="automake-1.9 automake-1.10 automake-1.11" ;;
306 1.10*) automake_progs="automake-1.10 automake-1.11" ;;
307 1.11*) automake_progs="automake-1.11" ;;
308 esac
309 version_check automake AUTOMAKE "$automake_progs" $REQUIRED_AUTOMAKE_VERSION \
310 "http://ftp.gnu.org/pub/gnu/automake/automake-$REQUIRED_AUTOMAKE_VERSION.tar.gz" || DIE=1
311 ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
313 if $want_libtool; then
314 version_check libtool LIBTOOLIZE libtoolize $REQUIRED_LIBTOOL_VERSION \
315 "http://ftp.gnu.org/pub/gnu/libtool/libtool-$REQUIRED_LIBTOOL_VERSION.tar.gz" || DIE=1
316 require_m4macro libtool.m4
319 if $want_gettext; then
320 version_check gettext GETTEXTIZE gettextize $REQUIRED_GETTEXT_VERSION \
321 "http://ftp.gnu.org/pub/gnu/gettext/gettext-$REQUIRED_GETTEXT_VERSION.tar.gz" || DIE=1
322 require_m4macro gettext.m4
325 if $want_glib_gettext; then
326 version_check glib-gettext GLIB_GETTEXTIZE glib-gettextize $REQUIRED_GLIB_GETTEXT_VERSION \
327 "ftp://ftp.gtk.org/pub/gtk/v2.2/glib-$REQUIRED_GLIB_GETTEXT_VERSION.tar.gz" || DIE=1
328 require_m4macro glib-gettext.m4
331 if $want_intltool; then
332 version_check intltool INTLTOOLIZE intltoolize $REQUIRED_INTLTOOL_VERSION \
333 "http://ftp.gnome.org/pub/GNOME/sources/intltool/" || DIE=1
334 require_m4macro intltool.m4
337 if $want_pkg_config; then
338 version_check pkg-config PKG_CONFIG pkg-config $REQUIRED_PKG_CONFIG_VERSION \
339 "'http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-$REQUIRED_PKG_CONFIG_VERSION.tar.gz" || DIE=1
340 require_m4macro pkg.m4
343 if $want_gtk_doc; then
344 version_check gtk-doc GTKDOCIZE gtkdocize $REQUIRED_GTK_DOC_VERSION \
345 "http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/" || DIE=1
346 require_m4macro gtk-doc.m4
349 if $want_gnome_doc_utils; then
350 version_check gnome-doc-utils GNOME_DOC_PREPARE gnome-doc-prepare $REQUIRED_GNOME_DOC_UTILS_VERSION \
351 "http://ftp.gnome.org/pub/GNOME/sources/gnome-doc-utils/" || DIE=1
354 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
355 version_check gnome-common DOC_COMMON gnome-doc-common \
356 $REQUIRED_DOC_COMMON_VERSION " " || DIE=1
359 check_m4macros || DIE=1
361 if [ "$DIE" -eq 1 ]; then
362 exit 1
365 if [ "$#" = 0 ]; then
366 printerr "**Warning**: I am going to run \`configure' with no arguments."
367 printerr "If you wish to pass any to it, please specify them on the"
368 printerr \`$0\'" command line."
369 printerr
372 topdir=`pwd`
373 for configure_ac in $configure_files; do
374 dirname=`dirname $configure_ac`
375 basename=`basename $configure_ac`
376 if [ -f $dirname/NO-AUTO-GEN ]; then
377 echo skipping $dirname -- flagged as no auto-gen
378 elif [ ! -w $dirname ]; then
379 echo skipping $dirname -- directory is read only
380 else
381 printbold "Processing $configure_ac"
382 cd $dirname
384 # Note that the order these tools are called should match what
385 # autoconf's "autoupdate" package does. See bug 138584 for
386 # details.
388 # programs that might install new macros get run before aclocal
389 if grep "^A[CM]_PROG_LIBTOOL" $basename >/dev/null ||
390 grep "^LT_INIT" $basename >/dev/null; then
391 printbold "Running $LIBTOOLIZE..."
392 $LIBTOOLIZE --force --copy || exit 1
395 if grep "^AM_GLIB_GNU_GETTEXT" $basename >/dev/null; then
396 printbold "Running $GLIB_GETTEXTIZE... Ignore non-fatal messages."
397 echo "no" | $GLIB_GETTEXTIZE --force --copy || exit 1
398 elif grep "^AM_GNU_GETTEXT" $basename >/dev/null; then
399 if grep "^AM_GNU_GETTEXT_VERSION" $basename > /dev/null; then
400 printbold "Running autopoint..."
401 autopoint --force || exit 1
402 else
403 printbold "Running $GETTEXTIZE... Ignore non-fatal messages."
404 echo "no" | $GETTEXTIZE --force --copy || exit 1
408 if grep "^AC_PROG_INTLTOOL" $basename >/dev/null ||
409 grep "^IT_PROG_INTLTOOL" $basename >/dev/null; then
410 printbold "Running $INTLTOOLIZE..."
411 $INTLTOOLIZE --force --copy --automake || exit 1
413 if grep "^GTK_DOC_CHECK" $basename >/dev/null; then
414 printbold "Running $GTKDOCIZE..."
415 $GTKDOCIZE --copy || exit 1
418 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
419 printbold "Running gnome-doc-common..."
420 gnome-doc-common --copy || exit 1
422 if grep "^GNOME_DOC_INIT" $basename >/dev/null; then
423 printbold "Running $GNOME_DOC_PREPARE..."
424 $GNOME_DOC_PREPARE --force --copy || exit 1
427 # Now run aclocal to pull in any additional macros needed
429 # if the AC_CONFIG_MACRO_DIR() macro is used, pass that
430 # directory to aclocal.
431 m4dir=`cat "$basename" | grep '^AC_CONFIG_MACRO_DIR' | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
432 if [ -n "$m4dir" ]; then
433 m4dir="-I $m4dir"
435 printbold "Running $ACLOCAL..."
436 $ACLOCAL $m4dir $ACLOCAL_FLAGS || exit 1
438 if grep "GNOME_AUTOGEN_OBSOLETE" aclocal.m4 >/dev/null; then
439 printerr "*** obsolete gnome macros were used in $configure_ac"
442 # Now that all the macros are sorted, run autoconf and autoheader ...
443 printbold "Running $AUTOCONF..."
444 $AUTOCONF || exit 1
445 if grep "^A[CM]_CONFIG_HEADER" $basename >/dev/null; then
446 printbold "Running $AUTOHEADER..."
447 $AUTOHEADER || exit 1
448 # this prevents automake from thinking config.h.in is out of
449 # date, since autoheader doesn't touch the file if it doesn't
450 # change.
451 test -f config.h.in && touch config.h.in
454 # Finally, run automake to create the makefiles ...
455 printbold "Running $AUTOMAKE..."
456 cp -pf COPYING COPYING.autogen_bak
457 cp -pf INSTALL INSTALL.autogen_bak
458 if [ $REQUIRED_AUTOMAKE_VERSION != 1.4 ]; then
459 $AUTOMAKE --gnu --add-missing --force --copy || exit 1
460 else
461 $AUTOMAKE --gnu --add-missing --copy || exit 1
463 cmp COPYING COPYING.autogen_bak || cp -pf COPYING.autogen_bak COPYING
464 cmp INSTALL INSTALL.autogen_bak || cp -pf INSTALL.autogen_bak INSTALL
465 rm -f COPYING.autogen_bak INSTALL.autogen_bak
467 cd "$topdir"
469 done
471 conf_flags="--enable-maintainer-mode"
473 if test x$NOCONFIGURE = x; then
474 printbold Running $srcdir/configure $conf_flags "$@" ...
475 $srcdir/configure $conf_flags "$@" \
476 && echo Now type \`make\' to compile $PKG_NAME || exit 1
477 else
478 echo Skipping configure process.