Subject: bug#11294: [RFC] build: support and require Automake-NG

From: Stefano Lattarini <[email-masked]>
Date: Tue, 08 May 2012 17:03:40 +0200

On 04/21/2012 11:48 AM, Stefano Lattarini wrote:
> * configure.ac (AM_INIT_AUTOMAKE): Add the 'ng' option, to ensure that
> mainstream Automake is not used by mistake when bootstrapping.  Also,
> bump the required Automake version from '1.11.1' to '1.11e', which is
> the latest (and still development-only) version of Automake-NG at the
> moment of writing.
> * bootstrap (check_versions): Hacked to handle automake and aclocal
> from Automake-NG specially.  This change should be backported to Gnulib
> proper in a later step.
> * bootstrap.conf ($buildreq): Require "automake-ng" and "aclocal-ng"
> version >= 0.5; don't require mainstream "automake" anymore.
> 
> Signed-off-by: Stefano Lattarini <[email-masked]>
> ---
> 
>  I'd like this to be applied to an experimental branch in the coreutils
>  repository, which will be used to test and experiment with Automake-NG
>  in a real-world, important, medium-complexity package like GNU coreutils
>  is.
> 
>  I hope you'll agree this is a sensible move, which could bring advantages
>  and improvements to both coreutils and Automake-NG.
> 
I've updated the patch to take into account:

 - the recent bump in the Automake-NG version (1.11e => 1.12a);
 - the bump in the minimal Autoconf version required by Automake-NG
   (2.62 => 2.65);
 - the support for Automake-NG recently added to the Gnulib-provided
   bootstrap script
 - the removal of the m4 macro 'AM_PROG_MKDIR_P' from the master
   branch of the Automake repository (and thus from Automake-NG,
   where 'master' is regularly merged).

So, OK to apply this patch to a new branch in the coreutils official
repository?  Or it's better if I clone the coreutils repo on GitHub
and work there, to have more freedom while experimenting?

Regards,
  Stefano
>From c71f1ea695ba9ee3ecc6bbaa8136a9dbf6b18df9 Mon Sep 17 00:00:00 2001
Message-Id: <c71f1ea69[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Fri, 20 Apr 2012 13:28:28 +0200
Subject: [PATCH] build: support and require Automake-NG

* configure.ac (AC_PREREQ): Require Autoconf version >= 2.65,
since that is the minimal version supported by Automake-NG.
(AM_INIT_AUTOMAKE): Add the 'ng' option, to ensure that mainstream
Automake is not used by mistake when bootstrapping.  Also, bump the
required Automake version from '1.11.1' to '1.12a', which is the
latest (and still development-only) version of Automake-NG at the
moment of writing.
* bootstrap: Updated from latest Gnulib.  In particular ...
(check_versions): ...  this now handles the automake and aclocal
from Automake-NG.
* bootstrap.conf ($buildreq): Require 'automake-ng' and
'aclocal-ng'; don't require mainstream 'automake' anymore.
Bump required 'autoconf' version to 2.65.
* m4/mkdirp-compat.m4: New file, contain a definition of the macro
'AM_PROG_MKDIR_P' (simply as an alias to the Autoconf-provided
macro 'AC_PROG_MKDIR_P'), that is used by the Gettext-provided
macro 'AM_PO_SUBDIRS', but which has been removed in Automake-NG
(as well as in the master branch of mainline Automake).

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 bootstrap           |   44 ++++++++++++++++++++++++++++++++++++++++----
 bootstrap.conf      |    5 +++--
 configure.ac        |    4 ++--
 m4/mkdirp-compat.m4 |   24 ++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 8 deletions(-)
 create mode 100644 m4/mkdirp-compat.m4

diff --git a/bootstrap b/bootstrap
index c8ee3cc..c496d29 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2012-02-11.09; # UTC
+scriptversion=2012-04-26.13; # UTC
 
 # Bootstrap this package from checked-out sources.
 
@@ -36,6 +36,10 @@ nl='
 LC_ALL=C
 export LC_ALL
 
+# Ensure that CDPATH is not set.  Otherwise, the output from cd
+# would cause trouble in at least one use below.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
 local_gl_dir=gl
 
 me=$0
@@ -423,12 +427,28 @@ check_versions() {
       $use_git || continue
     fi
     # Honor $APP variables ($TAR, $AUTOCONF, etc.)
-    appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
+    appvar=`echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
     test "$appvar" = TAR && appvar=AMTAR
     case $appvar in
         GZIP) ;; # Do not use $GZIP:  it contains gzip options.
         *) eval "app=\${$appvar-$app}" ;;
     esac
+
+    # Handle the still-experimental Automake-NG programs specially.
+    # They remain named as the mainstream Automake programs ("automake",
+    # and "aclocal") to avoid gratuitous incompatibilities with
+    # pre-existing usages (by, say, autoreconf, or custom autogen.sh
+    # scripts), but correctly identify themselves (as being part of
+    # "GNU automake-ng") when asked their version.
+    case $app in
+      automake-ng|aclocal-ng)
+        app=`echo "$app" | sed 's/-ng$//'`
+        ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
+          echo "$me: Error: '$app' not found or not from Automake-NG" >&2
+          ret=1
+          continue
+        } ;;
+    esac
     if [ "$req_ver" = "-" ]; then
       # Merely require app to exist; not all prereq apps are well-behaved
       # so we have to rely on $? rather than get_version.
@@ -758,9 +778,15 @@ fi
 # Autoreconf runs aclocal before libtoolize, which causes spurious
 # warnings if the initial aclocal is confused by the libtoolized
 # (or worse out-of-date) macro directory.
+# libtoolize 1.9b added the --install option; but we support back
+# to libtoolize 1.5.22, where the install action was default.
 if test $use_libtool = 1; then
-  echo "running: $LIBTOOLIZE --copy --install"
-  $LIBTOOLIZE --copy --install
+  install=
+  case $($LIBTOOLIZE --help) in
+    *--install*) install=--install ;;
+  esac
+  echo "running: $LIBTOOLIZE $install --copy"
+  $LIBTOOLIZE $install --copy
 fi
 
 version_controlled_file() {
@@ -863,6 +889,16 @@ if test $with_gettext = yes; then
     }
   ' po/Makevars.template >po/Makevars || exit 1
 
+  # If the 'gettext' module is in use, grab the latest Makefile.in.in.
+  # If only the 'gettext-h' module is in use, assume autopoint already
+  # put the correct version of this file into place.
+  case $gnulib_modules in
+  *gettext-h*) ;;
+  *gettext*)
+    cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in || exit 1
+    ;;
+  esac
+
   if test -d runtime-po; then
     # Similarly for runtime-po/Makevars, but not quite the same.
     rm -f runtime-po/Makevars
diff --git a/bootstrap.conf b/bootstrap.conf
index eab6606..ea6f75b 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -308,8 +308,9 @@ gnulib_tool_option_extras="--tests-base=gnulib-tests --with-tests --symlink\
 
 # Build prerequisites
 buildreq="\
-autoconf   2.64
-automake   1.11.1
+automake-ng -
+aclocal-ng  -
+autoconf   2.65
 autopoint  -
 bison      -
 gettext    0.17
diff --git a/configure.ac b/configure.ac
index 5a4860e..e327665 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@
 
 dnl Written by Jim Meyering.
 
-AC_PREREQ([2.64])
+AC_PREREQ([2.65])
 
 # Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which
 # indicates that it is built from the 219th delta (in _some_ repository)
@@ -32,7 +32,7 @@ AC_CONFIG_SRCDIR([src/ls.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
 
-AM_INIT_AUTOMAKE([1.11.1 no-dist-gzip dist-xz color-tests parallel-tests])
+AM_INIT_AUTOMAKE([1.12a ng no-dist-gzip dist-xz color-tests parallel-tests])
 AM_SILENT_RULES([yes]) # make --enable-silent-rules the default.
 
 dnl POSIXCHECK is worthwhile for maintainers, but adds several seconds
diff --git a/m4/mkdirp-compat.m4 b/m4/mkdirp-compat.m4
new file mode 100644
index 0000000..0cec37f
--- /dev/null
+++ b/m4/mkdirp-compat.m4
@@ -0,0 +1,24 @@
+# mkdirp-compat.m4 serial 1
+
+# Define of the macro 'AM_PROG_MKDIR_P', simply as an alias to
+# the Autoconf-provided macro 'AC_PROG_MKDIR_P'.
+# AM_PROG_MKDIR_P is still used by the Gettext-provided macro
+# 'AM_PO_SUBDIRS', but has been removed in Automake-NG (as well
+# as in the master branch of mainline Automake).
+
+# Copyright (C) 2012 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([AM_PROG_MKDIR_P], [AC_PROG_MKDIR_P])
-- 
1.7.9.5