Re: cvs: php4 / acinclude.m4 configure.in /main streams.c

From: Date: Thu, 02 Jan 2003 20:56:56 +0000
Subject: Re: cvs: php4 / acinclude.m4 configure.in /main streams.c
References: 1 2 3 4  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-17532@lists.php.net to get a copy of this message
In message <Pine.LNX.4.44.0301021822190.23713-100000@zaneeb.brainnet.i> Wez Furlong <wez@thebrainroom.com> 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 alex@alexwaugh.com RISC OS software from http://www.alexwaugh.com/

« previous php.cvs (#17532) next »