/[gentoo-x86]/eclass/php-ext-source-r2.eclass
Gentoo

Diff of /eclass/php-ext-source-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20