2 # Run this to generate all the initial makefiles, etc.
5 test "$PKG_NAME" || PKG_NAME=Package
6 test "$srcdir" || srcdir=.
8 # default version requirements ...
9 test "$REQUIRED_AUTOCONF_VERSION" || REQUIRED_AUTOCONF_VERSION=2.53
10 test "$REQUIRED_AUTOMAKE_VERSION" || REQUIRED_AUTOMAKE_VERSION=1.9
11 test "$REQUIRED_LIBTOOL_VERSION" || REQUIRED_LIBTOOL_VERSION=1.4.3
12 test "$REQUIRED_GETTEXT_VERSION" || REQUIRED_GETTEXT_VERSION=0.10.40
13 test "$REQUIRED_GLIB_GETTEXT_VERSION" || REQUIRED_GLIB_GETTEXT_VERSION=2.2.0
14 test "$REQUIRED_INTLTOOL_VERSION" || REQUIRED_INTLTOOL_VERSION=0.25
15 test "$REQUIRED_PKG_CONFIG_VERSION" || REQUIRED_PKG_CONFIG_VERSION=0.14.0
16 test "$REQUIRED_GTK_DOC_VERSION" || REQUIRED_GTK_DOC_VERSION=1.0
17 test "$REQUIRED_DOC_COMMON_VERSION" || REQUIRED_DOC_COMMON_VERSION=2.3.0
18 test "$REQUIRED_GNOME_DOC_UTILS_VERSION" || REQUIRED_GNOME_DOC_UTILS_VERSION=0.4.2
20 # a list of required m4 macros. Package can set an initial value
21 test "$REQUIRED_M4MACROS" || REQUIRED_M4MACROS=
22 test "$FORBIDDEN_M4MACROS" || FORBIDDEN_M4MACROS=
24 # Not all echo versions allow -n, so we check what is possible. This test is
25 # based on the one in autoconf.
38 # some terminal codes ...
39 if tty < /dev/null 1>/dev/null 2>&1; then
40 boldface="`tput bold 2>/dev/null`"
41 normal="`tput sgr0 2>/dev/null`"
47 echo $ECHO_N "$boldface" $ECHO_C
49 echo $ECHO_N "$normal" $ECHO_C
56 # compare_versions MIN_VERSION ACTUAL_VERSION
57 # returns true if ACTUAL_VERSION >= MIN_VERSION
62 IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="."
63 set $ch_actual_version
64 for ch_min in $ch_min_version; do
65 ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
66 if [ -z "$ch_min" ]; then break; fi
67 if [ -z "$ch_cur" ]; then ch_status=1; break; fi
68 if [ $ch_cur -gt $ch_min ]; then break; fi
69 if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
76 # version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
77 # checks to see if the package is available
86 vc_checkprog=`eval echo "\\$$vc_variable"`
87 if [ -n "$vc_checkprog" ]; then
88 printbold "using $vc_checkprog for $vc_package"
92 if test "x$vc_package" = "xautomake" -a "x$vc_min_version" = "x1.4"; then
97 printbold "checking for $vc_package $vc_comparator $vc_min_version..."
98 for vc_checkprog in $vc_checkprogs; do
99 echo $ECHO_N " testing $vc_checkprog... " $ECHO_C
100 if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
101 vc_actual_version=`$vc_checkprog --version | head -n 1 | \
102 sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
103 if compare_versions $vc_min_version $vc_actual_version; then
104 echo "found $vc_actual_version"
106 eval "$vc_variable=$vc_checkprog; \
107 ${vc_variable}_VERSION=$vc_actual_version"
111 echo "too old (found version $vc_actual_version)"
117 if [ "$vc_status" != 0 ]; then
118 printerr "***Error***: You must have $vc_package $vc_comparator $vc_min_version installed"
119 printerr " to build $PKG_NAME. Download the appropriate package for"
120 printerr " from your distribution or get the source tarball at"
121 printerr " $vc_source"
129 # require_m4macro filename.m4
130 # adds filename.m4 to the list of required macros
132 case "$REQUIRED_M4MACROS" in
133 $1\ * | *\ $1\ * | *\ $1) ;;
134 *) REQUIRED_M4MACROS="$REQUIRED_M4MACROS $1" ;;
139 case "$FORBIDDEN_M4MACROS" in
140 $1\ * | *\ $1\ * | *\ $1) ;;
141 *) FORBIDDEN_M4MACROS="$FORBIDDEN_M4MACROS $1" ;;
146 # add_to_cm_macrodirs dirname
147 # Adds the dir to $cm_macrodirs, if it's not there yet.
148 add_to_cm_macrodirs() {
149 case $cm_macrodirs in
150 "$1 "* | *" $1 "* | *" $1") ;;
151 *) cm_macrodirs="$cm_macrodirs $1";;
156 # print_m4macros_error
157 # Prints an error message saying that autoconf macros were misused
158 print_m4macros_error() {
159 printerr "***Error***: some autoconf macros required to build $PKG_NAME"
160 printerr " were not found in your aclocal path, or some forbidden"
161 printerr " macros were found. Perhaps you need to adjust your"
162 printerr " ACLOCAL_FLAGS?"
168 # Checks that all the requested macro files are in the aclocal macro path
169 # Uses REQUIRED_M4MACROS and ACLOCAL variables.
171 # construct list of macro directories
172 cm_macrodirs=`$ACLOCAL --print-ac-dir`
173 # aclocal also searches a version specific dir, eg. /usr/share/aclocal-1.9
174 # but it contains only Automake's own macros, so we can ignore it.
176 # Read the dirlist file, supported by Automake >= 1.7.
177 # If AUTOMAKE was defined, no version was detected.
178 if [ -z "$AUTOMAKE_VERSION" ] || compare_versions 1.7 $AUTOMAKE_VERSION && [ -s $cm_macrodirs/dirlist ]; then
179 cm_dirlist=`sed 's/[ ]*#.*//;/^$/d' $cm_macrodirs/dirlist`
180 if [ -n "$cm_dirlist" ] ; then
181 for cm_dir in $cm_dirlist; do
182 if [ -d $cm_dir ]; then
183 add_to_cm_macrodirs $cm_dir
189 # Parse $ACLOCAL_FLAGS
191 while [ $# -gt 0 ]; do
192 if [ "$1" = "-I" ]; then
193 add_to_cm_macrodirs "$2"
200 if [ -n "$REQUIRED_M4MACROS" ]; then
201 printbold "Checking for required M4 macros..."
202 # check that each macro file is in one of the macro dirs
203 for cm_macro in $REQUIRED_M4MACROS; do
205 for cm_dir in $cm_macrodirs; do
206 if [ -f "$cm_dir/$cm_macro" ]; then
210 # The macro dir in Cygwin environments may contain a file
211 # called dirlist containing other directories to look in.
212 if [ -f "$cm_dir/dirlist" ]; then
213 for cm_otherdir in `cat $cm_dir/dirlist`; do
214 if [ -f "$cm_otherdir/$cm_macro" ]; then
221 if $cm_macrofound; then
224 printerr " $cm_macro not found"
229 if [ "$cm_status" != 0 ]; then
233 if [ -n "$FORBIDDEN_M4MACROS" ]; then
234 printbold "Checking for forbidden M4 macros..."
235 # check that each macro file is in one of the macro dirs
236 for cm_macro in $FORBIDDEN_M4MACROS; do
238 for cm_dir in $cm_macrodirs; do
239 if [ -f "$cm_dir/$cm_macro" ]; then
244 if $cm_macrofound; then
245 printerr " $cm_macro found (should be cleared from macros dir)"
250 if [ "$cm_status" != 0 ]; then
256 # try to catch the case where the macros2/ directory hasn't been cleared out.
257 forbid_m4macro gnome-cxx-check.m4
261 want_glib_gettext=false
263 want_pkg_config=false
265 want_gnome_doc_utils=false
266 want_maintainer_mode=false
268 find_configure_files() {
270 if test -f "$1/configure.ac"; then
271 configure_ac="$1/configure.ac"
272 elif test -f "$1/configure.in"; then
273 configure_ac="$1/configure.in"
275 if test "x$configure_ac" != x; then
277 # TODO We have not detected the right autoconf yet!
278 autoconf -t 'AC_CONFIG_SUBDIRS:$1' "$configure_ac" | while read dir; do
279 find_configure_files "$1/$dir"
284 configure_files="`find_configure_files $srcdir`"
286 for configure_ac in $configure_files; do
287 dirname=`dirname $configure_ac`
288 if [ -f $dirname/NO-AUTO-GEN ]; then
289 echo skipping $dirname -- flagged as no auto-gen
292 if grep "^A[CM]_PROG_LIBTOOL" $configure_ac >/dev/null ||
293 grep "^LT_INIT" $configure_ac >/dev/null; then
296 if grep "^AM_GNU_GETTEXT" $configure_ac >/dev/null; then
299 if grep "^AM_GLIB_GNU_GETTEXT" $configure_ac >/dev/null; then
300 want_glib_gettext=true
302 if grep "^AC_PROG_INTLTOOL" $configure_ac >/dev/null ||
303 grep "^IT_PROG_INTLTOOL" $configure_ac >/dev/null; then
306 if grep "^PKG_CHECK_MODULES" $configure_ac >/dev/null; then
309 if grep "^GTK_DOC_CHECK" $configure_ac >/dev/null; then
312 if grep "^GNOME_DOC_INIT" $configure_ac >/dev/null; then
313 want_gnome_doc_utils=true
316 # check that AM_MAINTAINER_MODE is used
317 if grep "^AM_MAINTAINER_MODE" $configure_ac >/dev/null; then
318 want_maintainer_mode=true
321 if grep "^YELP_HELP_INIT" $configure_ac >/dev/null; then
322 require_m4macro yelp.m4
325 # check to make sure gnome-common macros can be found ...
326 if grep "^GNOME_COMMON_INIT" $configure_ac >/dev/null ||
327 grep "^GNOME_DEBUG_CHECK" $configure_ac >/dev/null ||
328 grep "^GNOME_MAINTAINER_MODE_DEFINES" $configure_ac >/dev/null; then
329 require_m4macro gnome-common.m4
331 if grep "^GNOME_COMPILE_WARNINGS" $configure_ac >/dev/null ||
332 grep "^GNOME_CXX_WARNINGS" $configure_ac >/dev/null; then
333 require_m4macro gnome-compiler-flags.m4
335 if grep "^GNOME_CODE_COVERAGE" $configure_ac >/dev/null; then
336 require_m4macro gnome-code-coverage.m4
340 #tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13
342 export WANT_AUTOCONF_2_5
343 version_check autoconf AUTOCONF 'autoconf2.50 autoconf autoconf-2.53' $REQUIRED_AUTOCONF_VERSION \
344 "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTOCONF_VERSION.tar.gz"
345 AUTOHEADER=`echo $AUTOCONF | sed s/autoconf/autoheader/`
347 case $REQUIRED_AUTOMAKE_VERSION in
348 1.4*) automake_progs="automake-1.4" ;;
349 1.5*) automake_progs="automake-1.12 automake-1.11 automake-1.10 automake-1.9 automake-1.8 automake-1.7 automake-1.6 automake-1.5" ;;
350 1.6*) automake_progs="automake-1.12 automake-1.11 automake-1.10 automake-1.9 automake-1.8 automake-1.7 automake-1.6" ;;
351 1.7*) automake_progs="automake-1.12 automake-1.11 automake-1.10 automake-1.9 automake-1.8 automake-1.7" ;;
352 1.8*) automake_progs="automake-1.12 automake-1.11 automake-1.10 automake-1.9 automake-1.8" ;;
353 1.9*) automake_progs="automake-1.12 automake-1.11 automake-1.10 automake-1.9" ;;
354 1.10*) automake_progs="automake-1.12 automake-1.11 automake-1.10" ;;
355 1.11*) automake_progs="automake-1.12 automake-1.11" ;;
356 1.12*) automake_progs="automake-1.12" ;;
358 version_check automake AUTOMAKE "$automake_progs" $REQUIRED_AUTOMAKE_VERSION \
359 "http://ftp.gnu.org/pub/gnu/automake/automake-$REQUIRED_AUTOMAKE_VERSION.tar.gz"
360 ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
362 if $want_libtool; then
363 version_check libtool LIBTOOLIZE "libtoolize glibtoolize" $REQUIRED_LIBTOOL_VERSION \
364 "http://ftp.gnu.org/pub/gnu/libtool/libtool-$REQUIRED_LIBTOOL_VERSION.tar.gz"
365 require_m4macro libtool.m4
368 if $want_gettext; then
369 version_check gettext GETTEXTIZE gettextize $REQUIRED_GETTEXT_VERSION \
370 "http://ftp.gnu.org/pub/gnu/gettext/gettext-$REQUIRED_GETTEXT_VERSION.tar.gz"
371 require_m4macro gettext.m4
374 if $want_glib_gettext; then
375 version_check glib-gettext GLIB_GETTEXTIZE glib-gettextize $REQUIRED_GLIB_GETTEXT_VERSION \
376 "ftp://ftp.gtk.org/pub/gtk/v2.2/glib-$REQUIRED_GLIB_GETTEXT_VERSION.tar.gz"
377 require_m4macro glib-gettext.m4
380 if $want_intltool; then
381 version_check intltool INTLTOOLIZE intltoolize $REQUIRED_INTLTOOL_VERSION \
382 "http://ftp.gnome.org/pub/GNOME/sources/intltool/"
383 require_m4macro intltool.m4
386 if $want_pkg_config; then
387 version_check pkg-config PKG_CONFIG pkg-config $REQUIRED_PKG_CONFIG_VERSION \
388 "'http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-$REQUIRED_PKG_CONFIG_VERSION.tar.gz"
389 require_m4macro pkg.m4
392 if $want_gtk_doc; then
393 version_check gtk-doc GTKDOCIZE gtkdocize $REQUIRED_GTK_DOC_VERSION \
394 "http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/"
395 require_m4macro gtk-doc.m4
398 if $want_gnome_doc_utils; then
399 version_check gnome-doc-utils GNOME_DOC_PREPARE gnome-doc-prepare $REQUIRED_GNOME_DOC_UTILS_VERSION \
400 "http://ftp.gnome.org/pub/GNOME/sources/gnome-doc-utils/"
403 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
404 version_check gnome-common DOC_COMMON gnome-doc-common \
405 $REQUIRED_DOC_COMMON_VERSION " "
410 if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then
411 printerr "**Warning**: I am going to run \`configure' with no arguments."
412 printerr "If you wish to pass any to it, please specify them on the"
413 printerr \`$0\'" command line."
418 for configure_ac in $configure_files; do
419 dirname=`dirname $configure_ac`
420 basename=`basename $configure_ac`
421 if [ -f $dirname/NO-AUTO-GEN ]; then
422 echo skipping $dirname -- flagged as no auto-gen
423 elif [ ! -w $dirname ]; then
424 echo skipping $dirname -- directory is read only
426 printbold "Processing $configure_ac"
429 # Note that the order these tools are called should match what
430 # autoconf's "autoupdate" package does. See bug 138584 for
433 # programs that might install new macros get run before aclocal
434 if grep "^A[CM]_PROG_LIBTOOL" $basename >/dev/null ||
435 grep "^LT_INIT" $basename >/dev/null; then
436 printbold "Running $LIBTOOLIZE..."
437 $LIBTOOLIZE --force --copy || exit 1
440 if grep "^AM_GLIB_GNU_GETTEXT" $basename >/dev/null; then
441 printbold "Running $GLIB_GETTEXTIZE... Ignore non-fatal messages."
442 echo "no" | $GLIB_GETTEXTIZE --force --copy || exit 1
443 elif grep "^AM_GNU_GETTEXT" $basename >/dev/null; then
444 if grep "^AM_GNU_GETTEXT_VERSION" $basename > /dev/null; then
445 printbold "Running autopoint..."
446 autopoint --force || exit 1
448 printbold "Running $GETTEXTIZE... Ignore non-fatal messages."
449 echo "no" | $GETTEXTIZE --force --copy || exit 1
453 if grep "^AC_PROG_INTLTOOL" $basename >/dev/null ||
454 grep "^IT_PROG_INTLTOOL" $basename >/dev/null; then
455 printbold "Running $INTLTOOLIZE..."
456 $INTLTOOLIZE --force --copy --automake || exit 1
458 if grep "^GTK_DOC_CHECK" $basename >/dev/null; then
459 printbold "Running $GTKDOCIZE..."
460 $GTKDOCIZE --copy || exit 1
463 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
464 printbold "Running gnome-doc-common..."
465 gnome-doc-common --copy || exit 1
467 if grep "^GNOME_DOC_INIT" $basename >/dev/null; then
468 printbold "Running $GNOME_DOC_PREPARE..."
469 $GNOME_DOC_PREPARE --force --copy || exit 1
472 # Now run aclocal to pull in any additional macros needed
474 # if the AC_CONFIG_MACRO_DIR() macro is used, pass that
475 # directory to aclocal.
476 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`
477 if [ -n "$m4dir" ]; then
480 printbold "Running $ACLOCAL..."
481 $ACLOCAL $m4dir $ACLOCAL_FLAGS || exit 1
483 if grep "GNOME_AUTOGEN_OBSOLETE" aclocal.m4 >/dev/null; then
484 printerr "*** obsolete gnome macros were used in $configure_ac"
487 # Now that all the macros are sorted, run autoconf and autoheader ...
488 printbold "Running $AUTOCONF..."
490 if grep "^A[CM]_CONFIG_HEADER" $basename >/dev/null; then
491 printbold "Running $AUTOHEADER..."
492 $AUTOHEADER || exit 1
493 # this prevents automake from thinking config.h.in is out of
494 # date, since autoheader doesn't touch the file if it doesn't
496 test -f config.h.in && touch config.h.in
499 # Finally, run automake to create the makefiles ...
500 printbold "Running $AUTOMAKE..."
501 if [ -f COPYING ]; then
502 cp -pf COPYING COPYING.autogen_bak
504 if [ -f INSTALL ]; then
505 cp -pf INSTALL INSTALL.autogen_bak
507 if [ $REQUIRED_AUTOMAKE_VERSION != 1.4 ]; then
508 $AUTOMAKE --gnu --add-missing --copy -Wno-portability || exit 1
510 $AUTOMAKE --gnu --add-missing --copy || exit 1
512 if [ -f COPYING.autogen_bak ]; then
513 cmp COPYING COPYING.autogen_bak > /dev/null || cp -pf COPYING.autogen_bak COPYING
514 rm -f COPYING.autogen_bak
516 if [ -f INSTALL.autogen_bak ]; then
517 cmp INSTALL INSTALL.autogen_bak > /dev/null || cp -pf INSTALL.autogen_bak INSTALL
518 rm -f INSTALL.autogen_bak
527 if $want_maintainer_mode; then
528 conf_flags="--enable-maintainer-mode"
531 if test x$NOCONFIGURE = x; then
532 printbold Running $srcdir/configure $conf_flags "$@" ...
533 $srcdir/configure $conf_flags "$@" \
534 && echo Now type \`make\' to compile $PKG_NAME || exit 1
536 echo Skipping configure process.