Sync with PHP Overlay: various updates.
authorLuca Longinotti <chtekk@gentoo.org>
Sun, 12 Mar 2006 13:24:36 +0000 (13:24 +0000)
committerLuca Longinotti <chtekk@gentoo.org>
Sun, 12 Mar 2006 13:24:36 +0000 (13:24 +0000)
eclass/php4_4-sapi.eclass
eclass/php5_0-sapi.eclass
eclass/php5_1-sapi.eclass

index 45858e2442ea2bc589b9259ec5c4c65b7d5f476a..7913495a9826d248a03fdd8f1d6ad78a514f7551 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/php4_4-sapi.eclass,v 1.12 2006/01/28 01:35:11 chtekk Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/php4_4-sapi.eclass,v 1.13 2006/03/12 13:24:36 chtekk Exp $
 #
 # ########################################################################
 #
@@ -32,7 +32,7 @@ inherit flag-o-matic eutils confutils libtool php-common-r1
 # copies of php which are compiled into other packages (e.g. php support
 # for the thttpd web server) don't need these variables
 
-if [ "${PHP_PACKAGE}" = 1 ]; then
+if [[ "${PHP_PACKAGE}" == 1 ]] ; then
        HOMEPAGE="http://www.php.net/"
        LICENSE="PHP-3"
        SRC_URI="http://www.php.net/distributions/${MY_PHP_P}.tar.bz2"
@@ -46,12 +46,6 @@ DEPEND="${DEPEND}
        !dev-php/php
        !dev-php/php-cgi
        !dev-php/mod_php
-       >=sys-devel/m4-1.4.3
-       >=sys-devel/libtool-1.5.18
-       >=sys-devel/automake-1.9.6
-       sys-devel/automake-wrapper
-       >=sys-devel/autoconf-2.59
-       sys-devel/autoconf-wrapper
        berkdb? ( =sys-libs/db-4* )
        bzip2? ( app-arch/bzip2 )
        cdb? ( dev-db/cdb )
@@ -106,6 +100,15 @@ DEPEND="${DEPEND} !dev-libs/9libs"
 # simplistic for now
 RDEPEND="${RDEPEND} ${DEPEND}"
 
+# those are only needed at compile-time
+DEPEND="${DEPEND}
+               >=sys-devel/m4-1.4.3
+               >=sys-devel/libtool-1.5.18
+               >=sys-devel/automake-1.9.6
+               sys-devel/automake-wrapper
+               >=sys-devel/autoconf-2.59
+               sys-devel/autoconf-wrapper"
+
 # Additional features
 #
 # They are in PDEPEND because we need PHP installed first!
@@ -122,12 +125,6 @@ PDEPEND="${PDEPEND}
 
 PHP_INI_FILE="php.ini"
 
-# ========================================================================
-# Hardened-PHP Support
-# ========================================================================
-
-[ -n "${HARDENEDPHP_PATCH}" ] && SRC_URI="${SRC_URI} hardenedphp? ( http://gentoo.longitekk.com/${HARDENEDPHP_PATCH} )"
-
 # ========================================================================
 
 EXPORT_FUNCTIONS pkg_setup src_compile src_install src_unpack pkg_postinst
@@ -211,7 +208,7 @@ php4_4-sapi_check_awkward_uses() {
        confutils_use_conflict "readline" "libedit"
 
        # Recode is not liked
-       confutils_use_conflict "recode" "mysql" "imap" "nis"
+       confutils_use_conflict "recode" "mysql" "imap" "yaz"
 
        # the MM extension isn't thread-safe
        confutils_use_conflict "sharedmem" "threads"
@@ -219,6 +216,44 @@ php4_4-sapi_check_awkward_uses() {
        confutils_warn_about_missing_deps
 }
 
+php4_4-sapi_set_php_ini_dir() {
+       PHP_INI_DIR="/etc/php/${PHPSAPI}-php4"
+       PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
+       PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
+}
+
+php4_4-sapi_install_ini() {
+       destdir=/usr/$(get_libdir)/php4
+
+       # get the extension dir
+       PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
+
+       # work out where we are installing the ini file
+       php4_4-sapi_set_php_ini_dir
+
+       local phpinisrc=php.ini-dist
+
+       dodir ${PHP_INI_DIR}
+       insinto ${PHP_INI_DIR}
+       newins ${phpinisrc} ${PHP_INI_FILE}
+
+       dodir ${PHP_EXT_INI_DIR}
+       dodir ${PHP_EXT_INI_DIR_ACTIVE}
+
+       # Java needs to insert the correct ini files
+       php_install_java_inifile
+
+       # Install any extensions built as shared objects
+       if useq sharedext ; then
+               for x in `ls "${D}/${PHPEXTDIR}/"*.so | sort | sed -e "s|.*java.*||g"` ; do
+                       inifilename=${x/.so/.ini}
+                       inifilename=`basename ${inifilename}`
+                       echo "extension=`basename ${x}`" >> "${D}/${PHP_EXT_INI_DIR}/${inifilename}"
+                       dosym "${PHP_EXT_INI_DIR}/${inifilename}" "${PHP_EXT_INI_DIR_ACTIVE}/${inifilename}"
+               done
+       fi
+}
+
 # ========================================================================
 # EXPORTED FUNCTIONS
 # ========================================================================
@@ -226,104 +261,109 @@ php4_4-sapi_check_awkward_uses() {
 php4_4-sapi_pkg_setup() {
        # let's do all the USE flag testing before we do anything else
        # this way saves a lot of time
-
        php4_4-sapi_check_awkward_uses
 }
 
 php4_4-sapi_src_unpack() {
-       if [ "${PHP_PACKAGE}" == 1 ] ; then
+       if [[ "${PHP_PACKAGE}" == 1 ]] ; then
                unpack ${A}
        fi
 
        cd "${S}"
 
-       # lib64 support
-       if [ -n "${LIB64_PATCH}" ] ; then
-               epatch "${WORKDIR}/${LIB64_PATCH}"
+       # Change PHP branding
+       PHPPR=${PR/r/}
+       if [[ "${PHPPR}" != "0" ]] ; then
+               sed -e "s|^EXTRA_VERSION=\"\"|EXTRA_VERSION=\"-pl${PHPPR}-gentoo\"|g" -i configure.in || die "Unable to change PHP branding to -pl${PHPPR}-gentoo"
        else
-               ewarn "There is no lib64 patch available for this PHP release yet!"
+               sed -e "s|^EXTRA_VERSION=\"\"|EXTRA_VERSION=\"-gentoo\"|g" -i configure.in || die "Unable to change PHP branding to -gentoo"
        fi
 
-       # Patch PHP to show Gentoo as the server platform
-       sed -e "s/PHP_UNAME=\`uname -a | xargs\`/PHP_UNAME=\`uname -s -n -r -v | xargs\`/g" -i configure.in || die "Failed to fix server platform name"
+       # multilib-strict support
+       if [[ -n "${MULTILIB_PATCH}" ]] && [[ -f "${WORKDIR}/${MULTILIB_PATCH}" ]] ; then
+               epatch "${WORKDIR}/${MULTILIB_PATCH}"
+       else
+               ewarn "There is no multilib-strict patch available for this PHP release yet!"
+       fi
 
-       # Patch PHP to support heimdal instead of mit-krb5
-       if has_version "app-crypt/heimdal" ; then
-               sed -e "s|gssapi_krb5|gssapi|g" -i acinclude.m4 || die "Failed to fix heimdal libname"
-               sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 || die "Failed to fix heimdal crypt lib"
+       # Apply general PHP4 patches
+       if [[ -d "${WORKDIR}/${MY_PHP_PV}/php4" ]] ; then
+               EPATCH_SOURCE="${WORKDIR}/${MY_PHP_PV}/php4" EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch
        fi
 
-       # Patch for PostgreSQL support
-       if use postgres ; then
-               sed -e 's|include/postgresql|include/postgresql include/postgresql/pgsql|g' -i ext/pgsql/config.m4 || die "Failed to fix PostgreSQL include paths"
+       # Apply version-specific PHP patches
+       if [[ -d "${WORKDIR}/${MY_PHP_PV}/${MY_PHP_PV}" ]] ; then
+               EPATCH_SOURCE="${WORKDIR}/${MY_PHP_PV}/${MY_PHP_PV}" EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch
        fi
 
+       # Patch PHP to show Gentoo as the server platform
+       sed -e "s/PHP_UNAME=\`uname -a | xargs\`/PHP_UNAME=\`uname -s -n -r -v | xargs\`/g" -i configure.in || die "Failed to fix server platform name"
+
        # Disable interactive make test
        sed -e 's/'`echo "\!getenv('NO_INTERACTION')"`'/false/g' -i run-tests.php
 
-       # stop php from activating the apache config, as we will do that ourselves
+       # Stop PHP from activating the Apache config, as we will do that ourselves
        for i in configure sapi/apache/config.m4 sapi/apache2filter/config.m4 sapi/apache2handler/config.m4 ; do
                sed -i.orig -e 's,-i -a -n php,-i -n php,g' ${i}
                sed -i.orig -e 's,-i -A -n php,-i -n php,g' ${i}
        done
 
-       # imap support
-       use imap && epatch "${FILESDIR}/4-any/php4-imap-symlink.diff"
+       # Patch PHP to support heimdal instead of mit-krb5
+       if has_version "app-crypt/heimdal" ; then
+               sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 || die "Failed to fix heimdal libname"
+               sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 || die "Failed to fix heimdal crypt library reference"
+       fi
 
-       # iodbc support
-       use iodbc && epatch "${FILESDIR}/4-any/php4-iodbc-config.diff"
-       use iodbc && epatch "${FILESDIR}/4-any/php4-with-iodbc.diff"
+       # Patch for PostgreSQL support
+       if useq postgres ; then
+               sed -e 's|include/postgresql|include/postgresql include/postgresql/pgsql|g' -i ext/pgsql/config.m4 || die "Failed to fix PostgreSQL include paths"
+       fi
 
-       # hardenedphp support
-       if use hardenedphp ; then
-               if [ -n "${HARDENEDPHP_PATCH}" ] ; then
+       # Hardened-PHP support 
+       if useq hardenedphp ; then
+               if [[ -n "${HARDENEDPHP_PATCH}" ]] && [[ -f "${DISTDIR}/${HARDENEDPHP_PATCH}" ]] ; then
                        epatch "${DISTDIR}/${HARDENEDPHP_PATCH}"
                else
-                       ewarn "There is no Hardened-PHP available for this PHP release yet!"
+                       ewarn "There is no Hardened-PHP patch available for this PHP release yet!"
                fi
        fi
 
        # fastbuild support
-       use fastbuild && epatch "${FILESDIR}/4-any/php4-fastbuild.patch"
-
-       # fix uClibc support, as it does not have the dn_skipname() function
-       epatch "${FILESDIR}/4-any/php4-uClibc-have_dn_skipname.patch"
+       if useq fastbuild ; then
+               if [[ -n "${FASTBUILD_PATCH}" ]] && [[ -f "${WORKDIR}/${FASTBUILD_PATCH}" ]] ; then
+                       epatch "${WORKDIR}/${FASTBUILD_PATCH}"
+               else
+                       ewarn "There is no fastbuild patch available for this PHP release yet!"
+               fi
+       fi
 
-       # fix configure scripts to correctly support HardenedPHP
-       # and patch PHP to support libtool 1.5
-       epatch "${FILESDIR}/4-any/php4-libtool-1.5.patch"
+       # Fix configure scripts to correctly support Hardened-PHP
        einfo "Running aclocal"
        WANT_AUTOMAKE=1.9 aclocal --force || die "Unable to run aclocal successfully"
        einfo "Running libtoolize"
        libtoolize --copy --force || die "Unable to run libtoolize successfully"
 
-       # rebuild configure to make sure it's up to date
+       # Rebuild configure to make sure it's up to date
        einfo "Rebuilding configure script"
        WANT_AUTOCONF=2.5 autoreconf --force -W no-cross || die "Unable to regenerate configure script successfully"
 
-       # run elibtoolize
+       # Run elibtoolize
        elibtoolize
 
        # Just in case ;-)
-       chmod 755 configure || die "Failed to chmod configure to 755"
-}
-
-set_php_ini_dir() {
-       PHP_INI_DIR="/etc/php/${PHPSAPI}-php4"
-       PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
-       PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
+       chmod 0755 configure || die "Failed to chmod configure to 0755"
 }
 
 php4_4-sapi_src_compile() {
        destdir=/usr/$(get_libdir)/php4
-       set_php_ini_dir
+       php4_4-sapi_set_php_ini_dir
 
        cd "${S}"
        confutils_init
 
        my_conf="${my_conf} --with-config-file-path=${PHP_INI_DIR} --with-config-file-scan-dir=${PHP_EXT_INI_DIR_ACTIVE} --without-pear"
 
-       #                               extension               USE flag                shared support?
+       #                                                       extension               USE flag                shared support?
        enable_extension_enable         "bcmath"                "bcmath"                1
        enable_extension_with           "bz2"                   "bzip2"                 1
        enable_extension_enable         "calendar"              "calendar"              1
@@ -358,7 +398,7 @@ php4_4-sapi_src_compile() {
        enable_extension_with           "oci8"                  "oci8"                  1
        enable_extension_with           "oci8-instant-client"   "oci8-instant-client"   1
        enable_extension_with           "oracle"                "oracle7"               1
-       enable_extension_with           "openssl"               "ssl"                   1
+       enable_extension_with           "openssl"               "ssl"                   0
        enable_extension_with           "openssl-dir"   "ssl"                   0 "/usr"
        enable_extension_disable        "overload"              "overload"              0
        enable_extension_with           "ovrimos"               "ovrimos"               1
@@ -400,7 +440,7 @@ php4_4-sapi_src_compile() {
                enable_extension_enable "dbx"           "dbx"           1
        fi
 
-       # support for the GD graphics library
+       # Support for the GD graphics library
        if useq gd-external ; then
                enable_extension_with   "freetype-dir"  "truetype"              0 "/usr"
                enable_extension_with   "t1lib"                 "truetype"              0 "/usr"
@@ -433,7 +473,7 @@ php4_4-sapi_src_compile() {
 
        # Interbase support
        if useq firebird || useq interbase ; then
-               my_conf="${my_conf} --with-interbase"
+               my_conf="${my_conf} --with-interbase=/usr"
        fi
 
        # LDAP support
@@ -483,14 +523,14 @@ php4_4-sapi_src_compile() {
                enable_extension_with           "dom-exslt"             "xsl"                   0       "/usr"
        fi
 
-       # session support
+       # Session support
        if ! useq session ; then
                enable_extension_disable        "session"       "session"               1
        else
                enable_extension_with           "mm"            "sharedmem"             0
        fi
 
-       # fix ELF-related problems
+       # Fix ELF-related problems
        if useq pic ; then
                einfo "Enabling PIC support"
                my_conf="${my_conf} --with-pic"
@@ -502,7 +542,7 @@ php4_4-sapi_src_compile() {
                ewarn "Enabling ZTS for Apache2 MPM"
        fi
 
-       # catch cflag problems
+       # Catch CFLAGS problems
        php_check_cflags
 
        # multilib support
@@ -510,9 +550,7 @@ php4_4-sapi_src_compile() {
                my_conf="--with-libdir=$(get_libdir) ${my_conf}"
        fi
 
-       # all done
-
-       # we don't use econf, because we need to override all of its settings
+       # We don't use econf, because we need to override all of its settings
        ./configure --prefix=${destdir} --sysconfdir=/etc --cache-file=./config.cache ${my_conf} || die "configure failed"
        emake || die "make failed"
 }
@@ -527,16 +565,15 @@ php4_4-sapi_src_install() {
        useq sharedext && PHP_INSTALLTARGETS="${PHP_INSTALLTARGETS} install-modules"
        make INSTALL_ROOT="${D}" ${PHP_INSTALLTARGETS} || die "install failed"
 
-       # get the extension dir
+       # Get the extension dir
        PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
 
-       # don't forget the php.ini file
+       # Don't forget the php.ini file
        local phpinisrc=php.ini-dist
        einfo "Setting extension_dir in php.ini"
        sed -e "s|^extension_dir .*$|extension_dir = ${PHPEXTDIR}|g" -i ${phpinisrc}
 
-       # A patch for PHP for security. PHP-CLI interface is exempt, as it cannot be
-       # fed bad data from outside.
+       # A patch for PHP for security
        einfo "Securing fopen wrappers"
        sed -e 's|^allow_url_fopen .*|allow_url_fopen = Off|g' -i ${phpinisrc}
 
@@ -547,42 +584,10 @@ php4_4-sapi_src_install() {
        # Java module and support needs to be installed
        php_install_java
 
-       # create the directory where we'll put php4-only php scripts
+       # Create the directory where we'll put php4-only php scripts
        keepdir /usr/share/php4
 }
 
-php4_4-sapi_install_ini() {
-       destdir=/usr/$(get_libdir)/php4
-
-       # get the extension dir
-       PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
-
-       # work out where we are installing the ini file
-       set_php_ini_dir
-
-       local phpinisrc=php.ini-dist
-
-       dodir ${PHP_INI_DIR}
-       insinto ${PHP_INI_DIR}
-       newins ${phpinisrc} ${PHP_INI_FILE}
-
-       dodir ${PHP_EXT_INI_DIR}
-       dodir ${PHP_EXT_INI_DIR_ACTIVE}
-
-       # Java needs to insert the correct ini files
-       php_install_java_inifile
-
-       # Install any extensions built as shared objects
-       if useq sharedext ; then
-               for x in `ls "${D}/${PHPEXTDIR}/"*.so | sort | sed -e "s|.*java.*||g"` ; do
-                       inifilename=${x/.so/.ini}
-                       inifilename=`basename ${inifilename}`
-                       echo "extension=`basename ${x}`" >> "${D}/${PHP_EXT_INI_DIR}/${inifilename}"
-                       dosym "${PHP_EXT_INI_DIR}/${inifilename}" "${PHP_EXT_INI_DIR_ACTIVE}/${inifilename}"
-               done
-       fi
-}
-
 php4_4-sapi_pkg_postinst() {
        # Update Apache1 to use mod_php
        if useq apache ; then
index 76cc4d27645f29d66a0667d1260f8fc7a87983e1..a0401213531950438567ed05d0dd8dde7f3e477b 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/php5_0-sapi.eclass,v 1.14 2006/01/28 01:35:11 chtekk Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/php5_0-sapi.eclass,v 1.15 2006/03/12 13:24:36 chtekk Exp $
 #
 # ########################################################################
 #
@@ -32,7 +32,7 @@ inherit flag-o-matic eutils confutils libtool php-common-r1
 # copies of php which are compiled into other packages (e.g. php support
 # for the thttpd web server) don't need these variables
 
-if [ "${PHP_PACKAGE}" = 1 ]; then
+if [[ "${PHP_PACKAGE}" == 1 ]] ; then
        HOMEPAGE="http://www.php.net/"
        LICENSE="PHP-3"
        SRC_URI="http://www.php.net/distributions/${MY_PHP_P}.tar.bz2"
@@ -46,12 +46,6 @@ DEPEND="${DEPEND}
        !dev-php/php
        !dev-php/php-cgi
        !dev-php/mod_php
-       >=sys-devel/m4-1.4.3
-       >=sys-devel/libtool-1.5.18
-       >=sys-devel/automake-1.9.6
-       sys-devel/automake-wrapper
-       >=sys-devel/autoconf-2.59
-       sys-devel/autoconf-wrapper
        berkdb? ( =sys-libs/db-4* )
        bzip2? ( app-arch/bzip2 )
        cdb? ( dev-db/cdb )
@@ -107,6 +101,15 @@ DEPEND="${DEPEND} !media-libs/libswf"
 # simplistic for now
 RDEPEND="${RDEPEND} ${DEPEND}"
 
+# those are only needed at compile-time
+DEPEND="${DEPEND}
+               >=sys-devel/m4-1.4.3
+               >=sys-devel/libtool-1.5.18
+               >=sys-devel/automake-1.9.6
+               sys-devel/automake-wrapper
+               >=sys-devel/autoconf-2.59
+               sys-devel/autoconf-wrapper"
+
 # Additional features
 #
 # They are in PDEPEND because we need PHP installed first!
@@ -124,12 +127,6 @@ PDEPEND="${PDEPEND}
 
 PHP_INI_FILE="php.ini"
 
-# ========================================================================
-# Hardened-PHP Support
-# ========================================================================
-
-[ -n "${HARDENEDPHP_PATCH}" ] && SRC_URI="${SRC_URI} hardenedphp? ( http://gentoo.longitekk.com/${HARDENEDPHP_PATCH} )"
-
 # ========================================================================
 
 EXPORT_FUNCTIONS pkg_setup src_compile src_install src_unpack pkg_postinst
@@ -175,6 +172,7 @@ php5_0-sapi_check_awkward_uses() {
        # XML related extensions
        confutils_use_depend_all "soap" "xml"
        confutils_use_depend_all "simplexml"    "xml"
+       confutils_use_depend_all "xmlrpc"       "xml"
        confutils_use_depend_all "xsl"  "xml"
        confutils_use_depend_all "wddx" "xml"
 
@@ -216,7 +214,7 @@ php5_0-sapi_check_awkward_uses() {
        confutils_use_conflict "readline" "libedit"
 
        # Recode is not liked
-       confutils_use_conflict "recode" "mysql" "imap" "nis"
+       confutils_use_conflict "recode" "mysql" "imap" "yaz"
 
        # the MM extension isn't thread-safe
        confutils_use_conflict "sharedmem" "threads"
@@ -224,6 +222,41 @@ php5_0-sapi_check_awkward_uses() {
        confutils_warn_about_missing_deps
 }
 
+php5_0-sapi_set_php_ini_dir() {
+       PHP_INI_DIR="/etc/php/${PHPSAPI}-php5"
+       PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
+       PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
+}
+
+php5_0-sapi_install_ini() {
+       destdir=/usr/$(get_libdir)/php5
+
+       # get the extension dir
+       PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
+
+       # work out where we are installing the ini file
+       php5_0-sapi_set_php_ini_dir
+
+       local phpinisrc=php.ini-dist
+
+       dodir ${PHP_INI_DIR}
+       insinto ${PHP_INI_DIR}
+       newins ${phpinisrc} ${PHP_INI_FILE}
+
+       dodir ${PHP_EXT_INI_DIR}
+       dodir ${PHP_EXT_INI_DIR_ACTIVE}
+
+       # Install any extensions built as shared objects
+       if useq sharedext ; then
+               for x in `ls "${D}/${PHPEXTDIR}/"*.so | sort` ; do
+                       inifilename=${x/.so/.ini}
+                       inifilename=`basename ${inifilename}`
+                       echo "extension=`basename ${x}`" >> "${D}/${PHP_EXT_INI_DIR}/${inifilename}"
+                       dosym "${PHP_EXT_INI_DIR}/${inifilename}" "${PHP_EXT_INI_DIR_ACTIVE}/${inifilename}"
+               done
+       fi
+}
+
 # ========================================================================
 # EXPORTED FUNCTIONS
 # ========================================================================
@@ -231,106 +264,100 @@ php5_0-sapi_check_awkward_uses() {
 php5_0-sapi_pkg_setup() {
        # let's do all the USE flag testing before we do anything else
        # this way saves a lot of time
-
        php5_0-sapi_check_awkward_uses
 }
 
 php5_0-sapi_src_unpack() {
-       if [ "${PHP_PACKAGE}" == 1 ] ; then
+       if [[ "${PHP_PACKAGE}" == 1 ]] ; then
                unpack ${A}
        fi
 
        cd "${S}"
 
-       # lib64 support
-       if [ -n "${LIB64_PATCH}" ] ; then
-               epatch "${WORKDIR}/${LIB64_PATCH}"
+       # Change PHP branding
+       PHPPR=${PR/r/}
+       if [[ "${PHPPR}" != "0" ]] ; then
+               sed -e "s|^EXTRA_VERSION=\"\"|EXTRA_VERSION=\"-pl${PHPPR}-gentoo\"|g" -i configure.in || die "Unable to change PHP branding to -pl${PHPPR}-gentoo"
        else
-               ewarn "There is no lib64 patch available for this PHP release yet!"
+               sed -e "s|^EXTRA_VERSION=\"\"|EXTRA_VERSION=\"-gentoo\"|g" -i configure.in || die "Unable to change PHP branding to -gentoo"
        fi
 
-       # Patch PHP to show Gentoo as the server platform
-       sed -e "s/PHP_UNAME=\`uname -a | xargs\`/PHP_UNAME=\`uname -s -n -r -v | xargs\`/g" -i configure.in || die "Failed to fix server platform name"
+       # multilib-strict support
+       if [[ -n "${MULTILIB_PATCH}" ]] && [[ -f "${WORKDIR}/${MULTILIB_PATCH}" ]] ; then
+               epatch "${WORKDIR}/${MULTILIB_PATCH}"
+       else
+               ewarn "There is no multilib-strict patch available for this PHP release yet!"
+       fi
 
-       # Patch PHP to support heimdal instead of mit-krb5
-       if has_version "app-crypt/heimdal" ; then
-               sed -e "s|gssapi_krb5|gssapi|g" -i acinclude.m4 || die "Failed to fix heimdal libname"
-               sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 || die "Failed to fix heimdal crypt lib"
+       # Apply general PHP5 patches
+       if [[ -d "${WORKDIR}/${MY_PHP_PV}/php5" ]] ; then
+               EPATCH_SOURCE="${WORKDIR}/${MY_PHP_PV}/php5" EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch
        fi
 
-       # Patch for PostgreSQL support
-       if use postgres ; then
-               sed -e 's|include/postgresql|include/postgresql include/postgresql/pgsql|g' -i ext/pgsql/config.m4 || die "Failed to fix PostgreSQL include paths"
+       # Apply version-specific PHP patches
+       if [[ -d "${WORKDIR}/${MY_PHP_PV}/${MY_PHP_PV}" ]] ; then
+               EPATCH_SOURCE="${WORKDIR}/${MY_PHP_PV}/${MY_PHP_PV}" EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch
        fi
 
+       # Patch PHP to show Gentoo as the server platform
+       sed -e "s/PHP_UNAME=\`uname -a | xargs\`/PHP_UNAME=\`uname -s -n -r -v | xargs\`/g" -i configure.in || die "Failed to fix server platform name"
+
        # Disable interactive make test
        sed -e 's/'`echo "\!getenv('NO_INTERACTION')"`'/false/g' -i run-tests.php
 
-       # Patch for session persistence bug
-       epatch "${FILESDIR}/5.0-any/php5-soap_persistence_session.diff"
-
-       # stop php from activating the apache config, as we will do that ourselves
+       # Stop PHP from activating the Apache config, as we will do that ourselves
        for i in configure sapi/apache/config.m4 sapi/apache2filter/config.m4 sapi/apache2handler/config.m4 ; do
                sed -i.orig -e 's,-i -a -n php5,-i -n php5,g' ${i}
                sed -i.orig -e 's,-i -A -n php5,-i -n php5,g' ${i}
        done
 
-       # imap support
-       use imap && epatch "${FILESDIR}/5.0-any/php5-imap-symlink.diff"
+       # Patch PHP to support heimdal instead of mit-krb5
+       if has_version "app-crypt/heimdal" ; then
+               sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 || die "Failed to fix heimdal libname"
+               sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 || die "Failed to fix heimdal crypt library reference"
+       fi
 
-       # iodbc support
-       use iodbc && epatch "${FILESDIR}/5.0-any/php5-iodbc-config.diff"
-       use iodbc && epatch "${FILESDIR}/5.0-any/php5-with-iodbc.diff"
+       # Patch for PostgreSQL support
+       if useq postgres ; then
+               sed -e 's|include/postgresql|include/postgresql include/postgresql/pgsql|g' -i ext/pgsql/config.m4 || die "Failed to fix PostgreSQL include paths"
+       fi
 
-       # hardenedphp support
-       if use hardenedphp ; then
-               if [ -n "${HARDENEDPHP_PATCH}" ] ; then
+       # Hardened-PHP support 
+       if useq hardenedphp ; then
+               if [[ -n "${HARDENEDPHP_PATCH}" ]] && [[ -f "${DISTDIR}/${HARDENEDPHP_PATCH}" ]] ; then
                        epatch "${DISTDIR}/${HARDENEDPHP_PATCH}"
                else
-                       ewarn "There is no Hardened-PHP available for this PHP release yet!"
+                       ewarn "There is no Hardened-PHP patch available for this PHP release yet!"
                fi
        fi
 
-       # fix problems compiling with apache2
-       if useq apache2 && ! useq threads ; then
-               epatch "${FILESDIR}/5.0-any/php5-prefork.patch"
-       fi
-
-       # fix configure scripts to correctly support HardenedPHP
-       # and patch PHP to support libtool 1.5
-       epatch "${FILESDIR}/5.0-any/php5-libtool-1.5.patch"
+       # Fix configure scripts to correctly support Hardened-PHP
        einfo "Running aclocal"
        WANT_AUTOMAKE=1.9 aclocal --force || die "Unable to run aclocal successfully"
        einfo "Running libtoolize"
        libtoolize --copy --force || die "Unable to run libtoolize successfully"
 
-       # rebuild configure to make sure it's up to date
+       # Rebuild configure to make sure it's up to date
        einfo "Rebuilding configure script"
        WANT_AUTOCONF=2.5 autoreconf --force -W no-cross || die "Unable to regenerate configure script successfully"
 
-       # run elibtoolize
+       # Run elibtoolize
        elibtoolize
 
        # Just in case ;-)
-       chmod 755 configure || die "Failed to chmod configure to 755"
-}
-
-set_php_ini_dir() {
-       PHP_INI_DIR="/etc/php/${PHPSAPI}-php5"
-       PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
-       PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
+       chmod 0755 configure || die "Failed to chmod configure to 0755"
 }
 
 php5_0-sapi_src_compile() {
        destdir=/usr/$(get_libdir)/php5
-       set_php_ini_dir
+       php5_0-sapi_set_php_ini_dir
 
        cd "${S}"
        confutils_init
 
        my_conf="${my_conf} --with-config-file-path=${PHP_INI_DIR} --with-config-file-scan-dir=${PHP_EXT_INI_DIR_ACTIVE} --without-pear"
 
-       #                               extension               USE flag                shared support?
+       #                                                       extension               USE flag                shared support?
        enable_extension_enable         "bcmath"                "bcmath"                1
        enable_extension_with           "bz2"                   "bzip2"                 1
        enable_extension_enable         "calendar"              "calendar"              1
@@ -365,7 +392,7 @@ php5_0-sapi_src_compile() {
        enable_extension_with           "oci8"                  "oci8"                  1
        enable_extension_with           "oci8-instant-client"   "oci8-instant-client"   1
        enable_extension_with           "oracle"                "oracle7"               1
-       enable_extension_with           "openssl"               "ssl"                   1
+       enable_extension_with           "openssl"               "ssl"                   0
        enable_extension_with           "openssl-dir"   "ssl"                   0 "/usr"
        enable_extension_with           "ovrimos"               "ovrimos"               1
        enable_extension_enable         "pcntl"                 "pcntl"                 1
@@ -407,7 +434,7 @@ php5_0-sapi_src_compile() {
                enable_extension_with "qdbm"            "qdbm"          1
        fi
 
-       # support for the GD graphics library
+       # Support for the GD graphics library
        if useq gd-external ; then
                enable_extension_with   "freetype-dir"  "truetype"              0 "/usr"
                enable_extension_with   "t1lib"                 "truetype"              0 "/usr"
@@ -435,7 +462,7 @@ php5_0-sapi_src_compile() {
 
        # Interbase support
        if useq firebird || useq interbase ; then
-               my_conf="${my_conf} --with-interbase"
+               my_conf="${my_conf} --with-interbase=/usr"
        fi
 
        # LDAP support
@@ -476,21 +503,21 @@ php5_0-sapi_src_compile() {
        enable_extension_with           "readline"              "readline"              0
        enable_extension_with           "libedit"               "libedit"               1
 
-       # session support
+       # Session support
        if ! useq session ; then
                enable_extension_disable        "session"       "session"               1
        else
                enable_extension_with           "mm"            "sharedmem"             0
        fi
 
-       # sqlite support
+       # Sqlite support
        if ! useq sqlite ; then
                enable_extension_without        "sqlite"                "sqlite"        0
        else
                enable_extension_enable         "sqlite-utf8"   "nls"           0
        fi
 
-       # fix ELF-related problems
+       # Fix ELF-related problems
        if useq pic ; then
                einfo "Enabling PIC support"
                my_conf="${my_conf} --with-pic"
@@ -498,11 +525,11 @@ php5_0-sapi_src_compile() {
 
        # apache2 & threads support
        if useq apache2 && useq threads ; then
-               my_conf="${my_conf} --enable-maintainer-zts --enable-experimental-zts"
+               my_conf="${my_conf} --enable-maintainer-zts"
                ewarn "Enabling ZTS for Apache2 MPM"
        fi
 
-       # catch cflag problems
+       # Catch CFLAGS problems
        php_check_cflags
 
        # multilib support
@@ -510,9 +537,7 @@ php5_0-sapi_src_compile() {
                my_conf="--with-libdir=$(get_libdir) ${my_conf}"
        fi
 
-       # all done
-
-       # we don't use econf, because we need to override all of its settings
+       # We don't use econf, because we need to override all of its settings
        ./configure --prefix=${destdir} --sysconfdir=/etc --cache-file=./config.cache ${my_conf} || die "configure failed"
        emake || die "make failed"
 }
@@ -527,7 +552,7 @@ php5_0-sapi_src_install() {
        useq sharedext && PHP_INSTALLTARGETS="${PHP_INSTALLTARGETS} install-modules"
        make INSTALL_ROOT="${D}" ${PHP_INSTALLTARGETS} || die "install failed"
 
-       # install missing header files
+       # Install missing header files
        if useq nls ; then
                dodir ${destdir}/include/php/ext/mbstring/libmbfl/mbfl
                insinto ${destdir}/include/php/ext/mbstring/libmbfl/mbfl
@@ -536,16 +561,15 @@ php5_0-sapi_src_install() {
                done
        fi
 
-       # get the extension dir
+       # Get the extension dir
        PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
 
-       # don't forget the php.ini file
+       # Don't forget the php.ini file
        local phpinisrc=php.ini-dist
        einfo "Setting extension_dir in php.ini"
        sed -e "s|^extension_dir .*$|extension_dir = ${PHPEXTDIR}|g" -i ${phpinisrc}
 
-       # A patch for PHP for security. PHP-CLI interface is exempt, as it cannot be
-       # fed bad data from outside.
+       # A patch for PHP for security
        einfo "Securing fopen wrappers"
        sed -e 's|^allow_url_fopen .*|allow_url_fopen = Off|g' -i ${phpinisrc}
 
@@ -553,39 +577,10 @@ php5_0-sapi_src_install() {
        einfo "Setting correct include_path"
        sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:/usr/share/php5:/usr/share/php"|' -i ${phpinisrc}
 
-       # create the directory where we'll put php5-only php scripts
+       # Create the directory where we'll put php5-only php scripts
        keepdir /usr/share/php5
 }
 
-php5_0-sapi_install_ini() {
-       destdir=/usr/$(get_libdir)/php5
-
-       # get the extension dir
-       PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
-
-       # work out where we are installing the ini file
-       set_php_ini_dir
-
-       local phpinisrc=php.ini-dist
-
-       dodir ${PHP_INI_DIR}
-       insinto ${PHP_INI_DIR}
-       newins ${phpinisrc} ${PHP_INI_FILE}
-
-       dodir ${PHP_EXT_INI_DIR}
-       dodir ${PHP_EXT_INI_DIR_ACTIVE}
-
-       # Install any extensions built as shared objects
-       if useq sharedext ; then
-               for x in `ls "${D}/${PHPEXTDIR}/"*.so | sort` ; do
-                       inifilename=${x/.so/.ini}
-                       inifilename=`basename ${inifilename}`
-                       echo "extension=`basename ${x}`" >> "${D}/${PHP_EXT_INI_DIR}/${inifilename}"
-                       dosym "${PHP_EXT_INI_DIR}/${inifilename}" "${PHP_EXT_INI_DIR_ACTIVE}/${inifilename}"
-               done
-       fi
-}
-
 php5_0-sapi_pkg_postinst() {
        # Update Apache1 to use mod_php
        if useq apache ; then
index ae0c958c1e4b900aadb1149ef602fc6de2e32499..87836285e73046dea6dad7df9075843724e832e6 100644 (file)
@@ -1,6 +1,6 @@
-# Copyright 1999-2005 Gentoo Foundation
+# Copyright 1999-2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/php5_1-sapi.eclass,v 1.16 2006/01/28 15:49:28 chtekk Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/php5_1-sapi.eclass,v 1.17 2006/03/12 13:24:36 chtekk Exp $
 #
 # ########################################################################
 #
@@ -32,26 +32,20 @@ inherit flag-o-matic eutils confutils libtool php-common-r1
 # copies of php which are compiled into other packages (e.g. php support
 # for the thttpd web server) don't need these variables
 
-if [ "${PHP_PACKAGE}" = 1 ]; then
+if [[ "${PHP_PACKAGE}" == 1 ]] ; then
        HOMEPAGE="http://www.php.net/"
        LICENSE="PHP-3"
        SRC_URI="http://www.php.net/distributions/${MY_PHP_P}.tar.bz2"
        S="${WORKDIR}/${MY_PHP_P}"
 fi
 
-IUSE="${IUSE} adabas bcmath berkdb birdstep bzip2 calendar cdb cjk crypt ctype curl curlwrappers db2 dba dbase dbmaker debug doc empress empress-bcs esoob exif fastbuild frontbase fdftk filepro firebird flatfile ftp gd gd-external gdbm gmp hardenedphp hyperwave-api iconv imap informix inifile interbase iodbc ipv6 java-external kerberos ldap libedit mcve memlimit mhash ming msql mssql mysql mysqli ncurses nls oci8 oci8-instant-client odbc pcntl pcre pdo pdo-external pic posix postgres qdbm readline recode sapdb sasl session sharedext sharedmem simplexml snmp soap sockets solid spell spl sqlite ssl sybase sybase-ct sysvipc threads tidy tokenizer truetype vm-goto vm-switch wddx xml xmlreader xmlrpc xpm xsl yaz zip zlib"
+IUSE="${IUSE} adabas bcmath berkdb birdstep bzip2 calendar cdb cjk crypt ctype curl curlwrappers db2 dba dbase dbmaker debug doc empress empress-bcs esoob exif fastbuild frontbase fdftk filepro firebird flatfile ftp gd gd-external gdbm gmp hardenedphp hash hyperwave-api iconv imap informix inifile interbase iodbc ipv6 java-external kerberos ldap libedit mcve memlimit mhash ming msql mssql mysql mysqli ncurses nls oci8 oci8-instant-client odbc pcntl pcre pdo pdo-external pic posix postgres qdbm readline reflection recode sapdb sasl session sharedext sharedmem simplexml snmp soap sockets solid spell spl sqlite ssl sybase sybase-ct sysvipc threads tidy tokenizer truetype vm-goto vm-switch wddx xml xmlreader xmlwriter xmlrpc xpm xsl yaz zip zlib"
 
 # these USE flags should have the correct dependencies
 DEPEND="${DEPEND}
        !dev-php/php
        !dev-php/php-cgi
        !dev-php/mod_php
-       >=sys-devel/m4-1.4.3
-       >=sys-devel/libtool-1.5.18
-       >=sys-devel/automake-1.9.6
-       sys-devel/automake-wrapper
-       >=sys-devel/autoconf-2.59
-       sys-devel/autoconf-wrapper
        berkdb? ( =sys-libs/db-4* )
        bzip2? ( app-arch/bzip2 )
        cdb? ( dev-db/cdb )
@@ -94,6 +88,7 @@ DEPEND="${DEPEND}
        wddx? ( >=dev-libs/libxml2-2.6.8 )
        xml? ( >=dev-libs/libxml2-2.6.8 )
        xmlreader? ( >=dev-libs/libxml2-2.6.8 )
+       xmlwriter? ( >=dev-libs/libxml2-2.6.8 )
        xmlrpc? ( >=dev-libs/libxml2-2.6.8 )
        xpm? ( || ( x11-libs/libXpm virtual/x11 ) )
        xsl? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 )
@@ -107,6 +102,15 @@ DEPEND="${DEPEND} !media-libs/libswf"
 # simplistic for now
 RDEPEND="${RDEPEND} ${DEPEND}"
 
+# those are only needed at compile-time
+DEPEND="${DEPEND}
+               >=sys-devel/m4-1.4.3
+               >=sys-devel/libtool-1.5.18
+               >=sys-devel/automake-1.9.6
+               sys-devel/automake-wrapper
+               >=sys-devel/autoconf-2.59
+               sys-devel/autoconf-wrapper"
+
 # Additional features
 #
 # They are in PDEPEND because we need PHP installed first!
@@ -124,12 +128,6 @@ PDEPEND="${PDEPEND}
 
 PHP_INI_FILE="php.ini"
 
-# ========================================================================
-# Hardened-PHP Support
-# ========================================================================
-
-[ -n "${HARDENEDPHP_PATCH}" ] && SRC_URI="${SRC_URI} hardenedphp? ( http://gentoo.longitekk.com/${HARDENEDPHP_PATCH} )"
-
 # ========================================================================
 
 EXPORT_FUNCTIONS pkg_setup src_compile src_install src_unpack pkg_postinst
@@ -175,8 +173,10 @@ php5_1-sapi_check_awkward_uses() {
        confutils_use_depend_all "soap" "xml"
        confutils_use_depend_all "simplexml"    "xml"
        confutils_use_depend_all "xsl"  "xml"
+       confutils_use_depend_all "xmlrpc"       "xml"
        confutils_use_depend_all "wddx" "xml"
        confutils_use_depend_all "xmlreader"    "xml"
+       confutils_use_depend_all "xmlwriter"    "xml"
 
        # IMAP support
        php_check_imap
@@ -220,7 +220,7 @@ php5_1-sapi_check_awkward_uses() {
        confutils_use_conflict "readline" "libedit"
 
        # Recode is not liked
-       confutils_use_conflict "recode" "mysql" "imap" "nis"
+       confutils_use_conflict "recode" "mysql" "imap" "yaz"
 
        # the MM extension isn't thread-safe
        confutils_use_conflict "sharedmem" "threads"
@@ -231,6 +231,41 @@ php5_1-sapi_check_awkward_uses() {
        confutils_warn_about_missing_deps
 }
 
+php5_1-sapi_set_php_ini_dir() {
+       PHP_INI_DIR="/etc/php/${PHPSAPI}-php5"
+       PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
+       PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
+}
+
+php5_1-sapi_install_ini() {
+       destdir=/usr/$(get_libdir)/php5
+
+       # get the extension dir
+       PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
+
+       # work out where we are installing the ini file
+       php5_1-sapi_set_php_ini_dir
+
+       local phpinisrc=php.ini-dist
+
+       dodir ${PHP_INI_DIR}
+       insinto ${PHP_INI_DIR}
+       newins ${phpinisrc} ${PHP_INI_FILE}
+
+       dodir ${PHP_EXT_INI_DIR}
+       dodir ${PHP_EXT_INI_DIR_ACTIVE}
+
+       # Install any extensions built as shared objects
+       if useq sharedext ; then
+               for x in `ls "${D}/${PHPEXTDIR}/"*.so | sort` ; do
+                       inifilename=${x/.so/.ini}
+                       inifilename=`basename ${inifilename}`
+                       echo "extension=`basename ${x}`" >> "${D}/${PHP_EXT_INI_DIR}/${inifilename}"
+                       dosym "${PHP_EXT_INI_DIR}/${inifilename}" "${PHP_EXT_INI_DIR_ACTIVE}/${inifilename}"
+               done
+       fi
+}
+
 # ========================================================================
 # EXPORTED FUNCTIONS
 # ========================================================================
@@ -238,107 +273,109 @@ php5_1-sapi_check_awkward_uses() {
 php5_1-sapi_pkg_setup() {
        # let's do all the USE flag testing before we do anything else
        # this way saves a lot of time
-
        php5_1-sapi_check_awkward_uses
 }
 
 php5_1-sapi_src_unpack() {
-       if [ "${PHP_PACKAGE}" == 1 ] ; then
+       if [[ "${PHP_PACKAGE}" == 1 ]] ; then
                unpack ${A}
        fi
 
        cd "${S}"
 
-       # lib64 support
-       if [ -n "${LIB64_PATCH}" ] ; then
-               epatch "${WORKDIR}/${LIB64_PATCH}"
+       # Change PHP branding
+       PHPPR=${PR/r/}
+       if [[ "${PHPPR}" != "0" ]] ; then
+               sed -e "s|^EXTRA_VERSION=\"\"|EXTRA_VERSION=\"-pl${PHPPR}-gentoo\"|g" -i configure.in || die "Unable to change PHP branding to -pl${PHPPR}-gentoo"
        else
-               ewarn "There is no lib64 patch available for this PHP release yet!"
+               sed -e "s|^EXTRA_VERSION=\"\"|EXTRA_VERSION=\"-gentoo\"|g" -i configure.in || die "Unable to change PHP branding to -gentoo"
        fi
 
-       # Patch PHP to show Gentoo as the server platform
-       sed -e "s/PHP_UNAME=\`uname -a | xargs\`/PHP_UNAME=\`uname -s -n -r -v | xargs\`/g" -i configure.in || die "Failed to fix server platform name"
-
-       # Patch PHP to support heimdal instead of mit-krb5
-       if has_version "app-crypt/heimdal" ; then
-               sed -e "s|gssapi_krb5|gssapi|g" -i acinclude.m4 || die "Failed to fix heimdal libname"
-               sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 || die "Failed to fix heimdal crypt lib"
+       # multilib-strict support
+       if [[ -n "${MULTILIB_PATCH}" ]] && [[ -f "${WORKDIR}/${MULTILIB_PATCH}" ]] ; then
+               epatch "${WORKDIR}/${MULTILIB_PATCH}"
+       else
+               ewarn "There is no multilib-strict patch available for this PHP release yet!"
+       fi
+       
+       # Apply general PHP5 patches
+       if [[ -d "${WORKDIR}/${MY_PHP_PV}/php5" ]] ; then
+               EPATCH_SOURCE="${WORKDIR}/${MY_PHP_PV}/php5" EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch
        fi
 
-       # Patch for PostgreSQL support
-       if use postgres ; then
-               sed -e 's|include/postgresql|include/postgresql include/postgresql/pgsql|g' -i ext/pgsql/config.m4 || die "Failed to fix PostgreSQL include paths"
+       # Apply version-specific PHP patches
+       if [[ -d "${WORKDIR}/${MY_PHP_PV}/${MY_PHP_PV}" ]] ; then
+               EPATCH_SOURCE="${WORKDIR}/${MY_PHP_PV}/${MY_PHP_PV}" EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch
        fi
 
+       # Patch PHP to show Gentoo as the server platform
+       sed -e "s/PHP_UNAME=\`uname -a | xargs\`/PHP_UNAME=\`uname -s -n -r -v | xargs\`/g" -i configure.in || die "Failed to fix server platform name"
+
        # Disable interactive make test
        sed -e 's/'`echo "\!getenv('NO_INTERACTION')"`'/false/g' -i run-tests.php
 
-       # Patch for session persistence bug
-       epatch "${FILESDIR}/5.1-any/php5-soap_persistence_session.diff"
-
-       # stop php from activating the apache config, as we will do that ourselves
+       # Stop php from activating the Apache config, as we will do that ourselves
        for i in configure sapi/apache/config.m4 sapi/apache2filter/config.m4 sapi/apache2handler/config.m4 ; do
                sed -i.orig -e 's,-i -a -n php5,-i -n php5,g' ${i}
                sed -i.orig -e 's,-i -A -n php5,-i -n php5,g' ${i}
        done
 
-       # imap support
-       use imap && epatch "${FILESDIR}/5.1-any/php5-imap-symlink.diff"
+       # Patch PHP to support heimdal instead of mit-krb5
+       if has_version "app-crypt/heimdal" ; then
+               sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 || die "Failed to fix heimdal libname"
+               sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 || die "Failed to fix heimdal crypt library reference"
+       fi
 
-       # iodbc support
-       use iodbc && epatch "${FILESDIR}/5.1-any/php5-iodbc-config.diff"
-       use iodbc && epatch "${FILESDIR}/5.1-any/php5-with-iodbc.diff"
+       # Patch for PostgreSQL support
+       if useq postgres ; then
+               sed -e 's|include/postgresql|include/postgresql include/postgresql/pgsql|g' -i ext/pgsql/config.m4 || die "Failed to fix PostgreSQL include paths"
+       fi
 
-       # hardenedphp support
-       if use hardenedphp ; then
-               if [ -n "${HARDENEDPHP_PATCH}" ] ; then
+       # Hardened-PHP support 
+       if useq hardenedphp ; then
+               if [[ -n "${HARDENEDPHP_PATCH}" ]] && [[ -f "${DISTDIR}/${HARDENEDPHP_PATCH}" ]] ; then
                        epatch "${DISTDIR}/${HARDENEDPHP_PATCH}"
                else
-                       ewarn "There is no Hardened-PHP available for this PHP release yet!"
+                       ewarn "There is no Hardened-PHP patch available for this PHP release yet!"
                fi
        fi
 
        # fastbuild support
-       use fastbuild && epatch "${FILESDIR}/5.1-any/php5-fastbuild.patch"
-
-       # fix problems compiling with apache2
-       if useq apache2 && ! useq threads ; then
-               epatch "${FILESDIR}/5.1-any/php5-prefork.patch"
+       if useq fastbuild ; then
+               if [[ -n "${FASTBUILD_PATCH}" ]] && [[ -f "${WORKDIR}/${FASTBUILD_PATCH}" ]] ; then
+                       epatch "${WORKDIR}/${FASTBUILD_PATCH}"
+               else
+                       ewarn "There is no fastbuild patch available for this PHP release yet!"
+               fi
        fi
 
-       # fix configure scripts to correctly support HardenedPHP
+       # Fix configure scripts to correctly support Hardened-PHP
        einfo "Running aclocal"
        WANT_AUTOMAKE=1.9 aclocal --force || die "Unable to run aclocal successfully"
        einfo "Running libtoolize"
        libtoolize --copy --force || die "Unable to run libtoolize successfully"
 
-       # rebuild configure to make sure it's up to date
+       # Rebuild configure to make sure it's up to date
        einfo "Rebuilding configure script"
        WANT_AUTOCONF=2.5 autoreconf --force -W no-cross || die "Unable to regenerate configure script successfully"
 
-       # run elibtoolize
+       # Run elibtoolize
        elibtoolize
 
        # Just in case ;-)
-       chmod 755 configure || die "Failed to chmod configure to 755"
-}
-
-set_php_ini_dir() {
-       PHP_INI_DIR="/etc/php/${PHPSAPI}-php5"
-       PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext"
-       PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active"
+       chmod 0755 configure || die "Failed to chmod configure to 0755"
 }
 
 php5_1-sapi_src_compile() {
        destdir=/usr/$(get_libdir)/php5
-       set_php_ini_dir
+       php5_1-sapi_set_php_ini_dir
 
        cd "${S}"
        confutils_init
 
        my_conf="${my_conf} --with-config-file-path=${PHP_INI_DIR} --with-config-file-scan-dir=${PHP_EXT_INI_DIR_ACTIVE} --without-pear"
 
-       #                               extension               USE flag                shared support?
+       #                                                       extension               USE flag                shared support?
        enable_extension_enable         "bcmath"                "bcmath"                1
        enable_extension_with           "bz2"                   "bzip2"                 1
        enable_extension_enable         "calendar"              "calendar"              1
@@ -354,6 +391,7 @@ php5_1-sapi_src_compile() {
        enable_extension_enable         "ftp"                   "ftp"                   1
        enable_extension_with           "gettext"               "nls"                   1
        enable_extension_with           "gmp"                   "gmp"                   1
+       enable_extension_disable        "hash"                  "hash"                  0
        enable_extension_with           "hwapi"                 "hyperwave-api" 1
        enable_extension_without        "iconv"                 "iconv"                 0
        enable_extension_with           "informix"              "informix"              1
@@ -370,8 +408,12 @@ php5_1-sapi_src_compile() {
        enable_extension_with           "mssql"                 "mssql"                 1
        enable_extension_with           "ncurses"               "ncurses"               1
        enable_extension_with           "oci8"                  "oci8"                  1
-       enable_extension_with           "oci8-instant-client"   "oci8-instant-client"   1
-       enable_extension_with           "openssl"               "ssl"                   1
+       if useq oci8-instant-client ; then
+               OCI8IC_PKG="`best_version dev-db/oracle-instantclient-basic`"
+               OCI8IC_PKG="`printf ${OCI8IC_PKG} | sed -e 's|dev-db/oracle-instantclient-basic-||g' | sed -e 's|-r.*||g'`"
+       fi
+       enable_extension_with           "oci8"                  "oci8-instant-client"   1       "instantclient,/usr/lib/oracle/${OCI8IC_PKG}/client/lib"
+       enable_extension_with           "openssl"               "ssl"                   0
        enable_extension_with           "openssl-dir"   "ssl"                   0 "/usr"
        enable_extension_enable         "pcntl"                 "pcntl"                 1
        enable_extension_without        "pcre-regex"    "pcre"                  0
@@ -380,6 +422,7 @@ php5_1-sapi_src_compile() {
        enable_extension_disable        "posix"                 "posix"                 1
        enable_extension_with           "pspell"                "spell"                 1
        enable_extension_with           "recode"                "recode"                1
+       enable_extension_disable        "reflection"    "reflection"    0
        enable_extension_disable        "simplexml"             "simplexml"             1
        enable_extension_enable         "shmop"                 "sharedmem"             0
        enable_extension_with           "snmp"                  "snmp"                  1
@@ -395,7 +438,8 @@ php5_1-sapi_src_compile() {
        enable_extension_disable        "tokenizer"             "tokenizer"             1
        enable_extension_enable         "wddx"                  "wddx"                  1
        enable_extension_disable        "xml"                   "xml"                   0
-       enable_extension_with           "xmlreader"             "xmlreader"             1
+       enable_extension_disable        "xmlreader"             "xmlreader"             1
+       enable_extension_disable        "xmlwriter"             "xmlwriter"             1
        enable_extension_with           "xmlrpc"                "xmlrpc"                1
        enable_extension_with           "xsl"                   "xsl"                   1
        enable_extension_with           "zlib"                  "zlib"                  1
@@ -413,7 +457,7 @@ php5_1-sapi_src_compile() {
                enable_extension_with "qdbm"            "qdbm"          1
        fi
 
-       # support for the GD graphics library
+       # Support for the GD graphics library
        if useq gd-external ; then
                enable_extension_with   "freetype-dir"  "truetype"              0 "/usr"
                enable_extension_with   "t1lib"                 "truetype"              0 "/usr"
@@ -440,7 +484,7 @@ php5_1-sapi_src_compile() {
 
        # Interbase support
        if useq firebird || useq interbase ; then
-               my_conf="${my_conf} --with-interbase"
+               my_conf="${my_conf} --with-interbase=/usr"
        fi
 
        # LDAP support
@@ -497,14 +541,14 @@ php5_1-sapi_src_compile() {
        enable_extension_with           "readline"              "readline"              0
        enable_extension_with           "libedit"               "libedit"               1
 
-       # session support
+       # Session support
        if ! useq session ; then
                enable_extension_disable        "session"       "session"               1
        else
                enable_extension_with           "mm"            "sharedmem"             0
        fi
 
-       # sqlite support
+       # Sqlite support
        if ! useq sqlite ; then
                enable_extension_without        "sqlite"                "sqlite"        0
        else
@@ -521,7 +565,7 @@ php5_1-sapi_src_compile() {
                my_conf="${my_conf} --with-zend-vm=SWITCH"
        fi
 
-       # fix ELF-related problems
+       # Fix ELF-related problems
        if useq pic ; then
                einfo "Enabling PIC support"
                my_conf="${my_conf} --with-pic"
@@ -529,11 +573,11 @@ php5_1-sapi_src_compile() {
 
        # apache2 & threads support
        if useq apache2 && useq threads ; then
-               my_conf="${my_conf} --enable-maintainer-zts --enable-experimental-zts"
+               my_conf="${my_conf} --enable-maintainer-zts"
                ewarn "Enabling ZTS for Apache2 MPM"
        fi
 
-       # catch cflag problems
+       # Catch CFLAGS problems
        php_check_cflags
 
        # multilib support
@@ -541,9 +585,7 @@ php5_1-sapi_src_compile() {
                my_conf="--with-libdir=$(get_libdir) ${my_conf}"
        fi
 
-       # all done
-
-       # we don't use econf, because we need to override all of its settings
+       # We don't use econf, because we need to override all of its settings
        ./configure --prefix=${destdir} --sysconfdir=/etc --cache-file=./config.cache ${my_conf} || die "configure failed"
        emake || die "make failed"
 }
@@ -558,7 +600,7 @@ php5_1-sapi_src_install() {
        useq sharedext && PHP_INSTALLTARGETS="${PHP_INSTALLTARGETS} install-modules"
        make INSTALL_ROOT="${D}" ${PHP_INSTALLTARGETS} || die "install failed"
 
-       # install missing header files
+       # Install missing header files
        if useq nls ; then
                dodir ${destdir}/include/php/ext/mbstring/libmbfl/mbfl
                insinto ${destdir}/include/php/ext/mbstring/libmbfl/mbfl
@@ -567,16 +609,15 @@ php5_1-sapi_src_install() {
                done
        fi
 
-       # get the extension dir
+       # Get the extension dir
        PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
 
-       # don't forget the php.ini file
+       # Don't forget the php.ini file
        local phpinisrc=php.ini-dist
        einfo "Setting extension_dir in php.ini"
        sed -e "s|^extension_dir .*$|extension_dir = ${PHPEXTDIR}|g" -i ${phpinisrc}
 
-       # A patch for PHP for security. PHP-CLI interface is exempt, as it cannot be
-       # fed bad data from outside.
+       # A patch for PHP for security
        einfo "Securing fopen wrappers"
        sed -e 's|^allow_url_fopen .*|allow_url_fopen = Off|g' -i ${phpinisrc}
 
@@ -584,39 +625,10 @@ php5_1-sapi_src_install() {
        einfo "Setting correct include_path"
        sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:/usr/share/php5:/usr/share/php"|' -i ${phpinisrc}
 
-       # create the directory where we'll put php5-only php scripts
+       # Create the directory where we'll put php5-only php scripts
        keepdir /usr/share/php5
 }
 
-php5_1-sapi_install_ini() {
-       destdir=/usr/$(get_libdir)/php5
-
-       # get the extension dir
-       PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`"
-
-       # work out where we are installing the ini file
-       set_php_ini_dir
-
-       local phpinisrc=php.ini-dist
-
-       dodir ${PHP_INI_DIR}
-       insinto ${PHP_INI_DIR}
-       newins ${phpinisrc} ${PHP_INI_FILE}
-
-       dodir ${PHP_EXT_INI_DIR}
-       dodir ${PHP_EXT_INI_DIR_ACTIVE}
-
-       # Install any extensions built as shared objects
-       if useq sharedext ; then
-               for x in `ls "${D}/${PHPEXTDIR}/"*.so | sort` ; do
-                       inifilename=${x/.so/.ini}
-                       inifilename=`basename ${inifilename}`
-                       echo "extension=`basename ${x}`" >> "${D}/${PHP_EXT_INI_DIR}/${inifilename}"
-                       dosym "${PHP_EXT_INI_DIR}/${inifilename}" "${PHP_EXT_INI_DIR_ACTIVE}/${inifilename}"
-               done
-       fi
-}
-
 php5_1-sapi_pkg_postinst() {
        # Update Apache1 to use mod_php
        if useq apache ; then