diff -up php-5.2.10/configure.in.gnurc php-5.2.10/configure.in
--- php-5.2.10/configure.in.gnurc	2009-06-20 14:20:52.614348634 +0700
+++ php-5.2.10/configure.in	2009-06-20 14:21:19.638348069 +0700
@@ -58,6 +58,8 @@ AC_DEFUN([PHP_EXT_DIR],[ext/$1])dnl
 AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir/ext/$1])dnl
 AC_DEFUN([PHP_ALWAYS_SHARED],[])dnl
 
+AC_DEFINE([_GNU_SOURCE], 1, [Define to enable GNU C Library extensions])
+
 dnl Setting up the PHP version based on the information above.
 dnl -------------------------------------------------------------------------
 
diff -up php-5.2.10/ext/interbase/interbase.c.gnurc php-5.2.10/ext/interbase/interbase.c
--- php-5.2.10/ext/interbase/interbase.c.gnurc	2009-06-20 14:21:47.533348165 +0700
+++ php-5.2.10/ext/interbase/interbase.c	2009-06-20 14:22:02.843348007 +0700
@@ -24,7 +24,6 @@
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 
 #include "php.h"
 
diff -up php-5.2.10/ext/pdo_firebird/firebird_driver.c.gnurc php-5.2.10/ext/pdo_firebird/firebird_driver.c
--- php-5.2.10/ext/pdo_firebird/firebird_driver.c.gnurc	2009-06-20 14:22:31.629348657 +0700
+++ php-5.2.10/ext/pdo_firebird/firebird_driver.c	2009-06-20 14:22:45.334348000 +0700
@@ -22,7 +22,6 @@
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 
 #include "php.h"
 #ifdef ZEND_ENGINE_2
diff -up php-5.2.10/ext/standard/file.c.gnurc php-5.2.10/ext/standard/file.c
--- php-5.2.10/ext/standard/file.c.gnurc	2009-06-20 14:24:13.288473851 +0700
+++ php-5.2.10/ext/standard/file.c	2009-06-20 14:24:35.591472839 +0700
@@ -118,7 +118,6 @@ php_file_globals file_globals;
 
 #ifdef HAVE_FNMATCH
 #ifndef _GNU_SOURCE
-#define _GNU_SOURCE
 #endif
 #include <fnmatch.h>
 #endif
diff -up php-5.2.10/ext/zlib/zlib_fopen_wrapper.c.gnurc php-5.2.10/ext/zlib/zlib_fopen_wrapper.c
--- php-5.2.10/ext/zlib/zlib_fopen_wrapper.c.gnurc	2009-06-20 14:23:04.259348516 +0700
+++ php-5.2.10/ext/zlib/zlib_fopen_wrapper.c	2009-06-20 14:23:17.273348019 +0700
@@ -19,7 +19,6 @@
 
 /* $Id: zlib_fopen_wrapper.c,v 1.46.2.1.2.7 2009/01/20 15:43:05 felipe Exp $ */
 
-#define _GNU_SOURCE
 
 #include "php.h"
 #include "php_zlib.h"
diff -up php-5.2.10/main/php.h.gnurc php-5.2.10/main/php.h
--- php-5.2.10/main/php.h.gnurc	2009-06-20 14:24:54.857474024 +0700
+++ php-5.2.10/main/php.h	2009-06-20 14:25:11.045473468 +0700
@@ -30,6 +30,7 @@
 #define PHP_HAVE_STREAMS
 #define YYDEBUG 0
 
+#include "php_config.h"
 #include "php_version.h"
 #include "zend.h"
 #include "zend_qsort.h"
diff -up php-5.2.10/main/streams/cast.c.gnurc php-5.2.10/main/streams/cast.c
--- php-5.2.10/main/streams/cast.c.gnurc	2009-06-20 14:25:29.698474159 +0700
+++ php-5.2.10/main/streams/cast.c	2009-06-20 14:25:44.728473612 +0700
@@ -18,7 +18,6 @@
 
 /* $Id: cast.c,v 1.12.2.1.2.6 2009/06/03 08:59:19 kalle Exp $ */
 
-#define _GNU_SOURCE
 #include "php.h"
 #include "php_globals.h"
 #include "php_network.h"
diff -up php-5.2.10/main/streams/memory.c.gnurc php-5.2.10/main/streams/memory.c
--- php-5.2.10/main/streams/memory.c.gnurc	2009-06-20 14:26:02.701473978 +0700
+++ php-5.2.10/main/streams/memory.c	2009-06-20 14:26:09.618473497 +0700
@@ -18,7 +18,6 @@
 
 /* $Id: memory.c,v 1.8.2.6.2.21 2009/05/16 20:28:02 lbarnaud Exp $ */
 
-#define _GNU_SOURCE
 #include "php.h"
 
 PHPAPI int php_url_decode(char *str, int len);
diff -up php-5.2.10/main/streams/streams.c.gnurc php-5.2.10/main/streams/streams.c
--- php-5.2.10/main/streams/streams.c.gnurc	2009-06-20 14:26:21.765474083 +0700
+++ php-5.2.10/main/streams/streams.c	2009-06-20 14:26:26.938472749 +0700
@@ -21,7 +21,6 @@
 
 /* $Id: streams.c,v 1.82.2.6.2.38 2009/05/17 14:59:24 lbarnaud Exp $ */
 
-#define _GNU_SOURCE
 #include "php.h"
 #include "php_globals.h"
 #include "php_network.h"
diff -up php-5.2.10/Zend/zend_language_parser.c.gnurc php-5.2.10/Zend/zend_language_parser.c
--- php-5.2.10/Zend/zend_language_parser.c.gnurc	2009-06-20 14:27:06.496474223 +0700
+++ php-5.2.10/Zend/zend_language_parser.c	2009-06-20 14:27:30.868472846 +0700
@@ -356,6 +356,7 @@
 #include "zend_API.h"
 #include "zend_constants.h"
 
+#include <string.h>
 
 #define YYERROR_VERBOSE
 #define YYSTYPE znode
