automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AC_AUTOCONF_VERSION quoting


From: Eric Blake
Subject: AC_AUTOCONF_VERSION quoting
Date: Thu, 10 Apr 2008 15:59:13 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Automake should set a good example of proper macro quoting.  Expanding 
AC_AUTOCONF_VERSION is dangerous, since snapshot versions of autoconf include 
letters in the version string, which in turn could expand as inadvertent 
macros.  Is this okay to apply, as well as cherry-pick back to branch-1-10?

Meanwhile, now that Autoconf 2.62 is released, is it time to regenerate all the 
generated files in the automake repository with 2.62 rather than an autoconf 
snapshot?


>From 680877cce6a85e0a55a7659048c0431109f964b7 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 10 Apr 2008 09:51:23 -0600
Subject: [PATCH] AC_AUTOCONF_VERSION can inadvertently expand to a macro name.

* m4/amversion.in (AM_SET_CURRENT_AUTOMAKE_VERSION): Use proper
m4 quoting.
* aclocal.in (write_aclocal): Likewise.
* tests/missing6.test: New test.
* tests/Makefile.am (TESTS): Run it.
* tests/missing4.test: Adjust.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |   10 ++++++++++
 aclocal.in          |    2 +-
 m4/amversion.in     |    4 ++--
 tests/Makefile.am   |    1 +
 tests/missing4.test |    4 ++--
 tests/missing6.test |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 67 insertions(+), 5 deletions(-)
 create mode 100755 tests/missing6.test

diff --git a/ChangeLog b/ChangeLog
index 2ac33db..84df434 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-04-10  Eric Blake  <address@hidden>
+
+       AC_AUTOCONF_VERSION can inadvertently expand to a macro name.
+       * m4/amversion.in (AM_SET_CURRENT_AUTOMAKE_VERSION): Use proper
+       m4 quoting.
+       * aclocal.in (write_aclocal): Likewise.
+       * tests/missing6.test: New test.
+       * tests/Makefile.am (TESTS): Run it.
+       * tests/missing4.test: Adjust.
+
 2008-04-02  Eric Blake  <address@hidden>
 
        Make gnupload friendlier for VPATH usage.
diff --git a/aclocal.in b/aclocal.in
index 0436205..44d3d1e 100644
--- a/aclocal.in
+++ b/aclocal.in
@@ -797,7 +797,7 @@ sub write_aclocal ($@)
       # the file in the diagnostic anyway.
       $output = "m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(AC_AUTOCONF_VERSION, [$ac_version],,
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [$ac_version],,
 [m4_warning([this file was generated for autoconf $ac_version.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
diff --git a/m4/amversion.in b/m4/amversion.in
index ab57590..40a9ed4 100644
--- a/m4/amversion.in
+++ b/m4/amversion.in
@@ -1,6 +1,6 @@
 ##                                                          -*- Autoconf -*-
 ## @configure_input@
-# Copyright (C) 2002, 2003, 2005, 2006, 2007  Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, 
Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -34,4 +34,4 @@ AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
 [AM_AUTOMAKE_VERSION(address@hidden@])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 00f1785..8cddc57 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -389,6 +389,7 @@ missing2.test \
 missing3.test \
 missing4.test \
 missing5.test \
+missing6.test \
 mkinstall.test \
 mkinst2.test \
 mkinst3.test \
diff --git a/tests/missing4.test b/tests/missing4.test
index 7f2fe0d..137b999 100755
--- a/tests/missing4.test
+++ b/tests/missing4.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2006, 2007  Free Software Foundation, Inc.
+# Copyright (C) 2006, 2007, 2008  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
@@ -31,7 +31,7 @@ $AUTOMAKE
 ./configure
 $MAKE
 
-sed '1,20 s/AC_AUTOCONF_VERSION,/&9999/' < aclocal.m4 > aclocal.tmp
+sed '1,20 s/m4_defn(\[AC_AUTOCONF_VERSION\]),/9999,/' < aclocal.m4 > 
aclocal.tmp
 cmp aclocal.m4 aclocal.tmp && exit 1
 
 mv aclocal.tmp aclocal.m4
diff --git a/tests/missing6.test b/tests/missing6.test
new file mode 100755
index 0000000..56c6047
--- /dev/null
+++ b/tests/missing6.test
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2008  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, 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/>.
+
+# Make sure autoconf version checks in aclocal.m4 are robust.
+
+. ./defs || exit 1
+
+set -e
+
+{
+  echo 'm4_define([AC_AUTOCONF_VERSION], [9999a])'
+  echo 'm4_define([b], [oops])'
+  cat configure.in
+  echo AC_OUTPUT
+} >configure.ac
+rm configure.in
+
+touch Makefile.am
+
+$ACLOCAL
+$AUTOCONF 2>stderr
+grep 'You have another version of autoconf' stderr
+grep 'aclocal.m4:.*this file was generated for' stderr
+$AUTOMAKE
+./configure
+$MAKE
+
+sed 's/\[b\]/[a]/' < configure.ac > configure.tmp
+cmp configure.ac configure.tmp && exit 1
+
+mv configure.tmp configure.ac
+
+$MAKE 2>stderr
+cat stderr
+grep 'You have another version of autoconf' stderr
+grep 'aclocal.m4:.*this file was generated for autoconf 9999a' stderr
+
+:
-- 
1.5.5







reply via email to

[Prev in Thread] Current Thread [Next in Thread]