/[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.13
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.13 2011/08/15 12:48:27 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)
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
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-3 php5-2"
64
65# @ECLASS-VARIABLE: PHP_EXT_OPTIONAL_USE
66# @DESCRIPTION:
67# If set, this is the USE flag that the PHP dependencies are behind
68# Most commonly set as PHP_EXT_OPTIONAL_USE=php to get the dependencies behind
69# USE=php.
70
71# @ECLASS-VARIABLE: PHP_EXT_S
72# @DESCRIPTION:
73# The relative location of the temporary build directory for the PHP extension within
74# the source package. This is useful for packages that bundle the PHP extension.
75# Defaults to ${S}
76[[ -z "${PHP_EXT_S}" ]] && PHP_EXT_S="${S}"
64 77
65#Make sure at least one target is installed. Abuses USE dependencies. 78#Make sure at least one target is installed. Abuses USE dependencies.
66for target in $USE_PHP; do 79for target in ${USE_PHP}; do
67 IUSE="${IUSE} php_targets_$target" 80 IUSE="${IUSE} php_targets_${target}"
68 target=${target/+} 81 target=${target/+}
69 SELFDEPEND="$SELFDEPEND =$CATEGORY/$PF[php_targets_$target]" 82 SELFDEPEND="${SELFDEPEND} =${CATEGORY}/${PF}[php_targets_${target}]"
70 slot=${target/php} 83 slot=${target/php}
71 slot=${slot/-/.} 84 slot=${slot/-/.}
72 PHPDEPEND="$PHPDEPEND 85 PHPDEPEND="${PHPDEPEND}
73 php_targets_$target? ( dev-lang/php:${slot} )" 86 php_targets_${target}? ( dev-lang/php:${slot} )"
74done 87done
75 88
76RDEPEND="${RDEPEND} 89RDEPEND="${RDEPEND}
90 ${PHP_EXT_OPTIONAL_USE}${PHP_EXT_OPTIONAL_USE:+? ( }
77 || ( $SELFDEPEND ) 91 || ( ${SELFDEPEND} )
78 $PHPDEPEND" 92 ${PHPDEPEND}
93 ${PHP_EXT_OPTIONAL_USE:+ )}"
79 94
80 95
81# @FUNCTION: php-ext-source-r2_src_unpack 96# @FUNCTION: php-ext-source-r2_src_unpack
82# @DESCRIPTION: 97# @DESCRIPTION:
83# runs standard src_unpack + _phpize 98# runs standard src_unpack + _phpize
84# 99#
85# @VARIABLE: PHP_EXT_SKIP_PHPIZE 100# @VARIABLE: PHP_EXT_SKIP_PHPIZE
86# @DESCRIPTION: 101# @DESCRIPTION:
87# phpize will be run by default for all ebuilds that use 102# phpize will be run by default for all ebuilds that use
88# php-ext-source-r1_src_unpack 103# php-ext-source-r2_src_unpack
89# Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize. 104# Set PHP_EXT_SKIP_PHPIZE="yes" in your ebuild if you do not want to run phpize.
90php-ext-source-r2_src_unpack() { 105php-ext-source-r2_src_unpack() {
91 unpack ${A} 106 unpack ${A}
92 local slot orig_s="$S" 107 local slot orig_s="${PHP_EXT_S}"
93 for slot in $(php_get_slots); do 108 for slot in $(php_get_slots); do
94 cp -r "$orig_s" "${WORKDIR}/$slot" 109 cp -r "${orig_s}" "${WORKDIR}/${slot}"
110 done
111}
112
113php-ext-source-r2_src_prepare() {
114 local slot orig_s="${PHP_EXT_S}"
115 for slot in $(php_get_slots); do
95 php_init_slot_env $slot 116 php_init_slot_env ${slot}
96 if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
97 php-ext-source-r2_phpize 117 php-ext-source-r2_phpize
98 fi
99 done 118 done
100} 119}
101 120
102# @FUNCTION php-ext-source-r2_phpize 121# @FUNCTION php-ext-source-r2_phpize
103# @DESCRIPTION: 122# @DESCRIPTION:
104# Runs phpize and autotools in addition to the standard src_unpack 123# Runs phpize and autotools in addition to the standard src_unpack
105php-ext-source-r2_phpize() { 124php-ext-source-r2_phpize() {
125 if [[ "${PHP_EXT_SKIP_PHPIZE}" != 'yes' ]] ; then
106 # Create configure out of config.m4 126 # Create configure out of config.m4
107 # I wish I could run this to solve #329071, but I cannot 127 # I wish I could run this to solve #329071, but I cannot
108 #autotools_run_tool ${PHPIZE} 128 #autotools_run_tool ${PHPIZE}
109 ${PHPIZE} 129 ${PHPIZE}
110 # force run of libtoolize and regeneration of related autotools 130 # force run of libtoolize and regeneration of related autotools
111 # files (bug 220519) 131 # files (bug 220519)
112 rm aclocal.m4 132 rm aclocal.m4
113 eautoreconf 133 eautoreconf
134 fi
114} 135}
115 136
116# @FUNCTION: php-ext-source-r2_src_configure 137# @FUNCTION: php-ext-source-r2_src_configure
117# @DESCRIPTION: 138# @DESCRIPTION:
118# Takes care of standard configure for PHP extensions (modules). 139# Takes care of standard configure for PHP extensions (modules).
121# @DESCRIPTION: 142# @DESCRIPTION:
122# Set this in the ebuild to pass configure options to econf. 143# Set this in the ebuild to pass configure options to econf.
123php-ext-source-r2_src_configure() { 144php-ext-source-r2_src_configure() {
124 local slot 145 local slot
125 for slot in $(php_get_slots); do 146 for slot in $(php_get_slots); do
126 php_init_slot_env $slot 147 php_init_slot_env ${slot}
127 # Set the correct config options 148 # Set the correct config options
128 # We cannot use econf here, phpize/php-config deals with setting 149 # We cannot use econf here, phpize/php-config deals with setting
129 # --prefix etc to whatever the php slot was configured to use 150 # --prefix etc to whatever the php slot was configured to use
151 echo ./configure --with-php-config=${PHPCONFIG} ${my_conf}
130 ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile" 152 ./configure --with-php-config=${PHPCONFIG} ${my_conf} || die "Unable to configure code to compile"
131 done 153 done
132} 154}
133 155
134# @FUNCTION: php-ext-source-r2_src_compile 156# @FUNCTION: php-ext-source-r2_src_compile
137php-ext-source-r2_src_compile() { 159php-ext-source-r2_src_compile() {
138 # net-snmp creates this file #324739 160 # net-snmp creates this file #324739
139 addpredict /usr/share/snmp/mibs/.index 161 addpredict /usr/share/snmp/mibs/.index
140 # shm extension createss a semaphore file #173574 162 # shm extension createss a semaphore file #173574
141 addpredict /session_mm_cli0.sem 163 addpredict /session_mm_cli0.sem
142 local slot 164 local slot
143 for slot in $(php_get_slots); do 165 for slot in $(php_get_slots); do
144 php_init_slot_env $slot 166 php_init_slot_env ${slot}
145 emake || die "Unable to make code" 167 emake || die "Unable to make code"
146 168
147 done 169 done
148} 170}
149 171
155# @DESCRIPTION: 177# @DESCRIPTION:
156# Set in ebuild if you wish to install additional, package-specific documentation. 178# Set in ebuild if you wish to install additional, package-specific documentation.
157php-ext-source-r2_src_install() { 179php-ext-source-r2_src_install() {
158 local slot 180 local slot
159 for slot in $(php_get_slots); do 181 for slot in $(php_get_slots); do
160 php_init_slot_env $slot 182 php_init_slot_env ${slot}
161 183
162 # Let's put the default module away 184 # Let's put the default module away
163 insinto "${EXT_DIR}" 185 insinto "${EXT_DIR}"
164 newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension" 186 newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so" || die "Unable to install extension"
165 187
188 local doc
166 for doc in ${DOCS} ; do 189 for doc in ${DOCS} ; do
167 [[ -s ${doc} ]] && dodoc ${doc} 190 [[ -s ${doc} ]] && dodoc ${doc}
168 done 191 done
169 192
170 done 193 done
171 php-ext-source-r2_createinifiles 194 php-ext-source-r2_createinifiles
172} 195}
173 196
174 197
175php_get_slots() { 198php_get_slots() {
176 local s
177 local slot 199 local s slot
178 for slot in $USE_PHP; do 200 for slot in ${USE_PHP}; do
179 use php_targets_$slot && s+=" ${slot/-/.}" 201 use php_targets_${slot} && s+=" ${slot/-/.}"
180 done 202 done
181 echo $s 203 echo $s
182} 204}
183 205
184php_init_slot_env() { 206php_init_slot_env() {
185 libdir=$(get_libdir) 207 libdir=$(get_libdir)
186 208
187 PHPIZE="/usr/${libdir}/$1/bin/phpize" 209 PHPIZE="/usr/${libdir}/${1}/bin/phpize"
188 PHPCONFIG="/usr/${libdir}/$1/bin/php-config" 210 PHPCONFIG="/usr/${libdir}/${1}/bin/php-config"
189 PHPCLI="/usr/${libdir}/$1/bin/php" 211 PHPCLI="/usr/${libdir}/${1}/bin/php"
190 PHPCGI="/usr/${libdir}/$1/bin/php-cgi" 212 PHPCGI="/usr/${libdir}/${1}/bin/php-cgi"
191 PHP_PKG="$(best_version =dev-lang/php-${1:3}*)" 213 PHP_PKG="$(best_version =dev-lang/php-${1:3}*)"
192 PHPPREFIX="/usr/${libdir}/$slot" 214 PHPPREFIX="/usr/${libdir}/${slot}"
193 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" 215 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
216 PHP_CURRENTSLOT=${1:3}
194 217
195 S="${WORKDIR}/$1" 218 PHP_EXT_S="${WORKDIR}/${1}"
196 cd $S 219 cd "${PHP_EXT_S}"
197} 220}
198 221
199php-ext-source-r2_buildinilist() { 222php-ext-source-r2_buildinilist() {
200 # Work out the list of <ext>.ini files to edit/add to 223 # Work out the list of <ext>.ini files to edit/add to
201 if [[ -z "${PHPSAPILIST}" ]] ; then 224 if [[ -z "${PHPSAPILIST}" ]] ; then
202 PHPSAPILIST="apache2 cli cgi fpm" 225 PHPSAPILIST="apache2 cli cgi fpm"
203 fi 226 fi
204 227
205 PHPINIFILELIST="" 228 PHPINIFILELIST=""
206 229 local x
207 for x in ${PHPSAPILIST} ; do 230 for x in ${PHPSAPILIST} ; do
208 if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then 231 if [[ -f "/etc/php/${x}-${1}/php.ini" ]] ; then
209 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini" 232 PHPINIFILELIST="${PHPINIFILELIST} etc/php/${x}-${1}/ext/${PHP_EXT_NAME}.ini"
210 fi 233 fi
211 done 234 done
235 PHPFULLINIFILELIST="${PHPFULLINIFILELIST} ${PHPINIFILELIST}"
212} 236}
213 237
214# @FUNCTION: php-ext-source-r2_createinifiles 238# @FUNCTION: php-ext-source-r2_createinifiles
215# @DESCRIPTION: 239# @DESCRIPTION:
216# Builds ini files for every enabled slot and SAPI 240# Builds ini files for every enabled slot and SAPI
217php-ext-source-r2_createinifiles() { 241php-ext-source-r2_createinifiles() {
218 local slot 242 local slot
219 for slot in $(php_get_slots); do 243 for slot in $(php_get_slots); do
220 php_init_slot_env $slot 244 php_init_slot_env ${slot}
221 # Pull in the PHP settings 245 # Pull in the PHP settings
222 246
223 # Build the list of <ext>.ini files to edit/add to 247 # Build the list of <ext>.ini files to edit/add to
224 php-ext-source-r2_buildinilist $slot 248 php-ext-source-r2_buildinilist ${slot}
249
225 250
226 # Add the needed lines to the <ext>.ini files 251 # Add the needed lines to the <ext>.ini files
252 local file
227 if [[ "${PHP_EXT_INI}" = "yes" ]] ; then 253 if [[ "${PHP_EXT_INI}" = "yes" ]] ; then
254 for file in ${PHPINIFILELIST}; do
228 php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" 255 php-ext-source-r2_addextension "${PHP_EXT_NAME}.so" "${file}"
256 done
229 fi 257 fi
258
230 259
231 # Symlink the <ext>.ini files from ext/ to ext-active/ 260 # Symlink the <ext>.ini files from ext/ to ext-active/
261 local inifile
232 for inifile in ${PHPINIFILELIST} ; do 262 for inifile in ${PHPINIFILELIST} ; do
263 if [[ -n "${PHP_EXT_INIFILE}" ]]; then
264 cat "${FILESDIR}/${PHP_EXT_INIFILE}" > "${inifile}"
265 einfo "Added content of ${FILESDIR}/${PHP_EXT_INIFILE} to ${inifile}"
266 fi
267
268
269
270
233 inidir="${inifile/${PHP_EXT_NAME}.ini/}" 271 inidir="${inifile/${PHP_EXT_NAME}.ini/}"
234 inidir="${inidir/ext/ext-active}" 272 inidir="${inidir/ext/ext-active}"
235 dodir "/${inidir}" 273 dodir "/${inidir}"
236 dosym "/${inifile}" "/${inifile/ext/ext-active}" 274 dosym "/${inifile}" "/${inifile/ext/ext-active}"
237 done 275 done
238 276
239 # Add support for installing PHP files into a version dependant directory 277 # Add support for installing PHP files into a version dependant directory
240 PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}" 278 PHP_EXT_SHARED_DIR="/usr/share/php/${PHP_EXT_NAME}"
241 done 279 done
280
242} 281}
243 282
244php-ext-source-r2_addextension() { 283php-ext-source-r2_addextension() {
245 if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then 284 if [[ "${PHP_EXT_ZENDEXT}" = "yes" ]] ; then
246 # We need the full path for ZendEngine extensions 285 # We need the full path for ZendEngine extensions
247 # and we need to check for debugging enabled! 286 # and we need to check for debugging enabled!
248 if has_zts ; then 287 if has_version "dev-lang/php:${PHP_CURRENTSLOT}[threads]" ; then
249 if has_debug ; then 288 if has_version "dev-lang/php:${PHP_CURRENTSLOT}[debug]" ; then
250 ext_type="zend_extension_debug_ts" 289 ext_type="zend_extension_debug_ts"
251 else 290 else
252 ext_type="zend_extension_ts" 291 ext_type="zend_extension_ts"
253 fi 292 fi
254 ext_file="${EXT_DIR}/$1" 293 ext_file="${EXT_DIR}/${1}"
255 else 294 else
256 if has_debug ; then 295 if has_version "dev-lang/php:${PHP_CURRENTSLOT}[debug]"; then
257 ext_type="zend_extension_debug" 296 ext_type="zend_extension_debug"
258 else 297 else
259 ext_type="zend_extension" 298 ext_type="zend_extension"
260 fi 299 fi
261 ext_file="${EXT_DIR}/$1" 300 ext_file="${EXT_DIR}/${1}"
262 fi 301 fi
263 302
264 # php-5.3 unifies zend_extension loading and just requires the 303 # php-5.3 unifies zend_extension loading and just requires the
265 # zend_extension keyword with no suffix 304 # zend_extension keyword with no suffix
266 # TODO: drop previous code and this check once <php-5.3 support is 305 # TODO: drop previous code and this check once <php-5.3 support is
269 ext_type="zend_extension" 308 ext_type="zend_extension"
270 fi 309 fi
271 else 310 else
272 # We don't need the full path for normal extensions! 311 # We don't need the full path for normal extensions!
273 ext_type="extension" 312 ext_type="extension"
274 ext_file="$1" 313 ext_file="${1}"
275 fi 314 fi
276 315
277 php-ext-source-r2_addtoinifiles "${ext_type}" "${ext_file}" "Extension added" 316 php-ext-source-r2_addtoinifile "${ext_type}" "${ext_file}" "${2}" "Extension added"
278} 317}
279 318
280# $1 - Setting name 319# $1 - Setting name
281# $2 - Setting value 320# $2 - Setting value
282# $3 - File to add to 321# $3 - File to add to
283# $4 - Sanitized text to output 322# $4 - Sanitized text to output
284php-ext-source-r2_addtoinifile() { 323php-ext-source-r2_addtoinifile() {
324 local inifile="${WORKDIR}/${3}"
285 if [[ ! -d $(dirname $3) ]] ; then 325 if [[ ! -d $(dirname ${inifile}) ]] ; then
286 mkdir -p $(dirname $3) 326 mkdir -p $(dirname ${inifile})
287 fi 327 fi
288 328
289 # Are we adding the name of a section? 329 # Are we adding the name of a section?
290 if [[ ${1:0:1} == "[" ]] ; then 330 if [[ ${1:0:1} == "[" ]] ; then
291 echo "$1" >> "$3" 331 echo "${1}" >> "${inifile}"
292 my_added="$1" 332 my_added="${1}"
293 else 333 else
294 echo "$1=$2" >> "$3" 334 echo "${1}=${2}" >> "${inifile}"
295 my_added="$1=$2" 335 my_added="${1}=${2}"
296 fi 336 fi
297 337
298 if [[ -z "$4" ]] ; then 338 if [[ -z "${4}" ]] ; then
299 einfo "Added '$my_added' to /$3" 339 einfo "Added '${my_added}' to /${3}"
300 else 340 else
301 einfo "$4 to /$3" 341 einfo "${4} to /${3}"
302 fi 342 fi
303 343
304 insinto /$(dirname $3) 344 insinto /$(dirname ${3})
305 doins "$3" 345 doins "${inifile}"
306} 346}
307 347
308# @FUNCTION: php-ext-source-r2_addtoinifiles 348# @FUNCTION: php-ext-source-r2_addtoinifiles
309# @USAGE: <setting name> <setting value> [message to output]; or just [section name] 349# @USAGE: <setting name> <setting value> [message to output]; or just [section name]
310# @DESCRIPTION: 350# @DESCRIPTION:
323# php-ext-source-r2_addtoinifiles "[Debugger]" 363# php-ext-source-r2_addtoinifiles "[Debugger]"
324# php-ext-source-r2_addtoinifiles "debugger.enabled" "on" 364# php-ext-source-r2_addtoinifiles "debugger.enabled" "on"
325# php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on" 365# php-ext-source-r2_addtoinifiles "debugger.profiler_enabled" "on"
326# @CODE 366# @CODE
327php-ext-source-r2_addtoinifiles() { 367php-ext-source-r2_addtoinifiles() {
368 local x
328 for x in ${PHPINIFILELIST} ; do 369 for x in ${PHPFULLINIFILELIST} ; do
329 php-ext-source-r2_addtoinifile "$1" "$2" "$x" "$3" 370 php-ext-source-r2_addtoinifile "${1}" "${2}" "${x}" "${3}"
330 done 371 done
331} 372}

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

  ViewVC Help
Powered by ViewVC 1.1.20