AX_BUILD_CC_FOR_BUILD broken?

Éric Hoffman <[email protected]> Tue, 28 Mar 2017 21:36:14 -0400
Newsgroups gmane.comp.sysutils.autoconf.archive-maintainers
Message-ID <[email protected]>
Hello

I'm not sure if I'm using the right terms here, please excuse me, as my 
knowledge of the internals of autoconf scripts doesn't reach too far 
beyond typing './autogen.sh' which invoke autoconf and convert the 
configure.am file to configure... :-)

I'm currently debugging a 3rd party project, which I'm compiling under 
Windows MinGW.  The project Makefile.am uses a few instances of 'EXEEXT' 
and 'BUILD_EXEEXT'.  However, the 'BUILD_EXEEXT' variable always turned 
out empty (where it should be '.exe').

I started debugging, and found out about the script responsible to 
define the 'BUILD_EXEEXT' variable, which is in autoconf-archive 
'ax_prog_cc_for_build.m4'.  I understood that this script basically just 
pushdef some 'important' definitions, disable cross-compilation (for the 
following test), re-call AC_PROG_CC, extract the 'BUILD_EXEEXT' from the 
results, and restore the 'important' definitions.

So, the idea is neat and simple, however, it does not seem to work as 
intended because when AC_PROG_CC_FOR_BUILD invoke the autoconf's 
AC_PROG_CC, the AC_PROG_CC macro (defined in c.m4) invoke 
_AC_COMPILER_EXEEXT (defined in lang.m4) with m4_expand_once.

So, the evaluation of executable extension occur only once for the whole 
configure script (and is not re-evaluated for the native build).

Regards,
Eric