In message <[EMAIL PROTECTED]>
Wez Furlong <[EMAIL PROTECTED]> wrote:
> But how can you reliably detect a system with a broken libc when
> cross-compiling?
>
> I leave this for someone else to decide, although a more-or-less
> reasonable default is to for "have_broken_glibc_fopen_append=no" and
> hope that no-one files a problem report :)
How about the following (completely untested, so I bet the brackets
don't match up :-) Not perfect, but better than a blind guess. Caching
the value also makes it easier to manually override if it gets it wrong.
Alex
AC_DEFUN([PHP_BROKEN_GLIBC_FOPEN_APPEND],[
AC_MSG_CHECKING([for broken libc stdio])
AC_CACHE_VAL(have_broken_glibc_fopen_append,[
AC_TRY_RUN([
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *fp;
long position;
char *filename = "/tmp/phpglibccheck";
fp = fopen(filename, "w");
if (fp == NULL) {
perror("fopen");
exit(2);
}
fputs("foobar", fp);
fclose(fp);
fp = fopen(filename, "a+");
position = ftell(fp);
fclose(fp);
unlink(filename);
if (position == 0)
return 1;
return 0;
}
],
[have_broken_glibc_fopen_append=no],
[have_broken_glibc_fopen_append=yes ],
AC_TRY_COMPILE([
#include <features.h>
],[
#if __GLIBC_PREREQ(2,2)
int main(void)
{
return 0;
}
#else
choke me
#endif
],
[have_broken_glibc_fopen_append=yes ],
[have_broken_glibc_fopen_append=no ]
)
)])
if test "$have_broken_glibc_fopen_append" = "yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BROKEN_GLIBC_FOPEN_APPEND,1, [Define if your glibc borks on
fopen with mode a+])
else
AC_MSG_RESULT(no)
fi
])
--
Alex Waugh [EMAIL PROTECTED]
RISC OS software from http://www.alexwaugh.com/
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php