[Automake-NG] [FYI] [ng] dist: refactor handling of dist formats a little

2012-08-10 Thread Stefano Lattarini
* automake.in (handle_dist): Define list of default dist formats in the
new internal make variable 'am.dist.formats'.  Related adjustments.
(preprocess_file): Drop the following now-unused transforms: XZ, LZMA,
LZIP, BZIP2, COMPRESS, GZIP, SHAR, ZIP.
* lib/am/distdir.am: Drop any use of the removed transforms, throughout.
(DIST_TARGETS): Redefine in function of '$(am.dist.formats)'.
(.PHONY): Update in function of '$(am.dist.formats)'.
(am.dist.ext.gzip, am.dist.ext.bzip2, am.dist.ext.xz, am.dist.ext.lzip,
am.dist.ext.tarZ, am.dist.ext.shar, am.dist.ext.zip): New internal
variables.
(DIST_ARCHIVES): Redefine in function of them and of '$(am.dist.formats)'.

Signed-off-by: Stefano Lattarini 
---
 automake.in   | 34 --
 lib/am/distdir.am | 36 ++--
 2 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/automake.in b/automake.in
index c1806ab..71aa25e 100644
--- a/automake.in
+++ b/automake.in
@@ -3210,16 +3210,22 @@ sub handle_dist ()
   # The remaining definitions are only required when a dist target is used.
   return if option 'no-dist';
 
-  # At least one of the archive formats must be enabled.
+  # The list of tarball formats we must support.
+  my @archive_formats;
   if ($relative_dir eq '.')
 {
-  my $archive_defined = option 'no-dist-gzip' ? 0 : 1;
-  $archive_defined ||=
-   grep { option "dist-$_" } qw(shar zip tarZ bzip2 lzip lzma xz);
-  error (option 'no-dist-gzip',
-"no-dist-gzip specified but no dist-* specified,\n"
-. "at least one archive format must be enabled")
-   unless $archive_defined;
+  push @archive_formats, 'gzip' unless option 'no-dist-gzip';
+  foreach my $fmt (qw/shar zip tarZ bzip2 lzip xz/)
+{
+  push @archive_formats, $fmt if option "dist-$fmt";
+}
+  # At least one of the archive formats must be enabled.
+  if (@archive_formats == 0)
+{
+  error (option 'no-dist-gzip',
+ "no-dist-gzip specified but no dist-* specified,\n"
+ . "at least one archive format must be enabled");
+}
 }
 
   # Look for common files that should be included in distribution.
@@ -3281,6 +3287,7 @@ sub handle_dist ()
rule ('distcheck-hook') ? 'yes' : '');
   define_variable ('am.dist.handle-gettext', INTERNAL,
$seen_gettext && !$seen_gettext_external ? 'yes' : '');
+  define_variable ('am.dist.formats', INTERNAL, @archive_formats);
 
   # If the target 'dist-hook' exists, make sure it is run.  This
   # allows users to do random weird things to the distribution
@@ -5666,16 +5673,7 @@ sub preprocess_file ($%)
 
   # Complete %transform with global options.
   # Note that %transform goes last, so it overrides global options.
-  %transform = ( 'XZ'  => !! option 'dist-xz',
-'LZMA'=> !! option 'dist-lzma',
-'LZIP'=> !! option 'dist-lzip',
-'BZIP2'   => !! option 'dist-bzip2',
-'COMPRESS'=> !! option 'dist-tarZ',
-'GZIP'=>  ! option 'no-dist-gzip',
-'SHAR'=> !! option 'dist-shar',
-'ZIP' => !! option 'dist-zip',
-
-'INSTALL-INFO' =>  ! option 'no-installinfo',
+  %transform = ( 'INSTALL-INFO' =>  ! option 'no-installinfo',
 'INSTALL-MAN'  =>  ! option 'no-installman',
 'HAVE-MANS'=> !! var ('MANS'),
 'CK-NEWS'  => !! option 'check-news',
diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index 7595412..35d9a71 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -313,58 +313,50 @@ endif %?TOPDIR_P%
 
 if %?TOPDIR_P%
 
-?GZIP?DIST_ARCHIVES += $(distdir).tar.gz
+am.dist.ext.gzip  = tar.gz
+am.dist.ext.bzip2 = tar.bz2
+am.dist.ext.xz= tar.xz
+am.dist.ext.lzip  = tar.lz
+am.dist.ext.tarZ  = tar.Z
+am.dist.ext.shar  = shar.gz
+am.dist.ext.zip   = zip
+
+DIST_TARGETS  = $(foreach x,$(am.dist.formats),dist-$x)
+DIST_ARCHIVES = $(foreach x,$(am.dist.formats),$(distdir).$(am.dist.ext.$x))
+# FIXME: hack to prevent the dumb Automake parser from mangling the list of
+# .PHONY targets.
+$(am.chars.empty).PHONY: $(foreach x,$(am.dist.formats),dist-$x)
+
 GZIP_ENV = --best
-.PHONY: dist-gzip
 dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c 
>$(distdir).tar.gz
$(am__post_remove_distdir)
 
-?BZIP2?DIST_ARCHIVES += $(distdir).tar.bz2
-.PHONY: dist-bzip2
 dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c 
>$(distdir).tar.bz2
$(am__post_remove_distdir)
 
-?LZIP?DIST_ARCHIVES += $(distdir).tar.lz
-.PHONY: dist-lzip
 dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} 
>$(distdir).tar.lz
$(am__post_remove_distdir)
 
-?XZ?DIST_ARCHIVES += $(distdir).tar.xz
-.PHONY: dist-xz
 dist-xz: distdir

[Automake-NG] [FYI 2/2] [ng] rename: am.write-list-of-distfiles -> am.dist.write-filelist

2012-08-10 Thread Stefano Lattarini
* lib/am/distdir.am: Here.

Signed-off-by: Stefano Lattarini 
---
 lib/am/distdir.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index 46cd51b..7595412 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -75,7 +75,7 @@ am.dist.parent-dirs = \
 
 am.dist.xmkdir = \
   @$(MKDIR_P) $(patsubst %,"$(distdir)"/%,$1)$(am.chars.newline)
-am.write-list-of-distfiles = \
+am.dist.write-filelist = \
   @lst='$1'; for x in $$lst; do echo $$x; done \
 >> $(am.dir)/$@-list$(am.chars.newline)
 
@@ -169,7 +169,7 @@ endif %?TOPDIR_P%
 ## distribute could actually be a cross-filesystem symlink -- this can
 ## easily happen if "gettextize" was run on the distribution.
@rm -f $(am.dir)/$@-list
-   $(call am.xargs-map,am.write-list-of-distfiles, \
+   $(call am.xargs-map,am.dist.write-filelist, \
   $(am.dist.files-cooked))
@while read file; do \
 ## Always look for the file or directory to distribute in the build
-- 
1.7.12.rc0




[Automake-NG] [FYI 1/2] [ng] rename: am.mkdir-for-dist -> am.dist.xmkdir

2012-08-10 Thread Stefano Lattarini
* lib/am/distdir.am: Here.

Signed-off-by: Stefano Lattarini 
---
 lib/am/distdir.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index 2a08ad9..46cd51b 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -73,7 +73,7 @@ am.dist.parent-dirs = \
   $(call am.memoize,am.dist.parent-dirs,$(strip $(sort \
 $(filter-out ., $(patsubst ./%,%,$(dir $(am.dist.files-cooked)))
 
-am.mkdir-for-dist = \
+am.dist.xmkdir = \
   @$(MKDIR_P) $(patsubst %,"$(distdir)"/%,$1)$(am.chars.newline)
 am.write-list-of-distfiles = \
   @lst='$1'; for x in $$lst; do echo $$x; done \
@@ -161,7 +161,7 @@ if %?TOPDIR_P%
 endif %?TOPDIR_P%
 ## Make the subdirectories for the files, avoiding to exceed command
 ## line length limitations.
-   $(call am.xargs-map,am.mkdir-for-dist,$(am.dist.parent-dirs))
+   $(call am.xargs-map,am.dist.xmkdir,$(am.dist.parent-dirs))
 ## Install the files and directories, applying a "VPATH rewrite"
 ## by hand where needed.
 ## To get the files in the distribution directory, use 'cp', not 'ln'.
-- 
1.7.12.rc0




[Automake-NG] [FYI] [ng] distcheck: include it as a verbatim makefile fragment

2012-08-10 Thread Stefano Lattarini
* lib/am/distcheck.am: Rename ...
* lib/am/distcheck.mk: ... like this, and adjust to use GNU
make conditionals rather than Automake ones, and to allow for
user overrides of the '$(distcleancheck_listfiles)' variable.
Fix some comments while at it.
* automake.in (handle_dist): Include it suing the 'verbatim'
function.
* Makefile.am (dist_am_DATA): Adjust.
* t/distcheck-configure-flags-am.sh: Remove obsolete grepping
checks, that would cause the test to fails spuriously.
* t/distcheck-configure-flags.sh: Likewise.

Signed-off-by: Stefano Lattarini 
---
 Makefile.am   |  2 +-
 automake.in   |  3 +--
 lib/am/{distcheck.am => distcheck.mk} | 12 +++-
 t/distcheck-configure-flags-am.sh |  5 -
 t/distcheck-configure-flags.sh|  2 --
 5 files changed, 9 insertions(+), 15 deletions(-)
 rename lib/am/{distcheck.am => distcheck.mk} (95%)

diff --git a/Makefile.am b/Makefile.am
index 90c32fd..24b75d0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -195,11 +195,11 @@ dist_am_DATA = \
   lib/am/header-vars.mk \
   lib/am/tags.mk \
   lib/am/dejagnu.mk \
+  lib/am/distcheck.mk \
   lib/am/compile.am \
   lib/am/configure.am \
   lib/am/data.am \
   lib/am/depend2.am \
-  lib/am/distcheck.am \
   lib/am/distdir.am \
   lib/am/footer.am \
   lib/am/header.am \
diff --git a/automake.in b/automake.in
index ee4b192..c1806ab 100644
--- a/automake.in
+++ b/automake.in
@@ -3297,8 +3297,7 @@ sub handle_dist ()
   %transform,
   FILENAME_FILTER => $filename_filter,
'DIST-COMMON' => "@dist_common");
-  $output_rules .= &file_contents ('distcheck', new Automake::Location)
-if $relative_dir eq '.';
+  verbatim ('distcheck') if $relative_dir eq '.';
 }
 
 
diff --git a/lib/am/distcheck.am b/lib/am/distcheck.mk
similarity index 95%
rename from lib/am/distcheck.am
rename to lib/am/distcheck.mk
index a6f47d2..b358997 100644
--- a/lib/am/distcheck.am
+++ b/lib/am/distcheck.mk
@@ -15,9 +15,9 @@
 #  Checking the distribution.  #
 #  #
 
-if %?SUBDIRS%
+ifdef SUBDIRS
 AM_RECURSIVE_TARGETS += distcheck
-endif %?SUBDIRS%
+endif
 
 # This target untars the dist file and tries a VPATH configuration.  Then
 # it guarantees that the distribution is self-contained by making another
@@ -136,10 +136,12 @@ distuninstallcheck:
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
 
-## Define distcleancheck_listfiles and distcleancheck separately
-## from distcheck, so that they can be overridden by the user.
+# Define '$(distcleancheck_listfiles)' and 'distcleancheck' separately
+# from distcheck, so that they can be overridden by the user.
+ifeq ($(call am.vars.is-undef,distcleancheck_listfiles),yes)
+  distcleancheck_listfiles := find . -type f -print
+endif
 .PHONY: distcleancheck
-distcleancheck_listfiles = find . -type f -print
 distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
diff --git a/t/distcheck-configure-flags-am.sh 
b/t/distcheck-configure-flags-am.sh
index 828199e..f01a9b2 100755
--- a/t/distcheck-configure-flags-am.sh
+++ b/t/distcheck-configure-flags-am.sh
@@ -37,11 +37,6 @@ END
 
 $ACLOCAL
 $AUTOMAKE
-$FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
-$FGREP '$(AM_DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
-grep 'DISTCHECK_CONFIGURE_FLAGS.*AM_DISTCHECK_CONFIGURE_FLAGS' Makefile.in \
-  && exit 1
-
 $AUTOCONF
 ./configure --enable-success sentence='it works :-)'
 
diff --git a/t/distcheck-configure-flags.sh b/t/distcheck-configure-flags.sh
index fdec9a5..998c43d 100755
--- a/t/distcheck-configure-flags.sh
+++ b/t/distcheck-configure-flags.sh
@@ -32,8 +32,6 @@ unset sentence || :
 
 $ACLOCAL
 $AUTOMAKE
-$FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
-
 $AUTOCONF
 ./configure --enable-success sentence='it works :-)'
 
-- 
1.7.12.rc0




[Automake-NG] [FYI] [ng] distcheck: move in its own '*.am' fragment

2012-08-10 Thread Stefano Lattarini
* lib/am/distdir.am: From here ...
* lib/am/distcheck.am: ... to here.  That is especially useful because
all of the 'distcheck' target has to be protected by a if '%?TOPDIR_P%'
conditional (since the 'distcheck' target must only be present in the
top-level makefile), so that we can now remove this overly long
conditional from this fragment ...
* automake.in (handle_dist): ... and simply limiting the inclusion
of it to when '$reldir' is '.'.
* Makefile.am (dist_am_DATA): Adjust.

Signed-off-by: Stefano Lattarini 
---
 Makefile.am |   1 +
 automake.in |   2 +
 lib/am/distcheck.am | 151 
 lib/am/distdir.am   | 143 -
 4 files changed, 154 insertions(+), 143 deletions(-)
 create mode 100644 lib/am/distcheck.am

diff --git a/Makefile.am b/Makefile.am
index 42ed0f1..90c32fd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -199,6 +199,7 @@ dist_am_DATA = \
   lib/am/configure.am \
   lib/am/data.am \
   lib/am/depend2.am \
+  lib/am/distcheck.am \
   lib/am/distdir.am \
   lib/am/footer.am \
   lib/am/header.am \
diff --git a/automake.in b/automake.in
index d6bd1b0..ee4b192 100644
--- a/automake.in
+++ b/automake.in
@@ -3297,6 +3297,8 @@ sub handle_dist ()
   %transform,
   FILENAME_FILTER => $filename_filter,
'DIST-COMMON' => "@dist_common");
+  $output_rules .= &file_contents ('distcheck', new Automake::Location)
+if $relative_dir eq '.';
 }
 
 
diff --git a/lib/am/distcheck.am b/lib/am/distcheck.am
new file mode 100644
index 000..a6f47d2
--- /dev/null
+++ b/lib/am/distcheck.am
@@ -0,0 +1,151 @@
+## automake - create Makefile.in from Makefile.am
+## Copyright (C) 2001-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 2, 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.
+
+#  #
+#  Checking the distribution.  #
+#  #
+
+if %?SUBDIRS%
+AM_RECURSIVE_TARGETS += distcheck
+endif %?SUBDIRS%
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+.PHONY: distcheck
+distcheck: dist
+   case '$(DIST_ARCHIVES)' in \
+   *.tar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+   *.tar.bz2*) \
+ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+   *.tar.lz*) \
+ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+   *.tar.xz*) \
+ xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+   *.tar.Z*) \
+ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+   *.shar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+   *.zip*) \
+ unzip $(distdir).zip ;;\
+   esac
+## Make the new source tree read-only.  Distributions ought to work in
+## this case.  However, make the top-level directory writable so we
+## can make our new subdirs.
+   chmod -R a-w $(distdir)
+   chmod u+w $(distdir)
+   mkdir $(distdir)/_build $(distdir)/_inst
+## Undo the write access.
+   chmod a-w $(distdir)
+## With GNU make, the following command will be executed even with "make -n",
+## due to the presence of '$(MAKE)'.  That is normally all well (and '$(MAKE)'
+## is necessary for things like parallel distcheck), but here we don't want
+## execution.  To avoid MAKEFLAGS parsing hassles, use a witness file that a
+## non-'-n' run would have just created.
+   test -d $(distdir)/_build || exit 0; \
+## Compute the absolute path of '_inst'.  Strip any leading DOS drive
+## to allow DESTDIR installations.  Otherwise "$(DESTDIR)$(prefix)" would
+## expand to "c:/temp/am-dc-5668/c:/src/package/package-1.0/_inst".
+   dc_install_base=`cd $(distdir)/_inst && pwd | sed -e 
's,^[^:\\/]:[\\/],/,'` \
+## We will attempt a DESTDIR install in $dc_destdir.  We don't
+## create this directory under $dc_install_base, because it would
+## create very long directory names.
+ && dc_destdir="$${TMPDIR-/tmp}/am-dc-/" \
+ $(if $(am.dist.handle-distcheck-hook),&& $(MAKE) distcheck-hook) \
+ && cd $(distdir)/_build \
+ && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+   $(if $(am.dist.handle-gettext),--with-included-gettext) \
+## Additional flags for configure.  Keep this last in the configure
+## invocation so the developer and user can override previous options,
+## and let the user's f

[Automake-NG] [FYI] Merge branch 'master' into ng/master

2012-08-10 Thread Stefano Lattarini
commit b71160a4a1420c0e68a10b71af8d0990ab3d781d
Merge: 5468d52 ae1f40f
Author: Stefano Lattarini 
Date:   Fri Aug 10 17:44:57 2012 +0200

Merge branch 'master' into ng/master

* master:
  automake: remove an unused local variable
  distcheck: more resilient against possible failures
  cleanup: remove almost-unused global var 'am_relative_dir'

Signed-off-by: Stefano Lattarini 



[Automake-NG] [FYI] [ng] tests: reorganize gettext tests a bit

2012-08-10 Thread Stefano Lattarini
* t/gettext.sh: Move checks about PR/381 ...
* t/gettext-pr381.sh: ... to this new test.
* t/gettext.sh: Move checks about config.rpath requirement ...
* t/gettext-config-rpath.sh: ... to this new test.

Signed-off-by: Stefano Lattarini 
---
 t/gettext-config-rpath.sh | 45 +
 t/gettext-pr381.sh| 45 +
 t/gettext.sh  | 41 +++--
 3 files changed, 93 insertions(+), 38 deletions(-)
 create mode 100755 t/gettext-config-rpath.sh
 create mode 100755 t/gettext-pr381.sh

diff --git a/t/gettext-config-rpath.sh b/t/gettext-config-rpath.sh
new file mode 100755
index 000..613ee82
--- /dev/null
+++ b/t/gettext-config-rpath.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2002-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 2, 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 .
+
+# Check the config.rpath requirement.
+
+required='gettext'
+. ./defs || exit 1
+
+cat >> configure.ac << 'END'
+AM_GNU_GETTEXT
+# config.rpath is required by versions >= 0.14.3.
+AM_GNU_GETTEXT_VERSION([0.14.3])
+AC_OUTPUT
+END
+
+echo 'SUBDIRS = po intl' >Makefile.am
+mkdir po intl
+
+# If aclocal fails here, it may be that gettext is too old to provide
+# AM_GNU_GETTEXT_VERSION.  Similarly, autopoint will fail if it's
+# from an older version.  If gettext is too old to provide autopoint,
+# this will fail as well, so we're safe here.
+if ! $ACLOCAL && autopoint -n; then
+  skip_ "too old gettext installation"
+fi
+
+AUTOMAKE_fails --add-missing
+grep '^configure\.ac:.*required file.*config.rpath' stderr
+: > config.rpath
+$AUTOMAKE
+
+:
diff --git a/t/gettext-pr381.sh b/t/gettext-pr381.sh
new file mode 100755
index 000..1bb6320
--- /dev/null
+++ b/t/gettext-pr381.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2002-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 2, 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 .
+
+# Automake gettext support: regression check for PR/381:
+# 'SUBDIRS = po intl' must not be required if 'po/' doesn't exist.
+
+required='gettext'
+. ./defs || exit 1
+
+cat >> configure.ac << 'END'
+AM_GNU_GETTEXT
+AC_OUTPUT
+END
+
+$ACLOCAL
+
+: > config.guess
+: > config.rpath
+: > config.sub
+
+test ! -d po # Sanity check.
+mkdir sub
+echo 'SUBDIRS = sub' > Makefile.am
+$AUTOMAKE
+
+# Still, SUBDIRS must be defined.
+
+: > Makefile.am
+AUTOMAKE_fails
+grep '^configure\.ac:.*AM_GNU_GETTEXT used but SUBDIRS not defined' stderr
+
+:
diff --git a/t/gettext.sh b/t/gettext.sh
index 3527f70..5f89b61 100755
--- a/t/gettext.sh
+++ b/t/gettext.sh
@@ -19,36 +19,15 @@
 required='gettext'
 . ./defs || exit 1
 
-cat >>configure.ac <> configure.ac << 'END'
 AM_GNU_GETTEXT
-AM_GNU_GETTEXT_VERSION([0.14.3])
 AC_OUTPUT
 END
 
-: >Makefile.am
+: > Makefile.am
+: > config.rpath
 mkdir po intl
 
-# config.rpath is required by versions >= 0.14.3.  We try to verify
-# this requirement, but only when we find we have a working and recent
-# gettext installation.
-
-# If aclocal fails here, it may be that gettext is too old to
-# provide AM_GNU_GETTEXT_VERSION.
-if $ACLOCAL; then
-  # autopoint will fail if it's from an older version.
-  # If gettext is too old to provide autopoint, this will
-  # fail as well, so we're safe here.
-  if autopoint -n; then
-AUTOMAKE_fails --add-missing
-grep 'required.*config.rpath' stderr
-  fi
-fi
-
-: >config.rpath
-sed '/AM_GNU_GETTEXT_VERSION/d' configure.ac >configure.int
-mv -f configure.int configure.ac
-
-rm -rf autom4te.cache
 $ACLOCAL
 $AUTOCONF
 
@@ -76,18 +55,4 @@ echo distdir: > po/Makefile
 echo distdir: > intl/Makefile
 $MAKE -n distcheck | grep '.*--with-included-gettext'
 
-# 'SUBDIRS = po intl' isn't required if po/ doesn't exist.
-# PR/381.
-
-rm -rf po
-mkdir sub
-echo 'SUBDIRS = sub' >Makefile.am
-$AUTOMAKE
-
-# Still, SUBDIR

[Automake-NG] [FYI] [ng] tests: avoid spurious failure in a gettext test

2012-08-10 Thread Stefano Lattarini
* t/gettext2.sh: Here, remove obsolete grepping checks in favor
of more modern ones.
* t/gettext.sh: Likewise.  This doesn't fix any failure, but
makes the test more reliable.

Signed-off-by: Stefano Lattarini 
---
 t/gettext.sh  | 12 +---
 t/gettext2.sh |  4 +++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/t/gettext.sh b/t/gettext.sh
index a1925f1..3527f70 100755
--- a/t/gettext.sh
+++ b/t/gettext.sh
@@ -35,7 +35,6 @@ mkdir po intl
 # If aclocal fails here, it may be that gettext is too old to
 # provide AM_GNU_GETTEXT_VERSION.
 if $ACLOCAL; then
-
   # autopoint will fail if it's from an older version.
   # If gettext is too old to provide autopoint, this will
   # fail as well, so we're safe here.
@@ -49,7 +48,9 @@ fi
 sed '/AM_GNU_GETTEXT_VERSION/d' configure.ac >configure.int
 mv -f configure.int configure.ac
 
+rm -rf autom4te.cache
 $ACLOCAL
+$AUTOCONF
 
 # po/ and intl/ are required.
 
@@ -70,12 +71,15 @@ echo 'SUBDIRS = po intl' >Makefile.am
 $AUTOMAKE --add-missing
 
 # Make sure distcheck runs './configure --with-included-gettext'.
-grep 'with-included-gettext' Makefile.in
+./configure
+echo distdir: > po/Makefile
+echo distdir: > intl/Makefile
+$MAKE -n distcheck | grep '.*--with-included-gettext'
 
 # 'SUBDIRS = po intl' isn't required if po/ doesn't exist.
 # PR/381.
 
-rmdir po
+rm -rf po
 mkdir sub
 echo 'SUBDIRS = sub' >Makefile.am
 $AUTOMAKE
@@ -85,3 +89,5 @@ $AUTOMAKE
 : >Makefile.am
 AUTOMAKE_fails --add-missing
 grep 'AM_GNU_GETTEXT.*SUBDIRS' stderr
+
+:
diff --git a/t/gettext2.sh b/t/gettext2.sh
index f3d91b0..960ef36 100755
--- a/t/gettext2.sh
+++ b/t/gettext2.sh
@@ -29,6 +29,7 @@ END
 mkdir foo po
 
 $ACLOCAL
+$AUTOCONF
 
 # config.rpath is required.
 : >config.rpath
@@ -49,7 +50,8 @@ $AUTOMAKE --add-missing
 
 # Don't try running ./configure --with-included-gettext if the
 # user is using AM_GNU_GETTEXT([external]).
-grep 'with-included-gettext' Makefile.in && exit 1
+./configure
+$MAKE -n distcheck | grep 'with-included-gettext' && exit 1
 
 # intl/ isn't wanted with AM_GNU_GETTEXT([external]).
 
-- 
1.7.12.rc0




[Automake-NG] [FYI] [ng] tests: adjust weaknesses in the gettext tests

2012-08-10 Thread Stefano Lattarini
* t/gettext-macros.sh (m4/mk-dirp.m4): Define 'AM_PROG_MKDIR_P' rather
than 'AM_MKDIR_P', and in doing so, use 'AC_PROG_MKDIR_P' rather than
'AC_MKDIR_P'.

Signed-off-by: Stefano Lattarini 
---
 t/gettext-macros.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/gettext-macros.sh b/t/gettext-macros.sh
index 1d94dad..fad34a9 100755
--- a/t/gettext-macros.sh
+++ b/t/gettext-macros.sh
@@ -80,7 +80,7 @@ echo "export ACLOCAL_PATH" >> get.sh
 
 # Even recent versions of gettext used the now-obsolete 'AM_PROG_MKDIR_P'
 # m4 macro.  So we need the following to avoid spurious errors.
-echo 'AC_DEFUN([AM_MKDIR_P], [AC_MKDIR_P([$@])])' >> m4/mk-dirp.m4
+echo 'AC_DEFUN([AM_PROG_MKDIR_P], [AC_PROG_MKDIR_P([$@])])' >m4/am-mkdirp.m4
 
 . ./get.sh
 
-- 
1.7.12.rc0




[Automake-NG] [FYI] [ng] distcheck: --with-included-gettext: with a variable, not a transform

2012-08-10 Thread Stefano Lattarini
This is mostly a preparatory refactoring in view of future changes.

* automake.in (handle_dist): Define the new internal variable
'am.dist.handle-gettext' to "yes" if the package uses gettext,
to the empty string otherwise.  This takes over the role of the
transform 'GETTEXT', which has thus been removed.
* lib/am/distdir.am (distcheck): Adjust to rely on the new variable
instead than of the removed transform.

Signed-off-by: Stefano Lattarini 
---
 automake.in   | 3 ++-
 lib/am/distdir.am | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/automake.in b/automake.in
index 247da23..a7f423b 100644
--- a/automake.in
+++ b/automake.in
@@ -3285,7 +3285,8 @@ sub handle_dist ()
 
   define_variable ('am.dist.handle-distcheck-hook', INTERNAL,
rule ('distcheck-hook') ? 'yes' : '');
-  $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external;
+  define_variable ('am.dist.handle-gettext', INTERNAL,
+   $seen_gettext && !$seen_gettext_external ? 'yes' : '');
 
   # If the target 'dist-hook' exists, make sure it is run.  This
   # allows users to do random weird things to the distribution
diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index 8135062..844515e 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -446,7 +446,7 @@ distcheck: dist
  $(if $(am.dist.handle-distcheck-hook),&& $(MAKE) distcheck-hook) \
  && cd $(distdir)/_build \
  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
-?GETTEXT?  --with-included-gettext \
+   $(if $(am.dist.handle-gettext),--with-included-gettext) \
 ## Additional flags for configure.  Keep this last in the configure
 ## invocation so the developer and user can override previous options,
 ## and let the user's flags take precedence over the developer's ones.
-- 
1.7.12.rc0




[Automake-NG] [FYI] [ng] disthook: use a variable, not a transform, to decide whether to run it

2012-08-10 Thread Stefano Lattarini
This is mostly a preparatory refactoring in view of future changes.

* automake.in (handle_dist): Here, define the internal variable
'am.conf.handle-distcheck-hook' to "yes" if a user-defined
'distcheck-hook' rule, to the empty string otherwise.  This take
over the role of the transform 'DISTCHECK-HOOK', which has thus
been removed.
* lib/am/distdir.am (distcheck): Adjust to rely on the new variable
instead than of the removed transform.
* t/distcheck-hook.sh: Remove obsolete or obsolescent grepping checks.
* t/distcheck-hook2.sh: Likewise.

Signed-off-by: Stefano Lattarini 
---
 automake.in  | 3 ++-
 lib/am/distdir.am| 2 +-
 t/distcheck-hook.sh  | 4 
 t/distcheck-hook2.sh | 7 ---
 4 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/automake.in b/automake.in
index 153c246..5a43a47 100644
--- a/automake.in
+++ b/automake.in
@@ -3283,7 +3283,8 @@ sub handle_dist ()
   # relented.
   my $extra_dist = var ('EXTRA_DIST');
 
-  $transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook';
+  define_variable ('am.conf.handle-distcheck-hook', INTERNAL,
+   rule ('distcheck-hook') ? 'yes' : '');
   $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external;
 
   # If the target 'dist-hook' exists, make sure it is run.  This
diff --git a/lib/am/distdir.am b/lib/am/distdir.am
index efe576c..7ee1277 100644
--- a/lib/am/distdir.am
+++ b/lib/am/distdir.am
@@ -443,7 +443,7 @@ distcheck: dist
 ## create this directory under $dc_install_base, because it would
 ## create very long directory names.
  && dc_destdir="$${TMPDIR-/tmp}/am-dc-/" \
-?DISTCHECK-HOOK? && $(MAKE) distcheck-hook \
+ $(if $(am.conf.handle-distcheck-hook),&& $(MAKE) distcheck-hook) \
  && cd $(distdir)/_build \
  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
 ?GETTEXT?  --with-included-gettext \
diff --git a/t/distcheck-hook.sh b/t/distcheck-hook.sh
index ef64805..f806e4b 100755
--- a/t/distcheck-hook.sh
+++ b/t/distcheck-hook.sh
@@ -35,10 +35,6 @@ END
 
 $ACLOCAL
 $AUTOMAKE
-$FGREP 'distcheck-hook' Makefile.in
-$FGREP '$(MAKE) distcheck-hook' Makefile.in
-grep '^distcheck-hook:' Makefile.in
-
 $AUTOCONF
 ./configure
 
diff --git a/t/distcheck-hook2.sh b/t/distcheck-hook2.sh
index 7c7352b..de4c155 100755
--- a/t/distcheck-hook2.sh
+++ b/t/distcheck-hook2.sh
@@ -60,13 +60,6 @@ $AUTOMAKE
 $AUTOCONF
 cd ..
 
-# For debugging.
-$FGREP 'distcheck-hook' Makefile.in subpkg/Makefile.in
-
-$FGREP 'distcheck-hook' subpkg/Makefile.in && exit 1
-$FGREP '$(MAKE) distcheck-hook' Makefile.in
-grep '^distcheck-hook:' Makefile.in
-
 ./configure
 
 $MAKE
-- 
1.7.12.rc0




[Automake-NG] [FYI] Merge branch 'master' into ng/master

2012-08-10 Thread Stefano Lattarini
commit 1a6ebd193bc78a3c6641b62df2ff5369ec09c584
Merge: c84bdee 03b7cf9
Author: Stefano Lattarini 
AuthorDate: Fri Aug 10 13:27:14 2012 +0200
Commit: Stefano Lattarini 
CommitDate: Fri Aug 10 13:27:14 2012 +0200

Merge branch 'master' into ng/master

* master:
  cleanup: remove two almost-unused global variables: {am,in}_file_name
  cleanup: remove almost-unused global var 'topsrcdir'
  automake: remove an unused variable
  tests: make a test script more semantic
  tests: remove an obsolete, no-op test script
  tests: remove an obsolete test script

Signed-off-by: Stefano Lattarini 



Re: [Automake-NG] [PATCH 0/5] install/uninstall rules overhaul

2012-08-10 Thread Stefano Lattarini
On 08/09/2012 12:08 PM, Stefano Lattarini wrote:
> At least do some first steps in that direction.  Unfortunately, the
> need to support $(program_transform_name) is seriously hampering
> further progress; but I'm not sure removing that feature without
> further considerations would be a good idea, so let's stop at
> these patches for the moment.
> 
> I'll push this series in a few hours.
> 
> Regards,
>   Stefano
> 
> -*-*-*-
> 
> Stefano Lattarini (5):
>   [ng] refactor: remove all uses of '$(am__strip_dir)'
>   [ng] refactor: remove all uses of $(am__nobase_strip{,_setup})
>   [ng] am.xargs-map: can pass further arguments to the mapped function
>   [ng] uninstall: reimplement various recipes using more GNU make features
>   [ng] uninstall: refactor, more processing delegated to GNU make
> 
>  lib/am/data.am|  8 ++---
>  lib/am/header-vars.mk | 95 
> ++-
>  lib/am/libs.am| 18 +-
>  lib/am/lisp.am| 41 +++---
>  lib/am/ltlib.am   |  8 ++---
>  lib/am/mans.am| 16 -
>  lib/am/progs.am   | 23 ++---
>  lib/am/python.am  | 45 ++--
>  lib/am/scripts.am | 74 +++
>  lib/am/texinfos.am| 49 +-
>  t/am-xargs-map.sh | 60 +++-
>  t/internals.tap   | 29 +++-
>  12 files changed, 246 insertions(+), 220 deletions(-)
> 
Pushed now.

Regards,
  Stefano



Re: [Automake-NG] [PATCH] [ng] maintainer-mode: remove it altogether

2012-08-10 Thread Stefano Lattarini
On 08/09/2012 02:13 PM, Stefano Lattarini wrote:
> The best explanation for this move is given by excerpts from the
> Automake manual itself:
> 
> Several years ago François Pinard pointed out several arguments
> against this AM_MAINTAINER_MODE macro.  Most of them relate to
> insecurity.  By removing dependencies you get non-dependable builds:
> changes to sources files can have no effect on generated files and
> this can be very confusing when unnoticed.  He adds that security
> shouldn't be reserved to maintainers (what '--enable-maintainer-mode'
> suggests), on the contrary.  If one user has to modify a Makefile.am,
> then either Makefile.in should be updated or a error should be output
> (this is what Automake uses the 'missing' script for) but the last
> thing you want is that nothing happens and the user doesn't notice
> it (which is exactly what happens when rebuild rules are disabled by
> AM_MAINTAINER_MODE).
> 
> Jim Meyering, the inventor of the AM_MAINTAINER_MODE macro was swayed
> by François's arguments, and got rid of AM_MAINTAINER_MODE in all of
> his packages.
> 
> Since in Automake-NG we are breaking backward-compatibility in several
> ways already, this is a good occasion to get rid of another obsolescent,
> historical-reasons-only, more-dangerous-than-useful feature.
> 
> Admittedly, the manual went on saying:
> 
> Still many people continue to use AM_MAINTAINER_MODE, because it
> helps them working on projects where all files are kept under
> version control, and because missing isn't enough if you have the
> wrong version of the tools.
> 
> But then, the right solutions for using lies not in the use of the
> brittle AM_MAINTAINER_MODE macro; such solutions are indeed already
> explained in another section of the manual (in the section "CVS and
> generated files"):
> 
> In distributed development, developers are likely to have different
> version of the maintainer tools installed.  In this case rebuilds
> triggered by timestamp lossage will lead to spurious changes to
> generated files.  There are some popular solutions to this:
> 
> - All developers should use the same versions, so that the rebuilt
>   files are identical to files in CVS.  (This starts to be difficult
>   when each project you work on uses different versions).
> 
> - Or people use a script to fix the timestamp after a checkout (the
>   GCC folks have such a script).
> 
> The use of such a "timestamp-fixing" script is also suggested earlier
> in the section, in the discussion about the merits and limits of the
> 'missing' script.
> 
> * NG-NEWS: Update.
> * doc/automake-ng.texi: Likewise; among the other things ...
> (maintainer-mode): ... rename this node ...
> (maintainer tools): ... like this.
> * m4/maintainer.m4: Delete.
> * Makefile.am (dist_automake_ac_DATA): Delete.
> * automake.in ($seen_maint_mode): Remove this global variable.
> (scan_autoconf_trace): Don't trace 'AM_MAINTAINER_MODE'.
> (read_am_file): Don't special-handle '@MAINT@' substitutions;
> which were an anachronism anyway, according to pre-existing
> comments.
> (preprocess_file): Drop 'MAINTAINER-MODE' transform.
> * lib/am/configure.am: Remove all uses of the %MAINTAINER-MODE%
> transform.
> * lib/am/remake-hdr.am: Likewise.
> * lib/am/texi-vars.am: Likewise.
> * lib/am/lex.am, lib/am/yacc.am: Likewise, and simplify dropping
> the definition and use of (respectively) '$(am.lex.maybe-skip)'
> and '$(am.yacc.maybe-skip)'.
> * t/condlib.sh (configure.ac): Drop AM_MAINTAINER_MODE use.
> * t/flavor.sh: Likewise, and drop '--enable-maintainer-mode'
> from the './configure' invocation.
> * t/lex-pr204.sh: Remove as obsolete.
> * t/yacc-pr204.sh: Likewise.
> * t/maintmode-configure-msg.sh: Likewise.
> * t/mmode.sh: Likewise.
> * t/mmodely.sh: Likewise.
> * t/remake5.sh: Likewise.
> * t/lex-nodist.sh: Fix header comments to account for some of
> the deleted tests.
> * t/yacc-nodist.sh: Likewise.
>
Pushed now.

Regards,
  Stefano



[Automake-NG] [FYI] [ng] dejagnu: include verbatim

2012-08-10 Thread Stefano Lattarini
* lib/am/dejagnu.am: Rename ...
* lib/am/dejagnu.mk: ... like this, and rewrite partially to make it
readable verbatim.
* Makefile.am (dist_am_DATA): Adjust.
* automake.in (handle_tests): When DejaGNU support is needed, include
'dejagnu.mk' verbatim in the output Makefile.
* t/dejagnu2.sh: Adjust.

Signed-off-by: Stefano Lattarini 
---
 Makefile.am   |  2 +-
 automake.in   |  2 +-
 lib/am/dejagnu.mk | 56 ---
 t/dejagnu2.sh |  8 +---
 4 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index d2f014f..7d2b255 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -194,10 +194,10 @@ dist_am_DATA = \
   lib/am/clean.mk \
   lib/am/header-vars.mk \
   lib/am/tags.mk \
+  lib/am/dejagnu.mk \
   lib/am/compile.am \
   lib/am/configure.am \
   lib/am/data.am \
-  lib/am/dejagnu.am \
   lib/am/depend2.am \
   lib/am/distdir.am \
   lib/am/footer.am \
diff --git a/automake.in b/automake.in
index 4e28402..74560a4 100644
--- a/automake.in
+++ b/automake.in
@@ -3977,7 +3977,7 @@ sub handle_tests
 {
   if (option 'dejagnu')
 {
-  $output_rules .= file_contents ('dejagnu', new Automake::Location);
+  verbatim ('dejagnu');
 }
   else
 {
diff --git a/lib/am/dejagnu.mk b/lib/am/dejagnu.mk
index c3a9659..f34178b 100644
--- a/lib/am/dejagnu.mk
+++ b/lib/am/dejagnu.mk
@@ -14,15 +14,20 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see .
 
-## Name of tool to use.  Default is the same as the package.
+# Name of tool to use.  Default is the same as the package.
+ifeq ($(call am.vars.is-undef,DEJATOOL),yes)
 DEJATOOL = $(PACKAGE)
+endif
 
-## Default flags to pass to dejagnu.  The user can override this.
+# Default flags to pass to dejagnu.  The user can override this.
+ifeq ($(call am.vars.is-undef,$(RUNTESTDEFAULTFLAGS)),yes)
 RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
+endif
 
-EXPECT = expect
-RUNTEST = runtest
-
+# FIXME: is a good idea to let this being overridden from the
+# environment?
+EXPECT ?= expect
+RUNTEST ?= runtest
 
 .PHONY: check-DEJAGNU
 check-DEJAGNU: site.exp
@@ -40,13 +45,9 @@ check-DEJAGNU: site.exp
exit $$exit_status
 
 
-## --- ##
-## Building site.exp.  ##
-## --- ##
-
-## Note that in the rule we don't directly generate site.exp to avoid
-## the possibility of a corrupted site.exp if make is interrupted.
-## Jim Meyering has some useful text on this topic.
+# Note that in the rule we don't directly generate site.exp to avoid
+# the possibility of a corrupted site.exp if make is interrupted.
+# Jim Meyering has some useful text on this topic.
 site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
@echo 'Making a new site.exp file ...'
@echo '## these variables are automatically generated by make ##' 
>site.tmp
@@ -54,14 +55,20 @@ site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
@echo '# edit the last section' >>site.tmp
@echo 'set srcdir "$(srcdir)"' >>site.tmp
@echo "set objdir `pwd`" >>site.tmp
-## Quote the *_alias variables because they might be empty.
-   $(if $(am.conf.build-triplet),@echo 'set build_triplet $(build)' 
>>site.tmp)
-   $(if $(am.conf.build-triplet),@echo 'set build_alias "$(build_alias)"' 
>>site.tmp)
-   $(if $(am.conf.host-triplet),@echo 'set host_triplet $(host)' 
>>site.tmp)
-   $(if $(am.conf.host-triplet),@echo 'set host_alias "$(host_alias)"' 
>>site.tmp)
-   $(if $(am.conf.target-triplet),@echo 'set target_alias 
"$(target_alias)"' >>site.tmp)
-   $(if $(am.conf.target-triplet),@echo 'set target_triplet $(target)' 
>>site.tmp)
-## Allow the package author to extend site.exp.
+   @# Quote the *_alias variables because they might be empty.
+ifdef am.conf.build-triplet
+   @echo 'set build_triplet $(build)' >>site.tmp
+   @echo 'set build_alias "$(build_alias)"' >>site.tmp
+endif
+ifdef am.conf.host-triplet
+   @echo 'set host_triplet $(host)' >>site.tmp
+   @echo 'set host_alias "$(host_alias)"' >>site.tmp
+endif
+ifdef am.conf.target-triplet
+   @echo 'set target_triplet $(target)' >>site.tmp
+   @echo 'set target_alias "$(target_alias)"' >>site.tmp
+endif
+   @# Allow the package author to extend site.exp.
@list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
  echo "## Begin content included from file $$f.  Do not modify. ##" \
   && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
@@ -76,13 +83,8 @@ site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
@test ! -f site.exp || mv site.exp site.bak
@mv site.tmp site.exp
 
-## -- ##
-## Cleaning.  ##
-## -- ##
-
-## Any other cleaning must be done by the user or by the test suite
-## itself.  We can't predict what dejagnu or the test suite might
-## generate.
+# Any other cleaning must be done by the user or by the test suite it

[Automake-NG] [FYI] [ng] refactor: drop use of ?HOST?, ?BUILD? and ?TARGET? transforms

2012-08-10 Thread Stefano Lattarini
Instead, use the new make variables $(am.conf.host-triplet),
$(am.conf.build-triplet) and $(am.conf.host-triplet) are defined.

* automake.in (preprocess_file): Drop 'HOST', 'BUILD' and 'TARGET'
transforms.  Their role taken over ...
(generate_makefile): ... by the new variables 'am.conf.host-triplet',
'am.conf.build-triplet' and 'am.conf.target-triplet' defined here.
* lib/am/dejagnu.am: Adjust.
* t/triplet.sh: New test.

Signed-off-by: Stefano Lattarini 
---
 automake.in   | 14 +++
 lib/am/dejagnu.am | 12 -
 t/triplet.sh  | 73 +++
 3 files changed, 88 insertions(+), 11 deletions(-)
 create mode 100755 t/triplet.sh

diff --git a/automake.in b/automake.in
index c50e0ad..4e28402 100644
--- a/automake.in
+++ b/automake.in
@@ -5707,10 +5707,6 @@ sub preprocess_file ($%)
 'SUBDIRS'  => !! var ('SUBDIRS'),
 'TOPDIR_P' => $relative_dir eq '.',
 
-'BUILD'=> ($seen_canonical >= AC_CANONICAL_BUILD),
-'HOST' => ($seen_canonical >= AC_CANONICAL_HOST),
-'TARGET'   => ($seen_canonical >= AC_CANONICAL_TARGET),
-
 'LIBTOOL'  => !! var ('LIBTOOL'),
 'NONLIBTOOL'   => 1,
 'SILENT'   => silent_flag (),
@@ -6707,7 +6703,8 @@ sub generate_makefile ($$)
}
 }
 
-  # Must do this after reading .am file.
+  # Some of these must do this after reading .am file.
+
   define_variable ('subdir', INTERNAL, $relative_dir);
   define_variable ('am.conf.is-topdir', INTERNAL,
$relative_dir eq '.' ? "yes" : "");
@@ -6718,6 +6715,13 @@ sub generate_makefile ($$)
   define_variable ('am.relpath.makefile.in', INTERNAL,
prepend_srcdir ($makefile_in));
 
+  define_variable 'am.conf.build-triplet', INTERNAL,
+  $seen_canonical >= AC_CANONICAL_BUILD ? '$(build)' : '';
+  define_variable 'am.conf.host-triplet', INTERNAL,
+  $seen_canonical >= AC_CANONICAL_HOST ? '$(host)' : '';
+  define_variable 'am.conf.target-triplet', INTERNAL,
+  $seen_canonical >= AC_CANONICAL_TARGET ? '$(target)' : '';
+
   # If DIST_SUBDIRS is defined, make sure SUBDIRS is, so that
   # recursive rules are enabled.
   define_variable ('SUBDIRS', INTERNAL, '')
diff --git a/lib/am/dejagnu.am b/lib/am/dejagnu.am
index 42ba485..c3a9659 100644
--- a/lib/am/dejagnu.am
+++ b/lib/am/dejagnu.am
@@ -55,12 +55,12 @@ site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
@echo 'set srcdir "$(srcdir)"' >>site.tmp
@echo "set objdir `pwd`" >>site.tmp
 ## Quote the *_alias variables because they might be empty.
-?BUILD?@echo 'set build_alias "$(build_alias)"' >>site.tmp
-?BUILD?@echo 'set build_triplet $(build)' >>site.tmp
-?HOST? @echo 'set host_alias "$(host_alias)"' >>site.tmp
-?HOST? @echo 'set host_triplet $(host)' >>site.tmp
-?TARGET?   @echo 'set target_alias "$(target_alias)"' >>site.tmp
-?TARGET?   @echo 'set target_triplet $(target)' >>site.tmp
+   $(if $(am.conf.build-triplet),@echo 'set build_triplet $(build)' 
>>site.tmp)
+   $(if $(am.conf.build-triplet),@echo 'set build_alias "$(build_alias)"' 
>>site.tmp)
+   $(if $(am.conf.host-triplet),@echo 'set host_triplet $(host)' 
>>site.tmp)
+   $(if $(am.conf.host-triplet),@echo 'set host_alias "$(host_alias)"' 
>>site.tmp)
+   $(if $(am.conf.target-triplet),@echo 'set target_alias 
"$(target_alias)"' >>site.tmp)
+   $(if $(am.conf.target-triplet),@echo 'set target_triplet $(target)' 
>>site.tmp)
 ## Allow the package author to extend site.exp.
@list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
  echo "## Begin content included from file $$f.  Do not modify. ##" \
diff --git a/t/triplet.sh b/t/triplet.sh
new file mode 100755
index 000..f2796c3
--- /dev/null
+++ b/t/triplet.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# 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 2, 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 .
+
+# The $(host), $(build), $(target) variables, and their '*_alias'
+# and 'am.conf.*-triplet' counterparts.
+
+. ./defs || exit 1
+
+: > config.guess
+: > config.sub
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+grep "^am\.conf\.host-triplet = *$" Makefile.in
+grep "^am\.conf\.build-triplet = *$" Makefile.in
+grep "^am\.conf\.target-triplet = *$" Makefile

[Automake-NG] [FYI] {maint} cleanup: remove almost-unused global var 'topsrcdir'

2012-08-10 Thread Stefano Lattarini
Cherry picked from commit v1.12.2-740-ga7f24eb in AUtomake-NG.

* automake.in ($topsrcdir): Delete, it was only used once ...
(handle_LIBOBJS_or_ALLOCA): ... in here, so it's simpler to inline
its expansion.  Improve formatting of immediately surrounding code
a little while we are at it.
(initialize_per_input): Don't reset the deleted variable.

Signed-off-by: Stefano Lattarini 
---
 automake.in | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/automake.in b/automake.in
index 1a94c04..d85d361 100644
--- a/automake.in
+++ b/automake.in
@@ -484,9 +484,6 @@ my $am_relative_dir;
 my $in_file_name;
 my $relative_dir;
 
-# Relative path to the top directory.
-my $topsrcdir;
-
 # Greatest timestamp of the output's dependencies (excluding
 # configure's dependencies).
 my $output_deps_greatest_timestamp;
@@ -640,7 +637,6 @@ sub initialize_per_input ()
 
 $in_file_name = undef;
 $relative_dir = undef;
-$topsrcdir = undef;
 
 $output_deps_greatest_timestamp = 0;
 
@@ -2309,8 +2305,10 @@ sub handle_LIBOBJS_or_ALLOCA ($)
  # we are already there, and since the targets are built without
  # a $(top_builddir), it helps BSD Make to match them with
  # dependencies.
- $dir = "$config_libobj_dir/" if $config_libobj_dir ne '.';
- $dir = "$topsrcdir/$dir" if $relative_dir ne '.';
+ $dir = "$config_libobj_dir/"
+   if $config_libobj_dir ne '.';
+ $dir = backname ($relative_dir) . "/$dir"
+   if $relative_dir ne '.';
  define_variable ('LIBOBJDIR', "$dir", INTERNAL);
  $clean_files{"\$($var)"} = MOSTLY_CLEAN;
  # If LTLIBOBJS is used, we must also clear LIBOBJS (which might
@@ -8111,7 +8109,6 @@ sub generate_makefile ($$)
 
   $relative_dir = dirname ($makefile);
   $am_relative_dir = dirname ($makefile_am);
-  $topsrcdir = backname ($relative_dir);
 
   read_main_am_file ($makefile_am);
   if (handle_options)
-- 
1.7.12.rc0




[Automake-NG] [FYI] [ng] tags: rewrite to be included verbatim

2012-08-10 Thread Stefano Lattarini
* lib/am/tags.am: Moved ...
* lib/am/tags.mk: ... here, rewrite to be included verbatim, reformatted,
and enhanced to take over the role of ...
* automake.in (handle_tags): ... this function as well, which has thus
been removed.
(generate_makefile): Call the removed function no more.  Include 'tags.mk'
verbatim in the generated Makefile.
* Makefile.am (dist_am_DATA): Adjust.
* t/tags.sh: This weak grepping test is broken by the other changes done
here; so remove it, adding ...
* t/tags-id.sh: ... this in its place, which is more semantic, i.e.,
operated by actually running the 'ID' target.
* t/tags2.sh: Remove as obsolete.
* t/location.sh: Adjust to avoid spurious errors.
* t/targetclash.sh: Likewise.

Signed-off-by: Stefano Lattarini 
---
 Makefile.am |   2 +-
 automake.in |  32 +---
 lib/am/{tags.am => tags.mk} | 122 +++-
 t/location.sh   |   8 +--
 t/{tags.sh => tags-id.sh}   |  19 ++-
 t/tags2.sh  |  42 ---
 t/targetclash.sh|   4 +-
 7 files changed, 89 insertions(+), 140 deletions(-)
 rename lib/am/{tags.am => tags.mk} (62%)
 rename t/{tags.sh => tags-id.sh} (78%)
 delete mode 100755 t/tags2.sh

diff --git a/Makefile.am b/Makefile.am
index f85663c..d2f014f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -193,6 +193,7 @@ dist_am_DATA = \
   lib/am/check-typos.mk \
   lib/am/clean.mk \
   lib/am/header-vars.mk \
+  lib/am/tags.mk \
   lib/am/compile.am \
   lib/am/configure.am \
   lib/am/data.am \
@@ -217,7 +218,6 @@ dist_am_DATA = \
   lib/am/remake-hdr.am \
   lib/am/scripts.am \
   lib/am/subdirs.am \
-  lib/am/tags.am \
   lib/am/texi-vers.am \
   lib/am/texi-spec.am \
   lib/am/texinfos.am \
diff --git a/automake.in b/automake.in
index 5acd434..c50e0ad 100644
--- a/automake.in
+++ b/automake.in
@@ -3147,36 +3147,6 @@ sub handle_data
 'pkgdata', 'lisp', 'noinst', 'check');
 }
 
-# Handle TAGS.
-sub handle_tags
-{
-define_variable ('am.tags.files', INTERNAL,
- qw/$(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
-$(am.config-hdr.local.in)/);
-
-if (rvar('am.tags.files')->value_as_list_recursive
-  || var ('ETAGS_ARGS') || var ('SUBDIRS'))
-  {
-   $output_rules .= &file_contents ('tags', new Automake::Location);
-   set_seen 'TAGS_DEPENDENCIES';
-  }
-else
-  {
-reject_var ('TAGS_DEPENDENCIES',
-   "it doesn't make sense to define 'TAGS_DEPENDENCIES'"
-   . " without\nsources or 'ETAGS_ARGS'");
-   # Every Makefile must define some sort of TAGS rule.
-   # Otherwise, it would be possible for a top-level "make TAGS"
-   # to fail because some subdirectory failed.  Ditto ctags and
-# cscope.
-$output_rules .=
-  "tags TAGS:\n\n" .
-  "ctags CTAGS:\n\n" .
-  "cscope cscopelist:\n\n";
-  }
-}
-
-
 # user_phony_rule ($NAME)
 # ---
 # Return false if rule $NAME does not exist.  Otherwise,
@@ -6788,9 +6758,9 @@ sub generate_makefile ($$)
   handle_man_pages;
   handle_data;
   handle_headers;
+  verbatim ('tags');
   handle_subdirs;
   handle_user_recursion;
-  handle_tags;
   handle_minor_options;
 
   # Must come after invocation of handle_programs, handle_libraries and
diff --git a/lib/am/tags.am b/lib/am/tags.mk
similarity index 62%
rename from lib/am/tags.am
rename to lib/am/tags.mk
index bd7e2c7..aebd8b6 100644
--- a/lib/am/tags.am
+++ b/lib/am/tags.mk
@@ -14,6 +14,22 @@
 ## You should have received a copy of the GNU General Public License
 ## along with this program.  If not, see .
 
+# Every Makefile must define some sort of TAGS rule.  Otherwise, it
+# would be possible for a top-level "make TAGS" to fail because some
+# subdirectory failed.  Ditto for ctags and cscope.
+.PHONY: tags TAGS ctags CTAGS cscope cscopelist
+
+am.tags.files = \
+  $(call am.memoize,am.tags.files,$(strip \
+$(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) $(am.config-hdr.local.in)))
+
+# Let's see if we have to actually deal with tags creation.
+ifneq ($(or $(am.tags.files),$(ETAGS_ARGS),$(SUBDIRS)),)
+
+# -- #
+#  Tags-related internal variables.  #
+# -- #
+
 # Use $(sort) rather than $(am.util.uniq) here, because the former is
 # faster on long lists, and we don't care about the order of the list
 # anyway.
@@ -37,75 +53,70 @@ am.tags.subfiles = \
   $(call am.memoize,am.tags.subfiles,$(strip \
 $(foreach d,$(filter-out .,$(SUBDIRS)),$(wildcard $d/TAGS
 
-##  ##
-## ID.  ##
-##  ##
+
+# -- #
+#  ID database (from GNU id-utils).  #
+# -- #
 
 ID: $(am.tags.files)
mkid -fID $(am.tags.files.unique)
+am.clean.dist.f += ID
 
 
-## -- ##
-## TAGS.  ##
-## -- ##
+#  

[Automake-NG] [FYI] [ng] vars: new variable $(am.conf.is-topdir)

2012-08-10 Thread Stefano Lattarini
* automake.in (generate_makefile): Define that variable to "yes" if the
Makefile being currently generated is in the top-level directory, define
it to the empty string otherwise.  This offers a way (alternative to the
'%?TOPDIR_P%' transform) to determine whether a recipe is being executed
in the top-level directory or not.

Signed-off-by: Stefano Lattarini 
---
 automake.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/automake.in b/automake.in
index 3a9cca3..5acd434 100644
--- a/automake.in
+++ b/automake.in
@@ -6739,6 +6739,8 @@ sub generate_makefile ($$)
 
   # Must do this after reading .am file.
   define_variable ('subdir', INTERNAL, $relative_dir);
+  define_variable ('am.conf.is-topdir', INTERNAL,
+   $relative_dir eq '.' ? "yes" : "");
   define_variable ('am.conf.aux-dir', INTERNAL, $am_config_aux_dir);
   define_variable ('am.relpath.makefile', INTERNAL, basename ($makefile));
   define_variable ('am.relpath.makefile.am', INTERNAL,
-- 
1.7.12.rc0