bug-gnulib
[Top][All Lists]
Advanced

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

Re: an autoconf expert challenge


From: Ralf Wildenhues
Subject: Re: an autoconf expert challenge
Date: Wed, 24 Jan 2007 00:53:24 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello Bruno,

<http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/7552> is an older
message and I assume obsolete, now that the specific problem has been
fixed in a different manner, but I just stumbled over it again with
a solution in mind.  Dunno if the general issue is still relevant for
gnulib.

* Bruno Haible wrote on Fri, Oct 20, 2006 at 03:52:56PM CEST:
> Since gl_FUNC_ALLOCA may invoke AC_LIBOBJ, it must not be AC_REQUIREd -
> otherwise it won't work if you use it in two different gnulib libraries from
> the same configure.ac file.
> 
> Does anyone know how to write an automatic check for this rule: that
> autoconf macros that directly or indirectly invoke AC_LIBOBJ are not
> AC_REQUIREd?

They may not be directly nor indirectly required, yes?

Here's a very nasty hack, messing with deeply internal macros of Autoconf
to achieve /almost/ what you want: it complains about macros that call
AC_LIBOBJ and that are expanded because of being AC_REQUIRE/m4_require'd
by some other macro.  So, given
   AC_DEFUN([FOO], [AC_REQUIRE([BAR])])
   AC_DEFUN([BAR], [AC_LIBOBJ([bar])])

it will warn about
   FOO

because that will cause an expansion of BAR due to AC_REQUIRE; but it
won't warn about the sequence
   BAR
   FOO

because when the AC_REQUIRE([BAR]) is encountered, BAR has already been
expanded, thus the expansion code isn't gone over again.

Tested with CVS Autoconf only.  I think it should work with 2.60 and
2.61, but I advise strongly against using this in production code, and
promise that it will break eventually.  The outer m4_ifdef is merely to
disable the code for pre-2.60 Autoconf.

It finds about a dozen issues with `gnulib-tool --with-tests --test', so
you may want to look at them, see the output at the end of this message.

Cheers,
Ralf

# M4 code to put before or right after AC_INIT:
m4_ifdef([_m4_require_call],
[m4_rename([_m4_require_call], [_m4_require_call_orig])dnl
m4_define([_m4_require_call],
[m4_pushdef([AC_LIBOBJ],
  [m4_warning([AC_LIBOBJ called inside a require chain])dnl
   m4_expansion_stack_dump()])dnl
_m4_require_call_orig($@)[]dnl
m4_popdef([AC_LIBOBJ])])dnl
])


configure.ac:921: warning: AC_LIBOBJ called inside a require chain
glm4/getopt.m4:11: gl_GETOPT_SUBSTITUTE is expanded from...
glm4/argp.m4:7: gl_ARGP is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
glm4/getopt.m4:11: gl_GETOPT_SUBSTITUTE is expanded from...
glm4/argp.m4:7: gl_ARGP is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
../../../autoconf/lib/m4sugar/m4sh.m4:515: AS_IF is expanded from...
../../../autoconf/lib/autoconf/functions.m4:67: AC_CHECK_FUNC is expanded 
from...
../../../autoconf/lib/autoconf/functions.m4:88: AC_CHECK_FUNCS is expanded 
from...
glm4/getaddrinfo.m4:7: gl_GETADDRINFO is expanded from...
glm4/canon-host.m4:13: gl_PREREQ_CANON_HOST is expanded from...
glm4/canon-host.m4:7: gl_CANON_HOST is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
glm4/save-cwd.m4:7: gl_SAVE_CWD is expanded from...
glm4/openat.m4:90: gl_PREREQ_OPENAT is expanded from...
glm4/openat.m4:11: gl_FUNC_OPENAT is expanded from...
glm4/chdir-long.m4:35: gl_PREREQ_CHDIR_LONG is expanded from...
glm4/chdir-long.m4:16: gl_FUNC_CHDIR_LONG is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
glm4/openat.m4:69: gl_FUNC_FCHOWNAT is expanded from...
glm4/openat.m4:11: gl_FUNC_OPENAT is expanded from...
glm4/chdir-long.m4:35: gl_PREREQ_CHDIR_LONG is expanded from...
glm4/chdir-long.m4:16: gl_FUNC_CHDIR_LONG is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
glm4/fts.m4:17: gl_FUNC_FTS_CORE is expanded from...
glm4/fts.m4:7: gl_FUNC_FTS is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
../../../autoconf/lib/autoconf/functions.m4:831: 
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK is expanded from...
glm4/lstat.m4:12: gl_FUNC_LSTAT is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
../../../autoconf/lib/autoconf/functions.m4:932: AC_FUNC_MEMCMP is expanded 
from...
glm4/memcmp.m4:7: gl_FUNC_MEMCMP is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
glm4/mktime.m4:15: AC_FUNC_MKTIME is expanded from...
glm4/mktime.m4:212: gl_FUNC_MKTIME is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
glm4/strftime.m4:17: gl_FUNC_STRFTIME is expanded from...
glm4/strftime.m4:12: gl_FUNC_GNU_STRFTIME is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level
configure.ac:921: warning: AC_LIBOBJ called inside a require chain
../../../autoconf/lib/autoconf/functions.m4:1520: AC_FUNC_STRTOD is expanded 
from...
glm4/strtod.m4:7: gl_FUNC_STRTOD is expanded from...
configure.ac:47: gl_INIT is expanded from...
configure.ac:921: the top level




reply via email to

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