This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Surprising behavior of AM_CONDITIONAL
- From: Phil Edwards <phil at jaj dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 5 Jun 2003 14:17:01 -0400
- Subject: Surprising behavior of AM_CONDITIONAL
A snippet of irc conversation:
[13:44:09] <pme> Here's the question: we have some AM_CONDITIONAL
statements in configure, and in a Makefile.am, we have some
corresponding "if" statements. What happens if the AM_CONDITIONAL
is never executed?
[13:44:49] <DannyB> pme: Nuclear holocaust?
[13:44:47] <pme> It /looks/ like neither the true nor false case gets a
'#' setting in config.status, which means that /both/ statements in
the Makefile are executed.
[13:45:21] <pme> I say "looks"... that's the behavior I'm actually seeing,
and my working theory is that the AM_CONDITIONAL isn't being run.
[13:46:49] <pme> ...and it really surprises me that a binary conditional
defaults to "both". :-(
So, the code in, e.g., testsuite/Makefile.am which goes
# Enable wchar_t tests if capable.
if GLIBCPP_TEST_WCHAR_T
all-local: stamp_wchar
else
all-local:
endif
becomes
all-local: stamp_wchar
all-local:
which is Extraordinarily Bad on a platform which /would/ have taken the
'false' branch, /if/ this
AM_CONDITIONAL(GLIBCPP_TEST_WCHAR_T, test "$enable_wchar_t" = yes)
had ever been executed.
Two problems here. One is the "you get both results" behavior of automake.
No ideas on what to do about that, if anything. I suspect this is simply a
"don't do that".
The other problem is that, in the cross-compiling case, where we don't
specify a particular target, the generic branch isn't doing those GLIBCPP_*
calls which would eventually call AM_CONDITIONAL. I think we might have
to pull all the AM_CONDITIONAL calls out to the bottom of configure.in,
after the Big Painful 'if' Statement. This will entail pulling all the
variables used by the AM_CONDITIONALs out to before the BPiS, to give them
sane defaults:
# configure.in
enable_wchar_t=no
if test x"$build" != x"$host"; then
...300+ lines...
else
...native tests...
GLIBCPP_CHECK_WCHAR_T_SUPPORT
fi
AM_CONDITIONAL(GLIBCPP_TEST_WCHAR_T, test "$enable_wchar_t" = yes)
Thoughts?
Phil
--
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace. We seek
not your counsel, nor your arms. Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen. - Samuel Adams