From: Alexandre Duret-Lutz Date: Fri, 21 Apr 2006 19:02:29 +0000 (+0000) Subject: * m4/amversion.in (_AM_AUTOCONF_VERSION): New macro. X-Git-Tag: Release-1-9b~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0562c007c70d0346938f82c1d4d950e88c3528bd;p=thirdparty%2Fautomake.git * 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. --- diff --git a/ChangeLog b/ChangeLog index bc74f94e8..f5ec487cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-04-21 Alexandre Duret-Lutz + + * 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. + 2006-04-20 Paul Lunau (tiny change) Ralf Wildenhues diff --git a/NEWS b/NEWS index 05eceb366..44e28f512 100644 --- a/NEWS +++ b/NEWS @@ -104,6 +104,20 @@ New in 1.9a: - `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: diff --git a/aclocal.in b/aclocal.in index b2738e435..acb05d253 100644 --- a/aclocal.in +++ b/aclocal.in @@ -140,6 +140,10 @@ my $m4_include_rx = "(m4_|m4_s|s)include\\((?:\\[([^]]+)\\]|([^],)\n]+))\\)"; # 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 @@ sub trace_used_macros () $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 @@ sub trace_used_macros () 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 @@ sub write_aclocal ($@) # 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 diff --git a/aclocal.m4 b/aclocal.m4 index 739c7d937..f348e6b74 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -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]) diff --git a/m4/amversion.in b/m4/amversion.in index 155c80ba7..c820cf0a7 100644 --- a/m4/amversion.in +++ b/m4/amversion.in @@ -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 @@ m4_if([$1], [@VERSION@], [], [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([@VERSION@])]) +[AM_AUTOMAKE_VERSION([@VERSION@])dnl +_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)]) diff --git a/m4/amversion.m4 b/m4/amversion.m4 index c70d5ea2a..56aa8366a 100644 --- a/m4/amversion.m4 +++ b/m4/amversion.m4 @@ -1,6 +1,6 @@ ## -*- Autoconf -*- ## Generated from amversion.in; do not edit by hand. -# 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 @@ m4_if([$1], [1.9a], [], [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([1.9a])]) +[AM_AUTOMAKE_VERSION([1.9a])dnl +_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)]) diff --git a/tests/Makefile.am b/tests/Makefile.am index ad43e1c78..1210b5ba7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -357,6 +357,7 @@ mdate4.test \ missing.test \ missing2.test \ missing3.test \ +missing4.test \ mkinstall.test \ mkinst2.test \ mkinst3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 78130fdce..c1d4da042 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -487,6 +487,7 @@ mdate4.test \ missing.test \ missing2.test \ missing3.test \ +missing4.test \ mkinstall.test \ mkinst2.test \ mkinst3.test \ diff --git a/tests/missing4.test b/tests/missing4.test new file mode 100755 index 000000000..32f0fb28a --- /dev/null +++ b/tests/missing4.test @@ -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 + +: