| 1 |
chtekk |
1.6 |
# Copyright 1999-2007 Gentoo Foundation
|
| 2 |
stuart |
1.1 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
jokey |
1.9 |
# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-base-r1.eclass,v 1.8 2007/09/01 15:58:17 jokey Exp $
|
| 4 |
stuart |
1.1 |
#
|
| 5 |
|
|
# Author: Tal Peer <coredumb@gentoo.org>
|
| 6 |
|
|
# Author: Stuart Herbert <stuart@gentoo.org>
|
| 7 |
chtekk |
1.6 |
# Author: Luca Longinotti <chtekk@gentoo.org>
|
| 8 |
jokey |
1.8 |
# Author: Jakub Moc <jakub@gentoo.org> (documentation)
|
| 9 |
|
|
|
| 10 |
|
|
# @ECLASS: php-ext-base-r1.eclass
|
| 11 |
|
|
# @MAINTAINER:
|
| 12 |
|
|
# Gentoo PHP team <php-bugs@gentoo.org>
|
| 13 |
|
|
# @BLURB: A unified interface for adding standalone PHP extensions.
|
| 14 |
|
|
# @DESCRIPTION:
|
| 15 |
|
|
# This eclass provides a unified interface for adding standalone
|
| 16 |
|
|
# PHP extensions (modules) to the php.ini files on your system.
|
| 17 |
stuart |
1.1 |
#
|
| 18 |
chtekk |
1.4 |
# Combined with php-ext-source-r1, we have a standardised solution for supporting
|
| 19 |
|
|
# PHP extensions.
|
| 20 |
stuart |
1.1 |
|
| 21 |
|
|
inherit depend.php
|
| 22 |
|
|
|
| 23 |
|
|
EXPORT_FUNCTIONS src_install
|
| 24 |
|
|
|
| 25 |
jokey |
1.8 |
# @ECLASS-VARIABLE: PHP_EXT_NAME
|
| 26 |
|
|
# @DESCRIPTION:
|
| 27 |
|
|
# The extension name. This must be set, otherwise the eclass dies.
|
| 28 |
|
|
# Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild
|
| 29 |
|
|
# inherits that eclass, you must set this manually before inherit.
|
| 30 |
chtekk |
1.6 |
[[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-base-r1 eclass"
|
| 31 |
stuart |
1.1 |
|
| 32 |
jokey |
1.8 |
# @ECLASS-VARIABLE: PHP_EXT_INI
|
| 33 |
|
|
# @DESCRIPTION:
|
| 34 |
|
|
# Controls whether or not to add a line to php.ini for the extension.
|
| 35 |
|
|
# Defaults to "yes" and should not be changed in most cases.
|
| 36 |
chtekk |
1.6 |
[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
|
| 37 |
stuart |
1.1 |
|
| 38 |
jokey |
1.8 |
# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
|
| 39 |
|
|
# @DESCRIPTION:
|
| 40 |
|
|
# Controls whether the extension is a ZendEngine extension or not.
|
| 41 |
|
|
# Defaults to "no" and if you don't know what is it, you don't need it.
|
| 42 |
chtekk |
1.6 |
[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
|
| 43 |
stuart |
1.1 |
|
| 44 |
jokey |
1.8 |
|
| 45 |
stuart |
1.1 |
php-ext-base-r1_buildinilist() {
|
| 46 |
chtekk |
1.6 |
# Work out the list of <ext>.ini files to edit/add to
|
| 47 |
|
|
if [[ -z "${PHPSAPILIST}" ]] ; then
|
| 48 |
chtekk |
1.7 |
PHPSAPILIST="apache2 cli cgi"
|
| 49 |
stuart |
1.1 |
fi
|
| 50 |
|
|
|
| 51 |
chtekk |
1.6 |
PHPINIFILELIST=""
|
| 52 |
stuart |
1.1 |
|
| 53 |
|
|
for x in ${PHPSAPILIST} ; do
|
| 54 |
chtekk |
1.6 |
if [[ -f "/etc/php/${x}-php${PHP_VERSION}/php.ini" ]] ; then
|
| 55 |
stuart |
1.1 |
PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-php${PHP_VERSION}/ext/${PHP_EXT_NAME}.ini"
|
| 56 |
|
|
fi
|
| 57 |
|
|
done
|
| 58 |
|
|
}
|
| 59 |
|
|
|
| 60 |
jokey |
1.8 |
# @FUNCTION: php-ext-base-r1_src_install
|
| 61 |
|
|
# @DESCRIPTION:
|
| 62 |
|
|
# Takes care of standard install for PHP extensions (modules).
|
| 63 |
stuart |
1.1 |
php-ext-base-r1_src_install() {
|
| 64 |
chtekk |
1.6 |
# Pull in the PHP settings
|
| 65 |
stuart |
1.1 |
has_php
|
| 66 |
|
|
addpredict /usr/share/snmp/mibs/.index
|
| 67 |
chtekk |
1.6 |
|
| 68 |
|
|
# Build the list of <ext>.ini files to edit/add to
|
| 69 |
stuart |
1.1 |
php-ext-base-r1_buildinilist
|
| 70 |
chtekk |
1.6 |
|
| 71 |
|
|
# Add the needed lines to the <ext>.ini files
|
| 72 |
|
|
if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
|
| 73 |
stuart |
1.1 |
php-ext-base-r1_addextension "${PHP_EXT_NAME}.so"
|
| 74 |
|
|
fi
|
| 75 |
chtekk |
1.6 |
|
| 76 |
|
|
# Symlink the <ext>.ini files from ext/ to ext-active/
|
| 77 |
chtekk |
1.3 |
for inifile in ${PHPINIFILELIST} ; do
|
| 78 |
chtekk |
1.6 |
inidir="${inifile/${PHP_EXT_NAME}.ini/}"
|
| 79 |
|
|
inidir="${inidir/ext/ext-active}"
|
| 80 |
chtekk |
1.3 |
dodir "/${inidir}"
|
| 81 |
|
|
dosym "/${inifile}" "/${inifile/ext/ext-active}"
|
| 82 |
|
|
done
|
| 83 |
chtekk |
1.6 |
|
| 84 |
|
|
# Add support for installing PHP files into a version dependant directory
|
| 85 |
stuart |
1.1 |
PHP_EXT_SHARED_DIR="/usr/share/${PHP_SHARED_CAT}/${PHP_EXT_NAME}"
|
| 86 |
|
|
}
|
| 87 |
|
|
|
| 88 |
|
|
php-ext-base-r1_addextension() {
|
| 89 |
chtekk |
1.6 |
if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
|
| 90 |
|
|
# We need the full path for ZendEngine extensions
|
| 91 |
|
|
# and we need to check for debugging enabled!
|
| 92 |
kloeri |
1.2 |
if has_zts ; then
|
| 93 |
chtekk |
1.6 |
if has_debug ; then
|
| 94 |
|
|
ext_type="zend_extension_debug_ts"
|
| 95 |
|
|
else
|
| 96 |
|
|
ext_type="zend_extension_ts"
|
| 97 |
|
|
fi
|
| 98 |
stuart |
1.1 |
ext_file="${EXT_DIR}/$1"
|
| 99 |
|
|
else
|
| 100 |
chtekk |
1.6 |
if has_debug ; then
|
| 101 |
|
|
ext_type="zend_extension_debug"
|
| 102 |
|
|
else
|
| 103 |
|
|
ext_type="zend_extension"
|
| 104 |
|
|
fi
|
| 105 |
stuart |
1.1 |
ext_file="${EXT_DIR}/$1"
|
| 106 |
|
|
fi
|
| 107 |
|
|
else
|
| 108 |
chtekk |
1.6 |
# We don't need the full path for normal extensions!
|
| 109 |
stuart |
1.1 |
ext_type="extension"
|
| 110 |
|
|
ext_file="$1"
|
| 111 |
|
|
fi
|
| 112 |
|
|
|
| 113 |
|
|
php-ext-base-r1_addtoinifiles "${ext_type}" "${ext_file}" "Extension added"
|
| 114 |
|
|
}
|
| 115 |
|
|
|
| 116 |
chtekk |
1.6 |
# $1 - Setting name
|
| 117 |
|
|
# $2 - Setting value
|
| 118 |
|
|
# $3 - File to add to
|
| 119 |
|
|
# $4 - Sanitized text to output
|
| 120 |
stuart |
1.1 |
php-ext-base-r1_addtoinifile() {
|
| 121 |
jokey |
1.9 |
if [[ ! -d $(dirname $3) ]] ; then
|
| 122 |
|
|
mkdir -p $(dirname $3)
|
| 123 |
stuart |
1.1 |
fi
|
| 124 |
|
|
|
| 125 |
chtekk |
1.6 |
# Are we adding the name of a section?
|
| 126 |
stuart |
1.1 |
if [[ ${1:0:1} == "[" ]] ; then
|
| 127 |
chtekk |
1.6 |
echo "$1" >> "$3"
|
| 128 |
stuart |
1.1 |
my_added="$1"
|
| 129 |
|
|
else
|
| 130 |
chtekk |
1.6 |
echo "$1=$2" >> "$3"
|
| 131 |
stuart |
1.1 |
my_added="$1=$2"
|
| 132 |
|
|
fi
|
| 133 |
|
|
|
| 134 |
chtekk |
1.6 |
if [[ -z "$4" ]] ; then
|
| 135 |
stuart |
1.1 |
einfo "Added '$my_added' to /$3"
|
| 136 |
|
|
else
|
| 137 |
|
|
einfo "$4 to /$3"
|
| 138 |
|
|
fi
|
| 139 |
|
|
|
| 140 |
jokey |
1.9 |
insinto /$(dirname $3)
|
| 141 |
chtekk |
1.6 |
doins "$3"
|
| 142 |
stuart |
1.1 |
}
|
| 143 |
|
|
|
| 144 |
jokey |
1.8 |
# @FUNCTION: php-ext-base-r1_addtoinifiles
|
| 145 |
|
|
# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
|
| 146 |
|
|
# @DESCRIPTION:
|
| 147 |
|
|
# Add value settings to php.ini file installed by the extension (module).
|
| 148 |
|
|
# You can also add a [section], see examples below.
|
| 149 |
|
|
#
|
| 150 |
|
|
# @CODE
|
| 151 |
|
|
# Add some settings for the extension:
|
| 152 |
|
|
#
|
| 153 |
|
|
# php-ext-base-r1_addtoinifiles "zend_optimizer.optimization_level" "15"
|
| 154 |
|
|
# php-ext-base-r1_addtoinifiles "zend_optimizer.enable_loader" "0"
|
| 155 |
|
|
# php-ext-base-r1_addtoinifiles "zend_optimizer.disable_licensing" "0"
|
| 156 |
|
|
#
|
| 157 |
|
|
# Adding values to a section in php.ini file installed by the extension:
|
| 158 |
|
|
#
|
| 159 |
|
|
# php-ext-base-r1_addtoinifiles "[Debugger]"
|
| 160 |
|
|
# php-ext-base-r1_addtoinifiles "debugger.enabled" "on"
|
| 161 |
|
|
# php-ext-base-r1_addtoinifiles "debugger.profiler_enabled" "on"
|
| 162 |
|
|
# @CODE
|
| 163 |
stuart |
1.1 |
php-ext-base-r1_addtoinifiles() {
|
| 164 |
|
|
for x in ${PHPINIFILELIST} ; do
|
| 165 |
|
|
php-ext-base-r1_addtoinifile "$1" "$2" "$x" "$3"
|
| 166 |
|
|
done
|
| 167 |
|
|
}
|