diff options
author | Gunnar Wrobel <wrobel@gentoo.org> | 2008-02-26 08:35:31 +0000 |
---|---|---|
committer | Gunnar Wrobel <wrobel@gentoo.org> | 2008-02-26 08:35:31 +0000 |
commit | 4353bbcafb0814078e3883ed81a6d08147877f06 (patch) | |
tree | 51e6a152eeaa1e0096f3320c33b0fb1bc70419da /eclass | |
parent | Require the patched php version. (diff) | |
download | kolab-4353bbcafb0814078e3883ed81a6d08147877f06.tar.gz kolab-4353bbcafb0814078e3883ed81a6d08147877f06.tar.bz2 kolab-4353bbcafb0814078e3883ed81a6d08147877f06.zip |
The move into portage seems to take longer than anticipated. Move Jakubs ebuilds from php-experimental here for the time being.
svn path=/overlay/; revision=2814
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/php-common-r1.eclass | 290 | ||||
-rw-r--r-- | eclass/php-pear-lib-r1.eclass | 94 | ||||
-rw-r--r-- | eclass/php-pear-r1.eclass | 105 | ||||
-rw-r--r-- | eclass/php5_2-sapi-r1.eclass | 713 | ||||
-rw-r--r-- | eclass/php5_2-sapi.eclass | 731 |
5 files changed, 1933 insertions, 0 deletions
diff --git a/eclass/php-common-r1.eclass b/eclass/php-common-r1.eclass new file mode 100644 index 0000000..1f8cce7 --- /dev/null +++ b/eclass/php-common-r1.eclass @@ -0,0 +1,290 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/php-common-r1.eclass,v 1.12 2007/11/29 23:11:04 jokey Exp $ + +# Based on robbat2's work on the php4 sapi eclass +# Based on stuart's work on the php5 sapi eclass + +# @ECLASS: php-common-r1.eclass +# @MAINTAINER: +# Gentoo PHP team <php-bugs@gentoo.org> +# @BLURB: Common functions which are shared between the PHP4 and PHP5 packages. +# @DESCRIPTION: +# This eclass provides common functions which are shared between the PHP4 and PHP5 packages. +# It is only used by php*-sapi eclasses currently and the functions are not intended +# for direct use in ebuilds. + + +# ======================================================================== +# CFLAG SANITY +# ======================================================================== + +php_check_cflags() { + # Filter the following from C[XX]FLAGS regardless, as apache won't be + # supporting LFS until 2.2 is released and in the tree. Fixes bug #24373. + filter-flags "-D_FILE_OFFSET_BITS=64" + filter-flags "-D_FILE_OFFSET_BITS=32" + filter-flags "-D_LARGEFILE_SOURCE=1" + filter-flags "-D_LARGEFILE_SOURCE" + + # Fixes bug #14067. + # Changed order to run it in reverse for bug #32022 and #12021. + replace-flags "-march=k6-3" "-march=i586" + replace-flags "-march=k6-2" "-march=i586" + replace-flags "-march=k6" "-march=i586" +} + +# ======================================================================== +# IMAP SUPPORT +# ======================================================================== + +php_check_imap() { + if ! use "imap" && ! phpconfutils_usecheck "imap" ; then + return + fi + + if use "ssl" || phpconfutils_usecheck "ssl" ; then + if ! built_with_use virtual/imap-c-client ssl ; then + eerror + eerror "IMAP with SSL requested, but your IMAP C-Client libraries are built without SSL!" + eerror + die "Please recompile the IMAP C-Client libraries with SSL support enabled" + fi + else + if built_with_use virtual/imap-c-client ssl ; then + eerror + eerror "IMAP without SSL requested, but your IMAP C-Client libraries are built with SSL!" + eerror + die "Please recompile the IMAP C-Client libraries with SSL support disabled" + fi + fi + + if use "kolab" || phpconfutils_usecheck "kolab" ; then + if ! built_with_use net-libs/c-client kolab ; then + eerror + eerror "IMAP with annotations support requested, but net-libs/c-client is built without it!" + eerror + die "Please recompile net-libs/c-client with USE=kolab." + fi + fi +} + +# ======================================================================== +# JAVA EXTENSION SUPPORT +# +# The bundled java extension is unique to PHP4, but there is +# now the PHP-Java-Bridge that works under both PHP4 and PHP5. +# ======================================================================== + +php_check_java() { + if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then + return + fi + + JDKHOME="$(java-config --jdk-home)" + NOJDKERROR="You need to use the 'java-config' utility to set your JVM to a JDK!" + if [[ -z "${JDKHOME}" ]] || [[ ! -d "${JDKHOME}" ]] ; then + eerror "${NOJDKERROR}" + die "${NOJDKERROR}" + fi + + # stuart@gentoo.org - 2003/05/18 + # Kaffe JVM is not a drop-in replacement for the Sun JDK at this time + if echo ${JDKHOME} | grep kaffe > /dev/null 2>&1 ; then + eerror + eerror "PHP will not build using the Kaffe Java Virtual Machine." + eerror "Please change your JVM to either Blackdown or Sun's." + eerror + eerror "To build PHP without Java support, please re-run this emerge" + eerror "and place the line:" + eerror " USE='-java-internal'" + eerror "in front of your emerge command, for example:" + eerror " USE='-java-internal' emerge =dev-lang/php-4*" + eerror + eerror "or edit your USE flags in /etc/make.conf." + die "Kaffe JVM not supported" + fi + + JDKVER=$(java-config --java-version 2>&1 | awk '/^java version/ { print $3 }' | xargs ) + einfo "Active JDK version: ${JDKVER}" + case "${JDKVER}" in + 1.4.*) ;; + 1.5.*) ewarn "Java 1.5 is NOT supported at this time, and might not work." ;; + *) eerror "A Java 1.4 JDK is recommended for Java support in PHP." ; die ;; + esac +} + +php_install_java() { + if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then + return + fi + + # We put these into /usr/lib so that they cannot conflict with + # other versions of PHP (e.g. PHP 4 & PHP 5) + insinto "${PHPEXTDIR}" + + einfo "Installing PHP java extension" + doins "modules/java.so" + + einfo "Creating PHP java extension symlink" + dosym "${PHPEXTDIR}/java.so" "${PHPEXTDIR}/libphp_java.so" + + einfo "Installing JAR for PHP" + doins "ext/java/php_java.jar" + + einfo "Installing Java test page" + newins "ext/java/except.php" "java-test.php" +} + +php_install_java_inifile() { + if ! use "java-internal" && ! phpconfutils_usecheck "java-internal" ; then + return + fi + + JAVA_LIBRARY="$(grep -- '-DJAVALIB' Makefile | sed -e 's,.\+-DJAVALIB=\"\([^"]*\)\".*$,\1,g;' | sort -u)" + + echo "extension = java.so" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" + echo "java.library = ${JAVA_LIBRARY}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" + echo "java.class.path = ${PHPEXTDIR}/php_java.jar" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" + echo "java.library.path = ${PHPEXTDIR}" >> "${D}/${PHP_EXT_INI_DIR}/java.ini" + + dosym "${PHP_EXT_INI_DIR}/java.ini" "${PHP_EXT_INI_DIR_ACTIVE}/java.ini" +} + +# ======================================================================== +# MTA SUPPORT +# ======================================================================== + +php_check_mta() { + if ! [[ -x "${ROOT}/usr/sbin/sendmail" ]] ; then + ewarn + ewarn "You need a virtual/mta that provides a sendmail compatible binary!" + ewarn "All major MTAs provide this, and it's usually some symlink created" + ewarn "as '${ROOT}/usr/sbin/sendmail*'. You should also be able to use other" + ewarn "MTAs directly, but you'll have to edit the sendmail_path directive" + ewarn "in your php.ini for this to work." + ewarn + fi +} + +# ======================================================================== +# ORACLE SUPPORT +# ======================================================================== + +php_check_oracle_all() { + if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then + eerror + eerror "You must have the ORACLE_HOME variable set in your environment to" + eerror "compile the Oracle extension." + eerror + die "Oracle configuration incorrect; user error" + fi + + if use "oci8" || use "oracle7" ; then + if has_version 'dev-db/oracle-instantclient-basic' ; then + ewarn + ewarn "Please ensure you have a full install of the Oracle client." + ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." + ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" + ewarn "want to use 'dev-db/oracle-instantclient-basic' as Oracle client." + ewarn + fi + fi +} + +php_check_oracle_8() { + if use "oci8" && [[ -z "${ORACLE_HOME}" ]] ; then + eerror + eerror "You must have the ORACLE_HOME variable set in your environment to" + eerror "compile the Oracle extension." + eerror + die "Oracle configuration incorrect; user error" + fi + + if use "oci8" ; then + if has_version 'dev-db/oracle-instantclient-basic' ; then + ewarn + ewarn "Please ensure you have a full install of the Oracle client." + ewarn "'dev-db/oracle-instantclient-basic' is NOT sufficient." + ewarn "Please enable the 'oci8-instant-client' USE flag instead, if you" + ewarn "want to use 'dev-db/oracle-instantclient-basic' as Oracle client." + ewarn + fi + fi +} + +# ======================================================================== +# POSTGRESQL SUPPORT +# ======================================================================== + +php_check_pgsql() { + if use "postgres" \ + && use "apache2" && use "threads" \ + && has_version ">=dev-db/libpq-8.1.3-r1" \ + && ! built_with_use ">=dev-db/libpq-8.1.3-r1" "threads" ; then + eerror + eerror "You must build dev-db/libpq with the 'threads' USE flag" + eerror "turned on if you want to build PHP with threads support!" + eerror + die "Rebuild dev-db/libpq with 'threads' USE flag enabled" + fi +} + +# ======================================================================== +# MYSQL CHARSET DETECTION SUPPORT ## Thanks to hoffie +# ======================================================================== + +php_get_mycnf_charset() { + # nothing todo if no mysql installed + if [[ ! -f "${ROOT}/etc/mysql/my.cnf" ]]; then + echo "empty" + return + fi + local sapi="${1}" + local section="" + local client_charset="" + local sapi_charset="" + + # remove comments and pipe the output to our while loop + while read line ; do + line=$(echo "${line}" | sed 's:[;#][^\n]*::g') + + # skip empty lines + if [[ "${line}" == "" ]] ; then + continue + fi + + # capture sections + tmp=$(echo "${line}" | sed 's:\[\([-a-z0-9\_]*\)\]:\1:') + if [[ "${line}" != "${tmp}" ]] ; then + section=${tmp} + else + # we don't need to check lines which are not in a section we are interested about + if [[ "${section}" != "client" && "${section}" != "php-${sapi}" ]] ; then + continue + fi + + # match default-character-set= lines + tmp=$(echo "${line}" | sed 's|^[[:space:]\ ]*default-character-set[[:space:]\ ]*=[[:space:]\ ]*\"\?\([a-z0-9\-]*\)\"\?|\1|') + if [[ "${line}" == "${tmp}" ]] ; then + # nothing changed, irrelevant line + continue + fi + if [[ "${section}" == "client" ]] ; then + client_charset="${tmp}" + else + if [[ "${section}" == "php-${sapi}" ]] ; then + sapi_charset="${tmp}" + fi + fi + fi + done < "${ROOT}/etc/mysql/my.cnf" + # if a sapi-specific section with a default-character-set= value was found we use it, otherwise we use the client charset (which may be empty) + if [[ -n "${sapi_charset}" ]] ; then + echo "${sapi_charset}" + elif [[ -n "${client_charset}" ]] ; then + echo "${client_charset}" + else + echo "empty" + fi +} diff --git a/eclass/php-pear-lib-r1.eclass b/eclass/php-pear-lib-r1.eclass new file mode 100644 index 0000000..20fff57 --- /dev/null +++ b/eclass/php-pear-lib-r1.eclass @@ -0,0 +1,94 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/php-pear-lib-r1.eclass,v 1.12 2007/09/02 17:49:20 jokey Exp $ +# +# Author: Luca Longinotti <chtekk@gentoo.org> + +# @ECLASS: php-pear-lib-r1.eclass +# @MAINTAINER: +# Gentoo PHP team <php-bugs@gentoo.org> +# @BLURB: Provides means for an easy installation of PEAR-based libraries. +# @DESCRIPTION: +# This class provides means for an easy installation of PEAR-based libraries, +# such as Creole, Jargon, Phing etc., while retaining the functionality to put +# the libraries into version-dependant directories. + +inherit depend.php multilib + +EXPORT_FUNCTIONS src_install + +DEPEND="dev-lang/php >=dev-php/PEAR-PEAR-1.6.1" +RDEPEND="${DEPEND}" + +# @FUNCTION: php-pear-lib-r1_src_install +# @DESCRIPTION: +# Takes care of standard install for PEAR-based libraries. +php-pear-lib-r1_src_install() { + has_php + + # SNMP support + addpredict /usr/share/snmp/mibs/.index + addpredict /var/lib/net-snmp/ + addpredict /session_mm_cli0.sem + + case "${CATEGORY}" in + dev-php) + if has_version '=dev-lang/php-5*' ; then + PHP_BIN="/usr/$(get_libdir)/php5/bin/php" + else + PHP_BIN="/usr/$(get_libdir)/php4/bin/php" + fi ;; + dev-php4) PHP_BIN="/usr/$(get_libdir)/php4/bin/php" ;; + dev-php5) PHP_BIN="/usr/$(get_libdir)/php5/bin/php" ;; + *) die "Version of PHP required by packages in category ${CATEGORY} unknown" + esac + + cd "${S}" + + if [[ -f "${WORKDIR}"/package2.xml ]] ; then + mv -f "${WORKDIR}/package2.xml" "${S}" + if has_version '>=dev-php/PEAR-PEAR-1.7.0' ; then + local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs" + pear -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" \ + install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package2.xml" || die "Unable to install PEAR package" + else + pear -d php_bin="${PHP_BIN}" install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package2.xml" || die "Unable to install PEAR package" + fi + else + mv -f "${WORKDIR}/package.xml" "${S}" + if has_version '>=dev-php/PEAR-PEAR-1.7.0' ; then + local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs" + pear -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" \ + install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package.xml" || die "Unable to install PEAR package" + else + pear -d php_bin="${PHP_BIN}" install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package.xml" || die "Unable to install PEAR package" + fi + fi + + rm -Rf "${D}/usr/share/php/.channels" \ + "${D}/usr/share/php/.depdblock" \ + "${D}/usr/share/php/.depdb" \ + "${D}/usr/share/php/.filemap" \ + "${D}/usr/share/php/.lock" \ + "${D}/usr/share/php/.registry" + + # install to the correct phpX folder, if not specified + # /usr/share/php will be kept, also sedding to substitute + # the path, many files can specify it wrongly + if [[ -n "${PHP_SHARED_CAT}" ]] && [[ "${PHP_SHARED_CAT}" != "php" ]] ; then + mv -f "${D}/usr/share/php" "${D}/usr/share/${PHP_SHARED_CAT}" || die "Unable to move files" + find "${D}/" -type f -exec sed -e "s|/usr/share/php|/usr/share/${PHP_SHARED_CAT}|g" -i {} \; \ + || die "Unable to change PHP path" + einfo + einfo "Installing to /usr/share/${PHP_SHARED_CAT} ..." + einfo + else + einfo + einfo "Installing to /usr/share/php ..." + einfo + fi +} diff --git a/eclass/php-pear-r1.eclass b/eclass/php-pear-r1.eclass new file mode 100644 index 0000000..fecaa5b --- /dev/null +++ b/eclass/php-pear-r1.eclass @@ -0,0 +1,105 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/php-pear-r1.eclass,v 1.19 2007/11/08 16:07:22 jokey Exp $ +# +# Author: Tal Peer <coredumb@gentoo.org> +# Author: Luca Longinotti <chtekk@gentoo.org> + +# @ECLASS: php-pear-r1.eclass +# @MAINTAINER: +# Gentoo PHP Team <php-bugs@gentoo.org> +# @BLURB: Provides means for an easy installation of PEAR packages. +# @DESCRIPTION: +# This eclass provides means for an easy installation of PEAR packages. +# For more information on PEAR, see http://pear.php.net/ +# Note that this eclass doesn't handle dependencies of PEAR packages +# on purpose; please use (R)DEPEND to define them correctly! + +inherit multilib + +EXPORT_FUNCTIONS src_install + +DEPEND="dev-lang/php >=dev-php/PEAR-PEAR-1.6.1" +RDEPEND="${DEPEND}" + +# @ECLASS-VARIABLE: PHP_PEAR_PKG_NAME +# @DESCRIPTION: +# Set this if the the PEAR package name differs from ${PN/PEAR-/} +# (generally shouldn't be the case). +[[ -z "${PHP_PEAR_PKG_NAME}" ]] && PHP_PEAR_PKG_NAME="${PN/PEAR-/}" + +fix_PEAR_PV() { + tmp="${PV}" + tmp="${tmp/_/}" + tmp="${tmp/rc/RC}" + tmp="${tmp/beta/b}" + tmp="${tmp/alpha/a}" + PEAR_PV="${tmp}" +} + +# @ECLASS-VARIABLE: PEAR_PV +# @DESCRIPTION: +# Set in ebuild if the eclass ${PV} mangling breaks SRC_URI for alpha/beta/rc versions +[[ -z "${PEAR_PV}" ]] && fix_PEAR_PV + +PEAR_PN="${PHP_PEAR_PKG_NAME}-${PEAR_PV}" + +[[ -z "${SRC_URI}" ]] && SRC_URI="http://pear.php.net/get/${PEAR_PN}.tgz" +[[ -z "${HOMEPAGE}" ]] && HOMEPAGE="http://pear.php.net/${PHP_PEAR_PKG_NAME}" + +S="${WORKDIR}/${PEAR_PN}" + +# @FUNCTION: php-pear-r1_src_install +# @DESCRIPTION: +# Takes care of standard install for PEAR packages. +php-pear-r1_src_install() { + # SNMP support + addpredict /usr/share/snmp/mibs/.index + addpredict /var/lib/net-snmp/ + addpredict /session_mm_cli0.sem + + case "${CATEGORY}" in + dev-php) + if has_version '=dev-lang/php-5*' ; then + PHP_BIN="/usr/$(get_libdir)/php5/bin/php" + else + PHP_BIN="/usr/$(get_libdir)/php4/bin/php" + fi ;; + dev-php4) PHP_BIN="/usr/$(get_libdir)/php4/bin/php" ;; + dev-php5) PHP_BIN="/usr/$(get_libdir)/php5/bin/php" ;; + *) die "Version of PHP required by packages in category ${CATEGORY} unknown" + esac + + cd "${S}" + + if [[ -f "${WORKDIR}"/package2.xml ]] ; then + mv -f "${WORKDIR}/package2.xml" "${S}" + if has_version '>=dev-php/PEAR-PEAR-1.7.0' ; then + local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs" + pear -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" \ + install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package2.xml" || die "Unable to install PEAR package" + else + pear -d php_bin="${PHP_BIN}" install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package2.xml" || die "Unable to install PEAR package" + fi + else + mv -f "${WORKDIR}/package.xml" "${S}" + if has_version '>=dev-php/PEAR-PEAR-1.7.0' ; then + local WWW_DIR="/usr/share/webapps/${PN}/${PVR}/htdocs" + pear -d php_bin="${PHP_BIN}" -d www_dir="${WWW_DIR}" \ + install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package.xml" || die "Unable to install PEAR package" + else + pear -d php_bin="${PHP_BIN}" install --force --loose --nodeps --offline --packagingroot="${D}" \ + "${S}/package.xml" || die "Unable to install PEAR package" + fi + fi + + rm -Rf "${D}/usr/share/php/.channels" \ + "${D}/usr/share/php/.depdblock" \ + "${D}/usr/share/php/.depdb" \ + "${D}/usr/share/php/.filemap" \ + "${D}/usr/share/php/.lock" \ + "${D}/usr/share/php/.registry" +} diff --git a/eclass/php5_2-sapi-r1.eclass b/eclass/php5_2-sapi-r1.eclass new file mode 100644 index 0000000..1fdb7d6 --- /dev/null +++ b/eclass/php5_2-sapi-r1.eclass @@ -0,0 +1,713 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/php5_2-sapi.eclass,v 1.17 2007/11/12 18:13:29 wltjr Exp $ + +# ======================================================================== +# Based on robbat2's work on the php4 sapi eclass +# +# Author: Stuart Herbert <stuart@gentoo.org> +# Author: Luca Longinotti <chtekk@gentoo.org> +# +# ======================================================================== + +# @ECLASS: php5_2-sapi.eclass +# @MAINTAINER: +# Gentoo PHP team <php-bugs@gentoo.org> +# @BLURB: Eclass for building different php-5.2 SAPI instances. +# @DESCRIPTION: +# Eclass for building different php-5.2 SAPI instances. Use it for the +# new-style =dev-lang/php-5.2* ebuilds. + + +PHPCONFUTILS_MISSING_DEPS="adabas birdstep db2 dbmaker empress empress-bcs esoob frontbase interbase msql oci8 sapdb solid sybase sybase-ct" + +WANT_AUTOCONF="latest" +WANT_AUTOMAKE="latest" + +inherit db-use flag-o-matic autotools toolchain-funcs libtool eutils phpconfutils php-common-r1 + +# @ECLASS-VARIABLE: MY_PHP_P +# @DESCRIPTION: +# Set MY_PHP_P in the ebuild as needed to match tarball version. + +# @ECLASS-VARIABLE: PHP_PACKAGE +# @DESCRIPTION: +# We only set this variable if we are building a copy of php which can be +# installed as a package in its own. +# Copies of php which are compiled into other packages (e.g. php support +# for the thttpd web server) don't need this variable. +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="adabas bcmath berkdb birdstep bzip2 calendar cdb cjk crypt ctype curl curlwrappers db2 dbase dbmaker debug doc empress empress-bcs esoob exif frontbase fdftk filter firebird flatfile ftp gd gd-external gdbm gmp hash iconv imap inifile interbase iodbc ipv6 java-external json kerberos ldap ldap-sasl libedit mcve mhash msql mssql mysql mysqli ncurses nls oci8 oci8-instant-client odbc pcntl pcre pdo pic posix postgres qdbm readline reflection recode sapdb session sharedext sharedmem simplexml snmp soap sockets solid spell spl sqlite ssl suhosin sybase sybase-ct sysvipc tidy tokenizer truetype unicode wddx xml xmlreader xmlwriter xmlrpc xpm xsl yaz zip zip-external zlib" + +# these USE flags should have the correct dependencies +DEPEND="adabas? ( >=dev-db/unixODBC-1.8.13 ) + berkdb? ( =sys-libs/db-4* ) + birdstep? ( >=dev-db/unixODBC-1.8.13 ) + bzip2? ( app-arch/bzip2 ) + cdb? ( || ( dev-db/cdb dev-db/tinycdb ) ) + cjk? ( !gd? ( !gd-external? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) ) ) + crypt? ( >=dev-libs/libmcrypt-2.4 ) + curl? ( >=net-misc/curl-7.10.5 ) + db2? ( >=dev-db/unixODBC-1.8.13 ) + dbmaker? ( >=dev-db/unixODBC-1.8.13 ) + empress? ( >=dev-db/unixODBC-1.8.13 ) + empress-bcs? ( >=dev-db/unixODBC-1.8.13 ) + esoob? ( >=dev-db/unixODBC-1.8.13 ) + exif? ( !gd? ( !gd-external? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) ) ) + fdftk? ( app-text/fdftk ) + firebird? ( dev-db/firebird ) + gd? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) + gd-external? ( media-libs/gd ) + gdbm? ( >=sys-libs/gdbm-1.8.0 ) + gmp? ( >=dev-libs/gmp-4.1.2 ) + iconv? ( virtual/libiconv ) + imap? ( virtual/imap-c-client ) + iodbc? ( dev-db/libiodbc >=dev-db/unixODBC-1.8.13 ) + kerberos? ( virtual/krb5 ) + ldap? ( !oci8? ( >=net-nds/openldap-1.2.11 ) ) + ldap-sasl? ( !oci8? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 ) ) + libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) ) + mcve? ( >=dev-libs/openssl-0.9.7 ) + mhash? ( app-crypt/mhash ) + mssql? ( dev-db/freetds ) + mysql? ( virtual/mysql ) + mysqli? ( >=virtual/mysql-4.1 ) + ncurses? ( sys-libs/ncurses ) + nls? ( sys-devel/gettext ) + oci8-instant-client? ( dev-db/oracle-instantclient-basic ) + odbc? ( >=dev-db/unixODBC-1.8.13 ) + pcre? ( >=dev-libs/libpcre-7.0 ) + postgres? ( >=dev-db/libpq-7.1 ) + qdbm? ( dev-db/qdbm ) + readline? ( sys-libs/readline ) + recode? ( app-text/recode ) + sapdb? ( >=dev-db/unixODBC-1.8.13 ) + sharedmem? ( dev-libs/mm ) + simplexml? ( >=dev-libs/libxml2-2.6.8 ) + snmp? ( >=net-analyzer/net-snmp-5.2 ) + soap? ( >=dev-libs/libxml2-2.6.8 ) + solid? ( >=dev-db/unixODBC-1.8.13 ) + spell? ( >=app-text/aspell-0.50 ) + sqlite? ( =dev-db/sqlite-2* pdo? ( =dev-db/sqlite-3* ) ) + ssl? ( >=dev-libs/openssl-0.9.7 ) + sybase? ( dev-db/freetds ) + tidy? ( app-text/htmltidy ) + truetype? ( =media-libs/freetype-2* >=media-libs/t1lib-5.0.0 !gd? ( !gd-external? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) ) ) + wddx? ( >=dev-libs/libxml2-2.6.8 ) + xml? ( >=dev-libs/libxml2-2.6.8 ) + xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv ) + xmlreader? ( >=dev-libs/libxml2-2.6.8 ) + xmlwriter? ( >=dev-libs/libxml2-2.6.8 ) + xpm? ( x11-libs/libXpm >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) + xsl? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 ) + zip? ( sys-libs/zlib ) + zlib? ( sys-libs/zlib ) + virtual/mta" + +# libswf conflicts with ming and should not +# be installed with the new PHP ebuilds +DEPEND="${DEPEND} + !media-libs/libswf" + +# simplistic for now +RDEPEND="${DEPEND}" + +# those are only needed at compile-time +DEPEND="${DEPEND} + >=sys-devel/m4-1.4.3 + >=sys-devel/libtool-1.5.18" + +# Additional features +# +# They are in PDEPEND because we need PHP installed first! +PDEPEND="doc? ( app-doc/php-docs ) + filter? ( !dev-php5/pecl-filter ) + java-external? ( dev-php5/php-java-bridge ) + json? ( !dev-php5/pecl-json ) + mcve? ( dev-php5/pecl-mcve ) + pdo? ( !dev-php5/pecl-pdo ) + suhosin? ( dev-php5/suhosin ) + yaz? ( dev-php5/pecl-yaz ) + zip? ( !dev-php5/pecl-zip ) + zip-external? ( dev-php5/pecl-zip )" + +# ======================================================================== +# php.ini Support +# ======================================================================== + +PHP_INI_FILE="php.ini" +PHP_INI_UPSTREAM="php.ini-dist" + +# ======================================================================== + +# @ECLASS-VARIABLE: PHP_PATCHSET_REV +# @DESCRIPTION: +# Provides PHP patchsets support. +SRC_URI="${SRC_URI} http://gentoo.longitekk.com/php-patchset-${MY_PHP_PV}-r${PHP_PATCHSET_REV}.tar.bz2" + +# @ECLASS-VARIABLE: SUHOSIN_PATCH +# @DESCRIPTION: +# Tarball name for Suhosin patch (see http://www.suhosin.org/). +# This feature will not be available in php if unset. +[[ -n "${SUHOSIN_PATCH}" ]] && SRC_URI="${SRC_URI} suhosin? ( http://gentoo.longitekk.com/${SUHOSIN_PATCH} )" + + +# ======================================================================== + +EXPORT_FUNCTIONS pkg_setup src_compile src_install src_unpack pkg_postinst + +# ======================================================================== +# INTERNAL FUNCTIONS +# ======================================================================== + +php5_2-sapi_check_use_flags() { + # Multiple USE dependencies + phpconfutils_use_depend_any "truetype" "gd" "gd" "gd-external" + phpconfutils_use_depend_any "cjk" "gd" "gd" "gd-external" + phpconfutils_use_depend_any "exif" "gd" "gd" "gd-external" + + # Simple USE dependencies + phpconfutils_use_depend_all "xpm" "gd" + phpconfutils_use_depend_all "gd" "zlib" + phpconfutils_use_depend_all "simplexml" "xml" + phpconfutils_use_depend_all "soap" "xml" + phpconfutils_use_depend_all "wddx" "xml" + phpconfutils_use_depend_all "xmlrpc" "xml" + phpconfutils_use_depend_all "xmlreader" "xml" + phpconfutils_use_depend_all "xmlwriter" "xml" + phpconfutils_use_depend_all "xsl" "xml" + phpconfutils_use_depend_all "filter" "pcre" + phpconfutils_use_depend_all "xmlrpc" "iconv" + phpconfutils_use_depend_all "java-external" "session" + phpconfutils_use_depend_all "ldap-sasl" "ldap" + phpconfutils_use_depend_all "mcve" "ssl" + phpconfutils_use_depend_all "suhosin" "unicode" + phpconfutils_use_depend_all "adabas" "odbc" + phpconfutils_use_depend_all "birdstep" "odbc" + phpconfutils_use_depend_all "dbmaker" "odbc" + phpconfutils_use_depend_all "empress-bcs" "odbc" "empress" + phpconfutils_use_depend_all "empress" "odbc" + phpconfutils_use_depend_all "esoob" "odbc" + phpconfutils_use_depend_all "db2" "odbc" + phpconfutils_use_depend_all "iodbc" "odbc" + phpconfutils_use_depend_all "sapdb" "odbc" + phpconfutils_use_depend_all "solid" "odbc" + phpconfutils_use_depend_all "test" "pcre" "cli" + + # Direct USE conflicts + phpconfutils_use_conflict "gd" "gd-external" + phpconfutils_use_conflict "oci8" "oci8-instant-client" + phpconfutils_use_conflict "oci8" "ldap-sasl" + phpconfutils_use_conflict "zip" "zip-external" + phpconfutils_use_conflict "qdbm" "gdbm" + phpconfutils_use_conflict "readline" "libedit" + phpconfutils_use_conflict "recode" "mysql" "imap" "yaz" + phpconfutils_use_conflict "sharedmem" "threads" + phpconfutils_use_conflict "firebird" "interbase" + + # IMAP support + php_check_imap + + # Mail support + php_check_mta + + # PostgreSQL support + php_check_pgsql + + # Oracle support + php_check_oracle_8 + + phpconfutils_warn_about_external_deps + + export PHPCONFUTILS_AUTO_USE="${PHPCONFUTILS_AUTO_USE}" +} + +php5_2-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_2-sapi_install_ini() { + destdir="/usr/$(get_libdir)/php5" + + # get the extension dir, if not already defined + [[ -z "${PHPEXTDIR}" ]] && PHPEXTDIR="$("${D}/${destdir}/bin/php-config" --extension-dir)" + + # work out where we are installing the ini file + php5_2-sapi_set_php_ini_dir + + cp "${PHP_INI_UPSTREAM}" "${PHP_INI_UPSTREAM}-${PHPSAPI}" + local phpinisrc="${PHP_INI_UPSTREAM}-${PHPSAPI}" + + # Set the extension dir + einfo "Setting extension_dir in php.ini" + sed -e "s|^extension_dir .*$|extension_dir = ${PHPEXTDIR}|g" -i ${phpinisrc} + + # A patch for PHP for security + einfo "Securing fopen wrappers" + sed -e 's|^allow_url_include .*|allow_url_include = Off|g' -i ${phpinisrc} + + # Set the include path to point to where we want to find PEAR packages + einfo "Setting correct include_path" + sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:/usr/share/php5:/usr/share/php"|' -i ${phpinisrc} + + # Add needed MySQL extensions charset configuration + local phpmycnfcharset="" + + if [[ "${PHPSAPI}" == "cli" ]] ; then + phpmycnfcharset="$(php_get_mycnf_charset cli)" + einfo "MySQL extensions charset for 'cli' SAPI is: ${phpmycnfcharset}" + elif [[ "${PHPSAPI}" == "cgi" ]] ; then + phpmycnfcharset="$(php_get_mycnf_charset cgi-fcgi)" + einfo "MySQL extensions charset for 'cgi' SAPI is: ${phpmycnfcharset}" + elif [[ "${PHPSAPI}" == "apache2" ]] ; then + phpmycnfcharset="$(php_get_mycnf_charset apache2handler)" + einfo "MySQL extensions charset for 'apache2' SAPI is: ${phpmycnfcharset}" + else + einfo "No supported SAPI found for which to get the MySQL charset." + fi + + if [[ -n "${phpmycnfcharset}" ]] && [[ "${phpmycnfcharset}" != "empty" ]] ; then + einfo "Setting MySQL extensions charset to ${phpmycnfcharset}" + echo "" >> ${phpinisrc} + echo "; MySQL extensions default connection charset settings" >> ${phpinisrc} + echo "mysql.connect_charset = ${phpmycnfcharset}" >> ${phpinisrc} + echo "mysqli.connect_charset = ${phpmycnfcharset}" >> ${phpinisrc} + echo "pdo_mysql.connect_charset = ${phpmycnfcharset}" >> ${phpinisrc} + else + echo "" >> ${phpinisrc} + echo "; MySQL extensions default connection charset settings" >> ${phpinisrc} + echo ";mysql.connect_charset = utf8" >> ${phpinisrc} + echo ";mysqli.connect_charset = utf8" >> ${phpinisrc} + echo ";pdo_mysql.connect_charset = utf8" >> ${phpinisrc} + fi + + 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 use 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 +# ======================================================================== + +# @FUNCTION: php5_2-sapi_pkg_setup +# @DESCRIPTION: +# Performs all the USE flag testing and magic before we do anything else. +# This way saves a lot of time. +php5_2-sapi_pkg_setup() { + php5_2-sapi_check_use_flags +} + +# @FUNCTION: php5_2-sapi_src_unpack +# @DESCRIPTION: +# Takes care of unpacking, patching and autotools magic and disables +# interactive tests. + +# @VARIABLE: PHP_EXTRA_BRANDING +# @DESCRIPTION: +# This variable allows an ebuild to add additional information like +# snapshot dates to the version line. +php5_2-sapi_src_unpack() { + cd "${S}" + + [[ -z "${PHP_EXTRA_BRANDING}" ]] && PHP_EXTRA_BRANDING="" + + # Change PHP branding + PHPPR=${PR/r/} + # >=php-5.2.4 has PHP_EXTRA_VERSION, previous had EXTRA_VERSION + sed -re "s|^(PHP_)?EXTRA_VERSION=\".*\"|\1EXTRA_VERSION=\"${PHP_EXTRA_BRANDING}-pl${PHPPR}-gentoo\"|g" -i configure.in \ + || die "Unable to change PHP branding to ${PHP_EXTRA_BRANDING}-pl${PHPPR}-gentoo" + + # multilib-strict support + if [[ -n "${MULTILIB_PATCH}" ]] && [[ -f "${WORKDIR}/${MULTILIB_PATCH}" ]] ; then + epatch "${WORKDIR}/${MULTILIB_PATCH}" + else + die "multilib-strict patch missing" + 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 + + # 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" + + # Suhosin support + if use suhosin ; then + if [[ -n "${SUHOSIN_PATCH}" ]] && [[ -f "${DISTDIR}/${SUHOSIN_PATCH}" ]] ; then + epatch "${DISTDIR}/${SUHOSIN_PATCH}" + else + ewarn "There is no Suhosin patch available for this PHP release yet!" + fi + fi + + # Stop PHP from activating the Apache config, as we will do that ourselves + for i in configure 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 + + # 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 + + # 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" + fi + + # Make sure that autotools stuff is up-to-date as several things change it: + # suhosin, our branding sed... + einfo "Running aclocal" + aclocal --force || die "Unable to run aclocal successfully" + einfo "Running libtoolize" + libtoolize --copy --force || die "Unable to run libtoolize successfully" + einfo "Rebuilding configure script" + autoreconf --force -W no-cross || die "Unable to regenerate configure script successfully" + elibtoolize + + # Just in case ;-) + chmod 0755 configure || die "Failed to chmod configure to 0755" +} + +# @FUNCTION: php5_2-sapi_src_compile +# @DESCRIPTION: +# Takes care of compiling php according to USE flags set by user (and those automagically +# enabled via phpconfutils eclass if unavoidable). +php5_2-sapi_src_compile() { + destdir="/usr/$(get_libdir)/php5" + + php5_2-sapi_set_php_ini_dir + + cd "${S}" + + phpconfutils_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? + phpconfutils_extension_enable "bcmath" "bcmath" 1 + phpconfutils_extension_with "bz2" "bzip2" 1 + phpconfutils_extension_enable "calendar" "calendar" 1 + phpconfutils_extension_disable "ctype" "ctype" 0 + phpconfutils_extension_with "curl" "curl" 1 + phpconfutils_extension_with "curlwrappers" "curlwrappers" 0 + phpconfutils_extension_enable "dbase" "dbase" 1 + phpconfutils_extension_disable "dom" "xml" 0 + phpconfutils_extension_enable "exif" "exif" 1 + phpconfutils_extension_with "fbsql" "frontbase" 1 + phpconfutils_extension_with "fdftk" "fdftk" 1 "/opt/fdftk-6.0" + phpconfutils_extension_disable "filter" "filter" 0 + phpconfutils_extension_enable "ftp" "ftp" 1 + phpconfutils_extension_with "gettext" "nls" 1 + phpconfutils_extension_with "gmp" "gmp" 1 + phpconfutils_extension_disable "hash" "hash" 0 + phpconfutils_extension_without "iconv" "iconv" 0 + phpconfutils_extension_disable "ipv6" "ipv6" 0 + phpconfutils_extension_disable "json" "json" 0 + phpconfutils_extension_with "kerberos" "kerberos" 0 "/usr" + phpconfutils_extension_disable "libxml" "xml" 0 + phpconfutils_extension_enable "mbstring" "unicode" 1 + phpconfutils_extension_with "mcrypt" "crypt" 1 + phpconfutils_extension_with "mhash" "mhash" 1 + phpconfutils_extension_with "msql" "msql" 1 + phpconfutils_extension_with "mssql" "mssql" 1 + phpconfutils_extension_with "ncurses" "ncurses" 1 + phpconfutils_extension_with "openssl" "ssl" 0 + phpconfutils_extension_with "openssl-dir" "ssl" 0 "/usr" + phpconfutils_extension_enable "pcntl" "pcntl" 1 + phpconfutils_extension_with "pcre-regex" "pcre" 0 "/usr" + phpconfutils_extension_disable "pdo" "pdo" 0 + phpconfutils_extension_with "pgsql" "postgres" 1 + phpconfutils_extension_disable "posix" "posix" 0 + phpconfutils_extension_with "pspell" "spell" 1 + phpconfutils_extension_with "recode" "recode" 1 + phpconfutils_extension_disable "reflection" "reflection" 0 + phpconfutils_extension_disable "simplexml" "simplexml" 0 + phpconfutils_extension_enable "shmop" "sharedmem" 0 + phpconfutils_extension_with "snmp" "snmp" 1 + phpconfutils_extension_enable "soap" "soap" 1 + phpconfutils_extension_enable "sockets" "sockets" 1 + phpconfutils_extension_disable "spl" "spl" 0 + phpconfutils_extension_with "sybase" "sybase" 1 + phpconfutils_extension_with "sybase-ct" "sybase-ct" 1 + phpconfutils_extension_enable "sysvmsg" "sysvipc" 1 + phpconfutils_extension_enable "sysvsem" "sysvipc" 1 + phpconfutils_extension_enable "sysvshm" "sysvipc" 1 + phpconfutils_extension_with "tidy" "tidy" 1 + phpconfutils_extension_disable "tokenizer" "tokenizer" 0 + phpconfutils_extension_enable "wddx" "wddx" 1 + phpconfutils_extension_disable "xml" "xml" 0 + phpconfutils_extension_disable "xmlreader" "xmlreader" 0 + phpconfutils_extension_disable "xmlwriter" "xmlwriter" 0 + phpconfutils_extension_with "xmlrpc" "xmlrpc" 1 + phpconfutils_extension_with "xsl" "xsl" 1 + phpconfutils_extension_enable "zip" "zip" 1 + phpconfutils_extension_with "zlib" "zlib" 1 + phpconfutils_extension_enable "debug" "debug" 0 + + # DBA support + if use cdb || use berkdb || use flatfile || use gdbm || use inifile || use qdbm ; then + my_conf="${my_conf} --enable-dba${shared}" + fi + + # Tell PHP where the db.h is on FreeBSD +# if use berkdb ; then +# append-cppflags "-I$(db_includedir)" +# fi + + # DBA drivers support + phpconfutils_extension_with "cdb" "cdb" 0 + phpconfutils_extension_with "db4" "berkdb" 0 + phpconfutils_extension_with "flatfile" "flatfile" 0 + phpconfutils_extension_with "gdbm" "gdbm" 0 + phpconfutils_extension_with "inifile" "inifile" 0 + phpconfutils_extension_with "qdbm" "qdbm" 0 + + # Support for the GD graphics library + if use gd-external || phpconfutils_usecheck gd-external ; then + phpconfutils_extension_with "freetype-dir" "truetype" 0 "/usr" + phpconfutils_extension_with "t1lib" "truetype" 0 "/usr" + phpconfutils_extension_enable "gd-jis-conv" "cjk" 0 + phpconfutils_extension_with "gd" "gd-external" 1 "/usr" + else + phpconfutils_extension_with "freetype-dir" "truetype" 0 "/usr" + phpconfutils_extension_with "t1lib" "truetype" 0 "/usr" + phpconfutils_extension_enable "gd-jis-conv" "cjk" 0 + phpconfutils_extension_with "jpeg-dir" "gd" 0 "/usr" + phpconfutils_extension_with "png-dir" "gd" 0 "/usr" + phpconfutils_extension_with "xpm-dir" "xpm" 0 "/usr" + # enable gd last, so configure can pick up the previous settings + phpconfutils_extension_with "gd" "gd" 0 + fi + + # IMAP support + if use imap || phpconfutils_usecheck imap ; then + phpconfutils_extension_with "imap" "imap" 1 + phpconfutils_extension_with "imap-ssl" "ssl" 0 + fi + + # Interbase support + if use interbase ; then + my_conf="${my_conf} --with-interbase=/opt" + fi + + # Firebird support - see Bug 186791 + if use firebird ; then + my_conf="${my_conf} --with-interbase=/usr" + fi + + # LDAP support + if use ldap || phpconfutils_usecheck ldap ; then + if use oci8 ; then + phpconfutils_extension_with "ldap" "ldap" 1 "${ORACLE_HOME}" + else + phpconfutils_extension_with "ldap" "ldap" 1 + phpconfutils_extension_with "ldap-sasl" "ldap-sasl" 0 + fi + fi + + # MySQL support + if use mysql ; then + phpconfutils_extension_with "mysql" "mysql" 1 "/usr" + phpconfutils_extension_with "mysql-sock" "mysql" 0 "/var/run/mysqld/mysqld.sock" + fi + + # MySQLi support + phpconfutils_extension_with "mysqli" "mysqli" 1 "/usr/bin/mysql_config" + + # ODBC support + if use odbc || phpconfutils_usecheck odbc ; then + phpconfutils_extension_with "unixODBC" "odbc" 1 "/usr" + + phpconfutils_extension_with "adabas" "adabas" 1 + phpconfutils_extension_with "birdstep" "birdstep" 1 + phpconfutils_extension_with "dbmaker" "dbmaker" 1 + phpconfutils_extension_with "empress" "empress" 1 + if use empress || phpconfutils_usecheck empress ; then + phpconfutils_extension_with "empress-bcs" "empress-bcs" 0 + fi + phpconfutils_extension_with "esoob" "esoob" 1 + phpconfutils_extension_with "ibm-db2" "db2" 1 + phpconfutils_extension_with "iodbc" "iodbc" 1 "/usr" + phpconfutils_extension_with "sapdb" "sapdb" 1 + phpconfutils_extension_with "solid" "solid" 1 + fi + + # Oracle support + if use oci8 ; then + phpconfutils_extension_with "oci8" "oci8" 1 + fi + if use 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')" + phpconfutils_extension_with "oci8" "oci8-instant-client" 1 "instantclient,/usr/lib/oracle/${OCI8IC_PKG}/client/lib" + fi + + # PDO support + if use pdo || phpconfutils_usecheck pdo ; then + phpconfutils_extension_with "pdo-dblib" "mssql" 1 + # The PDO-Firebird driver is broken and unmaintained upstream + # phpconfutils_extension_with "pdo-firebird" "firebird" 1 + phpconfutils_extension_with "pdo-mysql" "mysql" 1 "/usr" + if use oci8 ; then + phpconfutils_extension_with "pdo-oci" "oci8" 1 + fi + if use 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')" + phpconfutils_extension_with "pdo-oci" "oci8-instant-client" 1 "instantclient,/usr,${OCI8IC_PKG}" + fi + phpconfutils_extension_with "pdo-odbc" "odbc" 1 "unixODBC,/usr" + phpconfutils_extension_with "pdo-pgsql" "postgres" 1 + phpconfutils_extension_with "pdo-sqlite" "sqlite" 1 "/usr" + fi + + # readline/libedit support + # You can use readline or libedit, but you can't use both + phpconfutils_extension_with "readline" "readline" 0 + phpconfutils_extension_with "libedit" "libedit" 0 + + # Session support + if ! use session && ! phpconfutils_usecheck session ; then + phpconfutils_extension_disable "session" "session" 0 + else + phpconfutils_extension_with "mm" "sharedmem" 0 + fi + + # SQLite support + if ! use sqlite && ! phpconfutils_usecheck sqlite ; then + phpconfutils_extension_without "sqlite" "sqlite" 0 + else + phpconfutils_extension_with "sqlite" "sqlite" 0 "/usr" + phpconfutils_extension_enable "sqlite-utf8" "unicode" 0 + fi + + # Fix ELF-related problems + if use pic || phpconfutils_usecheck pic ; then + einfo "Enabling PIC support" + my_conf="${my_conf} --with-pic" + fi + + # Catch CFLAGS problems + php_check_cflags + + # multilib support + if [[ $(get_libdir) != lib ]] ; then + my_conf="--with-libdir=$(get_libdir) ${my_conf}" + fi + + # Support user-passed configuration parameters + [[ -z "${EXTRA_ECONF}" ]] && EXTRA_ECONF="" + + # Set the correct compiler for cross-compilation + tc-export CC + + # We don't use econf, because we need to override all of its settings + ./configure --prefix=${destdir} --host=${CHOST} --mandir=${destdir}/man --infodir=${destdir}/info --sysconfdir=/etc --cache-file=./config.cache ${my_conf} ${EXTRA_ECONF} || die "configure failed" + emake || die "make failed" +} + +# @FUNCTION: php5_2-sapi_src_install +# @DESCRIPTION: +# Takes care of installing php (and its shared extensions if enabled). +php5_2-sapi_src_install() { + destdir="/usr/$(get_libdir)/php5" + + cd "${S}" + + addpredict /usr/share/snmp/mibs/.index + + # Install PHP + make INSTALL_ROOT="${D}" install-build install-headers install-programs || die "make install failed" + + # Install missing header files + if use unicode || phpconfutils_usecheck unicode ; then + dodir ${destdir}/include/php/ext/mbstring + insinto ${destdir}/include/php/ext/mbstring + for x in $(ls "${S}/ext/mbstring/"*.h) ; do + file="$(basename "${x}")" + doins ext/mbstring/${file} + done + dodir ${destdir}/include/php/ext/mbstring/oniguruma + insinto ${destdir}/include/php/ext/mbstring/oniguruma + for x in $(ls "${S}/ext/mbstring/oniguruma/"*.h) ; do + file=$(basename "${x}") + doins ext/mbstring/oniguruma/${file} + done + dodir ${destdir}/include/php/ext/mbstring/libmbfl/mbfl + insinto ${destdir}/include/php/ext/mbstring/libmbfl/mbfl + for x in $(ls "${S}/ext/mbstring/libmbfl/mbfl/"*.h) ; do + file=$(basename "${x}") + doins ext/mbstring/libmbfl/mbfl/${file} + done + fi + + # Get the extension dir, if not already defined + [[ -z "${PHPEXTDIR}" ]] && PHPEXTDIR="$("${D}/${destdir}/bin/php-config" --extension-dir)" + + # And install the modules to it + if use sharedext ; then + for x in $(ls "${S}/modules/"*.so | sort) ; do + module=$(basename "${x}") + modulename="${module/.so/}" + insinto "${PHPEXTDIR}" + einfo "Installing PHP ${modulename} extension" + doins "modules/${module}" + done + fi + + # Generate the USE file for PHP + phpconfutils_generate_usefile + + # Create the directory where we'll put php5-only php scripts + keepdir /usr/share/php5 +} + +# @FUNCTION: php5_2-sapi_pkg_postinst +# @DESCRIPTION: +# Provides important information to users after install is finished. +php5_2-sapi_pkg_postinst() { + ewarn "If you have additional third party PHP extensions (such as" + ewarn "dev-php5/phpdbg) you may need to recompile them now." + ewarn + if use sharedext ; then + ewarn "Make sure to use etc-update or dispatch-conf so that extension-specific" + ewarn "ini files get merged properly" + ewarn + fi + + ewarn "USE=\"pic\" slows down PHP but has to be enabled on setups where TEXTRELs" + ewarn "are disabled (e.g. when using PaX in the kernel). On hardened profiles this" + ewarn "USE flag is enabled automatically" + ewarn +} diff --git a/eclass/php5_2-sapi.eclass b/eclass/php5_2-sapi.eclass new file mode 100644 index 0000000..3c7e433 --- /dev/null +++ b/eclass/php5_2-sapi.eclass @@ -0,0 +1,731 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/eclass/php5_2-sapi.eclass,v 1.17 2007/11/12 18:13:29 wltjr Exp $ + +# ======================================================================== +# Based on robbat2's work on the php4 sapi eclass +# +# Author: Stuart Herbert <stuart@gentoo.org> +# Author: Luca Longinotti <chtekk@gentoo.org> +# +# ======================================================================== + +# @ECLASS: php5_2-sapi.eclass +# @MAINTAINER: +# Gentoo PHP team <php-bugs@gentoo.org> +# @BLURB: Eclass for building different php-5.2 SAPI instances. +# @DESCRIPTION: +# Eclass for building different php-5.2 SAPI instances. Use it for the +# new-style =dev-lang/php-5.2* ebuilds. + + +PHPCONFUTILS_MISSING_DEPS="adabas birdstep db2 dbmaker empress empress-bcs esoob frontbase interbase msql oci8 sapdb solid sybase sybase-ct" + +WANT_AUTOCONF="latest" +WANT_AUTOMAKE="latest" + +inherit db-use flag-o-matic autotools toolchain-funcs libtool eutils phpconfutils php-common-r1 + +# @ECLASS-VARIABLE: MY_PHP_P +# @DESCRIPTION: +# Set MY_PHP_P in the ebuild as needed to match tarball version. + +# @ECLASS-VARIABLE: PHP_PACKAGE +# @DESCRIPTION: +# We only set this variable if we are building a copy of php which can be +# installed as a package in its own. +# Copies of php which are compiled into other packages (e.g. php support +# for the thttpd web server) don't need this variable. +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="adabas bcmath berkdb birdstep bzip2 calendar cdb cjk crypt ctype curl curlwrappers db2 dbase dbmaker debug doc empress empress-bcs esoob exif frontbase fdftk filter firebird flatfile ftp gd gd-external gdbm gmp hash iconv imap inifile interbase iodbc ipv6 java-external json kerberos ldap ldap-sasl libedit mcve mhash msql mssql mysql mysqli ncurses nls oci8 oci8-instant-client odbc pcntl pcre pdo pic posix postgres qdbm readline reflection recode sapdb session sharedext sharedmem simplexml snmp soap sockets solid spell spl sqlite ssl suhosin sybase sybase-ct sysvipc tidy tokenizer truetype unicode wddx xml xmlreader xmlwriter xmlrpc xpm xsl yaz zip zip-external zlib" + +# these USE flags should have the correct dependencies +DEPEND="adabas? ( >=dev-db/unixODBC-1.8.13 ) + berkdb? ( =sys-libs/db-4* ) + birdstep? ( >=dev-db/unixODBC-1.8.13 ) + bzip2? ( app-arch/bzip2 ) + cdb? ( || ( dev-db/cdb dev-db/tinycdb ) ) + cjk? ( !gd? ( !gd-external? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) ) ) + crypt? ( >=dev-libs/libmcrypt-2.4 ) + curl? ( >=net-misc/curl-7.10.5 ) + db2? ( >=dev-db/unixODBC-1.8.13 ) + dbmaker? ( >=dev-db/unixODBC-1.8.13 ) + empress? ( >=dev-db/unixODBC-1.8.13 ) + empress-bcs? ( >=dev-db/unixODBC-1.8.13 ) + esoob? ( >=dev-db/unixODBC-1.8.13 ) + exif? ( !gd? ( !gd-external? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) ) ) + fdftk? ( app-text/fdftk ) + firebird? ( dev-db/firebird ) + gd? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) + gd-external? ( media-libs/gd ) + gdbm? ( >=sys-libs/gdbm-1.8.0 ) + gmp? ( >=dev-libs/gmp-4.1.2 ) + iconv? ( virtual/libiconv ) + imap? ( virtual/imap-c-client ) + iodbc? ( dev-db/libiodbc >=dev-db/unixODBC-1.8.13 ) + kerberos? ( virtual/krb5 ) + kolab? ( >=net-libs/c-client-2004g-r1 ) + ldap? ( !oci8? ( >=net-nds/openldap-1.2.11 ) ) + ldap-sasl? ( !oci8? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 ) ) + libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) ) + mcve? ( >=dev-libs/openssl-0.9.7 ) + mhash? ( app-crypt/mhash ) + mssql? ( dev-db/freetds ) + mysql? ( virtual/mysql ) + mysqli? ( >=virtual/mysql-4.1 ) + ncurses? ( sys-libs/ncurses ) + nls? ( sys-devel/gettext ) + oci8-instant-client? ( dev-db/oracle-instantclient-basic ) + odbc? ( >=dev-db/unixODBC-1.8.13 ) + postgres? ( >=dev-db/libpq-7.1 ) + qdbm? ( dev-db/qdbm ) + readline? ( sys-libs/readline ) + recode? ( app-text/recode ) + sapdb? ( >=dev-db/unixODBC-1.8.13 ) + sharedmem? ( dev-libs/mm ) + simplexml? ( >=dev-libs/libxml2-2.6.8 ) + snmp? ( >=net-analyzer/net-snmp-5.2 ) + soap? ( >=dev-libs/libxml2-2.6.8 ) + solid? ( >=dev-db/unixODBC-1.8.13 ) + spell? ( >=app-text/aspell-0.50 ) + sqlite? ( =dev-db/sqlite-2* pdo? ( =dev-db/sqlite-3* ) ) + ssl? ( >=dev-libs/openssl-0.9.7 ) + sybase? ( dev-db/freetds ) + tidy? ( app-text/htmltidy ) + truetype? ( =media-libs/freetype-2* >=media-libs/t1lib-5.0.0 !gd? ( !gd-external? ( >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) ) ) + wddx? ( >=dev-libs/libxml2-2.6.8 ) + xml? ( >=dev-libs/libxml2-2.6.8 ) + xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv ) + xmlreader? ( >=dev-libs/libxml2-2.6.8 ) + xmlwriter? ( >=dev-libs/libxml2-2.6.8 ) + xpm? ( x11-libs/libXpm >=media-libs/jpeg-6b media-libs/libpng sys-libs/zlib ) + xsl? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 ) + zip? ( sys-libs/zlib ) + zlib? ( sys-libs/zlib ) + virtual/mta" + +# libswf conflicts with ming and should not +# be installed with the new PHP ebuilds +DEPEND="${DEPEND} + !media-libs/libswf" + +# simplistic for now +RDEPEND="${DEPEND}" + +# those are only needed at compile-time +DEPEND="${DEPEND} + >=sys-devel/m4-1.4.3 + >=sys-devel/libtool-1.5.18" + +# Additional features +# +# They are in PDEPEND because we need PHP installed first! +PDEPEND="doc? ( app-doc/php-docs ) + filter? ( !dev-php5/pecl-filter ) + java-external? ( dev-php5/php-java-bridge ) + json? ( !dev-php5/pecl-json ) + mcve? ( dev-php5/pecl-mcve ) + pdo? ( !dev-php5/pecl-pdo ) + suhosin? ( dev-php5/suhosin ) + yaz? ( dev-php5/pecl-yaz ) + zip? ( !dev-php5/pecl-zip ) + zip-external? ( dev-php5/pecl-zip )" + +# ======================================================================== +# php.ini Support +# ======================================================================== + +PHP_INI_FILE="php.ini" +PHP_INI_UPSTREAM="php.ini-dist" + +# ======================================================================== + +# @ECLASS-VARIABLE: PHP_PATCHSET_REV +# @DESCRIPTION: +# Provides PHP patchsets support. +SRC_URI="${SRC_URI} http://gentoo.longitekk.com/php-patchset-${MY_PHP_PV}-r${PHP_PATCHSET_REV}.tar.bz2" + +# @ECLASS-VARIABLE: SUHOSIN_PATCH +# @DESCRIPTION: +# Tarball name for Suhosin patch (see http://www.suhosin.org/). +# This feature will not be available in php if unset. +[[ -n "${SUHOSIN_PATCH}" ]] && SRC_URI="${SRC_URI} suhosin? ( http://gentoo.longitekk.com/${SUHOSIN_PATCH} )" + + +# ======================================================================== + +EXPORT_FUNCTIONS pkg_setup src_compile src_install src_unpack pkg_postinst + +# ======================================================================== +# INTERNAL FUNCTIONS +# ======================================================================== + +php5_2-sapi_check_use_flags() { + # Multiple USE dependencies + phpconfutils_use_depend_any "truetype" "gd" "gd" "gd-external" + phpconfutils_use_depend_any "cjk" "gd" "gd" "gd-external" + phpconfutils_use_depend_any "exif" "gd" "gd" "gd-external" + + # Simple USE dependencies + phpconfutils_use_depend_all "xpm" "gd" + phpconfutils_use_depend_all "gd" "zlib" + phpconfutils_use_depend_all "simplexml" "xml" + phpconfutils_use_depend_all "soap" "xml" + phpconfutils_use_depend_all "wddx" "xml" + phpconfutils_use_depend_all "xmlrpc" "xml" + phpconfutils_use_depend_all "xmlreader" "xml" + phpconfutils_use_depend_all "xmlwriter" "xml" + phpconfutils_use_depend_all "xsl" "xml" + phpconfutils_use_depend_all "filter" "pcre" + phpconfutils_use_depend_all "xmlrpc" "iconv" + phpconfutils_use_depend_all "java-external" "session" + phpconfutils_use_depend_all "ldap-sasl" "ldap" + phpconfutils_use_depend_all "mcve" "ssl" + phpconfutils_use_depend_all "suhosin" "unicode" + phpconfutils_use_depend_all "adabas" "odbc" + phpconfutils_use_depend_all "birdstep" "odbc" + phpconfutils_use_depend_all "dbmaker" "odbc" + phpconfutils_use_depend_all "empress-bcs" "odbc" "empress" + phpconfutils_use_depend_all "empress" "odbc" + phpconfutils_use_depend_all "esoob" "odbc" + phpconfutils_use_depend_all "db2" "odbc" + phpconfutils_use_depend_all "iodbc" "odbc" + phpconfutils_use_depend_all "sapdb" "odbc" + phpconfutils_use_depend_all "solid" "odbc" + phpconfutils_use_depend_all "kolab" "imap" + + # Direct USE conflicts + phpconfutils_use_conflict "gd" "gd-external" + phpconfutils_use_conflict "oci8" "oci8-instant-client" + phpconfutils_use_conflict "oci8" "ldap-sasl" + phpconfutils_use_conflict "zip" "zip-external" + phpconfutils_use_conflict "qdbm" "gdbm" + phpconfutils_use_conflict "readline" "libedit" + phpconfutils_use_conflict "recode" "mysql" "imap" "yaz" "kolab" + phpconfutils_use_conflict "sharedmem" "threads" + phpconfutils_use_conflict "firebird" "interbase" + + # IMAP support + php_check_imap + + # Mail support + php_check_mta + + # PostgreSQL support + php_check_pgsql + + # Oracle support + php_check_oracle_8 + + phpconfutils_warn_about_external_deps + + export PHPCONFUTILS_AUTO_USE="${PHPCONFUTILS_AUTO_USE}" +} + +php5_2-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_2-sapi_install_ini() { + destdir=/usr/$(get_libdir)/php5 + + # get the extension dir, if not already defined + [[ -z "${PHPEXTDIR}" ]] && PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`" + + # work out where we are installing the ini file + php5_2-sapi_set_php_ini_dir + + cp "${PHP_INI_UPSTREAM}" "${PHP_INI_UPSTREAM}-${PHPSAPI}" + local phpinisrc="${PHP_INI_UPSTREAM}-${PHPSAPI}" + + # Set the extension dir + einfo "Setting extension_dir in php.ini" + sed -e "s|^extension_dir .*$|extension_dir = ${PHPEXTDIR}|g" -i ${phpinisrc} + + # A patch for PHP for security + einfo "Securing fopen wrappers" + sed -e 's|^allow_url_fopen .*|allow_url_fopen = Off|g' -i ${phpinisrc} + + # Set the include path to point to where we want to find PEAR packages + einfo "Setting correct include_path" + sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:/usr/share/php5:/usr/share/php"|' -i ${phpinisrc} + + # Add needed MySQL extensions charset configuration + local phpmycnfcharset="" + + if [[ "${PHPSAPI}" == "cli" ]] ; then + phpmycnfcharset="`php_get_mycnf_charset cli`" + einfo "MySQL extensions charset for 'cli' SAPI is: ${phpmycnfcharset}" + elif [[ "${PHPSAPI}" == "cgi" ]] ; then + phpmycnfcharset="`php_get_mycnf_charset cgi-fcgi`" + einfo "MySQL extensions charset for 'cgi' SAPI is: ${phpmycnfcharset}" + elif [[ "${PHPSAPI}" == "apache2" ]] ; then + phpmycnfcharset="`php_get_mycnf_charset apache2handler`" + einfo "MySQL extensions charset for 'apache2' SAPI is: ${phpmycnfcharset}" + else + einfo "No supported SAPI found for which to get the MySQL charset." + fi + + if [[ -n "${phpmycnfcharset}" ]] && [[ "${phpmycnfcharset}" != "empty" ]] ; then + einfo "Setting MySQL extensions charset to ${phpmycnfcharset}" + echo "" >> ${phpinisrc} + echo "; MySQL extensions default connection charset settings" >> ${phpinisrc} + echo "mysql.connect_charset = ${phpmycnfcharset}" >> ${phpinisrc} + echo "mysqli.connect_charset = ${phpmycnfcharset}" >> ${phpinisrc} + echo "pdo_mysql.connect_charset = ${phpmycnfcharset}" >> ${phpinisrc} + else + echo "" >> ${phpinisrc} + echo "; MySQL extensions default connection charset settings" >> ${phpinisrc} + echo ";mysql.connect_charset = utf8" >> ${phpinisrc} + echo ";mysqli.connect_charset = utf8" >> ${phpinisrc} + echo ";pdo_mysql.connect_charset = utf8" >> ${phpinisrc} + fi + + 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 use 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 +# ======================================================================== + +# @FUNCTION: php5_2-sapi_pkg_setup +# @DESCRIPTION: +# Performs all the USE flag testing and magic before we do anything else. +# This way saves a lot of time. +php5_2-sapi_pkg_setup() { + php5_2-sapi_check_use_flags +} + +# @FUNCTION: php5_2-sapi_src_unpack +# @DESCRIPTION: +# Takes care of unpacking, patching and autotools magic and disables +# interactive tests. + +# @VARIABLE: PHP_EXTRA_BRANDING +# @DESCRIPTION: +# This variable allows an ebuild to add additional information like +# snapshot dates to the version line. +php5_2-sapi_src_unpack() { + cd "${S}" + + [[ -z "${PHP_EXTRA_BRANDING}" ]] && PHP_EXTRA_BRANDING="" + + # Change PHP branding + PHPPR=${PR/r/} + # >=php-5.2.4 has PHP_EXTRA_VERSION, previous had EXTRA_VERSION + sed -re "s|^(PHP_)?EXTRA_VERSION=\".*\"|\1EXTRA_VERSION=\"${PHP_EXTRA_BRANDING}-pl${PHPPR}-gentoo\"|g" -i configure.in \ + || die "Unable to change PHP branding to ${PHP_EXTRA_BRANDING}-pl${PHPPR}-gentoo" + + # 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 + + # 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 + for i in configure 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 + + # 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 + + # 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" + fi + + # Suhosin support + if use suhosin ; then + if [[ -n "${SUHOSIN_PATCH}" ]] && [[ -f "${DISTDIR}/${SUHOSIN_PATCH}" ]] ; then + epatch "${DISTDIR}/${SUHOSIN_PATCH}" + else + ewarn "There is no Suhosin patch available for this PHP release yet!" + fi + fi + + # Fix configure scripts to correctly support Suhosin + einfo "Running aclocal" + 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 + einfo "Rebuilding configure script" + autoreconf --force -W no-cross || die "Unable to regenerate configure script successfully" + + # Run elibtoolize + elibtoolize + + # Just in case ;-) + chmod 0755 configure || die "Failed to chmod configure to 0755" +} + +# @FUNCTION: php5_2-sapi_src_compile +# @DESCRIPTION: +# Takes care of compiling php according to USE flags set by user (and those automagically +# enabled via phpconfutils eclass if unavoidable). +php5_2-sapi_src_compile() { + destdir=/usr/$(get_libdir)/php5 + + php5_2-sapi_set_php_ini_dir + + cd "${S}" + + phpconfutils_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? + phpconfutils_extension_enable "bcmath" "bcmath" 1 + phpconfutils_extension_with "bz2" "bzip2" 1 + phpconfutils_extension_enable "calendar" "calendar" 1 + phpconfutils_extension_disable "ctype" "ctype" 0 + phpconfutils_extension_with "curl" "curl" 1 + phpconfutils_extension_with "curlwrappers" "curlwrappers" 0 + phpconfutils_extension_enable "dbase" "dbase" 1 + phpconfutils_extension_disable "dom" "xml" 0 + phpconfutils_extension_enable "exif" "exif" 1 + phpconfutils_extension_with "fbsql" "frontbase" 1 + phpconfutils_extension_with "fdftk" "fdftk" 1 "/opt/fdftk-6.0" + phpconfutils_extension_disable "filter" "filter" 0 + phpconfutils_extension_enable "ftp" "ftp" 1 + phpconfutils_extension_with "gettext" "nls" 1 + phpconfutils_extension_with "gmp" "gmp" 1 + phpconfutils_extension_disable "hash" "hash" 0 + phpconfutils_extension_without "iconv" "iconv" 0 + phpconfutils_extension_disable "ipv6" "ipv6" 0 + phpconfutils_extension_disable "json" "json" 0 + phpconfutils_extension_with "kerberos" "kerberos" 0 "/usr" + phpconfutils_extension_disable "libxml" "xml" 0 + phpconfutils_extension_enable "mbstring" "unicode" 1 + phpconfutils_extension_with "mcrypt" "crypt" 1 + phpconfutils_extension_with "mhash" "mhash" 1 + phpconfutils_extension_with "msql" "msql" 1 + phpconfutils_extension_with "mssql" "mssql" 1 + phpconfutils_extension_with "ncurses" "ncurses" 1 + phpconfutils_extension_with "openssl" "ssl" 0 + phpconfutils_extension_with "openssl-dir" "ssl" 0 "/usr" + phpconfutils_extension_enable "pcntl" "pcntl" 1 + phpconfutils_extension_without "pcre-regex" "pcre" 0 + phpconfutils_extension_disable "pdo" "pdo" 0 + phpconfutils_extension_with "pgsql" "postgres" 1 + phpconfutils_extension_disable "posix" "posix" 0 + phpconfutils_extension_with "pspell" "spell" 1 + phpconfutils_extension_with "recode" "recode" 1 + phpconfutils_extension_disable "reflection" "reflection" 0 + phpconfutils_extension_disable "simplexml" "simplexml" 0 + phpconfutils_extension_enable "shmop" "sharedmem" 0 + phpconfutils_extension_with "snmp" "snmp" 1 + phpconfutils_extension_enable "soap" "soap" 1 + phpconfutils_extension_enable "sockets" "sockets" 1 + phpconfutils_extension_disable "spl" "spl" 0 + phpconfutils_extension_with "sybase" "sybase" 1 + phpconfutils_extension_with "sybase-ct" "sybase-ct" 1 + phpconfutils_extension_enable "sysvmsg" "sysvipc" 1 + phpconfutils_extension_enable "sysvsem" "sysvipc" 1 + phpconfutils_extension_enable "sysvshm" "sysvipc" 1 + phpconfutils_extension_with "tidy" "tidy" 1 + phpconfutils_extension_disable "tokenizer" "tokenizer" 0 + phpconfutils_extension_enable "wddx" "wddx" 1 + phpconfutils_extension_disable "xml" "xml" 0 + phpconfutils_extension_disable "xmlreader" "xmlreader" 0 + phpconfutils_extension_disable "xmlwriter" "xmlwriter" 0 + phpconfutils_extension_with "xmlrpc" "xmlrpc" 1 + phpconfutils_extension_with "xsl" "xsl" 1 + phpconfutils_extension_enable "zip" "zip" 1 + phpconfutils_extension_with "zlib" "zlib" 1 + phpconfutils_extension_enable "debug" "debug" 0 + + # DBA support + if use cdb || use berkdb || use flatfile || use gdbm || use inifile || use qdbm ; then + my_conf="${my_conf} --enable-dba${shared}" + fi + + # Tell PHP where the db.h is on FreeBSD +# if use berkdb ; then +# append-cppflags "-I$(db_includedir)" +# fi + + # DBA drivers support + phpconfutils_extension_with "cdb" "cdb" 0 + phpconfutils_extension_with "db4" "berkdb" 0 + phpconfutils_extension_with "flatfile" "flatfile" 0 + phpconfutils_extension_with "gdbm" "gdbm" 0 + phpconfutils_extension_with "inifile" "inifile" 0 + phpconfutils_extension_with "qdbm" "qdbm" 0 + + # Support for the GD graphics library + if use gd-external || phpconfutils_usecheck gd-external ; then + phpconfutils_extension_with "freetype-dir" "truetype" 0 "/usr" + phpconfutils_extension_with "t1lib" "truetype" 0 "/usr" + phpconfutils_extension_enable "gd-jis-conv" "cjk" 0 + phpconfutils_extension_with "gd" "gd-external" 1 "/usr" + else + phpconfutils_extension_with "freetype-dir" "truetype" 0 "/usr" + phpconfutils_extension_with "t1lib" "truetype" 0 "/usr" + phpconfutils_extension_enable "gd-jis-conv" "cjk" 0 + phpconfutils_extension_with "jpeg-dir" "gd" 0 "/usr" + phpconfutils_extension_with "png-dir" "gd" 0 "/usr" + phpconfutils_extension_with "xpm-dir" "xpm" 0 "/usr" + # enable gd last, so configure can pick up the previous settings + phpconfutils_extension_with "gd" "gd" 0 + fi + + # IMAP support + if use imap || phpconfutils_usecheck imap ; then + phpconfutils_extension_with "imap" "imap" 1 + phpconfutils_extension_with "imap-ssl" "ssl" 0 + fi + + # Interbase support + if use interbase ; then + my_conf="${my_conf} --with-interbase=/opt" + fi + + # Firebird support - see Bug 186791 + if use firebird ; then + my_conf="${my_conf} --with-interbase=/usr" + fi + + # LDAP support + if use ldap || phpconfutils_usecheck ldap ; then + if use oci8 ; then + phpconfutils_extension_with "ldap" "ldap" 1 "${ORACLE_HOME}" + else + phpconfutils_extension_with "ldap" "ldap" 1 + phpconfutils_extension_with "ldap-sasl" "ldap-sasl" 0 + fi + fi + + # MySQL support + if use mysql ; then + phpconfutils_extension_with "mysql" "mysql" 1 "/usr" + phpconfutils_extension_with "mysql-sock" "mysql" 0 "/var/run/mysqld/mysqld.sock" + fi + + # MySQLi support + phpconfutils_extension_with "mysqli" "mysqli" 1 "/usr/bin/mysql_config" + + # ODBC support + if use odbc || phpconfutils_usecheck odbc ; then + phpconfutils_extension_with "unixODBC" "odbc" 1 "/usr" + + phpconfutils_extension_with "adabas" "adabas" 1 + phpconfutils_extension_with "birdstep" "birdstep" 1 + phpconfutils_extension_with "dbmaker" "dbmaker" 1 + phpconfutils_extension_with "empress" "empress" 1 + if use empress || phpconfutils_usecheck empress ; then + phpconfutils_extension_with "empress-bcs" "empress-bcs" 0 + fi + phpconfutils_extension_with "esoob" "esoob" 1 + phpconfutils_extension_with "ibm-db2" "db2" 1 + phpconfutils_extension_with "iodbc" "iodbc" 1 "/usr" + phpconfutils_extension_with "sapdb" "sapdb" 1 + phpconfutils_extension_with "solid" "solid" 1 + fi + + # Oracle support + if use oci8 ; then + phpconfutils_extension_with "oci8" "oci8" 1 + fi + if use 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'`" + phpconfutils_extension_with "oci8" "oci8-instant-client" 1 "instantclient,/usr/lib/oracle/${OCI8IC_PKG}/client/lib" + fi + + # PDO support + if use pdo || phpconfutils_usecheck pdo ; then + phpconfutils_extension_with "pdo-dblib" "mssql" 1 + # The PDO-Firebird driver is broken and unmaintained upstream + # phpconfutils_extension_with "pdo-firebird" "firebird" 1 + phpconfutils_extension_with "pdo-mysql" "mysql" 1 "/usr" + if use oci8 ; then + phpconfutils_extension_with "pdo-oci" "oci8" 1 + fi + if use 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'`" + phpconfutils_extension_with "pdo-oci" "oci8-instant-client" 1 "instantclient,/usr,${OCI8IC_PKG}" + fi + phpconfutils_extension_with "pdo-odbc" "odbc" 1 "unixODBC,/usr" + phpconfutils_extension_with "pdo-pgsql" "postgres" 1 + phpconfutils_extension_with "pdo-sqlite" "sqlite" 1 "/usr" + fi + + # readline/libedit support + # You can use readline or libedit, but you can't use both + phpconfutils_extension_with "readline" "readline" 0 + phpconfutils_extension_with "libedit" "libedit" 0 + + # Session support + if ! use session && ! phpconfutils_usecheck session ; then + phpconfutils_extension_disable "session" "session" 0 + else + phpconfutils_extension_with "mm" "sharedmem" 0 + fi + + # SQLite support + if ! use sqlite && ! phpconfutils_usecheck sqlite ; then + phpconfutils_extension_without "sqlite" "sqlite" 0 + else + phpconfutils_extension_with "sqlite" "sqlite" 0 "/usr" + phpconfutils_extension_enable "sqlite-utf8" "unicode" 0 + fi + + # Fix ELF-related problems + if use pic || phpconfutils_usecheck pic ; then + einfo "Enabling PIC support" + my_conf="${my_conf} --with-pic" + fi + + # Catch CFLAGS problems + php_check_cflags + + # multilib support + if [[ $(get_libdir) != lib ]] ; then + my_conf="--with-libdir=$(get_libdir) ${my_conf}" + fi + + # Support user-passed configuration parameters + [[ -z "${EXTRA_ECONF}" ]] && EXTRA_ECONF="" + + # Set the correct compiler for cross-compilation + tc-export CC + + # We don't use econf, because we need to override all of its settings + ./configure --prefix=${destdir} --host=${CHOST} --mandir=${destdir}/man --infodir=${destdir}/info --sysconfdir=/etc --cache-file=./config.cache ${my_conf} ${EXTRA_ECONF} || die "configure failed" + emake || die "make failed" +} + +# @FUNCTION: php5_2-sapi_src_install +# @DESCRIPTION: +# Takes care of installing php (and its shared extensions if enabled). +php5_2-sapi_src_install() { + destdir=/usr/$(get_libdir)/php5 + + cd "${S}" + + addpredict /usr/share/snmp/mibs/.index + + # Install PHP + make INSTALL_ROOT="${D}" install-build install-headers install-programs || die "make install failed" + + # Install missing header files + if use unicode || phpconfutils_usecheck unicode ; then + dodir ${destdir}/include/php/ext/mbstring + insinto ${destdir}/include/php/ext/mbstring + for x in `ls "${S}/ext/mbstring/"*.h` ; do + file=`basename ${x}` + doins ext/mbstring/${file} + done + dodir ${destdir}/include/php/ext/mbstring/oniguruma + insinto ${destdir}/include/php/ext/mbstring/oniguruma + for x in `ls "${S}/ext/mbstring/oniguruma/"*.h` ; do + file=`basename ${x}` + doins ext/mbstring/oniguruma/${file} + done + dodir ${destdir}/include/php/ext/mbstring/libmbfl/mbfl + insinto ${destdir}/include/php/ext/mbstring/libmbfl/mbfl + for x in `ls "${S}/ext/mbstring/libmbfl/mbfl/"*.h` ; do + file=`basename ${x}` + doins ext/mbstring/libmbfl/mbfl/${file} + done + fi + + # Get the extension dir, if not already defined + [[ -z "${PHPEXTDIR}" ]] && PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`" + + # And install the modules to it + if use sharedext ; then + for x in `ls "${S}/modules/"*.so | sort` ; do + module=`basename ${x}` + modulename=${module/.so/} + insinto "${PHPEXTDIR}" + einfo "Installing PHP ${modulename} extension" + doins "modules/${module}" + done + fi + + # Generate the USE file for PHP + phpconfutils_generate_usefile + + # Create the directory where we'll put php5-only php scripts + keepdir /usr/share/php5 +} + +# @FUNCTION: php5_2-sapi_pkg_postinst +# @DESCRIPTION: +# Provides important information to users after install is finished. +php5_2-sapi_pkg_postinst() { + ewarn "If you have additional third party PHP extensions (such as" + ewarn "dev-php5/phpdbg) you may need to recompile them now." + ewarn + + if use sharedext ; then + ewarn "Make sure to use etc-update or dispatch-conf so that extension-specific" + ewarn "ini files get merged properly" + ewarn + fi + + if use kolab ; then + ewarn "Please note that kolab support is still experimental!" + ewarn "Issues specific to USE=kolab must be reported to Gentoo bugzilla only!" + ewarn + ewarn "Kolab groupware server requires annotations support for IMAP, which is enabled" + ewarn "by a third-party patch. Please do NOT report issues with the imap extension" + ewarn "to bugs.php.net until you have recompiled both PHP and net-libs/c-client" + ewarn "with USE=\"-kolab\" and confirmed that those issues still exist!" + ewarn + fi + + ewarn "USE=\"pic\" slows down PHP but has to be enabled on setups where TEXTRELs" + ewarn "are disabled (e.g. when using PaX in the kernel). On hardened profiles this" + ewarn "USE flag is enabled automatically" + ewarn +} |