[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Broken makefile given Autoconf version mismatch
From: |
Alexandre Duret-Lutz |
Subject: |
Re: Broken makefile given Autoconf version mismatch |
Date: |
Thu, 20 Apr 2006 09:12:01 +0200 |
User-agent: |
Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) |
>>> "adl" == Alexandre Duret-Lutz <address@hidden> writes:
adl> Here is my attempt at checking Autoconf version in aclocal.m4.
adl> It would be nice if someone could suggest a better way to retrieve
adl> the Autoconf version:
Here is a second attempt that I think is superior to the
previous one in two ways :
* It doesn't require an extra run of autom4te to retrieve its version
(it simply it along with the other things it traces).
* It does not pollute aclocal.m4 with a version check if
automake is not used. (The contents of aclocal.m4 is not
really dependent on the Autoconf version, so I see little
point in this check if it's not for Automake.)
2006-04-20 Alexandre Duret-Lutz <address@hidden>
* m4/amversion.in (_AM_AUTOCONF_VERSION): New macro.
(AM_SET_CURRENT_AUTOMAKE_VERSION): Call it.
* aclocal.in (trace_used_macros): Trace _AM_AUTOCONF_VERSION.
(write_aclocal): Output a check for Autoconf's version in aclocal.m4.
Doing so ensures that users cannot build configure and Makefiles
with two different autoconf versions. Report from Noah Misch.
* tests/missing4.test: New file.
* tests/Makefile.am (TESTS): Add it.
Index: NEWS
===================================================================
RCS file: /cvs/automake/automake/NEWS,v
retrieving revision 1.304
diff -u -r1.304 NEWS
--- NEWS 21 Mar 2006 19:09:21 -0000 1.304
+++ NEWS 20 Apr 2006 07:09:36 -0000
@@ -104,6 +104,20 @@
- `dirlist' entries (for the aclocal search path) may use shell wildcards
such as `*', `?', or `[...]'.
+
+ - aclocal now outputs an autoconf version check in aclocal.m4 in
+ projects using automake.
+
+ For a few years, automake and aclocal have been calling autoconf
+ (or its underlying engine autom4te) to accurately retrieve the
+ data they need from configure.ac and its siblings. Doing so can
+ only work if all autotools use the same version of autoconf. For
+ instance a Makefile.in generated by automake for one version of
+ autoconf may stop working if configure is regenerated with another
+ version of autoconf, and vice versa.
+
+ This new version check ensures that the whole build system has
+ been generated using the same autoconf version.
New in 1.9:
Index: aclocal.in
===================================================================
RCS file: /cvs/automake/automake/aclocal.in,v
retrieving revision 1.137
diff -u -r1.137 aclocal.in
--- aclocal.in 26 Mar 2006 07:52:08 -0000 1.137
+++ aclocal.in 20 Apr 2006 07:09:36 -0000
@@ -140,6 +140,10 @@
# Match a serial number.
my $serial_line_rx = '^#\s*serial\s+(\S*)';
my $serial_number_rx = '^\d+(?:\.\d+)*$';
+
+# Autoconf version
+# Set by trace_used_macros.
+my $ac_version;
################################################################
@@ -607,9 +611,11 @@
$traces .= join (' ', grep { exists $files{$_} } @file_order) . " ";
# All candidate macros.
$traces .= join (' ',
- (map { "--trace='$_:\$f::\$n::\$1'" } ('AC_DEFUN',
- 'AC_DEFUN_ONCE',
- 'AU_DEFUN')),
+ (map { "--trace='$_:\$f::\$n::\$1'" }
+ ('AC_DEFUN',
+ 'AC_DEFUN_ONCE',
+ 'AU_DEFUN',
+ '_AM_AUTOCONF_VERSION')),
# Do not trace $1 for all other macros as we do
# not need it and it might contains harmful
# characters (like newlines).
@@ -632,6 +638,8 @@
if ($macro eq 'AC_DEFUN'
|| $macro eq 'AC_DEFUN_ONCE'
|| $macro eq 'AU_DEFUN');
+
+ $ac_version = $arg1 if $macro eq '_AM_AUTOCONF_VERSION';
}
$tracefh->close;
@@ -726,6 +734,17 @@
# FIXME: Shouldn't we diagnose this?
return 1 if ! length ($output);
+ if ($ac_version)
+ {
+ # Do not use "$output_file" here for the same reason we do not
+ # use it in the header below. autom4te will output the name of
+ # the file in the diagnostic anyway.
+ $output = "m4_if(m4_PACKAGE_VERSION, [$ac_version],,
+[m4_fatal([this file was generated for autoconf $ac_version], [63])])
+
+$output";
+ }
+
# We used to print `# $output_file generated automatically etc.' But
# this creates spurious differences when using autoreconf. Autoreconf
# creates aclocal.m4t and then rename it to aclocal.m4, but the
Index: aclocal.m4
===================================================================
RCS file: /cvs/automake/automake/aclocal.m4,v
retrieving revision 1.140
diff -u -r1.140 aclocal.m4
--- aclocal.m4 19 Mar 2006 05:04:27 -0000 1.140
+++ aclocal.m4 20 Apr 2006 07:09:36 -0000
@@ -11,6 +11,9 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
+m4_if(m4_PACKAGE_VERSION, [2.59c],,
+[m4_fatal([this file was generated for autoconf 2.59c], [63])])
+
m4_include([m4/amversion.m4])
m4_include([m4/auxdir.m4])
m4_include([m4/init.m4])
Index: m4/amversion.in
===================================================================
RCS file: /cvs/automake/automake/m4/amversion.in,v
retrieving revision 1.8
diff -u -r1.8 amversion.in
--- m4/amversion.in 13 Jan 2005 20:00:59 -0000 1.8
+++ m4/amversion.in 20 Apr 2006 07:09:36 -0000
@@ -1,6 +1,6 @@
## -*- Autoconf -*-
## @configure_input@
-# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -19,9 +19,17 @@
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too. Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
-# Call AM_AUTOMAKE_VERSION so it can be traced.
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
- [AM_AUTOMAKE_VERSION(address@hidden@])])
+[AM_AUTOMAKE_VERSION(address@hidden@])dnl
+_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)])
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.601
diff -u -r1.601 Makefile.am
--- tests/Makefile.am 9 Apr 2006 07:46:55 -0000 1.601
+++ tests/Makefile.am 20 Apr 2006 07:09:36 -0000
@@ -356,6 +356,7 @@
missing.test \
missing2.test \
missing3.test \
+missing4.test \
mkinstall.test \
mkinst2.test \
mkinst3.test \
Index: tests/missing4.test
===================================================================
RCS file: tests/missing4.test
diff -N tests/missing4.test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/missing4.test 20 Apr 2006 07:09:36 -0000
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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.
+#
+# GNU Automake 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 Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# See how well the rebuild rule handles an aclocal.m4 that was
+# generated for another version of autoconf.
+
+. ./defs || exit 1
+
+set -e
+
+echo AC_OUTPUT >>configure.in
+
+touch Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+sed '1,20 s/m4_PACKAGE_VERSION,/&9999/' < aclocal.m4 > aclocal.tmp
+cmp aclocal.m4 aclocal.tmp && exit 1
+
+mv aclocal.tmp aclocal.m4
+
+$MAKE 2>stderr
+cat stderr
+grep 'WARNING:.*automake.*probably too old' stderr
+grep 'WARNING:.*autoconf.*probably too old' stderr
+test 2 = `grep -c 'aclocal.m4:.*this file was generated for' stderr`
+
+$MAKE 2>stderr
+cat stderr
+grep 'WARNING:.*automake.*probably too old' stderr && exit 1
+grep 'WARNING:.*autoconf.*probably too old' stderr && exit 1
+grep 'aclocal.m4:.*this file was generated for' stderr && exit 1
+
+:
--
Alexandre Duret-Lutz
Shared books are happy books. http://www.bookcrossing.com/friend/gadl
- Re: Broken makefile given Autoconf version mismatch, (continued)
- Re: Broken makefile given Autoconf version mismatch, Ralf Wildenhues, 2006/04/13
- Re: Broken makefile given Autoconf version mismatch, Alexandre Duret-Lutz, 2006/04/13
- Re: Broken makefile given Autoconf version mismatch, Stepan Kasal, 2006/04/14
- Re: Broken makefile given Autoconf version mismatch, Paul Eggert, 2006/04/14
- Re: Broken makefile given Autoconf version mismatch, Alexandre Duret-Lutz, 2006/04/16
- Re: Broken makefile given Autoconf version mismatch, Stepan Kasal, 2006/04/16
- Re: Broken makefile given Autoconf version mismatch, Noah Misch, 2006/04/16
- Re: Broken makefile given Autoconf version mismatch, Bob Proulx, 2006/04/18
- Re: Broken makefile given Autoconf version mismatch, Noah Misch, 2006/04/18
- Re: Broken makefile given Autoconf version mismatch,
Alexandre Duret-Lutz <=
- Re: Broken makefile given Autoconf version mismatch, Stepan Kasal, 2006/04/20
- Re: Broken makefile given Autoconf version mismatch, Alexandre Duret-Lutz, 2006/04/20
- Re: Broken makefile given Autoconf version mismatch, Stepan Kasal, 2006/04/20
- Re: Broken makefile given Autoconf version mismatch, Ralf Wildenhues, 2006/04/20
- Re: Broken makefile given Autoconf version mismatch, Stepan Kasal, 2006/04/21
- Re: Broken makefile given Autoconf version mismatch, Ralf Wildenhues, 2006/04/21
- Re: Broken makefile given Autoconf version mismatch, Stepan Kasal, 2006/04/21