| 1 |
# Copyright 1999-2007 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext-source-r2.eclass,v 1.2 2010/10/06 19:58:45 olemarkus Exp $
|
| 4 |
#
|
| 5 |
# Author: Tal Peer <coredumb@gentoo.org>
|
| 6 |
# Author: Stuart Herbert <stuart@gentoo.org>
|
| 7 |
# Author: Luca Longinotti <chtekk@gentoo.org>
|
| 8 |
# Author: Jakub Moc <jakub@gentoo.org> (documentation)
|
| 9 |
# Author: Ole Markus With <olemarkus@gentoo.org>
|
| 10 |
|
| 11 |
# @ECLASS: php-ext-source-r2.eclass
|
| 12 |
# @MAINTAINER:
|
| 13 |
# Gentoo PHP team <php-bugs@gentoo.org>
|
| 14 |
# @BLURB: A unified interface for compiling and installing standalone PHP extensions.
|
| 15 |
# @DESCRIPTION:
|
| 16 |
# This eclass provides a unified interface for compiling and installing standalone
|
| 17 |
# PHP extensions (modules).
|
| 18 |
|
| 19 |
inherit flag-o-matic autotools depend.php
|
| 20 |
|
| 21 |
EXPORT_FUNCTIONS src_unpack src_configure src_compile src_install
|
| 22 |
|
| 23 |
# @ECLASS-VARIABLE: PHP_EXT_NAME
|
| 24 |
# @DESCRIPTION:
|
| 25 |
# The extension name. This must be set, otherwise the eclass dies.
|
| 26 |
# Only automagically set by php-ext-pecl-r1.eclass, so unless your ebuild
|
| 27 |
# inherits that eclass, you must set this manually before inherit.
|
| 28 |
[[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
|
| 29 |
|
| 30 |
DEPEND=">=sys-devel/m4-1.4.3
|
| 31 |
>=sys-devel/libtool-1.5.18"
|
| 32 |
RDEPEND=""
|
| 33 |
|
| 34 |
# Because of USE deps, we require at least EAPI 2
|
| 35 |
case ${EAPI} in
|
| 36 |
2|3) ;;
|
| 37 |
*)
|
| 38 |
die "php-ext-source-r2 is not compatible with EAPI=${EAPI}"
|
| 39 |
esac
|
| 40 |
|
| 41 |
# @ECLASS-VARIABLE: PHP_EXT_NAME
|
| 42 |
# @DESCRIPTION:
|
| 43 |
# The extension name. This must be set, otherwise the eclass dies.
|
| 44 |
# Only automagically set by php-ext-pecl-r2.eclass, so unless your ebuild
|
| 45 |
# inherits that eclass, you must set this manually before inherit.
|
| 46 |
[[ -z "${PHP_EXT_NAME}" ]] && die "No module name specified for the php-ext-source-r2 eclass"
|
| 47 |
|
| 48 |
# @ECLASS-VARIABLE: PHP_EXT_INI
|
| 49 |
# @DESCRIPTION:
|
| 50 |
# Controls whether or not to add a line to php.ini for the extension.
|
| 51 |
# Defaults to "yes" and should not be changed in most cases.
|
| 52 |
[[ -z "${PHP_EXT_INI}" ]] && PHP_EXT_INI="yes"
|
| 53 |
|
| 54 |
# @ECLASS-VARIABLE: PHP_EXT_ZENDEXT
|
| 55 |
# @DESCRIPTION:
|
| 56 |
# Controls whether the extension is a ZendEngine extension or not.
|
| 57 |
# Defaults to "no" and if you don't know what is it, you don't need it.
|
| 58 |
[[ -z "${PHP_EXT_ZENDEXT}" ]] && PHP_EXT_ZENDEXT="no"
|
| 59 |
|
| 60 |
# @ECLASS-VARIABLE: USE_PHP
|
| 61 |
# @DESCRIPTION:
|
| 62 |
# Lists the PHP slots compatibile the extension is compatibile with
|
| 63 |
[[ -z "${USE_PHP}" ]] && USE_PHP="php5-2 php5-3"
|
| 64 |
|
| 65 |
#Make sure at least one target is installed. Abuses USE dependencies.
|
| 66 |
for target in ${USE_PHP}; do
|
| 67 |
IUSE="${IUSE} php_targets_${target}"
|
| 68 |
target=${target/+}
|
| 69 |
SELFDEPEND="${SELFDEPEND} =${CATEGORY}/${PF}[php_targets_${target}]"
|
| 70 |
slot=${target/php}
|
| 71 |
slot=${slot/-/.}
|
| 72 |
PHPDEPEND="${PHPDEPEND}
|
| 73 |
php_targets_${target}? ( dev-lang/php:${slot} )"
|
| 74 |
done
|
| 75 |
|
| 76 |
RDEPEND="${RDEPEND}
|
| 77 |
|| ( ${SELFDEPEND} )
|
| 78 |
${PHPDEPEND}"
|
| 79 |
|
| 80 |
|
| 81 |
# @FUNCTION: php-ext-source-r2_src_unpack
|
| 82 |
# @DESCRIPTION:
|
| 83 |
# runs standard src_unpack + _phpize
|
| 84 |
#
|
| 85 |
# @VARIABLE: PHP_EXT_SKIP_PHPIZE
|
| 86 |
# @DESCRIPTION:
|
| 87 |
# phpize will be run by default for all ebuilds that use
|
| 88 |
# php-ext-source-r1_src_unpack
|
| 89 |
# Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize.
|
| 90 |
php-ext-source-r2_src_unpack() {
|
| 91 |
unpack ${A}
|
| 92 |
local slot orig_s="$S"
|
| 93 |
for slot in $(php_get_slots); do
|
| 94 |
cp -r "${orig_s}" "${WORKDIR}/${slot}"
|
| 95 |
php_init_slot_env ${slot}
|
| 96 |
if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
|
| 97 |
php-ext-source-r2_phpize
|
| 98 |
fi
|
| 99 |
done
|
| 100 |
}
|
| 101 |
|
| 102 |
# @FUNCTION php-ext-source-r2_phpize
|
| 103 |
# @DESCRIPTION:
|
| 104 |
# Runs phpize and autotools in addition to the standard src_unpack
|
| 105 |
php-ext-source-r2_phpize() {
|
| 106 |
# Create configure out of config.m4
|
| 107 |
# I wish I could run this to solve #329071, but I cannot
|
| 108 |
#autotools_run_tool ${PHPIZE}
|
| 109 |
${PHPIZE}
|
| 110 |
# force run of libtoolize and regeneration of related autotools
|
| 111 |
# files (bug 220519)
|
| 112 |
rm aclocal.m4
|
| 113 |
eautoreconf
|
| 114 |
}
|
| 115 |
|
| 116 |
# @FUNCTION: php-ext-source-r2_src_configure
|
| 117 |
# @DESCRIPTION:
|
| 118 |
# Takes care of standard configure for PHP extensions (modules).
|
| 119 |
#
|
| 120 |
# @VARIABLE: my_conf
|
| 121 |
# @DESCRIPTION:
|
| 122 |
# Set this in the ebuild to pass configure options to econf.
|
| 123 |
php-ext-source-r2_src_configure() {
|
| 124 |
local slot
|
| 125 |
for slot in $(php_get_slots); do
|
| 126 |
php_init_slot_env ${slot}
|
| 127 |
# Set the correct config options
|
| 128 |
# We cannot use econf here, phpize/php-config deals with setting
|
| 129 |
# --prefix etc to whatever the php slot was configured to use
|
| 130 |
./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile"
|
| 131 |
done
|
| 132 |
}
|
| 133 |
|
| 134 |
# @FUNCTION: php-ext-source-r2_src_compile
|
| 135 |
# @DESCRIPTION:
|
| 136 |
# Takes care of standard compile for PHP extensions (modules).
|
| 137 |
php-ext-source-r2_src_compile() {
|
| 138 |
# net-snmp creates this file #324739
|
| 139 |
addpredict /usr/share/snmp/mibs/.index
|
| 140 |
# shm extension createss a semaphore file #173574
|
| 141 |
addpredict /session_mm_cli0.sem
|
| 142 |
local slot
|
| 143 |
for slot in $(php_get_slots); do
|
| 144 |
php_init_slot_env ${slot}
|
| 145 |
emake || die "Unable to make code"
|
| 146 |
|
| 147 |
done
|
| 148 |
}
|
| 149 |
|
| 150 |
# @FUNCTION: php-ext-source-r1_src_install
|
| 151 |
# @DESCRIPTION:
|
| 152 |
# Takes care of standard install for PHP extensions (modules).
|
| 153 |
|
| 154 |
# @VARIABLE: DOCS
|
| 155 |
# @DESCRIPTION:
|
| 156 |
# Set in ebuild if you wish to install additional, package-specific documentation.
|
| 157 |
php-ext-source-r2_src_install() {
|
| 158 |
local slot
|
| 159 |
for slot in $(php_get_slots); do
|
| 160 |
php_init_slot_env ${slot}
|
| 161 |
|
| 162 |
# Let's put the default module away
|
| 163 |
insinto "${EXT_DIR}"
|
| 164 |
newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension"
|
| 165 |
|
| 166 |
local doc
|
| 167 |
for doc in ${DOCS} ; do
|
| 168 |
[[ -s ${doc} ]] && dodoc ${doc}
|
| 169 |
done
|
| 170 |
|
| 171 |
done
|
| 172 |
php-ext-source-r2_createinifiles
|
| 173 |
}
|
| 174 |
|
| 175 |
|
| 176 |
php_get_slots() {
|
| 177 |
local s slot
|
| 178 |
for slot in ${USE_PHP}; do
|
| 179 |
use php_targets_${slot} && s+=" ${slot/-/.}"
|
| 180 |
done
|
| 181 |
echo $s
|
| 182 |
}
|
| 183 |
|
| 184 |
php_init_slot_env() {
|
| 185 |
libdir=$(get_libdir)
|
| 186 |
|
| 187 |
PHPIZE="/usr/${libdir}/${1}/bin/phpize"
|
| 188 |
PHPCONFIG="/usr/${libdir}/${1}/bin/php-config"
|
| 189 |
PHPCLI="/usr/${libdir}/${1}/bin/php"
|
| 190 |
PHPCGI="/usr/${libdir}/${1}/bin/php-cgi"
|
| 191 |
PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
|
| 192 |
PHPPREFIX="/usr/${libdir}/${slot}"
|
| 193 |
EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
|
| 194 |
|
| 195 |
S="${WORKDIR}/${1}"
|
| 196 |
cd "${S}"
|
| 197 |
}
|
| 198 |
|
| 199 |
php-ext-source-r2_buildinilist() {
|
| 200 |
# Work out the list of <ext>.ini files to edit/add to
|
| 201 |
if [[ -z "${PHPSAPILIST}" ]] ; then
|
| 202 |
PHPSAPILIST="apache2 cli cgi fpm"
|
| 203 |
fi
|
| 204 |
|
| 205 |
PHPINIFILELIST=""
|
| 206 |
local x
|
| 207 |
for x in ${PHPSAPILIST} ; do
|
| 208 |
if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then
|
| 209 |
PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
|
| 210 |
fi
|
| 211 |
done
|
| 212 |
}
|
| 213 |
|
| 214 |
# @FUNCTION: php-ext-source-r2_createinifiles
|
| 215 |
# @DESCRIPTION:
|
| 216 |
# Builds ini files for every enabled slot and SAPI
|
| 217 |
php-ext-source-r2_createinifiles() {
|
| 218 |
local slot
|
| 219 |
for slot in $(php_get_slots); do
|
| 220 |
php_init_slot_env ${slot}
|
| 221 |
# Pull in the PHP settings
|
| 222 |
|
| 223 |
# Build the list of <ext>.ini files to edit/add to
|
| 224 |
php-ext-source-r2_buildinilist ${slot}
|
| 225 |
|
| 226 |
# Add the needed lines to the <ext>.ini files
|
| 227 |
if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
|
| 228 |
php-ext-source-r2_addextension "${PHP_EXT_NAME}.so"
|
| 229 |
fi
|
| 230 |
|
| 231 |
# Symlink the <ext>.ini files from ext/ to ext-active/
|
| 232 |
for inifile in ${PHPINIFILELIST} ; do
|
| 233 |
inidir="${inifile/${PHP_EXT_NAME}.ini/}"
|
| 234 |
inidir="${inidir/ext/ext-active}"
|
| 235 |
dodir "/${inidir}"
|
| 236 |
dosym "/${inifile}" "/${inifile/ext/ext-active}"
|
| 237 |
done
|
| 238 |
|
| 239 |
# Add support for installing PHP files into a version dependant directory
|
| 240 |
PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}"
|
| 241 |
done
|
| 242 |
}
|
| 243 |
|
| 244 |
php-ext-source-r2_addextension() {
|
| 245 |
if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
|
| 246 |
# We need the full path for ZendEngine extensions
|
| 247 |
# and we need to check for debugging enabled!
|
| 248 |
if has_zts ; then
|
| 249 |
if has_debug ; then
|
| 250 |
ext_type="zend_extension_debug_ts"
|
| 251 |
else
|
| 252 |
ext_type="zend_extension_ts"
|
| 253 |
fi
|
| 254 |
ext_file="${EXT_DIR}/${1}"
|
| 255 |
else
|
| 256 |
if has_debug ; then
|
| 257 |
ext_type="zend_extension_debug"
|
| 258 |
else
|
| 259 |
ext_type="zend_extension"
|
| 260 |
fi
|
| 261 |
ext_file="${EXT_DIR}/${1}"
|
| 262 |
fi
|
| 263 |
|
| 264 |
# php-5.3 unifies zend_extension loading and just requires the
|
| 265 |
# zend_extension keyword with no suffix
|
| 266 |
# TODO: drop previous code and this check once <php-5.3 support is
|
| 267 |
# discontinued
|
| 268 |
if has_version '>=dev-lang/php-5.3' ; then
|
| 269 |
ext_type="zend_extension"
|
| 270 |
fi
|
| 271 |
else
|
| 272 |
# We don't need the full path for normal extensions!
|
| 273 |
ext_type="extension"
|
| 274 |
ext_file="${1}"
|
| 275 |
fi
|
| 276 |
|
| 277 |
php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added"
|
| 278 |
}
|
| 279 |
|
| 280 |
# $1 - Setting name
|
| 281 |
# $2 - Setting value
|
| 282 |
# $3 - File to add to
|
| 283 |
# $4 - Sanitized text to output
|
| 284 |
php-ext-source-r2_addtoinifile() {
|
| 285 |
if [[ ! -d $(dirname ${3}) ]] ; then
|
| 286 |
mkdir -p $(dirname ${3})
|
| 287 |
fi
|
| 288 |
|
| 289 |
# Are we adding the name of a section?
|
| 290 |
if [[ ${1:0:1} == "[" ]] ; then
|
| 291 |
echo "${1}" >> "${3}"
|
| 292 |
my_added="${1}"
|
| 293 |
else
|
| 294 |
echo "${1}=${2}" >> "${3}"
|
| 295 |
my_added="${1}=${2}"
|
| 296 |
fi
|
| 297 |
|
| 298 |
if [[ -z "${4}" ]] ; then
|
| 299 |
einfo "Added '${my_added}' to /${3}"
|
| 300 |
else
|
| 301 |
einfo "${4} to /${3}"
|
| 302 |
fi
|
| 303 |
|
| 304 |
insinto /$(dirname ${3})
|
| 305 |
doins "${3}"
|
| 306 |
}
|
| 307 |
|
| 308 |
# @FUNCTION: php-ext-source-r2_addtoinifiles
|
| 309 |
# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
|
| 310 |
# @DESCRIPTION:
|
| 311 |
# Add value settings to php.ini file installed by the extension (module).
|
| 312 |
# You can also add a [section], see examples below.
|
| 313 |
#
|
| 314 |
# @CODE
|
| 315 |
# Add some settings for the extension:
|
| 316 |
#
|
| 317 |
# php-ext-source-r2_addtoinifiles "zend_optimizer.optimization_level" "15"
|
| 318 |
# php-ext-source-r2_addtoinifiles "zend_optimizer.enable_loader" "0"
|
| 319 |
# php-ext-source-r2_addtoinifiles "zend_optimizer.disable_licensing" "0"
|
| 320 |
#
|
| 321 |
# Adding values to a section in php.ini file installed by the extension:
|
| 322 |
#
|
| 323 |
# php-ext-source-r2_addtoinifiles "[Debugger]"
|
| 324 |
# php-ext-source-r2_addtoinifiles "debugger.enabled" "on"
|
| 325 |
# php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on"
|
| 326 |
# @CODE
|
| 327 |
php-ext-source-r2_addtoinifiles() {
|
| 328 |
local x
|
| 329 |
for x in ${PHPINIFILELIST} ; do
|
| 330 |
php-ext-source-r2_addtoinifile "${1}" "${2}" "${x}" "${3}"
|
| 331 |
done
|
| 332 |
}
|