On Sat, Aug 19, 2000 at 12:16:33AM -0300, Alexandre Oliva wrote:
> The following message is a courtesy copy of an article
> that has been posted to gnu.utils.bug as well.
> 
> On Aug 18, 2000, [EMAIL PROTECTED] (Carlo Wood) wrote:
> 
> > In the documentation of autoconf it reads that AC_TRY_RUN, when
> > it fails, passes the return value of the program in the shell
> > variable $?.  This is not true, the variable is always 0.
> 
> Indeed.  Please report this to the autoconf mailing list,
> [EMAIL PROTECTED]

AND, the documentation in autoconf.info says to mail bug
reports to

<quote>
   Mail suggestions and bug reports for Autoconf to
   `[EMAIL PROTECTED]'.  Please include the Autoconf version
   number, which you can get by running `autoconf --version'.
</quote>

there is no mention of gnu.org.

~>autoconf --version
Autoconf version 2.13
~>bash -version
GNU bash, version 1.14.7(1)
~>uname -a
Linux jolan 2.4.0-test1 #8 Thu Jun 29 01:38:20 CEST 2000 i686 unknown

Test case:

if (cat doesnotexist; exit) 2>/dev/null
then 
  echo "it DID exist"
else
  echo "The failed program was:"
  echo $?
fi

~>./do-test
The failed program was:
0

Its worse however; I couldn't even get it working by
putting an echo $? directly under the `else' in
AC_TRY_RUN_NATIVE:  You'll have to test this using
autoconf to be sure it works.

When I read the documentation I think that the
originally intended behaviour was this:

if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}
then
dnl Don't remove the temporary files here, so they can be examined.
  ./conftest 2>/dev/null
  ifelse([$2], , :, [$2])
else
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
ifelse([$3], , , [  rm -fr conftest*
  $3
])dnl
fi

which will execute [$2] when the compilation succeeds.
But - well, that changes the behaviour of AC_TRY_RUN
too drasticcally of course.

If you choose to only chang the documentation, then
I suggest you add the following to it:

"If you want to check the exit code of your test
 program ($?), then write your tests as follows:

   int main(int argc, char* argv[])
   {
     if (argc == 1)
       exit(0);
     // ... real test
     exit(real_value);
   }

 and use AC_TRY_RUN in the following way:

   AC_TRY_RUN([PROGRAM-CODE],
   ./conftest really
   xx_cv_yyy=$?,
   [AC_MSG_ERROR(Failed to compile a test program!?)],
   xx_cv_yyy=4 dnl Guess a default for cross compiling
   )
"

Regards,

-- 
Carlo Wood <[EMAIL PROTECTED]>                        -=- Jesus Loves you -=-

Reply via email to