Quantcast

m4_divert_text

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

m4_divert_text

Russell Shaw
Hi,

In binutils/configure.ac there is:

m4_divert_text([PARSE_ARGS],
[case $srcdir in
   *" "*)
m4_pushdef([AS_MESSAGE_LOG_FD], [])dnl
     AC_MSG_ERROR([path to source, $srcdir, contains spaces])
m4_popdef([AS_MESSAGE_LOG_FD])dnl
     ;;
esac
ac_subdirs_all=`cd $srcdir && echo */configure | sed 's,/configure,,g'`
])


I can't find where it's used, and was wondering how one would use this definition.

Doesn't the pushdef/popdef pair make it useless?

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: m4_divert_text

Eric Blake-3
On 09/14/2016 07:26 AM, Russell Shaw wrote:

> Hi,
>
> In binutils/configure.ac there is:
>
> m4_divert_text([PARSE_ARGS],
> [case $srcdir in
>   *" "*)
> m4_pushdef([AS_MESSAGE_LOG_FD], [])dnl
>     AC_MSG_ERROR([path to source, $srcdir, contains spaces])
> m4_popdef([AS_MESSAGE_LOG_FD])dnl
>     ;;
> esac
> ac_subdirs_all=`cd $srcdir && echo */configure | sed 's,/configure,,g'`
> ])
>
>
> I can't find where it's used, and was wondering how one would use this
> definition.
AS_MESSAGE_LOG_FD is documented;
https://www.gnu.org/software/autoconf/manual/autoconf.html#AS_005fMESSAGE_005fLOG_005fFD.

But let's look at what happens here.  AC_MSG_ERROR is a synonym for
AS_ERROR, and the definition of AS_ERROR is:

m4_defun_init([AS_ERROR],
[m4_append_uniq([_AS_CLEANUP],
  [m4_divert_text([M4SH-INIT-FN], [_AS_ERROR_PREPARE[]])])],
[as_fn_error m4_default([$2], [$?])
"_AS_QUOTE([$1])"m4_ifval(AS_MESSAGE_LOG_FD,
  [ "$LINENO" AS_MESSAGE_LOG_FD])])

That is, the result of invoking AC_MSG_ERROR is a shell-script call to
the function as_fun_error, with either 2 arguments (the error code and
message) or 4 arguments (the error code, message, current line number,
and log fd), based on whether the current macro definition of
AS_MESSAGE_LOG_FD is blank.  Looking at that shell function, it behaves
differently according to whether the third and fourth arguments are
present, by additionally logging to the log fd.

So what binutils is doing is writing a low-level macro where they DON'T
want the message logged to config.log, so they temporarily redefine
AS_MESSAGE_LOG_FD to the empty string around the duration of the
expansion of AC_MSG_ERROR, in order to change how that macro is expanded.


>
> Doesn't the pushdef/popdef pair make it useless?

No, the pushdef/popdef pair is what makes it so that the temporary
non-logging nature of AC_MSG_ERROR() lasts only for the duration of the
expansion of this snippet, rather than the rest of configure.ac.

--
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf

signature.asc (617 bytes) Download Attachment
Loading...