diff -ruN php-5.4.4.orig/ext/dom/documenttype.c php-5.4.4/ext/dom/documenttype.c
--- php-5.4.4.orig/ext/dom/documenttype.c	2012-06-13 00:54:23.000000000 -0400
+++ php-5.4.4/ext/dom/documenttype.c	2013-10-30 12:57:57.000000000 -0400
@@ -205,7 +205,13 @@
 		if (buff != NULL) {
 			xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
 			xmlOutputBufferFlush(buff);
+
+#ifdef LIBXML2_NEW_BUFFER
+			ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff),
+			             xmlOutputBufferGetSize(buff), 1);
+#else
 			ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1);
+#endif
 			(void)xmlOutputBufferClose(buff);
 			return SUCCESS;
 		}
diff -ruN php-5.4.4.orig/ext/dom/node.c php-5.4.4/ext/dom/node.c
--- php-5.4.4.orig/ext/dom/node.c	2012-06-13 00:54:23.000000000 -0400
+++ php-5.4.4/ext/dom/node.c	2013-10-30 12:57:23.000000000 -0400
@@ -1895,9 +1895,17 @@
         RETVAL_FALSE;
     } else {
 		if (mode == 0) {
+#ifdef LIBXML2_NEW_BUFFER
+            ret = xmlOutputBufferGetSize(buf);
+#else
 			ret = buf->buffer->use;
+#endif
 			if (ret > 0) {
+#ifdef LIBXML2_NEW_BUFFER
+                RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1);
+#else
 				RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
+#endif
 			} else {
 				RETVAL_EMPTY_STRING();
 			}
diff -ruN php-5.4.4.orig/ext/simplexml/simplexml.c php-5.4.4/ext/simplexml/simplexml.c
--- php-5.4.4.orig/ext/simplexml/simplexml.c	2012-06-13 00:54:23.000000000 -0400
+++ php-5.4.4/ext/simplexml/simplexml.c	2013-10-30 12:57:57.000000000 -0400
@@ -1417,7 +1417,12 @@
 
 			xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding);
 			xmlOutputBufferFlush(outbuf);
+#ifdef LIBXML2_NEW_BUFFER
+			RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf),
+			               xmlOutputBufferGetSize(outbuf), 1);
+#else
 			RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1);
+#endif
 			xmlOutputBufferClose(outbuf);
 		}
 	} else {
diff -ruN php-5.4.4.orig/fink/crontab php-5.4.4/fink/crontab
--- php-5.4.4.orig/fink/crontab	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/crontab	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,7 @@
+# /etc/cron.d/php5: crontab fragment for php5
+#  This purges session files older than X, where X is defined in seconds
+#  as the largest value of session.gc_maxlifetime from all your php.ini
+#  files, or 24 minutes if not defined.  See @FINKPREFIX@/lib/php5/maxlifetime
+
+# Look for and purge old sessions every 30 minutes
+09,39 *     * * *     root   [ -x @FINKPREFIX@/lib/php5/maxlifetime ] && [ -d @FINKPREFIX@/var/lib/php5 ] && find @FINKPREFIX@/var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_race -cmin +$(@FINKPREFIX@/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete
diff -ruN php-5.4.4.orig/fink/extramodulelist php-5.4.4/fink/extramodulelist
--- php-5.4.4.orig/fink/extramodulelist	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/extramodulelist	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,10 @@
+mysql MySQL mysqli
+mysql MySQL pdo_mysql
+mysqlnd MySQL mysql
+mysqlnd MySQL mysqli
+mysqlnd MySQL pdo_mysql
+interbase InterBase/Firebird pdo_firebird
+odbc ODBC pdo_odbc
+pgsql PostgreSQL pdo_pgsql
+sqlite SQLite pdo_sqlite
+sybase Sybase pdo_dblib
diff -ruN php-5.4.4.orig/fink/libapache2-mod-php5.conf php-5.4.4/fink/libapache2-mod-php5.conf
--- php-5.4.4.orig/fink/libapache2-mod-php5.conf	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/libapache2-mod-php5.conf	2012-06-07 12:59:45.000000000 -0600
@@ -0,0 +1,16 @@
+<IfModule mod_php5.c>
+    <FilesMatch "\.ph(p3?|tml)$">
+	SetHandler application/x-httpd-php
+    </FilesMatch>
+    <FilesMatch "\.phps$">
+	SetHandler application/x-httpd-php-source
+    </FilesMatch>
+    # To disable php in user directories uncomment the following lines
+    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
+    # prevents .htaccess files from disabling it.
+    #<IfModule mod_userdir.c>
+    #    <Directory /Users/*/Sites>
+    #        php_admin_value engine Off
+    #    </Directory>
+    #</IfModule>
+</IfModule>
diff -ruN php-5.4.4.orig/fink/libapache2-mod-php5.load php-5.4.4/fink/libapache2-mod-php5.load
--- php-5.4.4.orig/fink/libapache2-mod-php5.load	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/libapache2-mod-php5.load	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1 @@
+LoadModule php5_module @FINKPREFIX@/lib/apache2/modules/libphp5.so
diff -ruN php-5.4.4.orig/fink/libapache2-mod-php5filter.conf php-5.4.4/fink/libapache2-mod-php5filter.conf
--- php-5.4.4.orig/fink/libapache2-mod-php5filter.conf	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/libapache2-mod-php5filter.conf	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,6 @@
+<IfModule mod_php5.c>
+    <FilesMatch "\.ph(p3?|tml)$">
+	SetInputFilter PHP
+	SetOutputFilter PHP
+    </FilesMatch>
+</IfModule>
diff -ruN php-5.4.4.orig/fink/libapache2-mod-php5filter.load php-5.4.4/fink/libapache2-mod-php5filter.load
--- php-5.4.4.orig/fink/libapache2-mod-php5filter.load	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/libapache2-mod-php5filter.load	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1 @@
+LoadModule php5_module @FINKPREFIX@/lib/apache2/modules/libphp5filter.so
diff -ruN php-5.4.4.orig/fink/maxlifetime php-5.4.4/fink/maxlifetime
--- php-5.4.4.orig/fink/maxlifetime	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/maxlifetime	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+
+max=1440
+
+if which php5 >/dev/null 2>&1; then
+    for sapi in apache2 apache2filter cgi fpm; do
+	if [ -e /etc/php5/${sapi}/php.ini ]; then
+	    cur=$(php5 -c /etc/php5/${sapi}/php.ini -d "error_reporting='~E_ALL'" -r 'print ini_get("session.gc_maxlifetime");')
+	    [ -z "$cur" ] && cur=0
+	    [ "$cur" -gt "$max" ] && max=$cur
+	fi
+    done
+else
+    for ini in /etc/php5/*/php.ini /etc/php5/conf.d/*.ini; do
+        cur=$(sed -n -e 's/^[[:space:]]*session.gc_maxlifetime[[:space:]]*=[[:space:]]*\([0-9]\+\).*$/\1/p' $ini 2>/dev/null || true);
+        [ -z "$cur" ] && cur=0
+        [ "$cur" -gt "$max" ] && max=$cur
+    done
+fi
+
+echo $(($max/60))
+
+exit 0
diff -ruN php-5.4.4.orig/fink/modulelist php-5.4.4/fink/modulelist
--- php-5.4.4.orig/fink/modulelist	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/modulelist	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,22 @@
+curl CURL
+common PDO pdo 10
+enchant Enchant
+gd GD
+gmp GMP
+imap IMAP
+interbase Interbase
+intl Internationalisation
+ldap LDAP
+mcrypt MCrypt
+mysql MySQL
+mysqlnd MySQL mysqlnd 10
+odbc ODBC
+pgsql PostgreSQL
+pspell pspell
+recode recode
+snmp SNMP
+sqlite SQLite sqlite3
+sybase Sybase mssql
+tidy tidy
+xmlrpc XML-RPC
+xsl XSL
diff -ruN php-5.4.4.orig/fink/patches/64_bit_datetime.patch php-5.4.4/fink/patches/64_bit_datetime.patch
--- php-5.4.4.orig/fink/patches/64_bit_datetime.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/64_bit_datetime.patch	2012-06-12 13:58:38.000000000 -0600
@@ -0,0 +1,12 @@
+--- a/ext/standard/datetime.c
++++ b/ext/standard/datetime.c
+@@ -20,6 +20,9 @@
+ 
+ /* $Id$ */
+ 
++#define _XOPEN_SOURCE	/* needed to get strptime() declared */
++#define _BSD_SOURCE		/* needed to get ulong declared */
++
+ #include "php.h"
+ #include "zend_operators.h"
+ #include "datetime.h"
diff -ruN php-5.4.4.orig/fink/patches/Add-information-about-which-INI-file-is-which-inside.patch php-5.4.4/fink/patches/Add-information-about-which-INI-file-is-which-inside.patch
--- php-5.4.4.orig/fink/patches/Add-information-about-which-INI-file-is-which-inside.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/Add-information-about-which-INI-file-is-which-inside.patch	2012-06-12 11:43:02.000000000 -0600
@@ -0,0 +1,22 @@
+--- a/php.ini-development
++++ b/php.ini-development
+@@ -83,6 +83,8 @@
+ ; development version only in development environments as errors shown to
+ ; application users can inadvertently leak otherwise secure information.
+ 
++; This is php.ini-development INI file.
++
+ ;;;;;;;;;;;;;;;;;;;
+ ; Quick Reference ;
+ ;;;;;;;;;;;;;;;;;;;
+--- a/php.ini-production
++++ b/php.ini-production
+@@ -83,6 +83,8 @@
+ ; development version only in development environments as errors shown to
+ ; application users can inadvertently leak otherwise secure information.
+ 
++; This is php.ini-production INI file.
++
+ ;;;;;;;;;;;;;;;;;;;
+ ; Quick Reference ;
+ ;;;;;;;;;;;;;;;;;;;
diff -ruN php-5.4.4.orig/fink/patches/PEAR-Builder-print-info-about-php5-dev.patch php-5.4.4/fink/patches/PEAR-Builder-print-info-about-php5-dev.patch
--- php-5.4.4.orig/fink/patches/PEAR-Builder-print-info-about-php5-dev.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/PEAR-Builder-print-info-about-php5-dev.patch	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,10 @@
+--- a/PEAR/Builder.php	2011-05-14 20:43:01.000000000 +0000
++++ b/PEAR/Builder.php		2011-05-26 15:56:41.096485701 +0000
+@@ -309,6 +309,8 @@ class PEAR_Builder extends PEAR_Common
+         }
+ 
+         if (!$err) {
++             print "If the command failed with 'phpize: not found' then you need to install php5-dev package";
++             print "You can do it by running 'fink install php5-dev' as a root user";
+             return $this->raiseError("`phpize' failed");
+         }
diff -ruN php-5.4.4.orig/fink/patches/backport-upstream-lp592442.patch php-5.4.4/fink/patches/backport-upstream-lp592442.patch
--- php-5.4.4.orig/fink/patches/backport-upstream-lp592442.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/backport-upstream-lp592442.patch	2012-06-12 13:20:21.000000000 -0600
@@ -0,0 +1,21 @@
+--- a/ext/openssl/xp_ssl.c
++++ b/ext/openssl/xp_ssl.c
+@@ -395,6 +395,18 @@ static inline int php_openssl_setup_cryp
+ 	}
+ #endif
+ 
++#if OPENSSL_VERSION_NUMBER >= 0x0090806fL
++	{
++		zval **val;
++
++		if (stream->context && SUCCESS == php_stream_context_get_option(
++								stream->context, "ssl", "no_ticket", &val) &&
++						zval_is_true(*val)) {
++					SSL_CTX_set_options(sslsock->ctx, SSL_OP_NO_TICKET);
++		}
++	}
++#endif
++
+ 	sslsock->ssl_handle = php_SSL_new_from_context(sslsock->ctx, stream TSRMLS_CC);
+ 	if (sslsock->ssl_handle == NULL) {
+ 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create an SSL handle");
diff -ruN php-5.4.4.orig/fink/patches/dont-gitclean-in-build.patch php-5.4.4/fink/patches/dont-gitclean-in-build.patch
--- php-5.4.4.orig/fink/patches/dont-gitclean-in-build.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/dont-gitclean-in-build.patch	2012-06-12 13:12:19.000000000 -0600
@@ -0,0 +1,18 @@
+Author: Sean Finney <seanius@debian.org>
+Description: Don't run git-clean via buildconf
+ Calling buildconf indirectly invokes vcsclean, which calls the gitclean-work
+ target of build/build.mk, which calls among other things git clean -X -f -d,
+ which in turn nukes the quilt .pc directory making life quite difficult for
+ us.
+ .
+ This patch doesn't need to go upstream, as they likely don't want to support
+ having a patch system on top of their source.
+--- a/build/build.mk
++++ b/build/build.mk
+@@ -75,6 +75,5 @@ gitclean-work:
+ 	@if (test ! -f '.git/info/exclude' || grep -s "git-ls-files" .git/info/exclude); then \
+ 		(echo "Rebuild .git/info/exclude" && echo '*.o' > .git/info/exclude && git svn propget svn:ignore | grep -v config.nice >> .git/info/exclude); \
+ 	fi; \
+-	git clean -X -f -d;
+ 
+ .PHONY: $(ALWAYS) snapshot
diff -ruN php-5.4.4.orig/fink/patches/exif_nesting_level.patch php-5.4.4/fink/patches/exif_nesting_level.patch
--- php-5.4.4.orig/fink/patches/exif_nesting_level.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/exif_nesting_level.patch	2012-06-12 12:59:48.000000000 -0600
@@ -0,0 +1,16 @@
+Description: Increase maximum exif nesting level.
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- a/ext/exif/exif.c
++++ b/ext/exif/exif.c
+@@ -99,7 +99,7 @@ typedef unsigned char uchar;
+ 
+ #define EFREE_IF(ptr)	if (ptr) efree(ptr)
+ 
+-#define MAX_IFD_NESTING_LEVEL 100
++#define MAX_IFD_NESTING_LEVEL 250
+ 
+ /* {{{ arginfo */
+ ZEND_BEGIN_ARG_INFO(arginfo_exif_tagname, 0)
diff -ruN php-5.4.4.orig/fink/patches/extension_api.patch php-5.4.4/fink/patches/extension_api.patch
--- php-5.4.4.orig/fink/patches/extension_api.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/extension_api.patch	2012-06-12 13:02:42.000000000 -0600
@@ -0,0 +1,59 @@
+Description: Adds --phpapi argument to php-config(1)
+ .
+ TODO: make it more generic and add it to the man page.
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- a/configure.in
++++ b/configure.in
+@@ -1177,8 +1177,13 @@ dnl Build extension directory path
+ 
+ ZEND_MODULE_API_NO=`$EGREP '#define ZEND_MODULE_API_NO ' $srcdir/Zend/zend_modules.h|$SED 's/#define ZEND_MODULE_API_NO //'`
+ 
++FINK_PHP_API=$ZEND_MODULE_API_NO
++if echo "$CPPFLAGS $CFLAGS" | grep -q -- -D_FILE_OFFSET_BITS=64; then
++  FINK_PHP_API="${FINK_PHP_API}+lfs"
++fi
++
+ if test -z "$EXTENSION_DIR"; then
+-  extbasedir=$ZEND_MODULE_API_NO
++  extbasedir=$FINK_PHP_API
+   if test "$oldstyleextdir" = "yes"; then
+     if test "$PHP_DEBUG" = "1"; then
+       part1=debug
+@@ -1321,6 +1326,7 @@ PHP_SUBST(CXX)
+ PHP_SUBST(CXXFLAGS)
+ PHP_SUBST(CXXFLAGS_CLEAN)
+ PHP_SUBST_OLD(DEBUG_CFLAGS)
++PHP_SUBST_OLD(FINK_PHP_API)
+ PHP_SUBST_OLD(EXTENSION_DIR)
+ PHP_SUBST_OLD(EXTRA_LDFLAGS)
+ PHP_SUBST_OLD(EXTRA_LDFLAGS_PROGRAM)
+--- a/scripts/php-config.in
++++ b/scripts/php-config.in
+@@ -19,6 +19,7 @@ php_cli_binary=NONE
+ php_cgi_binary=NONE
+ configure_options="@CONFIGURE_OPTIONS@"
+ php_sapis="@PHP_INSTALLED_SAPIS@"
++phpapi="@FINK_PHP_API@"
+ 
+ # Set php_cli_binary and php_cgi_binary if available
+ for sapi in $php_sapis; do
+@@ -57,6 +58,8 @@ case "$1" in
+   echo $include_dir;;
+ --php-binary)
+   echo $php_binary;;
++--phpapi)
++  echo $phpapi;;
+ --php-sapis)
+   echo $php_sapis;;
+ --configure-options)
+@@ -80,6 +83,7 @@ Options:
+   --man-dir           [$man_dir]
+   --php-binary        [$php_binary]
+   --php-sapis         [$php_sapis]
++  --phpapi            [$phpapi]
+   --configure-options [$configure_options]
+   --version           [$version]
+   --vernum            [$vernum]
diff -ruN php-5.4.4.orig/fink/patches/fd_setsize_fix.patch php-5.4.4/fink/patches/fd_setsize_fix.patch
--- php-5.4.4.orig/fink/patches/fd_setsize_fix.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fd_setsize_fix.patch	2012-06-12 13:48:30.000000000 -0600
@@ -0,0 +1,26 @@
+Description: Fixes misuse of FD_SET()
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- a/ext/sockets/sockets.c
++++ b/ext/sockets/sockets.c
+@@ -889,6 +889,7 @@ static int php_sock_array_to_fd_set(zval
+ 
+ 		php_sock = (php_socket*) zend_fetch_resource(element TSRMLS_CC, -1, le_socket_name, NULL, 1, le_socket);
+ 		if (!php_sock) continue; /* If element is not a resource, skip it */
++		if (php_sock->bsd_socket > FD_SETSIZE) continue; /* must ignore it */
+ 
+ 		PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
+ 		if (php_sock->bsd_socket > *max_fd) {
+--- a/ext/standard/streamsfuncs.c
++++ b/ext/standard/streamsfuncs.c
+@@ -621,6 +621,8 @@ static int stream_array_to_fd_set(zval *
+ 		 * is not displayed.
+ 		 * */
+ 		if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd != -1) {
++			if (this_fd > FD_SETSIZE)
++				continue;
+ 
+ 			PHP_SAFE_FD_SET(this_fd, fds);
+ 
diff -ruN php-5.4.4.orig/fink/patches/fink_quirks.patch php-5.4.4/fink/patches/fink_quirks.patch
--- php-5.4.4.orig/fink/patches/fink_quirks.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fink_quirks.patch	2012-07-24 14:56:41.000000000 -0600
@@ -0,0 +1,260 @@
+Description: Changes to make php use versioned paths and other minor
+ cleanup changes.
+Origin: vendor
+Forwarded: not-needed
+Last-Update: 2010-01-18
+
+--- a/configure.in
++++ b/configure.in
+@@ -1068,7 +1068,7 @@ if test "$PHP_CLI" = "no"; then
+ fi
+ 
+ PHP_ARG_WITH(pear, [whether to install PEAR],
+-[  --with-pear=DIR         Install PEAR in DIR @<:@PREFIX/lib/php@:>@
++[  --with-pear=DIR         Install PEAR in DIR @<:@PREFIX/lib/php5@:>@
+   --without-pear          Do not install PEAR], DEFAULT, yes)
+ 
+ if test "$PHP_PEAR" != "no"; then
+@@ -1098,7 +1098,7 @@ dnl
+   if test "$PHP_PEAR" = "DEFAULT" || test "$PHP_PEAR" = "yes"; then
+     case $PHP_LAYOUT in
+       GNU) PEAR_INSTALLDIR=$datadir/pear;;
+-      *)   PEAR_INSTALLDIR=$libdir/php;;
++      *)   PEAR_INSTALLDIR=$libdir/php5;;
+     esac
+   fi
+ 
+@@ -1153,12 +1153,12 @@ test "$program_suffix" = "NONE" && progr
+ 
+ case $libdir in
+   '${exec_prefix}/lib')
+-    libdir=$libdir/php
++    libdir=$libdir/php5
+     ;;
+ esac
+ case $datadir in
+   '${prefix}/share')
+-    datadir=$datadir/php
++    datadir=$datadir/php5
+     ;;
+ esac
+ 
+@@ -1225,7 +1225,7 @@ EXPANDED_SYSCONFDIR=`eval echo $sysconfd
+ EXPANDED_DATADIR=$datadir
+ EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"`
+ EXPANDED_PHP_CONFIG_FILE_SCAN_DIR=`eval echo "$PHP_CONFIG_FILE_SCAN_DIR"`
+-INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR
++INCLUDE_PATH=.:$EXPANDED_PEAR_INSTALLDIR:/usr/share/pear
+ 
+ exec_prefix=$old_exec_prefix
+ libdir=$old_libdir
+--- a/ext/ext_skel
++++ b/ext/ext_skel
+@@ -70,7 +70,7 @@ if test -d "$extname" ; then
+ fi
+ 
+ if test -z "$skel_dir"; then
+-  skel_dir="skeleton"
++  skel_dir="@FINKPREFIX@/lib/php5/skeleton"
+ fi
+ 
+ ## convert skel_dir to full path
+--- a/php.ini-development
++++ b/php.ini-development
+@@ -702,7 +702,7 @@ default_mimetype = "text/html"
+ ;;;;;;;;;;;;;;;;;;;;;;;;;
+ 
+ ; UNIX: "/path1:/path2"
+-;include_path = ".:/php/includes"
++;include_path = ".:@FINKPREFIX@/share/php"
+ ;
+ ; Windows: "\path1;\path2"
+ ;include_path = ".;c:\php\includes"
+--- a/php.ini-production
++++ b/php.ini-production
+@@ -702,7 +702,7 @@ default_mimetype = "text/html"
+ ;;;;;;;;;;;;;;;;;;;;;;;;;
+ 
+ ; UNIX: "/path1:/path2"
+-;include_path = ".:/php/includes"
++;include_path = ".:@FINKPREFIX@/share/php"
+ ;
+ ; Windows: "\path1;\path2"
+ ;include_path = ".;c:\php\includes"
+@@ -859,51 +859,6 @@ default_socket_timeout = 60
+ ; If you only provide the name of the extension, PHP will look for it in its
+ ; default extension directory.
+ ;
+-; Windows Extensions
+-; Note that ODBC support is built in, so no dll is needed for it.
+-; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
+-; extension folders as well as the separate PECL DLL download (PHP 5).
+-; Be sure to appropriately set the extension_dir directive.
+-;
+-;extension=php_bz2.dll
+-;extension=php_curl.dll
+-;extension=php_fileinfo.dll
+-;extension=php_gd2.dll
+-;extension=php_gettext.dll
+-;extension=php_gmp.dll
+-;extension=php_intl.dll
+-;extension=php_imap.dll
+-;extension=php_interbase.dll
+-;extension=php_ldap.dll
+-;extension=php_mbstring.dll
+-;extension=php_exif.dll      ; Must be after mbstring as it depends on it
+-;extension=php_mysql.dll
+-;extension=php_mysqli.dll
+-;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
+-;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
+-;extension=php_openssl.dll
+-;extension=php_pdo_firebird.dll
+-;extension=php_pdo_mysql.dll
+-;extension=php_pdo_oci.dll
+-;extension=php_pdo_odbc.dll
+-;extension=php_pdo_pgsql.dll
+-;extension=php_pdo_sqlite.dll
+-;extension=php_pgsql.dll
+-;extension=php_pspell.dll
+-;extension=php_shmop.dll
+-
+-; The MIBS data available in the PHP distribution must be installed. 
+-; See http://www.php.net/manual/en/snmp.installation.php 
+-;extension=php_snmp.dll
+-
+-;extension=php_soap.dll
+-;extension=php_sockets.dll
+-;extension=php_sqlite3.dll
+-;extension=php_sybase_ct.dll
+-;extension=php_tidy.dll
+-;extension=php_xmlrpc.dll
+-;extension=php_xsl.dll
+-;extension=php_zip.dll
+ 
+ ;;;;;;;;;;;;;;;;;;;
+ ; Module Settings ;
+--- a/sapi/caudium/config.m4
++++ b/sapi/caudium/config.m4
+@@ -26,8 +26,8 @@ if test "$PHP_CAUDIUM" != "no"; then
+     AC_MSG_ERROR([Could not find a pike in $PHP_CAUDIUM/bin/])
+   fi
+   if $PIKE -e 'float v; int rel;sscanf(version(), "Pike v%f release %d", v, rel);v += rel/10000.0; if(v < 7.0268) exit(1); exit(0);'; then
+-    PIKE_MODULE_DIR=`$PIKE --show-paths 2>&1| grep '^Module' | sed -e 's/.*: //'`
+-    PIKE_INCLUDE_DIR=`echo $PIKE_MODULE_DIR | sed -e 's,lib/pike/modules,include/pike,' -e 's,lib/modules,include/pike,' `
++    PIKE_MODULE_DIR=`$PIKE --show-paths 2>&1| grep '^Master file' | sed -e 's/.*: //' -e 's/master.pike/modules/'`
++    PIKE_INCLUDE_DIR=`echo $PIKE_MODULE_DIR | sed -e 's,lib/modules,,' -e 's,modules,include,' `
+     if test -z "$PIKE_INCLUDE_DIR" || test -z "$PIKE_MODULE_DIR"; then
+       AC_MSG_ERROR(Failed to figure out Pike module and include directories)
+     fi
+@@ -84,7 +84,9 @@ if test "$PHP_CAUDIUM" != "no"; then
+   PIKE_VERSION=`$PIKE -e 'string v; int rel;sscanf(version(), "Pike v%s release %d", v, rel); write(v+"."+rel);'`   
+   AC_DEFINE(HAVE_CAUDIUM,1,[Whether to compile with Caudium support])
+   PHP_SELECT_SAPI(caudium, shared, caudium.c)
+-  INSTALL_IT="\$(INSTALL) -m 0755 $SAPI_SHARED $PHP_CAUDIUM/lib/$PIKE_VERSION/PHP5.so"
++  dnl FIXME: This is the ugliest hack in the world!
++  dnl INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)$PHP_CAUDIUM/lib/$PIKE_VERSION/ && \$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)$PHP_CAUDIUM/lib/$PIKE_VERSION/php5.so"
++  INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)$PHP_CAUDIUM/lib/$PIKE_VERSION/ && \$(INSTALL) -m 0755 .$SAPI_SHARED \$(INSTALL_ROOT)$PHP_CAUDIUM/lib/$PIKE_VERSION/PHP5.so"
+   RESULT="  *** Pike binary used:         $PIKE
+   *** Pike include dir(s) used: $PIKE_INCLUDE_DIR
+   *** Pike version:             $PIKE_VERSION"
+--- a/sapi/cli/php.1.in
++++ b/sapi/cli/php.1.in
+@@ -346,13 +346,14 @@ Shows configuration for extension
+ Show configuration file names
+ .SH FILES
+ .TP 15
+-.B php\-cli.ini
++.B @FINKPREFIX@/etc/php5/cli/php.ini
+ The configuration file for the CLI version of PHP.
+ .TP
+-.B php.ini
+-The standard configuration file will only be used when 
+-.B php\-cli.ini
+-cannot be found.
++.B @FINKPREFIX@/etc/php5/cgi/php.ini
++The configuration file for the CGI version of PHP.
++.TP
++.B @FINKPREFIX@/etc/php5/apache2/php.ini
++The configuration file for the version of PHP that apache2 uses.
+ .SH EXAMPLES
+ .TP 5
+ \fIphp \-r 'echo "Hello World\\n";'\fP
+--- a/scripts/Makefile.frag
++++ b/scripts/Makefile.frag
+@@ -3,8 +3,8 @@
+ # Build environment install
+ #
+ 
+-phpincludedir = $(includedir)/php
+-phpbuilddir = $(libdir)/build
++phpincludedir = $(includedir)/php5
++phpbuilddir = $(prefix)/lib/php5/build
+ 
+ BUILD_FILES = \
+ 	scripts/phpize.m4 \
+--- a/scripts/php-config.in
++++ b/scripts/php-config.in
+@@ -6,8 +6,8 @@ datarootdir="@datarootdir@"
+ exec_prefix="@exec_prefix@"
+ version="@PHP_VERSION@"
+ vernum="@PHP_VERSION_ID@"
+-include_dir="@includedir@/php"
+-includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
++include_dir="@includedir@/php5"
++includes="-I$include_dir -I$include_dir/main -I$include_dir/TSRM -I$include_dir/Zend -I$include_dir/ext -I$include_dir/ext/date/lib"
+ ldflags="@PHP_LDFLAGS@"
+ libs="@EXTRA_LIBS@"
+ extension_dir='@EXTENSION_DIR@'
+--- a/scripts/phpize.in
++++ b/scripts/phpize.in
+@@ -4,8 +4,8 @@
+ prefix='@prefix@'
+ datarootdir='@datarootdir@'
+ exec_prefix="`eval echo @exec_prefix@`"
+-phpdir="`eval echo @libdir@`/build"
+-includedir="`eval echo @includedir@`/php"
++phpdir="$prefix/lib/php5/build"
++includedir="$prefix/include/php5"
+ builddir="`pwd`"
+ SED="@SED@"
+ 
+--- php-5.4.3.orig/ext/pdo/config.m4	2012-05-07 23:22:56.000000000 -0600
++++ php-5.4.3.old/ext/pdo/config.m4	2012-06-12 15:33:12.000000000 -0600
+@@ -39,7 +39,7 @@
+ 
+   if test "$ext_shared" = "yes" ; then
+     case $host_alias in
+-      *darwin*)
++      *darwin7*)
+           AC_MSG_ERROR([
+ Due to the way that loadable modules work on OSX/Darwin, you need to
+ compile the PDO package statically into the PHP core.
+--- php-5.4.3.orig/ext/gd/config.m4	2012-05-07 23:22:56.000000000 -0600
++++ php-5.4.3.old/ext/gd/config.m4	2012-06-12 15:46:05.000000000 -0600
+@@ -102,7 +102,7 @@
+ AC_DEFUN([PHP_GD_JPEG],[
+   if test "$PHP_JPEG_DIR" != "no"; then
+ 
+-    for i in $PHP_JPEG_DIR /usr/local /usr; do
++    for i in $PHP_JPEG_DIR @FINKPREFIX@ /usr/local /usr; do
+       test -f $i/include/jpeglib.h && GD_JPEG_DIR=$i && break
+     done
+ 
+@@ -127,7 +127,7 @@
+ AC_DEFUN([PHP_GD_PNG],[
+   if test "$PHP_PNG_DIR" != "no"; then
+ 
+-    for i in $PHP_PNG_DIR /usr/local /usr; do
++    for i in $PHP_PNG_DIR @FINKPREFIX@ /usr/local /usr; do
+       test -f $i/include/png.h && GD_PNG_DIR=$i && break
+     done
+ 
+@@ -192,7 +192,7 @@
+ AC_DEFUN([PHP_GD_FREETYPE2],[
+   if test "$PHP_FREETYPE_DIR" != "no"; then
+ 
+-    for i in $PHP_FREETYPE_DIR /usr/local /usr; do
++    for i in $PHP_FREETYPE_DIR @FINKPREFIX@ /usr/local /usr; do
+       if test -f "$i/bin/freetype-config"; then
+         FREETYPE2_DIR=$i
+         FREETYPE2_CONFIG="$i/bin/freetype-config"
diff -ruN php-5.4.4.orig/fink/patches/fix_broken_5.3_tests.patch php-5.4.4/fink/patches/fix_broken_5.3_tests.patch
--- php-5.4.4.orig/fink/patches/fix_broken_5.3_tests.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fix_broken_5.3_tests.patch	2012-06-12 13:11:26.000000000 -0600
@@ -0,0 +1,30 @@
+Author: Sean Finney <seanius@debian.org>
+Description: Fix another small batch of broken test cases
+ * ext/standard/tests/php_ini_loaded_file.phpt: this test only works if
+   you call run-tests directly, but the included Makefile invokes the
+   test in such a way that it fails (it explicitly loads an ini file,
+   and the test assumes that none are loaded).  since it therefore seems
+   like a somewhat useless test it has been removed.
+ * cli/tests/006.phpt: $subject is <required> according to the docs for
+   the two pcre functions that report it as such, so the expected string has
+   been updated to match the output.
+ * php.orig/ext/posix/tests/posix_errno_variation2.phpt: SIGKILL is not
+   a defined constant unless the pcntl extension is loaded.  As was
+   done elsewhere (posix_kill_basic.phpt, which oddly seems to do the
+   same *incredibly sketchy* test that's done here), it's passed as a
+   variable hardcoded to 9 instead.  Did i mention that this test is
+   sketchy?
+Origin: vendor
+--- a/ext/posix/tests/posix_errno_variation2.phpt
++++ b/ext/posix/tests/posix_errno_variation2.phpt
+@@ -21,7 +21,9 @@ do {
+   $result = shell_exec("ps -p " . $pid);
+ } while (strstr($pid, $result)); 
+ 
+-posix_kill($pid, SIGKILL);
++/* don't depend on SIGKILL being defined (pcntl might not not be loaded) */
++$SIGKILL = 9;
++posix_kill($pid, $SIGKILL);
+ var_dump(posix_errno());
+ 
+ ?>
diff -ruN php-5.4.4.orig/fink/patches/fix_broken_sha2_test.patch php-5.4.4/fink/patches/fix_broken_sha2_test.patch
--- php-5.4.4.orig/fink/patches/fix_broken_sha2_test.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fix_broken_sha2_test.patch	2012-06-12 13:14:47.000000000 -0600
@@ -0,0 +1,39 @@
+--- a/ext/standard/config.m4
++++ b/ext/standard/config.m4
+@@ -182,12 +182,12 @@ AC_TRY_RUN([
+ 
+ main() {
+ #if HAVE_CRYPT
+-    char salt[30], answer[80];
+-    
+-    salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]='$'; salt[4]='b'; salt[5]='a'; salt[6]='r'; salt[7]='\0';
++    char salt[21], answer[21+86];
++
++    strcpy(salt,"\$6\$rasmuslerdorf\$");
+     strcpy(answer, salt);
+-    strcpy(&answer[29],"$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.");
+-    exit (strcmp((char *)crypt("foo",salt),answer));
++    strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/");
++    exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
+ #else
+ 	exit(0);
+ #endif
+@@ -211,12 +211,13 @@ AC_TRY_RUN([
+ 
+ main() {
+ #if HAVE_CRYPT
+-    char salt[30], answer[80];
+-    salt[0]='$'; salt[1]='5'; salt[2]='$'; salt[3]='$'; salt[4]='s'; salt[5]='a'; salt[6]='l'; salt[7]='t';  salt[8]='s'; salt[9]='t'; salt[10]='r'; salt[11]='i'; salt[12]='n'; salt[13]='g'; salt[14]='\0';    
+-    strcat(salt,"");
++    char salt[21], answer[21+43];
++
++    strcpy(salt,"\$5\$rasmuslerdorf\$");
+     strcpy(answer, salt);
+-    strcpy(&answer[29], "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5");
+-    exit (strcmp((char *)crypt("foo",salt),answer));
++    strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23");
++    exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
++
+ #else
+ 	exit(0);
+ #endif
diff -ruN php-5.4.4.orig/fink/patches/fix_broken_upstream_tests.patch php-5.4.4/fink/patches/fix_broken_upstream_tests.patch
--- php-5.4.4.orig/fink/patches/fix_broken_upstream_tests.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fix_broken_upstream_tests.patch	2012-06-12 13:07:11.000000000 -0600
@@ -0,0 +1,25 @@
+Description: Add missing settings to fix upstream tests
+Origin: vendor
+Forwarded: http://bugs.php.net/50796
+Last-Update: 2010-01-18
+
+--- a/ext/soap/tests/server009.phpt
++++ b/ext/soap/tests/server009.phpt
+@@ -10,6 +10,7 @@ SOAP Server 9: setclass and setpersisten
+ --INI--
+ session.auto_start=1
+ session.save_handler=files
++session.save_path=temp_session_store
+ --FILE--
+ <?php
+ class foo {
+--- a/ext/standard/tests/general_functions/phpinfo.phpt
++++ b/ext/standard/tests/general_functions/phpinfo.phpt
+@@ -1,5 +1,7 @@
+ --TEST--
+ phpinfo()
++--SKIPIF--
++<?php die("SKIP phpinfo - test suite's handling of "%s" is incompatible with this test"); ?>
+ --FILE--
+ <?php
+ var_dump(phpinfo());
diff -ruN php-5.4.4.orig/fink/patches/fix_crash_in__php_mssql_get_column_content_without_type.patch php-5.4.4/fink/patches/fix_crash_in__php_mssql_get_column_content_without_type.patch
--- php-5.4.4.orig/fink/patches/fix_crash_in__php_mssql_get_column_content_without_type.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fix_crash_in__php_mssql_get_column_content_without_type.patch	2012-06-12 13:18:24.000000000 -0600
@@ -0,0 +1,17 @@
+--- a/ext/mssql/php_mssql.c
++++ b/ext/mssql/php_mssql.c
+@@ -1106,6 +1106,14 @@ static void php_mssql_get_column_content
+ 			return;
+ 		}
+ 
++		if (res_length == 0) {
++			ZVAL_NULL(result);
++			return;
++		} else if (res_length < 0) {
++			ZVAL_FALSE(result);
++			return;
++		}
++
+ 		res_buf = (unsigned char *) emalloc(res_length+1);
+ 		bin = ((DBBINARY *)dbdata(mssql_ptr->link, offset));
+ 		res_buf[res_length] = '\0';
diff -ruN php-5.4.4.orig/fink/patches/fix_crypt_includes.patch php-5.4.4/fink/patches/fix_crypt_includes.patch
--- php-5.4.4.orig/fink/patches/fix_crypt_includes.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fix_crypt_includes.patch	2012-06-12 16:31:25.000000000 -0600
@@ -0,0 +1,62 @@
+--- php-5.4.3.orig/ext/standard/config.m4	2012-05-07 23:22:56.000000000 -0600
++++ php-5.4.3.old/ext/standard/config.m4	2012-06-12 16:30:26.000000000 -0600
+@@ -61,6 +61,9 @@
+   
+ AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
+   AC_TRY_RUN([
++#include <string.h>
++#include <stdlib.h>
++
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+@@ -85,6 +88,9 @@
+ 
+ AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[
+   AC_TRY_RUN([
++#include <string.h>
++#include <stdlib.h>
++
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+@@ -109,6 +115,9 @@
+ 
+ AC_CACHE_CHECK(for MD5 crypt, ac_cv_crypt_md5,[
+ AC_TRY_RUN([
++#include <string.h>
++#include <stdlib.h>
++
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+@@ -142,6 +151,9 @@
+ 
+ AC_CACHE_CHECK(for Blowfish crypt, ac_cv_crypt_blowfish,[
+ AC_TRY_RUN([
++#include <string.h>
++#include <stdlib.h>
++
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+@@ -172,6 +184,9 @@
+ 
+ AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_SHA512,[
+ AC_TRY_RUN([
++#include <string.h>
++#include <stdlib.h>
++
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+@@ -201,6 +216,9 @@
+ 
+ AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_SHA256,[
+ AC_TRY_RUN([
++#include <string.h>
++#include <stdlib.h>
++
+ #if HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
diff -ruN php-5.4.4.orig/fink/patches/force_libmysqlclient_r.patch php-5.4.4/fink/patches/force_libmysqlclient_r.patch
--- php-5.4.4.orig/fink/patches/force_libmysqlclient_r.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/force_libmysqlclient_r.patch	2012-06-12 13:58:43.000000000 -0600
@@ -0,0 +1,41 @@
+Description: Force linking to mysqlclient_r to avoid symbol conflicts.
+ apr-util's mysql driver is linked against that version of the library
+ but due to missing proper symbols versioning we are forced to link to
+ the re-entrant library too.
+Origin: other, http://bugs.debian.org/469081
+Forwarded: not-needed
+Last-Update: 2010-01-18
+
+--- a/ext/mysql/config.m4
++++ b/ext/mysql/config.m4
+@@ -76,7 +76,7 @@ elif test "$PHP_MYSQL" != "no"; then
+ Note that the MySQL client library is not bundled anymore!])
+   fi
+ 
+-  if test "$enable_maintainer_zts" = "yes"; then
++  if true || test "$enable_maintainer_zts" = "yes"; then
+     MYSQL_LIBNAME=mysqlclient_r
+   else
+     MYSQL_LIBNAME=mysqlclient
+--- a/ext/mysqli/config.m4
++++ b/ext/mysqli/config.m4
+@@ -25,7 +25,7 @@ elif test "$PHP_MYSQLI" != "no"; then
+     MYSQL_LIB_CFG='--libmysqld-libs'
+     dnl mysqlnd doesn't support embedded, so we have to add some extra stuff
+     mysqli_extra_sources="mysqli_embedded.c"
+-  elif test "$enable_maintainer_zts" = "yes"; then
++  elif true || test "$enable_maintainer_zts" = "yes"; then
+     MYSQL_LIB_CFG='--libs_r'
+     MYSQL_LIB_NAME='mysqlclient_r'
+   else
+--- a/ext/pdo_mysql/config.m4
++++ b/ext/pdo_mysql/config.m4
+@@ -55,7 +55,7 @@ if test "$PHP_PDO_MYSQL" != "no"; then
+       if test "x$SED" = "x"; then
+         AC_PATH_PROG(SED, sed)
+       fi
+-      if test "$enable_maintainer_zts" = "yes"; then
++      if true || test "$enable_maintainer_zts" = "yes"; then
+         PDO_MYSQL_LIBNAME=mysqlclient_r
+         PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs_r | $SED -e "s/'//g"`
+       else
diff -ruN php-5.4.4.orig/fink/patches/fpm-config.patch php-5.4.4/fink/patches/fpm-config.patch
--- php-5.4.4.orig/fink/patches/fpm-config.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/fpm-config.patch	2012-06-25 15:34:48.000000000 -0600
@@ -0,0 +1,54 @@
+Description: Add major version number to paths and allow process pools
+ to be configured in individual files in /etc/php5/fpm/pool.d/
+Origin: vendor
+Forwarded: not-needed
+Last-Update: 2010-07-30
+
+--- a/sapi/fpm/php-fpm.conf.in
++++ b/sapi/fpm/php-fpm.conf.in
+@@ -12,7 +12,7 @@
+ ; Relative path can also be used. They will be prefixed by:
+ ;  - the global prefix if it's been set (-p arguement)
+ ;  - @prefix@ otherwise
+-;include=etc/fpm.d/*.conf
++;include=@FINKPREFIX@/etc/php5/fpm/*.conf
+ 
+ ;;;;;;;;;;;;;;;;;;
+ ; Global Options ;
+@@ -22,14 +22,14 @@
+ ; Pid file
+ ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
+ ; Default Value: none
+-;pid = run/php-fpm.pid
++pid = @FINKPREFIX@/var/run/php5-fpm.pid
+ 
+ ; Error log file
+ ; If it's set to "syslog", log is sent to syslogd instead of being written
+ ; in a local file.
+ ; Note: the default prefix is @EXPANDED_LOCALSTATEDIR@
+ ; Default Value: log/php-fpm.log
+-;error_log = log/php-fpm.log
++error_log = @FINKPREFIX@/var/log/php5-fpm.log
+ 
+ ; syslog_facility is used to specify what type of program is logging the
+ ; message. This lets syslogd specify that messages from different facilities
+@@ -108,6 +108,10 @@
+ ; used in logs and stats. There is no limitation on the number of pools which
+ ; FPM can handle. Your system will tell you anyway :)
+ 
++; To configure the pools it is recommended to have one .conf file per
++; pool in the following directory:
++include=@FINKPREFIX@/etc/php5/fpm/pool.d/*.conf
++
+ ; Start a new pool named 'www'.
+ ; the variable $pool can we used in any directive and will be replaced by the
+ ; pool name ('www' here)
+@@ -442,7 +446,7 @@ pm.max_spare_servers = 3
+ ; Chdir to this directory at the start.
+ ; Note: relative path can be used.
+ ; Default Value: current directory or / when chroot
+-;chdir = /var/www
++chdir = /
+  
+ ; Redirect worker stdout and stderr into main error log. If not set, stdout and
+ ; stderr will be redirected to /dev/null according to FastCGI specs.
diff -ruN php-5.4.4.orig/fink/patches/gd-libJPEG-Version.patch php-5.4.4/fink/patches/gd-libJPEG-Version.patch
--- php-5.4.4.orig/fink/patches/gd-libJPEG-Version.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/gd-libJPEG-Version.patch	2012-06-07 11:57:52.000000000 -0600
@@ -0,0 +1,13 @@
+diff -ruN php-5.4.3.orig/ext/gd/libgd/gd_compat.c php-5.4.3.patched/ext/gd/libgd/gd_compat.c
+--- php-5.4.3.orig/ext/gd/libgd/gd_compat.c	2012-05-07 23:22:56.000000000 -0600
++++ php-5.4.3.patched/ext/gd/libgd/gd_compat.c	2012-06-07 11:57:03.000000000 -0600
+@@ -20,6 +20,9 @@
+ 		case 62:
+ 			return "6b";
+ 			break;
++		case 80:
++			return "8";
++			break;
+ 		default:
+ 			return "unknown";
+ 	}
diff -ruN php-5.4.4.orig/fink/patches/gdIOCtx.patch php-5.4.4/fink/patches/gdIOCtx.patch
--- php-5.4.4.orig/fink/patches/gdIOCtx.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/gdIOCtx.patch	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,124 @@
+--- a/ext/gd/gd_ctx.c
++++ b/ext/gd/gd_ctx.c
+@@ -46,33 +46,6 @@ static void _php_image_output_ctxfree(st
+ 	}
+ }
+ 
+-static void _php_image_stream_putc(struct gdIOCtx *ctx, int c)  {
+-	char ch = (char) c;
+-	php_stream * stream = (php_stream *)ctx->data;
+-	TSRMLS_FETCH();
+-	php_stream_write(stream, &ch, 1);
+-}
+-
+-static int _php_image_stream_putbuf(struct gdIOCtx *ctx, const void* buf, int l)
+-{
+-	php_stream * stream = (php_stream *)ctx->data;
+-	TSRMLS_FETCH();
+-	return php_stream_write(stream, (void *)buf, l);
+-}
+-
+-static void _php_image_stream_ctxfree(struct gdIOCtx *ctx)
+-{
+-	TSRMLS_FETCH();
+-
+-	if(ctx->data) {
+-		php_stream_close((php_stream *) ctx->data);
+-		ctx->data = NULL;
+-	}
+-	if(ctx) {
+-		efree(ctx);
+-	}
+-}
+-
+ /* {{{ _php_image_output_ctx */
+ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)())
+ {
+@@ -81,12 +54,11 @@ static void _php_image_output_ctx(INTERN
+ 	int file_len = 0;
+ 	long quality, basefilter;
+ 	gdImagePtr im;
++	FILE *fp = NULL;
+ 	int argc = ZEND_NUM_ARGS();
+ 	int q = -1, i;
+ 	int f = -1;
+ 	gdIOCtx *ctx = NULL;
+-	zval *to_zval = NULL;
+-	php_stream *stream;
+ 
+ 	/* The third (quality) parameter for Wbmp stands for the threshold when called from image2wbmp().
+ 	 * The third (quality) parameter for Wbmp and Xbm stands for the foreground color index when called
+@@ -103,7 +75,7 @@ static void _php_image_output_ctx(INTERN
+ 		 * PHP_GDIMG_TYPE_WBM 
+ 		 * PHP_GDIMG_TYPE_WEBP 
+ 		 * */
+-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|z/!ll", &imgind, &to_zval, &quality, &basefilter) == FAILURE) {
++		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|p!ll", &imgind, &file, &file_len, &quality, &basefilter) == FAILURE) {
+ 			return;
+ 		}
+ 	}
+@@ -117,21 +89,19 @@ static void _php_image_output_ctx(INTERN
+ 		}
+ 	}
+ 
+-	if (argc > 1 && to_zval != NULL) {
+-		if (Z_TYPE_P(to_zval) == IS_RESOURCE) {
+-			php_stream_from_zval_no_verify(stream, &to_zval);
+-			if (stream == NULL) {
+-				RETURN_FALSE;
+-			}
+-		} else if (Z_TYPE_P(to_zval) == IS_STRING) {
+-			stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
+-			if (stream == NULL) {
+-				RETURN_FALSE;
+-			}
+-		} else {
+-			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 2nd parameter, it must a filename or a stream");
++	if (argc > 1 && file_len) {
++		if (strlen(file) != file_len) {
++			RETURN_FALSE;
++		}
++		PHP_GD_CHECK_OPEN_BASEDIR(file, "Invalid filename");
++
++		fp = VCWD_FOPEN(file, "wb");
++		if (!fp) {
++			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing: %s", file, strerror(errno));
+ 			RETURN_FALSE;
+ 		}
++
++		ctx = gdNewFileCtx(fp);
+ 	} else {
+ 		ctx = emalloc(sizeof(gdIOCtx));
+ 		ctx->putC = _php_image_output_putc;
+@@ -145,14 +115,6 @@ static void _php_image_output_ctx(INTERN
+ #endif
+ 	}
+ 
+-	if (!ctx)	{
+-		ctx = emalloc(sizeof(gdIOCtx));
+-		ctx->putC = _php_image_stream_putc;
+-		ctx->putBuf = _php_image_stream_putbuf;
+-		ctx->gd_free = _php_image_stream_ctxfree;
+-		ctx->data = (void *)stream;
+-	}
+-
+ 	switch(image_type) {
+ 		case PHP_GDIMG_CONVERT_WBM:
+ 			if(q<0||q>255) {
+@@ -189,11 +151,12 @@ static void _php_image_output_ctx(INTERN
+ 			break;
+ 	}
+ 
+-#if HAVE_LIBGD204
+ 	ctx->gd_free(ctx);
+-#else
+-	ctx->free(ctx);
+-#endif
++
++	if(fp) {
++		fflush(fp);
++		fclose(fp);
++	}
+ 
+ 	RETURN_TRUE;
+ }
diff -ruN php-5.4.4.orig/fink/patches/giconv_is_inferior.patch php-5.4.4/fink/patches/giconv_is_inferior.patch
--- php-5.4.4.orig/fink/patches/giconv_is_inferior.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/giconv_is_inferior.patch	2012-06-14 11:36:36.000000000 -0600
@@ -0,0 +1,60 @@
+--- php-5.4.3.orig/acinclude.m4	2012-05-07 23:22:56.000000000 -0600
++++ php-5.4.3.old/acinclude.m4	2012-06-12 15:48:09.000000000 -0600
+@@ -2473,14 +2473,14 @@
+   if test "$found_iconv" = "no"; then
+ 
+     for i in $PHP_ICONV /usr/local /usr; do
+-      if test -r $i/include/giconv.h; then
+-        AC_DEFINE(HAVE_GICONV_H, 1, [ ])
++      if test -r $i/include/iconv.h; then
+         ICONV_DIR=$i
+-        iconv_lib_name=giconv
++        iconv_lib_name=iconv
+         break
+-      elif test -r $i/include/iconv.h; then
++      elif test -r $i/include/giconv.h; then
++        AC_DEFINE(HAVE_GICONV_H, 1, [ ])
+         ICONV_DIR=$i
+-        iconv_lib_name=iconv
++        iconv_lib_name=giconv
+         break
+       fi
+     done
+--- php-5.4.3.orig/aclocal.m4	2012-05-08 00:19:30.000000000 -0600
++++ php-5.4.3.old/aclocal.m4	2012-06-12 15:49:10.000000000 -0600
+@@ -2473,14 +2473,14 @@
+   if test "$found_iconv" = "no"; then
+ 
+     for i in $PHP_ICONV /usr/local /usr; do
+-      if test -r $i/include/giconv.h; then
+-        AC_DEFINE(HAVE_GICONV_H, 1, [ ])
++      if test -r $i/include/iconv.h; then
+         ICONV_DIR=$i
+-        iconv_lib_name=giconv
++        iconv_lib_name=iconv
+         break
+-      elif test -r $i/include/iconv.h; then
++      elif test -r $i/include/giconv.h; then
++        AC_DEFINE(HAVE_GICONV_H, 1, [ ])
+         ICONV_DIR=$i
+-        iconv_lib_name=iconv
++        iconv_lib_name=giconv
+         break
+       fi
+     done
+--- php-5.4.3.orig/ext/iconv/config.m4	2012-05-07 23:22:56.000000000 -0600
++++ php-5.4.3.old/ext/iconv/config.m4	2012-06-12 15:50:36.000000000 -0600
+@@ -31,10 +31,10 @@
+     CFLAGS="-I$PHP_ICONV_PREFIX/include $CFLAGS"
+     LDFLAGS="-L$PHP_ICONV_PREFIX/$PHP_LIBDIR $LDFLAGS"
+ 
+-    if test -r "$PHP_ICONV_PREFIX/include/giconv.h"; then
+-      PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/giconv.h"
+-    else
++    if test -r "$PHP_ICONV_PREFIX/include/iconv.h"; then
+       PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/iconv.h"
++    else
++      PHP_ICONV_H_PATH="$PHP_ICONV_PREFIX/include/giconv.h"
+     fi 
+ 
+     AC_MSG_CHECKING([if iconv is glibc's])
diff -ruN php-5.4.4.orig/fink/patches/ldap_fix.patch php-5.4.4/fink/patches/ldap_fix.patch
--- php-5.4.4.orig/fink/patches/ldap_fix.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/ldap_fix.patch	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,27 @@
+Description: Prevent null dereferencing in ldap_explode_dn()
+Origin: vendor
+Bug-Debian: http://bugs.debian.org/205405
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- a/ext/ldap/ldap.c
++++ b/ext/ldap/ldap.c
+@@ -1212,7 +1212,7 @@ PHP_FUNCTION(ldap_explode_dn)
+ 	}
+ 
+ 	i=0;
+-	while (ldap_value[i] != NULL) i++;
++	while (ldap_value && ldap_value[i] != NULL) i++;
+ 	count = i;
+ 
+ 	array_init(return_value);
+@@ -1222,7 +1222,8 @@ PHP_FUNCTION(ldap_explode_dn)
+ 		add_index_string(return_value, i, ldap_value[i], 1);
+ 	}
+ 
+-	ldap_value_free(ldap_value);
++	if (ldap_value)
++		ldap_value_free(ldap_value);
+ }
+ /* }}} */
+ 
diff -ruN php-5.4.4.orig/fink/patches/libdb_is_-ldb.patch php-5.4.4/fink/patches/libdb_is_-ldb.patch
--- php-5.4.4.orig/fink/patches/libdb_is_-ldb.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/libdb_is_-ldb.patch	2012-06-12 15:42:42.000000000 -0600
@@ -0,0 +1,29 @@
+Description: Let configure check detect version-less libdbs to support
+ newer versions without patching the configure code.
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- php-5.4.3.orig/ext/dba/config.m4	2012-05-07 23:22:56.000000000 -0600
++++ php-5.4.3.old/ext/dba/config.m4	2012-06-12 15:42:05.000000000 -0600
+@@ -320,9 +320,9 @@
+       THIS_PREFIX=$i
+       THIS_INCLUDE=$i/db4/db.h
+       break
+-    elif test -f "$i/include/db5.1/db.h"; then
++    elif test -f "$i/include/db5.3/db.h"; then
+       THIS_PREFIX=$i
+-      THIS_INCLUDE=$i/include/db5.1/db.h
++      THIS_INCLUDE=$i/include/db5.3/db.h
+       break
+     elif test -f "$i/include/db5.0/db.h"; then
+       THIS_PREFIX=$i
+@@ -362,7 +362,7 @@
+       break
+     fi
+   done
+-  PHP_DBA_DB_CHECK(4, db-5.1 db-5.0 db-4.8 db-4.7 db-4.6 db-4.5 db-4.4 db-4.3 db-4.2 db-4.1 db-4.0 db-4 db4 db, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
++  PHP_DBA_DB_CHECK(4, db-5.3, [(void)db_create((DB**)0, (DB_ENV*)0, 0)])
+ fi
+ PHP_DBA_STD_RESULT(db4,Berkeley DB4)
+ 
diff -ruN php-5.4.4.orig/fink/patches/libtool2.2.patch php-5.4.4/fink/patches/libtool2.2.patch
--- php-5.4.4.orig/fink/patches/libtool2.2.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/libtool2.2.patch	2012-06-12 12:51:29.000000000 -0600
@@ -0,0 +1,31 @@
+--- a/scripts/phpize.in
++++ b/scripts/phpize.in
+@@ -6,10 +6,16 @@ datarootdir='@datarootdir@'
+ exec_prefix="`eval echo @exec_prefix@`"
+ phpdir="$prefix/lib/php5/build"
+ includedir="$prefix/include/php5"
++aclocaldir="$prefix/share/aclocal"
+ builddir="`pwd`"
+ SED="@SED@"
+ 
+-FILES_BUILD="mkdep.awk scan_makefile_in.awk shtool libtool.m4"
++FILES_BUILD="mkdep.awk scan_makefile_in.awk shtool"
++if [ -f "$aclocaldir/ltsugar.m4" ]; then
++    LIBTOOL_FILES="libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4"
++else
++    LIBTOOL_FILES="libtool.m4"
++fi
+ FILES="acinclude.m4 Makefile.global config.sub config.guess ltmain.sh run-tests*.php"
+ CLEAN_FILES="$FILES *.o *.lo *.la .deps .libs/ build/ include/ modules/ install-sh \
+ 	mkinstalldirs missing config.nice config.sub config.guess configure configure.in \
+@@ -145,8 +151,9 @@ phpize_copy_files()
+   test -d build || mkdir build
+  
+   (cd "$phpdir" && cp $FILES_BUILD "$builddir"/build)
++  (cd "$aclocaldir" && cp $LIBTOOL_FILES "$builddir"/build)
+   (cd "$phpdir" && cp $FILES "$builddir")
+-  (cd "$builddir" && cat acinclude.m4 ./build/libtool.m4 > aclocal.m4)
++  (cd "$builddir/build" && cat ../acinclude.m4 $LIBTOOL_FILES > ../aclocal.m4)
+ }
+ 
+ phpize_replace_prefix()
diff -ruN php-5.4.4.orig/fink/patches/libxml-reset-the-handler.patch php-5.4.4/fink/patches/libxml-reset-the-handler.patch
--- php-5.4.4.orig/fink/patches/libxml-reset-the-handler.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/libxml-reset-the-handler.patch	2012-06-12 11:52:07.000000000 -0600
@@ -0,0 +1,23 @@
+--- a/ext/libxml/libxml.c
++++ b/ext/libxml/libxml.c
+@@ -851,7 +851,6 @@ static PHP_MSHUTDOWN_FUNCTION(libxml)
+ {
+ 	if (!_php_libxml_per_request_initialization) {
+ 		xmlSetGenericErrorFunc(NULL, NULL);
+-		xmlSetStructuredErrorFunc(NULL, NULL);
+ 
+ 		xmlParserInputBufferCreateFilenameDefault(NULL);
+ 		xmlOutputBufferCreateFilenameDefault(NULL);
+@@ -867,11 +866,11 @@ static int php_libxml_post_deactivate()
+ 	/* reset libxml generic error handling */
+ 	if (_php_libxml_per_request_initialization) {
+ 		xmlSetGenericErrorFunc(NULL, NULL);
+-		xmlSetStructuredErrorFunc(NULL, NULL);
+ 
+ 		xmlParserInputBufferCreateFilenameDefault(NULL);
+ 		xmlOutputBufferCreateFilenameDefault(NULL);
+ 	}
++	xmlSetStructuredErrorFunc(NULL, NULL);
+ 
+ 	if (LIBXML(stream_context)) {
+ 		/* the steam_context resource will be released by resource list destructor */
diff -ruN php-5.4.4.orig/fink/patches/lp564920-fix-big-files.patch php-5.4.4/fink/patches/lp564920-fix-big-files.patch
--- php-5.4.4.orig/fink/patches/lp564920-fix-big-files.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/lp564920-fix-big-files.patch	2012-06-12 13:19:24.000000000 -0600
@@ -0,0 +1,22 @@
+Description: don't mmap large files
+Author: Marc Deslauriers <marc.deslauriers@ubuntu.com>
+Bug: http://bugs.php.net/bug.php?id=52102
+Ubuntu-Bug: https://bugs.edge.launchpad.net/ubuntu/+source/php5/+bug/564920
+
+--- a/main/streams/plain_wrapper.c
++++ b/main/streams/plain_wrapper.c
+@@ -631,7 +631,13 @@ static int php_stdiop_set_option(php_str
+ 
+ 				switch (value) {
+ 					case PHP_STREAM_MMAP_SUPPORTED:
+-						return fd == -1 ? PHP_STREAM_OPTION_RETURN_ERR : PHP_STREAM_OPTION_RETURN_OK;
++						if (fd == -1)
++							return PHP_STREAM_OPTION_RETURN_ERR;
++						/* Don't mmap large files */
++						do_fstat(data, 1);
++						if (data->sb.st_size > 4 * 1024 * 1024)
++							return PHP_STREAM_OPTION_RETURN_ERR;
++						return PHP_STREAM_OPTION_RETURN_OK;
+ 
+ 					case PHP_STREAM_MMAP_MAP_RANGE:
+ 						do_fstat(data, 1);
diff -ruN php-5.4.4.orig/fink/patches/mssql-null-exception.patch php-5.4.4/fink/patches/mssql-null-exception.patch
--- php-5.4.4.orig/fink/patches/mssql-null-exception.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/mssql-null-exception.patch	2012-06-12 13:09:20.000000000 -0600
@@ -0,0 +1,13 @@
+--- a/ext/pdo_dblib/dblib_driver.c
++++ b/ext/pdo_dblib/dblib_driver.c
+@@ -308,8 +308,10 @@ static int pdo_dblib_handle_factory(pdo_
+ 		goto cleanup;
+ 	}
+ 
++#if PHP_DBLIB_IS_MSSQL
+ 	/* dblib do not return more than this length from text/image */
+ 	DBSETOPT(H->link, DBTEXTLIMIT, "2147483647");
++#endif
+ 
+ 	/* limit text/image from network */
+ 	DBSETOPT(H->link, DBTEXTSIZE, "2147483647");
diff -ruN php-5.4.4.orig/fink/patches/php-5.2.4-embed-darwin.patch php-5.4.4/fink/patches/php-5.2.4-embed-darwin.patch
--- php-5.4.4.orig/fink/patches/php-5.2.4-embed-darwin.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-5.2.4-embed-darwin.patch	2012-06-16 11:06:01.000000000 -0600
@@ -0,0 +1,33 @@
+--- a/sapi/embed/config.m4
++++ b/sapi/embed/config.m4
+@@ -12,7 +12,8 @@ if test "$PHP_EMBED" != "no"; then
+   case "$PHP_EMBED" in
+     yes|shared)
+       PHP_EMBED_TYPE=shared
+-      INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(prefix)/lib; \$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)\$(prefix)/lib"
++      EXTRA_LDFLAGS_DARWIN="-dynamiclib -version-info \$(PHP_MAJOR_VERSION):\$(PHP_MINOR_VERSION):\$(PHP_RELEASE_VERSION) -L@FINKPREFIX@/lib"
++      INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(libdir); \$(LIBTOOL) --mode=install \$(INSTALL) -m 0755 \$(OVERALL_TARGET) \$(INSTALL_ROOT)\$(libdir)"
+       ;;
+     static)
+       PHP_EMBED_TYPE=static
+--- a/Makefile.global	2012-06-12 22:54:23.000000000 -0600
++++ b/Makefile.global	2012-06-15 20:16:37.000000000 -0600
+@@ -16,7 +16,7 @@
+ build-binaries: $(PHP_BINARIES)
+ 
+ libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
+-	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
++	$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(libdir) $(EXTRA_LDFLAGS_DARWIN) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
+ 	-@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
+ 
+ libs/libphp$(PHP_MAJOR_VERSION).bundle: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
+--- a/configure.in	2012-06-12 22:54:23.000000000 -0600
++++ b/configure.in	2012-06-16 11:05:07.000000000 -0600
+@@ -1323,6 +1323,7 @@
+ PHP_SUBST_OLD(DEBUG_CFLAGS)
+ PHP_SUBST_OLD(EXTENSION_DIR)
+ PHP_SUBST_OLD(EXTRA_LDFLAGS)
++PHP_SUBST_OLD(EXTRA_LDFLAGS_DARWIN)
+ PHP_SUBST_OLD(EXTRA_LDFLAGS_PROGRAM)
+ PHP_SUBST_OLD(EXTRA_LIBS)
+ PHP_SUBST_OLD(ZEND_EXTRA_LIBS)
diff -ruN php-5.4.4.orig/fink/patches/php-5.2.4-embed.patch php-5.4.4/fink/patches/php-5.2.4-embed.patch
--- php-5.4.4.orig/fink/patches/php-5.2.4-embed.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-5.2.4-embed.patch	2012-06-12 11:53:46.000000000 -0600
@@ -0,0 +1,12 @@
+--- a/sapi/embed/config.m4
++++ b/sapi/embed/config.m4
+@@ -12,7 +12,8 @@ if test "$PHP_EMBED" != "no"; then
+   case "$PHP_EMBED" in
+     yes|shared)
+       PHP_EMBED_TYPE=shared
+-      INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(prefix)/lib; \$(INSTALL) -m 0755 $SAPI_SHARED \$(INSTALL_ROOT)\$(prefix)/lib"
++      EXTRA_LDFLAGS="$EXTRA_LDFLAGS -release \$(PHP_VERSION)"
++      INSTALL_IT="\$(mkinstalldirs) \$(INSTALL_ROOT)\$(libdir); \$(LIBTOOL) --mode=install \$(INSTALL) -m 0755 \$(OVERALL_TARGET) \$(INSTALL_ROOT)\$(libdir)"
+       ;;
+     static)
+       PHP_EMBED_TYPE=static
diff -ruN php-5.4.4.orig/fink/patches/php-5.2.4-norpath.patch php-5.4.4/fink/patches/php-5.2.4-norpath.patch
--- php-5.4.4.orig/fink/patches/php-5.2.4-norpath.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-5.2.4-norpath.patch	2012-06-12 13:22:47.000000000 -0600
@@ -0,0 +1,18 @@
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -432,6 +432,7 @@ AC_DEFUN([PHP_EVAL_INCLINE],[
+ dnl internal, don't use
+ AC_DEFUN([_PHP_ADD_LIBPATH_GLOBAL],[
+   PHP_RUN_ONCE(LIBPATH, $1, [
++    test "x$PHP_RPATH" != "xno" &&
+     test -n "$ld_runpath_switch" && LDFLAGS="$LDFLAGS $ld_runpath_switch$1"
+     LDFLAGS="$LDFLAGS -L$1"
+     PHP_RPATHS="$PHP_RPATHS $1"
+@@ -451,6 +452,7 @@ AC_DEFUN([PHP_ADD_LIBPATH],[
+     ],[
+       if test "$ext_shared" = "yes"; then
+         $2="-L$ai_p [$]$2"
++        test "x$PHP_RPATH" != "xno" && \
+         test -n "$ld_runpath_switch" && $2="$ld_runpath_switch$ai_p [$]$2"
+       else
+         _PHP_ADD_LIBPATH_GLOBAL([$ai_p])
diff -ruN php-5.4.4.orig/fink/patches/php-5.3.3-macropen.patch php-5.4.4/fink/patches/php-5.3.3-macropen.patch
--- php-5.4.4.orig/fink/patches/php-5.3.3-macropen.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-5.3.3-macropen.patch	2012-06-12 13:22:13.000000000 -0600
@@ -0,0 +1,36 @@
+--- a/ext/dba/dba.c
++++ b/ext/dba/dba.c
+@@ -907,7 +907,7 @@ static void php_dba_open(INTERNAL_FUNCTI
+ 		}
+ 	}
+ 
+-	if (error || hptr->open(info, &error TSRMLS_CC) != SUCCESS) {
++	if (error || (hptr->open)(info, &error TSRMLS_CC) != SUCCESS) {
+ 		dba_close(info TSRMLS_CC);
+ 		php_error_docref2(NULL TSRMLS_CC, Z_STRVAL_PP(args[0]), Z_STRVAL_PP(args[1]), E_WARNING, "Driver initialization failed for handler: %s%s%s", hptr->name, error?": ":"", error?error:"");
+ 		FREENOW;
+--- a/ext/dba/dba_db3.c
++++ b/ext/dba/dba_db3.c
+@@ -91,7 +91,7 @@ DBA_OPEN_FUNC(db3)
+ 
+ 	if ((err=db_create(&dbp, NULL, 0)) == 0) {
+ 	    dbp->set_errcall(dbp, php_dba_db3_errcall_fcn);
+-	    if ((err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0) {
++	    if ((err=(dbp->open)(dbp, info->path, NULL, type, gmode, filemode)) == 0) {
+ 			dba_db3_data *data;
+ 
+ 			data = pemalloc(sizeof(*data), info->flags&DBA_PERSISTENT);
+--- a/ext/dba/dba_db4.c
++++ b/ext/dba/dba_db4.c
+@@ -126,9 +126,9 @@ DBA_OPEN_FUNC(db4)
+ 	    dbp->set_errcall(dbp, php_dba_db4_errcall_fcn);
+ 	    if (
+ #if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1))
+-			(err=dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) {
++			(err=(dbp->open)(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) {
+ #else
+-			(err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0) {
++			(err=(dbp->open)(dbp, info->path, NULL, type, gmode, filemode)) == 0) {
+ #endif
+ 			dba_db4_data *data;
+ 
diff -ruN php-5.4.4.orig/fink/patches/php-5.3.9-gnusrc.patch php-5.4.4/fink/patches/php-5.3.9-gnusrc.patch
--- php-5.4.4.orig/fink/patches/php-5.3.9-gnusrc.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-5.3.9-gnusrc.patch	2012-06-12 11:55:15.000000000 -0600
@@ -0,0 +1,105 @@
+--- a/configure.in
++++ b/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 -------------------------------------------------------------------------
+ 
+--- a/ext/interbase/interbase.c
++++ b/ext/interbase/interbase.c
+@@ -24,7 +24,6 @@
+ #include "config.h"
+ #endif
+ 
+-#define _GNU_SOURCE
+ 
+ #include "php.h"
+ 
+--- a/ext/pdo_firebird/firebird_driver.c
++++ b/ext/pdo_firebird/firebird_driver.c
+@@ -22,7 +22,6 @@
+ #include "config.h"
+ #endif
+ 
+-#define _GNU_SOURCE
+ 
+ #include "php.h"
+ #ifdef ZEND_ENGINE_2
+--- a/ext/standard/file.c
++++ b/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
+ 
+--- a/ext/zlib/zlib_fopen_wrapper.c
++++ b/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"
+--- a/main/php.h
++++ b/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"
+--- a/main/streams/cast.c
++++ b/main/streams/cast.c
+@@ -18,7 +18,6 @@
+ 
+ /* $Id$ */
+ 
+-#define _GNU_SOURCE
+ #include "php.h"
+ #include "php_globals.h"
+ #include "php_network.h"
+--- a/main/streams/memory.c
++++ b/main/streams/memory.c
+@@ -18,7 +18,6 @@
+ 
+ /* $Id$ */
+ 
+-#define _GNU_SOURCE
+ #include "php.h"
+ 
+ PHPAPI int php_url_decode(char *str, int len);
+--- a/main/streams/streams.c
++++ b/main/streams/streams.c
+@@ -21,7 +21,6 @@
+ 
+ /* $Id$ */
+ 
+-#define _GNU_SOURCE
+ #include "php.h"
+ #include "php_globals.h"
+ #include "php_network.h"
+--- a/Zend/zend_language_parser.c
++++ b/Zend/zend_language_parser.c
+@@ -67,6 +67,8 @@
+ #define yydebug zenddebug
+ #define yynerrs zendnerrs
+ 
++#include <string.h>
++
+ 
+ /* Tokens.  */
+ #ifndef YYTOKENTYPE
diff -ruN php-5.4.4.orig/fink/patches/php-5.3.9-mysqlnd.patch php-5.4.4/fink/patches/php-5.3.9-mysqlnd.patch
--- php-5.4.4.orig/fink/patches/php-5.3.9-mysqlnd.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-5.3.9-mysqlnd.patch	2012-06-12 13:21:27.000000000 -0600
@@ -0,0 +1,22 @@
+--- a/ext/mysqlnd/mysqlnd.c
++++ b/ext/mysqlnd/mysqlnd.c
+@@ -695,7 +695,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connec
+ 		if (host_len == sizeof("localhost") - 1 && !strncasecmp(host, "localhost", host_len)) {
+ 			DBG_INF_FMT("socket=%s", socket_or_pipe? socket_or_pipe:"n/a");
+ 			if (!socket_or_pipe) {
+-				socket_or_pipe = "/tmp/mysql.sock";
++				socket_or_pipe = "@FINKPREFIX@/var/run/mysqld/mysqld.sock";
+ 			}
+ 			transport_len = mnd_sprintf(&transport, 0, "unix://%s", socket_or_pipe);
+ 			unix_socket = TRUE;
+--- a/ext/pdo_mysql/pdo_mysql.c
++++ b/ext/pdo_mysql/pdo_mysql.c
+@@ -50,7 +50,7 @@ ZEND_DECLARE_MODULE_GLOBALS(pdo_mysql);
+ #  define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
+ # else
+ #  if !PHP_WIN32
+-#   define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
++#   define PDO_MYSQL_UNIX_ADDR "@FINKPREFIX@/var/run/mysqld/mysqld.sock"
+ #  else
+ #   define PDO_MYSQL_UNIX_ADDR NULL
+ #  endif
diff -ruN php-5.4.4.orig/fink/patches/php-5.4.0-dlopen.patch php-5.4.4/fink/patches/php-5.4.0-dlopen.patch
--- php-5.4.4.orig/fink/patches/php-5.4.0-dlopen.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-5.4.0-dlopen.patch	2012-06-12 12:42:38.000000000 -0600
@@ -0,0 +1,17 @@
+--- a/Zend/zend.h
++++ b/Zend/zend.h
+@@ -90,11 +90,11 @@
+ # endif
+ 
+ # if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
+-#  define DL_LOAD(libname)			dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
++#  define DL_LOAD(libname)			dlopen(libname, RTLD_NOW  | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
+ # elif defined(RTLD_DEEPBIND)
+-#  define DL_LOAD(libname)			dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
++#  define DL_LOAD(libname)			dlopen(libname, RTLD_NOW  | RTLD_GLOBAL | RTLD_DEEPBIND)
+ # else
+-#  define DL_LOAD(libname)			dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
++#  define DL_LOAD(libname)			dlopen(libname, RTLD_NOW  | RTLD_GLOBAL)
+ # endif
+ # define DL_UNLOAD					dlclose
+ # if defined(DLSYM_NEEDS_UNDERSCORE)
diff -ruN php-5.4.4.orig/fink/patches/php-fpm-error-reporting.patch php-5.4.4/fink/patches/php-fpm-error-reporting.patch
--- php-5.4.4.orig/fink/patches/php-fpm-error-reporting.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-fpm-error-reporting.patch	2012-06-25 15:29:20.000000000 -0600
@@ -0,0 +1,107 @@
+--- a/sapi/fpm/fpm/fpm_main.c
++++ b/sapi/fpm/fpm/fpm_main.c
+@@ -646,12 +646,38 @@ static void sapi_cgi_register_variables(
+ 	}
+ }
+ 
+-static void sapi_cgi_log_message(char *message TSRMLS_DC)
++/* {{{ sapi_cgi_log_fastcgi
++ *
++ * Ignore level, we want to send all messages through fastcgi
++ */
++void sapi_cgi_log_fastcgi(int level, char *message, size_t len)
+ {
+-	if (CGIG(fcgi_logging)) {
+-		zlog(ZLOG_NOTICE, "PHP message: %s", message);
++	TSRMLS_FETCH();
++
++	fcgi_request *request = (fcgi_request*) SG(server_context);
++
++	/* ensure we want:
++	 * - to log (fastcgi.logging in php.ini)
++	 * - we are currently dealing with a request
++	 * - the message is not empty
++	 */
++	if (CGIG(fcgi_logging) && request && message && len > 0) {
++		char *buf = malloc(len + 2);
++		memcpy(buf, message, len);
++		memcpy(buf + len, "\n", sizeof("\n"));
++		fcgi_write(request, FCGI_STDERR, buf, len+1);
++		free(buf);
+ 	}
+ }
++/* }}} */
++
++/* {{{ sapi_cgi_log_message
++ */
++static void sapi_cgi_log_message(char *message)
++{
++	zlog(ZLOG_NOTICE, "PHP message: %s", message);
++}
++/* }}} */
+ 
+ /* {{{ php_cgi_ini_activate_user_config
+  */
+@@ -1772,6 +1798,9 @@ consult the installation file that came
+ 	fcgi_fd = fpm_run(&max_requests);
+ 	parent = 0;
+ 
++	/* onced forked tell zlog to also send messages through sapi_cgi_log_fastcgi() */
++	zlog_set_external_logger(sapi_cgi_log_fastcgi);
++
+ 	/* make php call us to get _ENV vars */
+ 	php_php_import_environment_variables = php_import_environment_variables;
+ 	php_import_environment_variables = cgi_php_import_environment_variables;
+--- a/sapi/fpm/fpm/zlog.c
++++ b/sapi/fpm/fpm/zlog.c
+@@ -22,6 +22,7 @@
+ static int zlog_fd = -1;
+ static int zlog_level = ZLOG_NOTICE;
+ static int launched = 0;
++static void (*external_logger)(int, char *, size_t) = NULL;
+ 
+ static const char *level_names[] = {
+ 	[ZLOG_DEBUG]   = "DEBUG",
+@@ -41,6 +42,12 @@ const int syslog_priorities[] = {
+ };
+ #endif
+ 
++void zlog_set_external_logger(void (*logger)(int, char *, size_t)) /* {{{ */
++{
++	external_logger = logger;
++}
++/* }}} */
++
+ const char *zlog_get_level_name(int log_level) /* {{{ */
+ {
+ 	if (log_level < 0) {
+@@ -101,6 +108,19 @@ void zlog_ex(const char *function, int l
+ 	int truncated = 0;
+ 	int saved_errno;
+ 
++	if (external_logger) {
++		va_start(args, fmt);
++		len = vsnprintf(buf, buf_size, fmt, args);
++		va_end(args);
++		if (len >= buf_size) {
++			memcpy(buf + buf_size - sizeof("..."), "...", sizeof("...") - 1);
++			len = buf_size - 1;
++		}
++		external_logger(flags & ZLOG_LEVEL_MASK, buf, len);
++		len = 0;
++		memset(buf, '\0', buf_size);
++	}
++
+ 	if ((flags & ZLOG_LEVEL_MASK) < zlog_level) {
+ 		return;
+ 	}
+--- a/sapi/fpm/fpm/zlog.h
++++ b/sapi/fpm/fpm/zlog.h
+@@ -9,6 +9,7 @@
+ 
+ struct timeval;
+ 
++void zlog_set_external_logger(void (*logger)(int, char *, size_t));
+ int zlog_set_fd(int new_fd);
+ int zlog_set_level(int new_value);
+ const char *zlog_get_level_name(int log_level);
diff -ruN php-5.4.4.orig/fink/patches/php-fpm-listen-on-unix-socket.patch php-5.4.4/fink/patches/php-fpm-listen-on-unix-socket.patch
--- php-5.4.4.orig/fink/patches/php-fpm-listen-on-unix-socket.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-fpm-listen-on-unix-socket.patch	2012-06-14 11:35:43.000000000 -0600
@@ -0,0 +1,11 @@
+--- a/sapi/fpm/php-fpm.conf.in
++++ b/sapi/fpm/php-fpm.conf.in
+@@ -144,7 +144,7 @@ group = @php_fpm_group@
+ ;                            specific port;
+ ;   '/path/to/unix/socket' - to listen on a unix socket.
+ ; Note: This value is mandatory.
+-listen = 127.0.0.1:9000
++listen = @FINKPREFIX@/var/run/php5-fpm.sock
+ 
+ ; Set listen(2) backlog.
+ ; Default Value: 128 (-1 on FreeBSD and OpenBSD)
diff -ruN php-5.4.4.orig/fink/patches/php-fpm-man-section-and-cleanup.patch php-5.4.4/fink/patches/php-fpm-man-section-and-cleanup.patch
--- php-5.4.4.orig/fink/patches/php-fpm-man-section-and-cleanup.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-fpm-man-section-and-cleanup.patch	2012-06-12 13:17:53.000000000 -0600
@@ -0,0 +1,38 @@
+Description: Fix php-fpm's manpage section to match location of binary
+ (/usr/sbin,) additionally, remove some stuff that is useless or
+ doesn't apply to Debian.
+Origin: vendor
+Forwarded: http://bugs.php.net/52476
+Last-Update: 2010-07-29
+
+--- a/sapi/fpm/php-fpm.8.in
++++ b/sapi/fpm/php-fpm.8.in
+@@ -112,15 +112,8 @@ The configuration file for the php-fpm d
+ .TP
+ .B php.ini
+ The standard php configuration file.
+-.SH EXAMPLES
+-You should use the init script provided to start and stop the php-fpm daemon. This situation applies for any unix systems which use init.d for their main process manager.
+-.P
+-.PD 1
+-.RS
+-sudo /etc/init.d/php-fpm start
+-.RE
+-.TP
+-If your installation has no appropriate init script, launch php-fpm with no arguments. It will launch as a daemon (background process) by default. The file @php_fpm_localstatedir@/run/php-fpm.pid determines whether php-fpm is already up and running. Once started, php-fpm then responds to several POSIX signals:
++.SH SIGNAL
++Once started, php-fpm then responds to several POSIX signals:
+ .P
+ .PD 0
+ .RS
+@@ -134,10 +127,6 @@ If your installation has no appropriate
+ .RE
+ .PD 1
+ .P
+-.SH TIPS
+-The PHP-FPM CGI daemon will work well with most popular webservers, including Apache2, lighttpd and nginx.
+-.PD 1
+-.P
+ .SH SEE ALSO
+ The PHP-FPM website:
+ .PD 0
diff -ruN php-5.4.4.orig/fink/patches/php-fpm-sysconfdir.patch php-5.4.4/fink/patches/php-fpm-sysconfdir.patch
--- php-5.4.4.orig/fink/patches/php-fpm-sysconfdir.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php-fpm-sysconfdir.patch	2012-06-14 11:35:05.000000000 -0600
@@ -0,0 +1,11 @@
+--- a/sapi/fpm/fpm/fpm_conf.c
++++ b/sapi/fpm/fpm/fpm_conf.c
+@@ -1562,7 +1562,7 @@ int fpm_conf_init_main(int test_conf) /*
+ 		char *tmp;
+ 
+ 		if (fpm_globals.prefix == NULL) {
+-			spprintf(&tmp, 0, "%s/php-fpm.conf", PHP_SYSCONFDIR);
++			spprintf(&tmp, 0, "%s/php5/fpm/php-fpm.conf", PHP_SYSCONFDIR);
+ 		} else {
+ 			spprintf(&tmp, 0, "%s/etc/php-fpm.conf", fpm_globals.prefix);
+ 		}
diff -ruN php-5.4.4.orig/fink/patches/php_crypt_revamped.patch php-5.4.4/fink/patches/php_crypt_revamped.patch
--- php-5.4.4.orig/fink/patches/php_crypt_revamped.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/php_crypt_revamped.patch	2012-06-25 15:27:58.000000000 -0600
@@ -0,0 +1,573 @@
+--- a/ext/standard/config.m4
++++ b/ext/standard/config.m4
+@@ -58,6 +58,12 @@ if test "$ac_cv_func_crypt" = "no"; then
+     AC_DEFINE(HAVE_CRYPT, 1, [ ])
+   ])
+ fi
++
++AC_CHECK_FUNCS(crypt_r, [ php_crypt_r="1" ], [ php_crypt_r="0" ])
++if test "x$php_crypt_r" = "x1"; then
++  PHP_CRYPT_R_STYLE
++  AC_DEFINE(HAVE_CRYPT_R, 1, [ ])
++fi
+   
+ AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
+   AC_TRY_RUN([
+@@ -229,11 +235,68 @@ main() {
+   ac_cv_crypt_SHA256=no
+ ])])
+ 
++dnl
++dnl Define PHP_*_CRYPT according to system
++dnl
++
++if test "$ac_cv_crypt_des" = "yes"; then
++  ac_result=1
++  ac_crypt_des=1
++else
++  ac_result=0
++  ac_crypt_des=0
++fi
++AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, $ac_result, [Whether the system supports standard DES salt])
++
++if test "$ac_cv_crypt_md5" = "yes"; then
++  ac_result=1
++  ac_crypt_md5=1
++else
++  ac_result=0
++  ac_crypt_md5=0
++fi
++AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, $ac_result, [Whether the system supports MD5 salt])
++
++if test "$ac_cv_crypt_blowfish" = "yes"; then
++  ac_result=1
++  ac_crypt_blowfish=1
++else
++  ac_result=0
++  ac_crypt_blowfish=0
++fi
++AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, $ac_result, [Whether the system supports BlowFish salt])
++
++if test "$ac_cv_crypt_ext_des" = "yes"; then
++  ac_result=1
++  ac_crypt_edes=1
++else
++  ac_result=0
++  ac_crypt_edes=0
++fi
++AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, $ac_result, [Whether the system supports extended DES salt])
++
++if test "$ac_cv_crypt_SHA512" = "yes"; then
++  ac_result=1
++  ac_crypt_sha512=1
++else
++  ac_result=0
++  ac_crypt_sha512=0
++fi
++AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, $ac_result, [Whether the system supports SHA512 salt])
++
++if test "$ac_cv_crypt_SHA256" = "yes"; then
++  ac_result=1
++  ac_crypt_sha256=1
++else
++  ac_result=0
++  ac_crypt_sha256=0
++fi
++AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, $ac_result, [Whether the system supports SHA256 salt])
+ 
+ dnl
+ dnl If one of them is missing, use our own implementation, portable code is then possible
+ dnl
+-if test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "x$php_crypt_r" = "x0"; then
++if test "$ac_cv_crypt_SHA512" = no || test "$ac_cv_crypt_SHA256" = "no" || test "$ac_cv_crypt_blowfish" = "no" || test "$ac_cv_crypt_des" = "no" || test "$ac_cv_crypt_md5" = "no" || test "$ac_cv_crypt_ext_des" = "no" || test "x$php_crypt_r" = "x0"; then
+ 
+   dnl
+   dnl Check for __alignof__ support in the compiler
+@@ -267,74 +330,15 @@ if test "$ac_cv_crypt_blowfish" = "no" |
+     AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))])
+   fi
+     
+-
+-  AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 1, [Whether PHP has to use its own crypt_r for blowfish, des, ext des and md5])
+-  AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, 1, [Whether the system supports standard DES salt])
+-  AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, 1, [Whether the system supports BlowFish salt])
+-  AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, 1, [Whether the system supports extended DES salt])
+-  AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, 1, [Whether the system supports MD5 salt])
+-  AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, 1, [Whether the system supports SHA512 salt])
+-  AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, 1, [Whether the system supports SHA256 salt])
++  ac_result=1
+ 
+   PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
+ else
+-  if test "$ac_cv_crypt_des" = "yes"; then
+-    ac_result=1
+-    ac_crypt_des=1
+-  else
+-    ac_result=0
+-    ac_crypt_des=0
+-  fi
+-  AC_DEFINE_UNQUOTED(PHP_STD_DES_CRYPT, $ac_result, [Whether the system supports standard DES salt])
+-
+-  if test "$ac_cv_crypt_blowfish" = "yes"; then
+-    ac_result=1
+-    ac_crypt_blowfish=1
+-  else
+-    ac_result=0
+-    ac_crypt_blowfish=0
+-  fi
+-  AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, $ac_result, [Whether the system supports BlowFish salt])
+-
+-  if test "$ac_cv_crypt_ext_des" = "yes"; then
+-    ac_result=1
+-    ac_crypt_edes=1
+-  else
+-    ac_result=0
+-    ac_crypt_edes=0
+-  fi
+-  AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, $ac_result, [Whether the system supports extended DES salt])
+-
+-  if test "$ac_cv_crypt_md5" = "yes"; then
+-    ac_result=1
+-    ac_crypt_md5=1
+-  else
+-    ac_result=0
+-    ac_crypt_md5=0
+-  fi
+-  AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, $ac_result, [Whether the system supports MD5 salt])  
+-  
+-  if test "$ac_cv_crypt_sha512" = "yes"; then
+-    ac_result=1
+-    ac_crypt_sha512=1
+-  else
+-    ac_result=0
+-    ac_crypt_sha512=0
+-  fi
+-  AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, $ac_result, [Whether the system supports SHA512 salt])
+-
+-  if test "$ac_cv_crypt_sha256" = "yes"; then
+-    ac_result=1
+-    ac_crypt_sha256=1
+-  else
+-    ac_result=0
+-    ac_crypt_sha256=0
+-  fi
+-  AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, $ac_result, [Whether the system supports SHA256 salt])
+-
+-  AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des])
++  ac_result=0
+ fi
+ 
++AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, $ac_result, [Whether PHP has to use its own crypt_r for blowfish, des and ext des])
++
+ dnl
+ dnl Check for available functions
+ dnl
+--- a/ext/standard/crypt.c
++++ b/ext/standard/crypt.c
+@@ -32,13 +32,12 @@
+ #if PHP_USE_PHP_CRYPT_R
+ # include "php_crypt_r.h"
+ # include "crypt_freesec.h"
+-#else
+-# if HAVE_CRYPT_H
+-#  if defined(CRYPT_R_GNU_SOURCE) && !defined(_GNU_SOURCE)
+-#   define _GNU_SOURCE
+-#  endif
+-#  include <crypt.h>
++#endif
++#if HAVE_CRYPT_H
++# if defined(CRYPT_R_GNU_SOURCE) && !defined(_GNU_SOURCE)
++#  define _GNU_SOURCE
+ # endif
++# include <crypt.h>
+ #endif
+ #if TM_IN_SYS_TIME
+ #include <sys/time.h>
+@@ -64,56 +63,50 @@
+  * PHP_EXT_DES_CRYPT, PHP_MD5_CRYPT and PHP_BLOWFISH_CRYPT as appropriate
+  * for the target platform. */
+ 
+-#if PHP_STD_DES_CRYPT
+-#define PHP_MAX_SALT_LEN 2
+-#endif
+-
+-#if PHP_EXT_DES_CRYPT
+-#undef PHP_MAX_SALT_LEN
+-#define PHP_MAX_SALT_LEN 9
++#if defined(HAVE_CRYPT_R) && (defined(_REENTRANT) || defined(_THREAD_SAFE))
++# define PHP_USE_SYSTEM_CRYPT_R
+ #endif
+ 
+-#if PHP_MD5_CRYPT
+-#undef PHP_MAX_SALT_LEN
+-#define PHP_MAX_SALT_LEN 12
+-#endif
++#define PHP_MAX_STD_DES_SALT_LEN 2
++#define PHP_MAX_STD_DES_HASH_LEN 11
+ 
+-#if PHP_BLOWFISH_CRYPT
+-#undef PHP_MAX_SALT_LEN
+-#define PHP_MAX_SALT_LEN 60
+-#endif
+-
+-#if PHP_SHA512_CRYPT
+-#undef PHP_MAX_SALT_LEN
+-#define PHP_MAX_SALT_LEN 123
+-#endif
+-
+-
+-/* If the configure-time checks fail, we provide DES.
+- * XXX: This is a hack. Fix the real problem! */
+-
+-#ifndef PHP_MAX_SALT_LEN
+-#define PHP_MAX_SALT_LEN 2
+-#undef PHP_STD_DES_CRYPT
+-#define PHP_STD_DES_CRYPT 1
+-#endif
++#define PHP_MAX_EXT_DES_SALT_LEN 9
++#define PHP_MAX_EXT_DES_HASH_LEN 11
++
++#define PHP_MAX_MD5_SALT_LEN 12
++#define PHP_MAX_MD5_HASH_LEN 22
++
++#define PHP_MAX_BLOWFISH_SALT_LEN 29
++#define PHP_MAX_BLOWFISH_HASH_LEN 31
++ 
++#define PHP_MAX_SHA256_SALT_LEN 37
++#define PHP_MAX_SHA256_HASH_LEN 43
++
++#define PHP_MAX_SHA512_SALT_LEN 37
++#define PHP_MAX_SHA512_HASH_LEN 86
++
++/* 
++ * Maximum salt length is from SHA512
++ * Maximum hash length is from SHA512
++ */
++#define PHP_MAX_SALT_LEN 37
++#define PHP_MAX_HASH_LEN 86
+ 
+ #define PHP_CRYPT_RAND php_rand(TSRMLS_C)
+ 
+ PHP_MINIT_FUNCTION(crypt) /* {{{ */
+ {
+ 	REGISTER_LONG_CONSTANT("CRYPT_SALT_LENGTH", PHP_MAX_SALT_LEN, CONST_CS | CONST_PERSISTENT);
+-	REGISTER_LONG_CONSTANT("CRYPT_STD_DES", PHP_STD_DES_CRYPT, CONST_CS | CONST_PERSISTENT);
+-	REGISTER_LONG_CONSTANT("CRYPT_EXT_DES", PHP_EXT_DES_CRYPT, CONST_CS | CONST_PERSISTENT);
+-	REGISTER_LONG_CONSTANT("CRYPT_MD5", PHP_MD5_CRYPT, CONST_CS | CONST_PERSISTENT);
+-	REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP_BLOWFISH_CRYPT, CONST_CS | CONST_PERSISTENT);
+-
++	REGISTER_LONG_CONSTANT("CRYPT_STD_DES", PHP_STD_DES_CRYPT | PHP_USE_PHP_CRYPT_R, CONST_CS | CONST_PERSISTENT);
++	REGISTER_LONG_CONSTANT("CRYPT_EXT_DES", PHP_EXT_DES_CRYPT | PHP_USE_PHP_CRYPT_R, CONST_CS | CONST_PERSISTENT);
++	REGISTER_LONG_CONSTANT("CRYPT_MD5", PHP_MD5_CRYPT | PHP_USE_PHP_CRYPT_R, CONST_CS | CONST_PERSISTENT);
++	REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP_BLOWFISH_CRYPT | PHP_USE_PHP_CRYPT_R, CONST_CS | CONST_PERSISTENT);
+ #ifdef PHP_SHA256_CRYPT
+-   REGISTER_LONG_CONSTANT("CRYPT_SHA256", PHP_SHA256_CRYPT, CONST_CS | CONST_PERSISTENT);
++	REGISTER_LONG_CONSTANT("CRYPT_SHA256", PHP_SHA256_CRYPT | PHP_USE_PHP_CRYPT_R, CONST_CS | CONST_PERSISTENT);
+ #endif
+ 
+ #ifdef PHP_SHA512_CRYPT
+-   REGISTER_LONG_CONSTANT("CRYPT_SHA512", PHP_SHA512_CRYPT, CONST_CS | CONST_PERSISTENT);
++	REGISTER_LONG_CONSTANT("CRYPT_SHA512", PHP_SHA512_CRYPT | PHP_USE_PHP_CRYPT_R, CONST_CS | CONST_PERSISTENT);
+ #endif
+ 
+ #if PHP_USE_PHP_CRYPT_R
+@@ -124,15 +117,15 @@ PHP_MINIT_FUNCTION(crypt) /* {{{ */
+ }
+ /* }}} */
+ 
++#if PHP_USE_PHP_CRYPT_R
+ PHP_MSHUTDOWN_FUNCTION(crypt) /* {{{ */
+ {
+-#if PHP_USE_PHP_CRYPT_R
+ 	php_shutdown_crypt_r();
+-#endif
+ 
+ 	return SUCCESS;
+ }
+ /* }}} */
++#endif
+ 
+ static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ 
+@@ -150,160 +143,158 @@ static void php_to64(char *s, long v, in
+ PHP_FUNCTION(crypt)
+ {
+ 	char salt[PHP_MAX_SALT_LEN + 1];
++	int salt_len = 0;
++	char output[PHP_MAX_SALT_LEN + PHP_MAX_HASH_LEN + 1];
+ 	char *str, *salt_in = NULL;
+ 	int str_len, salt_in_len = 0;
+-	char *crypt_res;
+-	salt[0] = salt[PHP_MAX_SALT_LEN] = '\0';
++	char *crypt_res = NULL;
++#if PHP_USE_PHP_CRYPT_R
++	struct php_crypt_extended_data extended_buffer;
++#endif
++#if defined(PHP_USE_SYSTEM_CRYPT_R)
++#  if defined(CRYPT_R_STRUCT_CRYPT_DATA)
++	struct crypt_data buffer;
++#  elif defined(CRYPT_R_CRYPTD)
++	CRYPTD buffer;
++#  else
++#    error Data struct used by crypt_r() is unknown. Please report.
++#  endif
++#endif
+ 
+-	/* This will produce suitable results if people depend on DES-encryption
+-	 * available (passing always 2-character salt). At least for glibc6.1 */
+-	memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1);
++	salt[0] = salt[PHP_MAX_SALT_LEN] = '\0';
+ 
+ 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) {
+ 		return;
+ 	}
+ 
+-	if (salt_in) {
+-		memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len));
+-	}
+-
+-	/* The automatic salt generation covers standard DES, md5-crypt and Blowfish (simple) */
+-	if (!*salt) {
+-#if PHP_MD5_CRYPT
+-		strncpy(salt, "$1$", PHP_MAX_SALT_LEN);
+-		php_to64(&salt[3], PHP_CRYPT_RAND, 4);
+-		php_to64(&salt[7], PHP_CRYPT_RAND, 4);
+-		strncpy(&salt[11], "$", PHP_MAX_SALT_LEN - 11);
+-#elif PHP_STD_DES_CRYPT
+-		php_to64(&salt[0], PHP_CRYPT_RAND, 2);
+-		salt[2] = '\0';
+-#endif
+-		salt_in_len = strlen(salt);
++	if (salt_in && (salt_in_len > 0)) {
++		salt_len = MIN(PHP_MAX_SALT_LEN, salt_in_len);
++		memcpy(salt, salt_in, salt_len);
++		salt[salt_len] = '\0';
+ 	} else {
+-		salt_in_len = MIN(PHP_MAX_SALT_LEN, salt_in_len);
++		/* Use SHA512 as default algorithm */
++		salt[0] = '$'; salt[1] = '6'; salt[2] = '$';
++		php_to64(&salt[3],  PHP_CRYPT_RAND, 4);
++		php_to64(&salt[7],  PHP_CRYPT_RAND, 4);
++		php_to64(&salt[11], PHP_CRYPT_RAND, 4);
++		salt[15] = '$'; salt[16] = '\0';
++		salt_len = 16;
+ 	}
+ 
+-/* Windows (win32/crypt) has a stripped down version of libxcrypt and 
+-	a CryptoApi md5_crypt implementation */
+-#if PHP_USE_PHP_CRYPT_R
+ 	{
+-		struct php_crypt_extended_data buffer;
++#if PHP_USE_PHP_CRYPT_R
++		memset(&extended_buffer, 0, sizeof(extended_buffer));
++#endif
++#if defined(PHP_USE_SYSTEM_CRYPT_R)
++# if defined(CRYPT_R_STRUCT_CRYPT_DATA)
++		buffer->initialized = 0;
++# else
++		memset(&buffer, 0, sizeof(buffer));
++# endif
++#endif
+ 
+ 		if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$') {
+-			char output[MD5_HASH_MAX_LEN];
+-
+-			RETURN_STRING(php_md5_crypt_r(str, salt, output), 1);
++			/* CRYPT_MD5 */
++#if PHP_MD5_CRYPT
++# if defined(PHP_USE_SYSTEM_CRYPT_R)
++# warning Using system MD5 crypt function, which is OK on Debian system
++			crypt_res = crypt_r(str, salt, &buffer);
++# else
++			crypt_res = crypt(str, salt);
++# endif
++#elif PHP_USE_PHP_CRYPT_R
++# error Using PHP MD5 crypt function, should not happen on Debian system
++			crypt_res = php_md5_crypt_r(str, salt, output);
++#endif
+ 		} else if (salt[0]=='$' && salt[1]=='6' && salt[2]=='$') {
+-			const char sha512_salt_prefix[] = "$6$";
+-			const char sha512_rounds_prefix[] = "rounds=";
+-			char *output;
+-			int needed = (sizeof(sha512_salt_prefix) - 1
+-						+ sizeof(sha512_rounds_prefix) + 9 + 1
+-						+ strlen(salt) + 1 + 43 + 1);
+-			output = emalloc(needed);
+-			salt[salt_in_len] = '\0';
+-
+-			crypt_res = php_sha512_crypt_r(str, salt, output, needed);
+-			if (!crypt_res) {
+-				if (salt[0]=='*' && salt[1]=='0') {
+-					RETVAL_STRING("*1", 1);
+-				} else {
+-					RETVAL_STRING("*0", 1);
+-				}
+-			} else {
+-				RETVAL_STRING(output, 1);
+-			}
+-
+-			memset(output, 0, PHP_MAX_SALT_LEN + 1);
+-			efree(output);
++			/* CRYPT_SHA512 */
++#if PHP_SHA512_CRYPT
++# warning Using system SHA512 crypt function, which is OK on Debian system
++# if defined(PHP_USE_SYSTEM_CRYPT_R)
++			crypt_res = crypt_r(str, salt, &buffer);
++# else
++			crypt_res = crypt(str, salt);
++# endif
++#elif PHP_USE_PHP_CRYPT_R
++# error Using PHP SHA512 crypt function, should not happen on Debian system
++			crypt_res = php_sha512_crypt_r(str, salt, output, sizeof(output));
++#endif
+ 		} else if (salt[0]=='$' && salt[1]=='5' && salt[2]=='$') {
+-			const char sha256_salt_prefix[] = "$5$";
+-			const char sha256_rounds_prefix[] = "rounds=";
+-			char *output;
+-			int needed = (sizeof(sha256_salt_prefix) - 1
+-						+ sizeof(sha256_rounds_prefix) + 9 + 1
+-						+ strlen(salt) + 1 + 43 + 1);
+-			output = emalloc(needed);
+-			salt[salt_in_len] = '\0';
+-
+-			crypt_res = php_sha256_crypt_r(str, salt, output, needed);
+-			if (!crypt_res) {
+-				if (salt[0]=='*' && salt[1]=='0') {
+-					RETVAL_STRING("*1", 1);
+-				} else {
+-					RETVAL_STRING("*0", 1);
+-				}
+-			} else {
+-				RETVAL_STRING(output, 1);
+-			}
+-
+-			memset(output, 0, PHP_MAX_SALT_LEN + 1);
+-			efree(output);
++			/* CRYPT_SHA256 */
++#if PHP_SHA256_CRYPT
++# warning Using system SHA256 crypt function, which is OK on Debian system
++# if defined(PHP_USE_SYSTEM_CRYPT_R)
++			crypt_res = crypt_r(str, salt, &buffer);
++# else
++			crypt_res = crypt(str, salt);
++# endif
++#elif PHP_USE_PHP_CRYPT_R
++# error Using PHP SHA256 crypt function, should not happen on Debian system
++			crypt_res = php_sha256_crypt_r(str, salt, output, sizeof(output));
++#endif
+ 		} else if (
+ 				salt[0] == '$' &&
+ 				salt[1] == '2' &&
+ 				salt[2] >= 'a' && salt[2] <= 'z' &&
+ 				salt[3] == '$' &&
+-				salt[4] >= '0' && salt[4] <= '3' &&
+-				salt[5] >= '0' && salt[5] <= '9' &&
+ 				salt[6] == '$') {
+-			char output[PHP_MAX_SALT_LEN + 1];
+-
+-			memset(output, 0, PHP_MAX_SALT_LEN + 1);
+-
++			/* CRYPT_BLOWFISH */
++#if PHP_BLOWFISH_CRYPT
++# error Using system BlowFish crypt function, should not happen on Debian system
++# if defined(PHP_USE_SYSTEM_CRYPT_R)
++			crypt_res = crypt_r(str, salt, &buffer);
++# else
++			crypt_res = crypt(str, salt);
++# endif
++#elif PHP_USE_PHP_CRYPT_R
++# warning Using PHP BlowFish crypt function, which is OK on Debian system
+ 			crypt_res = php_crypt_blowfish_rn(str, salt, output, sizeof(output));
+-			if (!crypt_res) {
+-				if (salt[0]=='*' && salt[1]=='0') {
+-					RETVAL_STRING("*1", 1);
+-				} else {
+-					RETVAL_STRING("*0", 1);
+-				}
+-			} else {
+-				RETVAL_STRING(output, 1);
+-			}
+-
+-			memset(output, 0, PHP_MAX_SALT_LEN + 1);
++#endif
++		} else if (salt[0]=='_' && 
++				   salt_len == 9) {
++			/* CRYPT_EXT_DES */
++#if PHP_EXT_DES_CRYPT
++# error Using system extended DES crypt function, should not happen on Debian system
++# if defined(PHP_USE_SYSTEM_CRYPT_R)
++			crypt_res = crypt_r(str, salt, &buffer);
++# else
++			crypt_res = crypt(str, salt);
++# endif
++#elif PHP_USE_PHP_CRYPT_R
++# warning Using PHP extended DES crypt function, which is OK on Debian system
++			_crypt_extended_init_r();
++			crypt_res = _crypt_extended_r(str, salt, &extended_buffer);
++#endif
+ 		} else {
+-			memset(&buffer, 0, sizeof(buffer));
++			/* CRYPT_STD_DES */
++#if PHP_STD_DES_CRYPT
++# warning Using system standard DES crypt function, which is OK on Debian system
++# if defined(PHP_USE_SYSTEM_CRYPT_R)
++			crypt_res = crypt_r(str, salt, &buffer);
++# else
++			crypt_res = crypt(str, salt);
++# endif
++#elif PHP_USE_PHP_CRYPT_R
++# error Using PHP standard DES crypt function, should not happen on Debian system
+ 			_crypt_extended_init_r();
+-
+-			crypt_res = _crypt_extended_r(str, salt, &buffer);
+-			if (!crypt_res) {
+-				if (salt[0]=='*' && salt[1]=='0') {
+-					RETURN_STRING("*1", 1);
+-				} else {
+-					RETURN_STRING("*0", 1);
+-				}
+-			} else {
+-				RETURN_STRING(crypt_res, 1);
+-			}
++			crypt_res = _crypt_extended_r(str, salt, &extended_buffer);
++#endif
+ 		}
+-	}
+-#else
+ 
+-# if defined(HAVE_CRYPT_R) && (defined(_REENTRANT) || defined(_THREAD_SAFE))
+-	{
+-#  if defined(CRYPT_R_STRUCT_CRYPT_DATA)
+-		struct crypt_data buffer;
+-		memset(&buffer, 0, sizeof(buffer));
+-#  elif defined(CRYPT_R_CRYPTD)
+-		CRYPTD buffer;
+-#  else
+-#    error Data struct used by crypt_r() is unknown. Please report.
+-#  endif
+-		crypt_res = crypt_r(str, salt, &buffer);
+ 		if (!crypt_res) {
+-				if (salt[0]=='*' && salt[1]=='0') {
+-					RETURN_STRING("*1", 1);
+-				} else {
+-					RETURN_STRING("*0", 1);
+-				}
++			if (salt[0]=='*' && salt[1]=='0') {
++				RETVAL_STRING("*1", 1);
++			} else {
++				RETVAL_STRING("*0", 1);
++			}
+ 		} else {
+-			RETURN_STRING(crypt_res, 1);
++			RETVAL_STRING(crypt_res, 1);
++		}
++		memset(salt, 0, sizeof(salt));
++		if (output[0]!='\0') {
++			memset(output, 0, sizeof(output));
+ 		}
+ 	}
+-# endif
+-#endif
+ }
+ /* }}} */
+ #endif
diff -ruN php-5.4.4.orig/fink/patches/phpinfo_no_configure.patch php-5.4.4/fink/patches/phpinfo_no_configure.patch
--- php-5.4.4.orig/fink/patches/phpinfo_no_configure.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/phpinfo_no_configure.patch	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,33 @@
+Description: Disable configure parameters on phpinfo() output
+ .
+ Patch needs to be discussed with upstream and the issues that lead to
+ its addition re-checked.  Quoting changelog entry:
+ .
+ Add [...], which disables the display of our "Configure Command" in
+ phpinfo(), which was the source of many bogus bug reports over the
+ years, due to people misinterpreting its meaning.
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- a/ext/standard/info.c
++++ b/ext/standard/info.c
+@@ -704,7 +704,7 @@ PHPAPI void php_print_info(int flag TSRM
+ #ifdef ARCHITECTURE
+ 		php_info_print_table_row(2, "Architecture", ARCHITECTURE);
+ #endif
+-#ifdef CONFIGURE_COMMAND
++#if 0
+ 		php_info_print_table_row(2, "Configure Command", CONFIGURE_COMMAND );
+ #endif
+ 
+--- a/ext/standard/tests/general_functions/phpinfo.phpt
++++ b/ext/standard/tests/general_functions/phpinfo.phpt
+@@ -20,7 +20,6 @@ PHP Version => %s
+ 
+ System => %s
+ Build Date => %s%a
+-Configure Command => %s
+ Server API => Command Line Interface
+ Virtual Directory Support => %s
+ Configuration File (php.ini) Path => %s
diff -ruN php-5.4.4.orig/fink/patches/posixness_fix.patch php-5.4.4/fink/patches/posixness_fix.patch
--- php-5.4.4.orig/fink/patches/posixness_fix.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/posixness_fix.patch	2012-06-12 11:49:49.000000000 -0600
@@ -0,0 +1,52 @@
+--- a/TSRM/tsrm_config_common.h
++++ b/TSRM/tsrm_config_common.h
+@@ -1,6 +1,10 @@
+ #ifndef TSRM_CONFIG_COMMON_H
+ #define TSRM_CONFIG_COMMON_H
+ 
++#ifndef PATH_MAX
++#define PATH_MAX 4096
++#endif
++
+ #ifndef __CYGWIN__
+ # if WINNT|WIN32
+ #  define TSRM_WIN32
+--- a/ext/date/lib/parse_tz.c
++++ b/ext/date/lib/parse_tz.c
+@@ -18,6 +18,10 @@
+ 
+ /* $Id$ */
+ 
++#ifndef PATH_MAX
++#define PATH_MAX 4096
++#endif
++
+ #include "timelib.h"
+ 
+ #include <stdio.h>
+--- a/ext/standard/proc_open.c
++++ b/ext/standard/proc_open.c
+@@ -24,6 +24,10 @@
+ # define __EXTENSIONS__	1	/* Solaris: uint */
+ #endif
+ 
++#ifndef PATH_MAX
++#define PATH_MAX 4096
++#endif
++
+ #include "php.h"
+ #include <stdio.h>
+ #include <ctype.h>
+--- a/main/php.h
++++ b/main/php.h
+@@ -245,6 +245,10 @@ END_EXTERN_C()
+ /* macros */
+ #define STR_PRINT(str)	((str)?(str):"")
+ 
++#ifndef PATH_MAX
++#define PATH_MAX 4096
++#endif
++
+ #ifndef MAXPATHLEN
+ # ifdef PATH_MAX
+ #  define MAXPATHLEN PATH_MAX
diff -ruN php-5.4.4.orig/fink/patches/proc_open.patch php-5.4.4/fink/patches/proc_open.patch
--- php-5.4.4.orig/fink/patches/proc_open.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/proc_open.patch	2012-06-12 13:05:21.000000000 -0600
@@ -0,0 +1,11 @@
+--- a/ext/standard/proc_open.c
++++ b/ext/standard/proc_open.c
+@@ -61,7 +61,7 @@
+  * */
+ #ifdef PHP_CAN_SUPPORT_PROC_OPEN
+ 
+-#if 0 && HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT && HAVE_SYS_IOCTL_H && HAVE_TERMIOS_H
++#if HAVE_PTSNAME && HAVE_GRANTPT && HAVE_UNLOCKPT && HAVE_SYS_IOCTL_H && HAVE_TERMIOS_H
+ # include <sys/ioctl.h>
+ # include <termios.h>
+ # define PHP_CAN_DO_PTS	1
diff -ruN php-5.4.4.orig/fink/patches/recode_is_shared.patch php-5.4.4/fink/patches/recode_is_shared.patch
--- php-5.4.4.orig/fink/patches/recode_is_shared.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/recode_is_shared.patch	2012-06-12 15:37:19.000000000 -0600
@@ -0,0 +1,16 @@
+Description: Turn recode conflicts error message into a warning. The
+ recode extension is packaged as a shared library in Debian.
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- a/ext/recode/config9.m4
++++ b/ext/recode/config9.m4
+@@ -13,6 +13,6 @@ if test "$PHP_RECODE" != "no"; then
+   fi
+ 
+   if test -n "$recode_conflict"; then
+-    AC_MSG_ERROR([recode extension can not be configured together with:$recode_conflict])
++    AC_MSG_WARN([recode extension can not be used together with:$recode_conflict])
+   fi
+ fi
diff -ruN php-5.4.4.orig/fink/patches/session_save_path.patch php-5.4.4/fink/patches/session_save_path.patch
--- php-5.4.4.orig/fink/patches/session_save_path.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/session_save_path.patch	2012-06-14 11:33:14.000000000 -0600
@@ -0,0 +1,40 @@
+Description: Set the default session.save_path dir to @FINKPREFIX@/var/lib/php5.
+ This is the directory that has been used in Debian to store the
+ session files and is partially protected by dir permissions.
+Origin: vendor
+Forwarded: not-needed
+Last-Update: 2010-05-01
+
+--- a/ext/session/session.c
++++ b/ext/session/session.c
+@@ -705,7 +705,7 @@ static ZEND_INI_MH(OnUpdateSmartStr) /*
+ /* {{{ PHP_INI
+  */
+ PHP_INI_BEGIN()
+-	STD_PHP_INI_ENTRY("session.save_path",          "",          PHP_INI_ALL, OnUpdateSaveDir,save_path,          php_ps_globals,    ps_globals)
++	STD_PHP_INI_ENTRY("session.save_path",          "@FINKPREFIX@/var/lib/php5",          PHP_INI_ALL, OnUpdateSaveDir,save_path,          php_ps_globals,    ps_globals)
+ 	STD_PHP_INI_ENTRY("session.name",               "PHPSESSID", PHP_INI_ALL, OnUpdateString, session_name,       php_ps_globals,    ps_globals)
+ 	PHP_INI_ENTRY("session.save_handler",           "files",     PHP_INI_ALL, OnUpdateSaveHandler)
+ 	STD_PHP_INI_BOOLEAN("session.auto_start",       "0",         PHP_INI_ALL, OnUpdateBool,   auto_start,         php_ps_globals,    ps_globals)
+--- a/php.ini-development
++++ b/php.ini-development
+@@ -1391,7 +1391,7 @@ session.save_handler = files
+ ; where MODE is the octal representation of the mode. Note that this
+ ; does not overwrite the process's umask.
+ ; http://php.net/session.save-path
+-;session.save_path = "/tmp"
++;session.save_path = "@FINKPREFIX@/var/lib/php5"
+ 
+ ; Whether to use cookies.
+ ; http://php.net/session.use-cookies
+--- a/php.ini-production
++++ b/php.ini-production
+@@ -1346,7 +1346,7 @@ session.save_handler = files
+ ; where MODE is the octal representation of the mode. Note that this
+ ; does not overwrite the process's umask.
+ ; http://php.net/session.save-path
+-;session.save_path = "/tmp"
++;session.save_path = "@FINKPREFIX@/var/lib/php5"
+ 
+ ; Whether to use cookies.
+ ; http://php.net/session.use-cookies
diff -ruN php-5.4.4.orig/fink/patches/shtool_mkdir_-p_-race-condition.patch php-5.4.4/fink/patches/shtool_mkdir_-p_-race-condition.patch
--- php-5.4.4.orig/fink/patches/shtool_mkdir_-p_-race-condition.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/shtool_mkdir_-p_-race-condition.patch	2012-06-12 13:13:05.000000000 -0600
@@ -0,0 +1,25 @@
+Description: Workaround a race condition in shtool's mkdir -p
+ This workaround can be affected by another race condition where a
+ different process running under a different user creates the directory,
+ which would make the chown/chmod calls fail.
+ .
+ This is the version of the patch sent to shtool upstream.
+Origin: vendor
+Forwarded: yes
+Last-Update: 2010-02-18
+
+--- a/build/shtool
++++ b/build/shtool
+@@ -1003,7 +1003,11 @@ mkdir )
+                     if [ ".$opt_t" = .yes ]; then
+                         echo "mkdir $pathcomp" 1>&2
+                     fi
+-                    mkdir $pathcomp || errstatus=$?
++                    mkdir $pathcomp || {
++                        _errstatus=$?
++                        [ -d "$pathcomp" ] || errstatus=${_errstatus}
++                        unset _errstatus
++                    }
+                     if [ ".$opt_o" != . ]; then
+                         if [ ".$opt_t" = .yes ]; then
+                             echo "chown $opt_o $pathcomp" 1>&2
diff -ruN php-5.4.4.orig/fink/patches/static_openssl.patch php-5.4.4/fink/patches/static_openssl.patch
--- php-5.4.4.orig/fink/patches/static_openssl.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/static_openssl.patch	2012-06-12 12:52:34.000000000 -0600
@@ -0,0 +1,13 @@
+--- a/acinclude.m4
++++ b/acinclude.m4
+@@ -2390,9 +2390,7 @@ AC_DEFUN([PHP_SETUP_OPENSSL],[
+ 
+     PHP_ADD_INCLUDE($OPENSSL_INCDIR)
+   
+-    PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
+-      PHP_ADD_LIBRARY(crypto,,$1)
+-    ],[
++    PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [:],[
+       AC_MSG_ERROR([libcrypto not found!])
+     ],[
+       -L$OPENSSL_LIBDIR
diff -ruN php-5.4.4.orig/fink/patches/strcmp_null-OnUpdateErrorLog.patch php-5.4.4/fink/patches/strcmp_null-OnUpdateErrorLog.patch
--- php-5.4.4.orig/fink/patches/strcmp_null-OnUpdateErrorLog.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/strcmp_null-OnUpdateErrorLog.patch	2012-06-12 13:10:36.000000000 -0600
@@ -0,0 +1,13 @@
+--- /dev/null
++++ b/tests/func/null-new_val.phpt
+@@ -0,0 +1,10 @@
++--TEST--
++ini_restore strcmp NULL new_val
++--FILE--
++<?php
++
++ini_set('error_log','ini_set_works');
++ini_restore('error_log');
++
++?>
++--EXPECT--
diff -ruN php-5.4.4.orig/fink/patches/sybase-alias.patch php-5.4.4/fink/patches/sybase-alias.patch
--- php-5.4.4.orig/fink/patches/sybase-alias.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/sybase-alias.patch	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,41 @@
+--- a/ext/mssql/php_mssql.c
++++ b/ext/mssql/php_mssql.c
+@@ -178,6 +178,38 @@ const zend_function_entry mssql_function
+  	PHP_FE(mssql_execute,				arginfo_mssql_execute)
+ 	PHP_FE(mssql_free_statement,		arginfo_mssql_free_statement)
+  	PHP_FE(mssql_guid_string,			arginfo_mssql_guid_string)
++#if !defined(PHP_WIN32) && !defined(HAVE_SYBASE_CT)
++        PHP_FALIAS(sybase_connect, mssql_connect,		arginfo_mssql_connect)
++        PHP_FALIAS(sybase_pconnect, mssql_pconnect,		arginfo_mssql_connect)
++        PHP_FALIAS(sybase_close, mssql_close,			arginfo_mssql_close)
++        PHP_FALIAS(sybase_select_db, mssql_select_db,		arginfo_mssql_select_db)
++        PHP_FALIAS(sybase_query, mssql_query,			arginfo_mssql_query)
++        PHP_FALIAS(sybase_fetch_batch, mssql_fetch_batch,	arginfo_mssql_fetch_batch)
++        PHP_FALIAS(sybase_affected_rows, mssql_rows_affected,	arginfo_mssql_rows_affected)
++        PHP_FALIAS(sybase_free_result, mssql_free_result,	arginfo_mssql_fetch_batch)
++        PHP_FALIAS(sybase_get_last_message, mssql_get_last_message,	arginfo_mssql_get_last_message)
++        PHP_FALIAS(sybase_num_rows, mssql_num_rows,		arginfo_mssql_fetch_batch)
++        PHP_FALIAS(sybase_num_fields, mssql_num_fields,		arginfo_mssql_fetch_batch)
++        PHP_FALIAS(sybase_fetch_field, mssql_fetch_field,	arginfo_mssql_fetch_field)
++        PHP_FALIAS(sybase_fetch_row, mssql_fetch_row,		arginfo_mssql_fetch_batch)
++        PHP_FALIAS(sybase_fetch_array, mssql_fetch_array,	arginfo_mssql_fetch_array)
++        PHP_FALIAS(sybase_fetch_assoc, mssql_fetch_assoc,	arginfo_mssql_fetch_assoc)
++        PHP_FALIAS(sybase_fetch_object, mssql_fetch_object,	arginfo_mssql_fetch_batch)
++        PHP_FALIAS(sybase_field_length, mssql_field_length,	arginfo_mssql_field_length)
++        PHP_FALIAS(sybase_field_name, mssql_field_name,		arginfo_mssql_field_length)
++        PHP_FALIAS(sybase_field_type, mssql_field_type,		arginfo_mssql_field_length)
++        PHP_FALIAS(sybase_data_seek, mssql_data_seek,		arginfo_mssql_data_seek)
++        PHP_FALIAS(sybase_field_seek, mssql_field_seek,		arginfo_mssql_fetch_field)
++        PHP_FALIAS(sybase_result, mssql_result,			arginfo_mssql_result)
++        PHP_FALIAS(sybase_next_result, mssql_next_result,	arginfo_mssql_fetch_assoc)
++        PHP_FALIAS(sybase_min_error_severity, mssql_min_error_severity,	arginfo_mssql_min_error_severity)
++        PHP_FALIAS(sybase_min_message_severity, mssql_min_message_severity,	arginfo_mssql_min_error_severity)
++        PHP_FALIAS(sybase_init, mssql_init,			arginfo_mssql_init)
++        PHP_FALIAS(sybase_bind, mssql_bind,			arginfo_mssql_bind)
++        PHP_FALIAS(sybase_execute, mssql_execute,		arginfo_mssql_execute)
++        PHP_FALIAS(sybase_free_statement, mssql_free_statement,	arginfo_mssql_free_statement)
++        PHP_FALIAS(sybase_guid_string, mssql_guid_string,	arginfo_mssql_guid_string)
++#endif
+ 	PHP_FE_END
+ };
+ /* }}} */
diff -ruN php-5.4.4.orig/fink/patches/we_WANT_libtool.patch php-5.4.4/fink/patches/we_WANT_libtool.patch
--- php-5.4.4.orig/fink/patches/we_WANT_libtool.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/we_WANT_libtool.patch	2012-06-12 12:57:46.000000000 -0600
@@ -0,0 +1,25 @@
+Description:
+ upstream ships an out of date version of libtool.  this ensures that
+ we build against an up-to-date version of libtool by running libtoolize
+ as part of our build process (this is called indirectly via ./buildconf.sh
+ from debian/rules)
+ .
+ note that we don't touch the libtool.m4 that they ship here, and this file
+ gets included in the build process as part of the phpize stuff.  however,
+ this is solved in ./debian/rules where it's overwritten with a symlink.
+Origin: vendor
+Forwarded: no
+Last-Update: 2010-01-18
+
+--- a/build/build2.mk
++++ b/build/build2.mk
+@@ -46,7 +46,8 @@ $(TOUCH_FILES):
+ 
+ aclocal.m4: configure.in acinclude.m4
+ 	@echo rebuilding $@
+-	cat acinclude.m4 ./build/libtool.m4 > $@
++	libtoolize --copy --install --automake --force
++	aclocal
+ 
+ configure: aclocal.m4 configure.in $(config_m4_files)
+ 	@echo rebuilding $@
diff -ruN php-5.4.4.orig/fink/patches/zend_int_overflow.patch php-5.4.4/fink/patches/zend_int_overflow.patch
--- php-5.4.4.orig/fink/patches/zend_int_overflow.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/zend_int_overflow.patch	2012-06-14 13:13:26.000000000 -0600
@@ -0,0 +1,110 @@
+Description: Another integer overflow/underflow logic fix.
+ Once again, don't rely on undefined behavior and instead detect
+ the overflow/underflow conditions intelligently.
+Bug: http://bugs.php.net/bug.php?id=51008
+Bug-Debian: http://bugs.debian.org/570144
+
+--- a/Zend/zend_hash.h	2012-06-12 22:54:23.000000000 -0600
++++ b/Zend/zend_hash.h	2012-06-14 13:11:12.000000000 -0600
+@@ -306,9 +306,11 @@
+ 
+ #define ZEND_HANDLE_NUMERIC_EX(key, length, idx, func) do {					\
+ 	register const char *tmp = key;											\
++	int negative = 0;											\
+ 																			\
+ 	if (*tmp == '-') {														\
+ 		tmp++;																\
++		negative = 1;																\
+ 	}																		\
+ 	if (*tmp >= '0' && *tmp <= '9') { /* possibly a numeric index */		\
+ 		const char *end = key + length - 1;									\
+@@ -321,19 +323,19 @@
+ 		     *tmp > '2')) { /* overflow */									\
+ 			break;															\
+ 		}																	\
+-		idx = (*tmp - '0');													\
++		idx = ((negative)?-1:1) * (*tmp - '0');													\
+ 		while (++tmp != end && *tmp >= '0' && *tmp <= '9') {				\
+-			idx = (idx * 10) + (*tmp - '0');								\
+-		}																	\
+-		if (tmp == end) {													\
+-			if (*key == '-') {												\
+-				if (idx-1 > LONG_MAX) { /* overflow */						\
+-					break;													\
+-				}															\
+-				idx = (ulong)(-(long)idx);									\
+-			} else if (idx > LONG_MAX) { /* overflow */						\
++			int digit = (*tmp - '0');						\
++			if ( (!negative) && idx <= (LONG_MAX-digit)/10 ) {						\
++				idx = (idx * 10) + digit;														\
++			} else if ( (negative) && idx >= (LONG_MIN+digit)/10 ) {						\
++				idx = (idx * 10) - digit;														\
++			} else {						\
++				--tmp; /* overflow or underflow, make sure tmp != end */														\
+ 				break;														\
+ 			}																\
++		}																	\
++		if (tmp == end) {																	\
+ 			func;															\
+ 		}																	\
+ 	}																		\
+--- a/Zend/tests/bug45877.phpt
++++ b/Zend/tests/bug45877.phpt
+@@ -1,23 +1,40 @@
+ --TEST--
+ Bug #45877 (Array key '2147483647' left as string)
+---INI--
+-precision=16
+ --FILE--
+ <?php
+-$keys = array(PHP_INT_MAX,
+-	(string) PHP_INT_MAX,
+-	(string) (-PHP_INT_MAX - 1),
+-	-PHP_INT_MAX - 1,
+-	(string) (PHP_INT_MAX + 1));
++$max = sprintf("%d", PHP_INT_MAX);
++switch($max) {
++case "2147483647": /* 32-bit systems */
++	$min = "-2147483648";
++	$overflow = "2147483648";
++	$underflow = "-2147483649";
++	break;
++case "9223372036854775807": /* 64-bit systems */
++	$min = "-9223372036854775808";
++	$overflow = "9223372036854775808";
++	$underflow = "-9223372036854775809";
++	break;
++default:
++	die("failed: unknown value for PHP_MAX_INT");
++	break;
++}
+ 
+-var_dump(array_fill_keys($keys, 1));
+-?>
+---EXPECTF--
+-array(3) {
+-  [%d7]=>
+-  int(1)
+-  [-%d8]=>
+-  int(1)
+-  ["%s"]=>
+-  int(1)
++function test_value($val, $msg) {
++	$a = array($val => 1);
++	$keys = array_keys($a);
++	if ($val == $keys[0]) $result = "ok";
++	else $result = "failed ($val != $keys[0])";
++	echo "$msg: $result\n";
+ }
++
++test_value($max, "max");
++test_value($overflow, "overflow");
++test_value($min, "min");
++test_value($underflow, "underflow");
++
++?>
++--EXPECT--
++max: ok
++overflow: ok
++min: ok
++underflow: ok
diff -ruN php-5.4.4.orig/fink/patches/zts_with_dl.patch php-5.4.4/fink/patches/zts_with_dl.patch
--- php-5.4.4.orig/fink/patches/zts_with_dl.patch	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/patches/zts_with_dl.patch	2012-06-12 13:58:33.000000000 -0600
@@ -0,0 +1,15 @@
+--- a/ext/standard/dl.c
++++ b/ext/standard/dl.c
+@@ -74,12 +74,7 @@ PHPAPI PHP_FUNCTION(dl)
+ 		(strcmp(sapi_module.name, "cli") != 0) &&
+ 		(strncmp(sapi_module.name, "embed", 5) != 0)
+ 	) {
+-#ifdef ZTS
+-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not supported in multithreaded Web servers - use extension=%s in your php.ini", filename);
+-		RETURN_FALSE;
+-#else
+ 		php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "dl() is deprecated - use extension=%s in your php.ini", filename);
+-#endif
+ 	}
+ 
+ 	php_dl(filename, MODULE_TEMPORARY, return_value, 0 TSRMLS_CC);
diff -ruN php-5.4.4.orig/fink/php5-module.ini php-5.4.4/fink/php5-module.ini
--- php-5.4.4.orig/fink/php5-module.ini	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/php5-module.ini	2012-05-09 15:45:14.000000000 -0600
@@ -0,0 +1,3 @@
+; configuration for php @extname@ module
+; priority=@priority@
+extension=@dsoname@.so
diff -ruN php-5.4.4.orig/fink/php5enmod php-5.4.4/fink/php5enmod
--- php-5.4.4.orig/fink/php5enmod	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/php5enmod	2012-06-12 13:25:42.000000000 -0600
@@ -0,0 +1,126 @@
+#!/bin/sh
+#
+#  php5enmod - a php5 module manager for Debian
+#
+#  Copyright 2012 Canonical Ltd., All Rights Reserved.
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  On Debian systems the full text of the GPL version 3 is available at
+#  /usr/share/common-licenses/GPL-3.
+#
+set -ue
+
+SCRIPT_NAME=${0##*/}
+ENABLED=0
+DISABLED=0
+VERBOSE=no
+
+cleanup() {
+    if [ "${VERBOSE}" != "no" ]; then
+	if [ ${ENABLED} -gt 0 ] ; then
+            echo "Enabled ${ENABLED} module(s), you may need to restart any running PHP processes."
+	fi
+	if [ ${DISABLED} -gt 0 ] ; then
+            echo "Disabled ${DISABLED} module(s), you may need to restart any running PHP processes."
+	fi
+    fi
+}
+
+trap cleanup EXIT
+
+usage() {
+    echo "usage: ${SCRIPT_NAME} module_name [ module_name_2 ]"
+    exit 1
+}
+
+error() {
+    echo "ERROR: ${1}" >&2
+    shift
+    local ecode=${1:-1}
+    exit ${ecode}
+}
+
+enmods() {
+    local modname=""
+    ENABLED=0
+    for modname in ${@} ; do
+        enmod ${modname}
+    done
+}
+
+dismods() {
+    DISABLED=0
+    local modname=""
+    for modname in ${@} ; do
+        dismod "${modname}"
+    done
+}
+
+enmod() {
+    local modname="$(basename "${1%/[0-9]*}")"
+    local priority="$(basename "${1#[a-z]*/}")"
+    [ "${modname}" = "${priority}" ] && priority=20
+    # assert $modname is in @FINKPREFIX@/etc/php5/mods-available
+    local source_ini="@FINKPREFIX@/etc/php5/mods-available/${modname}.ini"
+    [ -e "${source_ini}" ] || error "${source_ini} does not exist" 2
+    [ -z "${priority}" ] && priority=20
+        
+    # assert $modname is not present in @FINKPREFIX@/etc/php5/conf.d, or already symlink to @FINKPREFIX@/etc/php5/mods-available
+    local live_link="@FINKPREFIX@/etc/php5/conf.d/$priority-$modname.ini"
+    local live_link_content="../mods-available/$modname.ini"
+    if [ -e "${live_link}" ] ; then
+        if [ -h "${live_link}" ] ; then
+            local content="$(readlink "${live_link}")"
+            if [ "${content}" = "${live_link_content}" ] ; then
+                return
+            fi
+        fi
+        error "${modname} module symlink already exists in @FINKPREFIX@/etc/php5/conf.d with different content"
+    fi
+    ln -s "${live_link_content}" "${live_link}"
+    ENABLED=$((${ENABLED}+1))
+}
+
+dismod() {
+    local modname="$(basename "${1%/[0-9]*}")"
+    local live_link=""
+    local live_link_content="../mods-available/${modname}.ini"
+    local FOUND=0
+    for live_link in $(ls -1 @FINKPREFIX@/etc/php5/conf.d/*.ini); do
+        # assert $modname is in @FINKPREFIX@/etc/php5/conf.d
+	[ -e "${live_link}" ] || continue
+	[ -h "${live_link}" ] || continue
+        # assert $modname is a symlink to @FINKPREFIX@/etc/php5/mods-available
+	[ "$(readlink "${live_link}")" != "${live_link_content}" ] && continue
+	# remove the symlink
+	rm -f "${live_link}"
+	FOUND=1
+    done
+    [ "${FOUND}" -gt 0 ] && DISABLED=$(($DISABLED+1))
+}
+
+# parse args
+# modname
+[ -n ${1:-""} ] || usage
+
+case "${SCRIPT_NAME}" in
+php5enmod)
+    enmods $@
+    ;;
+php5dismod)
+    dismods $@
+    ;;
+*)
+    usage
+    ;;
+esac
+exit 0
diff -ruN php-5.4.4.orig/fink/setup-mysql.sh php-5.4.4/fink/setup-mysql.sh
--- php-5.4.4.orig/fink/setup-mysql.sh	1969-12-31 17:00:00.000000000 -0700
+++ php-5.4.4/fink/setup-mysql.sh	2012-06-13 13:55:29.000000000 -0600
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+set -eu
+
+[ $# -ge 2 ] || {
+    echo "Usage: fink/setup-mysql.sh port data-dir" >&2
+    exit 1
+}
+
+# CLI arguments #
+port=$1
+datadir=$2
+action=${3:-start}
+if [ "$(id -u)" -eq 0 ]; then
+    user="mysql"
+else
+    user="$(whoami)"
+fi
+
+# Some vars #
+
+socket=$datadir/mysql.sock
+# Commands:
+mysqladmin="mysqladmin --no-defaults --user root --port $port --host 127.0.0.1 --socket=$socket"
+mysqld="@FINKPREFIX@/sbin/mysqld --no-defaults --user=$user --bind-address=127.0.0.1 --port=$port --socket=$socket --datadir=$datadir"
+
+# Main code #
+
+if [ "$action" = "stop" ]; then
+    $mysqladmin shutdown
+    exit
+fi
+
+rm -rf $datadir
+mkdir -p $datadir
+chmod go-rx $datadir
+chown $user: $datadir
+
+mysql_install_db --no-defaults --user=$user --datadir=$datadir --rpm --force
+
+tmpf=$(mktemp php5_mysql_test-XXXXX)
+cat > "$tmpf" <<EOF
+USE mysql;
+UPDATE user SET password=PASSWORD('') WHERE user='root';
+FLUSH PRIVILEGES;
+EOF
+
+$mysqld --bootstrap --skip-grant-tables < "$tmpf"
+
+unlink "$tmpf"
+
+# Start the daemon
+$mysqld &
+
+pid=$!
+
+# Wait for the server to be actually available
+c=0;
+while ! nc -z 127.0.0.1 $port; do
+    c=$(($c+1));
+    sleep 3;
+    if [ $c -gt 20 ]; then
+	echo "Timed out waiting for mysql server to be available" >&2
+	if [ "$pid" ]; then
+	    kill $pid || :
+	    sleep 2
+	    kill -s KILL $pid || :
+	fi
+	exit 1
+    fi
+done
+
+# Check if the server is running
+$mysqladmin status
+# Drop the database if it exists
+$mysqladmin --force --silent drop test || true
+# Create new empty database
+$mysqladmin create test
