autoconf
[Top][All Lists]
Advanced

[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, 13 Apr 2006 20:52:48 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux)

| The patch to add AC_PREREQ to AM_PATH_LISPDIR is necessary not to
| prevent the failures Noah described, but simply to prevent users from
| trying to use the macro with an Autoconf version that is too old and
| does not cause `${datarootdir}' to be defined.

I was merely explaining why aclocal couldn't use AC_PREREQ.  I
didn't know about the patch you mention, sorry, and I couldn't
find it.  Maybe it's pending moderation?

Here is my attempt at checking Autoconf version in aclocal.m4.
It would be nice if someone could suggest a better way to retrieve
the Autoconf version:

   - tracing for 'm4_define' in order to catch the
     m4_PACKAGE_VERSION definition didn't work, because the
     definition seems to be done before the trace are enabled.
     (And anyway tracing m4_define generates a lot of useless
     output, so is not really satisfactory.)

   - running `echo m4_PACKAGE_VERSION | autom4te -l Autoconf-without-aclocal`
     doesn't work because apparently autom4te doesn't support reading
     from stdin.  (BTW, I can see that "autoconf" has some code to handle
     "-" as input, but I fail to see how that can work if autom4te cannot
     read stdin!)

I've though about doing the second idea using a temporary file,
but neither automake nor aclocal use temporary files, and I
think it'd be better to keep it that way.  Another idea would be
to make that file non-temporary, i.e., install it: I'd be fine
with this, but it just looks like a complicated way to retrieve
a version number.

Any cunning idea ?  Or can we tweak Autoconf to make its version
more accessible ?

2006-04-13  Alexandre Duret-Lutz  <address@hidden>

        * aclocal.in (trace_used_macros): Retrieve Autoconf's version.
        (write_aclocal): Check Autoconf's version in aclocal.m4.
        Doing so ensure 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: 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  13 Apr 2006 18:27:25 -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;
 
 ################################################################
 
@@ -602,6 +606,11 @@
   %files = strip_redundant_includes %files;
 
   my $traces = ($ENV{AUTOM4TE} || 'autom4te');
+
+  # Gross!
+  $ac_version = `$traces --version`;
+  $ac_version =~ s/^[^)]*[)]\s+(\S+)\s.*$/$1/s;
+
   $traces .= " --language Autoconf-without-aclocal-m4 ";
   # All candidate files.
   $traces .= join (' ', grep { exists $files{$_} } @file_order) . " ";
@@ -745,6 +756,9 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
+m4_if(m4_PACKAGE_VERSION, [$ac_version],,
+[m4_fatal([aclocal.m4 was generated for autoconf $ac_version], [63])])
+
 $output";
 
   # We try not to update $output_file unless necessary, because
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   13 Apr 2006 18:27:25 -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 13 Apr 2006 18:27:26 -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 handle an aclocal.m4 that was
+# generated with another version of Automake.
+
+. ./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 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 was generated for' stderr && exit 1
+
+:

-- 
Alexandre Duret-Lutz

Shared books are happy books.     http://www.bookcrossing.com/friend/gadl





reply via email to

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