automake-patches
[Top][All Lists]
Advanced

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

[RFC PATCH] Improve diagnostics wrt. mutliple AM_INIT_AUTOMAKE calls.


From: Nick Bowler
Subject: [RFC PATCH] Improve diagnostics wrt. mutliple AM_INIT_AUTOMAKE calls.
Date: Tue, 17 Aug 2021 00:15:32 -0400

If you expand AM_INIT_AUTOMAKE more than once with options, automake
currently barfs on the resulting m4 traces with a less-than-helpful
assertion failure ("global options already processed").  This also
prompts users to report bugs against Automake, when the actual
problem is with their autoconf input.

Avoid the problem by detecting the scenario at M4 time, which is the
best position to provide an accurate description of the error.  I cannot
imagine there is any good reason to expand AM_INIT_AUTOMAKE more than
once so we can just reject it outright.  In a typical flow this means
the error will now be reported early by aclocal, and hopefully this
explains better to the user what is wrong.  For example, with the
configure.ac from bug #50046:

  % aclocal
  configure.ac:12: error: AM_INIT_AUTOMAKE expanded multiple times
  /tmp/am/share/aclocal-1.16/init.m4:29: AM_INIT_AUTOMAKE is expanded from...
  configure.ac:10: the top level
  /tmp/am/share/aclocal-1.16/init.m4:29: AM_INIT_AUTOMAKE is expanded from...
  configure.ac:12: the top level
  autom4te-2.69: /usr/bin/m4 failed with exit status: 1
  aclocal: error: autom4te failed with exit status: 1

This addresses <https://debbugs.gnu.org/50046>.

* m4/init.m4: Make attempts to expand AM_INIT_AUTOMAKE more than
  once a fatal error at m4 time.
---

NOTE: this implementation depends on the undocumented m4sugar macro
m4_expansion_stack in order to display the location of both macro calls
(this is what m4_fatal uses internally to show the current location).

This seems like generally useful functionality.  I wonder if we should
consier describing it in the Autoconf manual.

 m4/init.m4 | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/m4/init.m4 b/m4/init.m4
index c5807d211..b4686b140 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -28,6 +28,10 @@ m4_defn([AC_PROG_CC])
 # release and drop the old call support.
 AC_DEFUN([AM_INIT_AUTOMAKE],
 [AC_PREREQ([2.65])dnl
+m4_ifdef([_$0_ALREADY_INIT],
+  [m4_fatal([$0 expanded multiple times
+]m4_defn([_$0_ALREADY_INIT]))],
+  [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
 dnl Autoconf wants to disallow AM_ names.  We explicitly allow
 dnl the ones we care about.
 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
-- 
2.31.1




reply via email to

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