--- php5.orig/configure.in
+++ php5/configure.in
@@ -136,6 +136,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 -------------------------------------------------------------------------
 
--- php5.orig/ext/interbase/interbase.c
+++ php5/ext/interbase/interbase.c
@@ -24,7 +24,6 @@
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 
 #include "php.h"
 
--- php5.orig/ext/pdo_firebird/firebird_driver.c
+++ php5/ext/pdo_firebird/firebird_driver.c
@@ -22,7 +22,6 @@
 #include "config.h"
 #endif
 
-#define _GNU_SOURCE
 
 #include "php.h"
 #ifdef ZEND_ENGINE_2
--- php5.orig/ext/standard/file.c
+++ php5/ext/standard/file.c
@@ -112,9 +112,6 @@ php_file_globals file_globals;
 #endif
 
 #if defined(HAVE_FNMATCH) && !defined(PHP_WIN32)
-# ifndef _GNU_SOURCE
-#  define _GNU_SOURCE
-# endif
 # include <fnmatch.h>
 #endif
 
--- php5.orig/ext/zlib/zlib_fopen_wrapper.c
+++ php5/ext/zlib/zlib_fopen_wrapper.c
@@ -19,8 +19,6 @@
 
 /* $Id$ */
 
-#define _GNU_SOURCE
-
 #include "php.h"
 #include "php_zlib.h"
 #include "fopen_wrappers.h"
--- php5.orig/main/php.h
+++ php5/main/php.h
@@ -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"
--- php5.orig/main/streams/cast.c
+++ php5/main/streams/cast.c
@@ -18,7 +18,6 @@
 
 /* $Id$ */
 
-#define _GNU_SOURCE
 #include "php.h"
 #include "php_globals.h"
 #include "php_network.h"
--- php5.orig/main/streams/memory.c
+++ php5/main/streams/memory.c
@@ -18,7 +18,6 @@
 
 /* $Id$ */
 
-#define _GNU_SOURCE
 #include "php.h"
 
 PHPAPI int php_url_decode(char *str, int len);
--- php5.orig/main/streams/streams.c
+++ php5/main/streams/streams.c
@@ -21,7 +21,6 @@
 
 /* $Id$ */
 
-#define _GNU_SOURCE
 #include "php.h"
 #include "php_globals.h"
 #include "php_network.h"
--- php5.orig/Zend/zend_language_parser.c
+++ php5/Zend/zend_language_parser.c
@@ -75,6 +75,8 @@
 
 /* Copy the first part of user declarations.  */
 
+#include <string.h>
+
 
 /*
    +----------------------------------------------------------------------+
