2005-05-27  Stepan Kasal  <kasal@ucw.cz>

	* macros2/gnome-autogen.sh: If REQUIRED_AUTOMAKE_VERSION is empty,
	  print a big annoying warning.  Introduce PREFER_NEWER_AUTOMAKE,
	  which defaults to 1.

diff -ur macros2/gnome-autogen.sh macros2/gnome-autogen.sh
--- macros2/gnome-autogen.sh	2005-05-27 08:00:21.000000000 +0200
+++ macros2/gnome-autogen.sh	2005-05-27 08:59:30.000000000 +0200
@@ -2,24 +2,47 @@
 # Run this to generate all the initial makefiles, etc.
 
 #name of package
-PKG_NAME=${PKG_NAME:-Package}
-srcdir=${srcdir:-.}
+: ${PKG_NAME:=Package}
+: ${srcdir:=.}
 
 # default version requirements ...
-REQUIRED_AUTOCONF_VERSION=${REQUIRED_AUTOCONF_VERSION:-2.53}
-REQUIRED_AUTOMAKE_VERSION=${REQUIRED_AUTOMAKE_VERSION:-1.4}
-REQUIRED_LIBTOOL_VERSION=${REQUIRED_LIBTOOL_VERSION:-1.4.3}
-REQUIRED_GETTEXT_VERSION=${REQUIRED_GETTEXT_VERSION:-0.10.40}
-REQUIRED_GLIB_GETTEXT_VERSION=${REQUIRED_GLIB_GETTEXT_VERSION:-2.2.0}
-REQUIRED_INTLTOOL_VERSION=${REQUIRED_INTLTOOL_VERSION:-0.25}
-REQUIRED_PKG_CONFIG_VERSION=${REQUIRED_PKG_CONFIG_VERSION:-0.14.0}
-REQUIRED_GTK_DOC_VERSION=${REQUIRED_GTK_DOC_VERSION:-1.0}
-REQUIRED_DOC_COMMON_VERSION=${REQUIRED_DOC_COMMON_VERSION:-2.3.0}
-REQUIRED_GNOME_DOC_UTILS_VERSION=${REQUIRED_GNOME_DOC_UTILS_VERSION:-0.1.3}
+: ${REQUIRED_AUTOCONF_VERSION:=2.53}
+: ${REQUIRED_LIBTOOL_VERSION:=1.4.3}
+: ${REQUIRED_GETTEXT_VERSION:=0.10.40}
+: ${REQUIRED_GLIB_GETTEXT_VERSION:=2.2.0}
+: ${REQUIRED_INTLTOOL_VERSION:=0.25}
+: ${REQUIRED_PKG_CONFIG_VERSION:=0.14.0}
+: ${REQUIRED_GTK_DOC_VERSION:=1.0}
+: ${REQUIRED_DOC_COMMON_VERSION:=2.3.0}
+: ${REQUIRED_GNOME_DOC_UTILS_VERSION:=0.1.3}
 
 # a list of required m4 macros.  Package can set an initial value
-REQUIRED_M4MACROS=${REQUIRED_M4MACROS:-}
-FORBIDDEN_M4MACROS=${FORBIDDEN_M4MACROS:-}
+: ${REQUIRED_M4MACROS:=}
+: ${FORBIDDEN_M4MACROS:=}
+
+: ${PREFER_NEWER_AUTOMAKE:=1}
+
+# Shall we prefer newer versions of Automake by default?
+#
+# 0) In most cases things just work; the interface of Automake 1.6-1.9 is
+# practically backward compatible.  So there is no significant difference.
+#
+# 1) If we prefer newer versions of Automake, and the package relies on
+# an older version, then the developer sees the problem, most probably an
+# instructive error message from Automake.  If Makefile.am cannot be fixed,
+# it's always possible to use PREFER_NEWER_AUTOMAKE=0.
+#
+# 2) OTOH, if we prefer older versions of Automake, then the developer
+# won't have any problems with "make dist".  But the problems are offset
+# to people trying to build from the distributed tarball.  The makefiles
+# generated by obsolete Automake lack years of debugging work.  The build
+# can easily fail on a platform with an unusual configuration.  These
+# problems are not easy to solve.  (It took me the whole day to find out
+# that mere "autoreconf" does it.) 
+#
+# Both alternatives have problems, but it's better to force developers to
+# fix their packages than compromising function of the released tarballs.
+
 
 # Not all echo versions allow -n, so we check what is possible. This test is
 # based on the one in autoconf.
@@ -41,6 +64,18 @@
     echo "$@" >&2
 }
 
+if [ "x$REQUIRED_AUTOMAKE_VERSION" = x ]; then
+	printerr "***Warning***: REQUIRED_AUTOMAKE_VERSION is not set."
+	printerr
+	printerr "  This means that Automake 1.4, which is hopelessly obsolete,"
+	printerr "  has to be used."
+	printerr
+	printerr "  Please upgrade your package to current Automake, and set"
+	printerr "  REQUIRED_AUTOMAKE_VERSION=1.5 in your autogen.sh."
+	printerr
+	REQUIRED_AUTOMAKE_VERSION=1.4
+fi
+
 # Usage:
 #     compare_versions MIN_VERSION ACTUAL_VERSION
 # returns true if ACTUAL_VERSION >= MIN_VERSION
@@ -78,7 +113,7 @@
 	return 0
     fi
 
-    if test "x$vc_package" = "xautomake" -a "x$vc_min_version" = "x1.4"; then
+    if [ "x$vc_package" = "xautomake" -a "x$vc_min_version" = "x1.4" ]; then
 	vc_comparator="="
     else
 	vc_comparator=">="
@@ -105,8 +140,8 @@
     done
     if [ "$vc_status" != 0 ]; then
 	printerr "***Error***: You must have $vc_package $vc_comparator $vc_min_version installed"
-	printerr "  to build $PKG_NAME.  Download the appropriate package for"
-	printerr "  from your distribution or get the source tarball at"
+	printerr "  to build $PKG_NAME.  Download the appropriate package from your"
+	printerr "  distribution or get the source tarball at"
         printerr "    $vc_source"
 	printerr
     fi
@@ -270,30 +305,42 @@
 WANT_AUTOCONF_2_5=1
 export WANT_AUTOCONF_2_5
 version_check autoconf AUTOCONF 'autoconf2.50 autoconf autoconf-2.53' $REQUIRED_AUTOCONF_VERSION \
-    "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTOCONF_VERSION.tar.gz" || DIE=1
+    "http://ftp.gnu.org/pub/gnu/autoconf/" || DIE=1
 AUTOHEADER=`echo $AUTOCONF | sed s/autoconf/autoheader/`
 
-case $REQUIRED_AUTOMAKE_VERSION in
-    1.4*) automake_progs="automake-1.4" ;;
-    1.5*) automake_progs="automake-1.5 automake-1.6 automake-1.7 automake-1.8 automake-1.9" ;;
-    1.6*) automake_progs="automake-1.6 automake-1.7 automake-1.8 automake-1.9" ;;
-    1.7*) automake_progs="automake-1.7 automake-1.8 automake-1.9" ;;
-    1.8*) automake_progs="automake-1.8 automake-1.9" ;;
-    1.9*) automake_progs="automake-1.9" ;;
-esac
+# Build the list of candidates for AUTOMAKE:
+if [ $PREFER_NEWER_AUTOMAKE != 0 ]; then
+    automake_progs=automake
+else
+    automake_progs=
+fi
+for ver in 1.9 1.8 1.7 1.6 1.5; do
+    if [ $PREFER_NEWER_AUTOMAKE != 0 ]; then
+	automake_progs="$automake_progs automake-$ver"
+    else
+	automake_progs="automake-$ver $automake_progs"
+    fi
+    case $REQUIRED_AUTOMAKE_VERSION in
+	$ver*)	# Don't add versions older than required:
+		break ;;
+	1.4)	# A special case; try only automake-1.4!
+		automake_progs="automake-1.4" ;;
+    esac
+done
+
 version_check automake AUTOMAKE "$automake_progs" $REQUIRED_AUTOMAKE_VERSION \
-    "http://ftp.gnu.org/pub/gnu/automake/automake-$REQUIRED_AUTOMAKE_VERSION.tar.gz" || DIE=1
+    "http://ftp.gnu.org/pub/gnu/automake/" || DIE=1
 ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
 
 if $want_libtool; then
     version_check libtool LIBTOOLIZE libtoolize $REQUIRED_LIBTOOL_VERSION \
-        "http://ftp.gnu.org/pub/gnu/libtool/libtool-$REQUIRED_LIBTOOL_VERSION.tar.gz" || DIE=1
+        "http://ftp.gnu.org/pub/gnu/libtool/" || DIE=1
     require_m4macro libtool.m4
 fi
 
 if $want_gettext; then
     version_check gettext GETTEXTIZE gettextize $REQUIRED_GETTEXT_VERSION \
-        "http://ftp.gnu.org/pub/gnu/gettext/gettext-$REQUIRED_GETTEXT_VERSION.tar.gz" || DIE=1
+        "http://ftp.gnu.org/pub/gnu/gettext/" || DIE=1
     require_m4macro gettext.m4
 fi
 
@@ -440,7 +487,7 @@
 
 conf_flags="--enable-maintainer-mode"
 
-if test x$NOCONFIGURE = x; then
+if [ x$NOCONFIGURE = x ]; then
     printbold Running $srcdir/configure $conf_flags "$@" ...
     $srcdir/configure $conf_flags "$@" \
 	&& echo Now type \`make\' to compile $PKG_NAME || exit 1
