/[gentoo-x86]/eclass/depend.php.eclass
Gentoo

Diff of /eclass/depend.php.eclass

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

Revision 1.16 Revision 1.30
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2011 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/depend.php.eclass,v 1.16 2006/08/07 07:10:16 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.30 2011/08/22 04:46:31 vapier Exp $
4# 4
5# ========================================================================
6#
7# depend.php.eclass 5# @ECLASS: depend.php.eclass
8# functions to allow ebuilds to depend on php4 and/or php5 6# @MAINTAINER:
9# 7# Gentoo PHP team <php-bugs@gentoo.org>
10# Author: Stuart Herbert 8# @AUTHOR:
11# <stuart@gentoo.org> 9# Author: Stuart Herbert <stuart@gentoo.org>
12# 10# Author: Luca Longinotti <chtekk@gentoo.org>
13# Author: Luca Longinotti 11# Author: Jakub Moc <jakub@gentoo.org> (documentation)
14# <chtekk@gentoo.org> 12# @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features.
15# 13# @DESCRIPTION:
16# Maintained by the PHP Herd <php-bugs@gentoo.org> 14# This eclass provides functions that allow ebuilds to depend on php5 and check
17# 15# for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install
18# ======================================================================== 16# documentation for PHP packages to php-specific location.
19 17
20inherit eutils phpconfutils 18inherit eutils phpconfutils
21 19
22# PHP4-only depend functions
23need_php4_cli() {
24 DEPEND="${DEPEND} =virtual/php-4*"
25 RDEPEND="${RDEPEND} =virtual/php-4*"
26 PHP_VERSION="4"
27}
28
29need_php4_httpd() {
30 DEPEND="${DEPEND} =virtual/httpd-php-4*"
31 RDEPEND="${RDEPEND} =virtual/httpd-php-4*"
32 PHP_VERSION="4"
33}
34
35need_php4() {
36 DEPEND="${DEPEND} =dev-lang/php-4*"
37 RDEPEND="${RDEPEND} =dev-lang/php-4*"
38 PHP_VERSION="4"
39 PHP_SHARED_CAT="php4"
40}
41
42# common settings go in here
43uses_php4() {
44 # cache this
45 libdir=$(get_libdir)
46
47 PHPIZE="/usr/${libdir}/php4/bin/phpize"
48 PHPCONFIG="/usr/${libdir}/php4/bin/php-config"
49 PHPCLI="/usr/${libdir}/php4/bin/php"
50 PHPCGI="/usr/${libdir}/php4/bin/php-cgi"
51 PHP_PKG="`best_version =dev-lang/php-4*`"
52 PHPPREFIX="/usr/${libdir}/php4"
53
54 einfo
55 einfo "Using ${PHP_PKG}"
56 einfo
57}
58
59# PHP5-only depend functions 20# PHP5-only depend functions
21
22# @FUNCTION: need_php5_cli
23# @DESCRIPTION:
24# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
25# with cli SAPI.
60need_php5_cli() { 26need_php5_cli() {
61 DEPEND="${DEPEND} =virtual/php-5*" 27 DEPEND="${DEPEND} =dev-lang/php-5*"
62 RDEPEND="${RDEPEND} =virtual/php-5*" 28 RDEPEND="${RDEPEND} =dev-lang/php-5*"
63 PHP_VERSION="5" 29 PHP_VERSION="5"
64} 30}
65 31
32# @FUNCTION: need_php5_httpd
33# @DESCRIPTION:
34# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
35# with either cgi or apache2 SAPI.
66need_php5_httpd() { 36need_php5_httpd() {
67 DEPEND="${DEPEND} =virtual/httpd-php-5*" 37 DEPEND="${DEPEND} =virtual/httpd-php-5*"
68 RDEPEND="${RDEPEND} =virtual/httpd-php-5*" 38 RDEPEND="${RDEPEND} =virtual/httpd-php-5*"
69 PHP_VERSION="5" 39 PHP_VERSION="5"
70} 40}
71 41
42# @FUNCTION: need_php5
43# @DESCRIPTION:
44# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
45# (with any SAPI).
72need_php5() { 46need_php5() {
73 DEPEND="${DEPEND} =dev-lang/php-5*" 47 DEPEND="${DEPEND} =dev-lang/php-5*"
74 RDEPEND="${RDEPEND} =dev-lang/php-5*" 48 RDEPEND="${RDEPEND} =dev-lang/php-5*"
75 PHP_VERSION="5" 49 PHP_VERSION="5"
76 PHP_SHARED_CAT="php5" 50 PHP_SHARED_CAT="php5"
83 57
84 PHPIZE="/usr/${libdir}/php5/bin/phpize" 58 PHPIZE="/usr/${libdir}/php5/bin/phpize"
85 PHPCONFIG="/usr/${libdir}/php5/bin/php-config" 59 PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
86 PHPCLI="/usr/${libdir}/php5/bin/php" 60 PHPCLI="/usr/${libdir}/php5/bin/php"
87 PHPCGI="/usr/${libdir}/php5/bin/php-cgi" 61 PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
88 PHP_PKG="`best_version =dev-lang/php-5*`" 62 PHP_PKG="$(best_version =dev-lang/php-5*)"
89 PHPPREFIX="/usr/${libdir}/php5" 63 PHPPREFIX="/usr/${libdir}/php5"
64 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
90 65
91 einfo 66 einfo
92 einfo "Using ${PHP_PKG}" 67 einfo "Using ${PHP_PKG}"
93 einfo 68 einfo
94} 69}
95 70
96# general PHP depend functions 71# general PHP depend functions
72
73# @FUNCTION: need_php_cli
74# @DESCRIPTION:
75# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
76# (any version) with cli SAPI.
97need_php_cli() { 77need_php_cli() {
98 DEPEND="${DEPEND} virtual/php" 78 DEPEND="${DEPEND} dev-lang/php"
99 RDEPEND="${RDEPEND} virtual/php" 79 RDEPEND="${RDEPEND} dev-lang/php"
100} 80}
101 81
82# @FUNCTION: need_php_httpd
83# @DESCRIPTION:
84# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
85# (any version) with either cgi or apache2 SAPI.
102need_php_httpd() { 86need_php_httpd() {
103 DEPEND="${DEPEND} virtual/httpd-php" 87 DEPEND="${DEPEND} virtual/httpd-php"
104 RDEPEND="${RDEPEND} virtual/httpd-php" 88 RDEPEND="${RDEPEND} virtual/httpd-php"
105} 89}
106 90
91# @FUNCTION: need_php
92# @DESCRIPTION:
93# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
94# (any version with any SAPI).
107need_php() { 95need_php() {
108 DEPEND="${DEPEND} dev-lang/php" 96 DEPEND="${DEPEND} dev-lang/php"
109 RDEPEND="${RDEPEND} dev-lang/php" 97 RDEPEND="${RDEPEND} dev-lang/php"
110 PHP_SHARED_CAT="php" 98 PHP_SHARED_CAT="php"
111} 99}
112 100
101# @FUNCTION: need_php_by_category
102# @DESCRIPTION:
103# Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version
104# determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or
105# dev-php5, respectively.
113need_php_by_category() { 106need_php_by_category() {
114 case "${CATEGORY}" in 107 case "${CATEGORY}" in
115 dev-php) need_php ;; 108 dev-php) need_php ;;
116 dev-php4) need_php4 ;;
117 dev-php5) need_php5 ;; 109 dev-php5) need_php5 ;;
118 *) die "I don't know which version of PHP packages in ${CATEGORY} require" 110 *) die "Version of PHP required by packages in category ${CATEGORY} unknown"
119 esac 111 esac
120} 112}
121 113
114
115# @FUNCTION: has_php
116# @DESCRIPTION:
122# Call this function from your pkg_setup, src_compile and src_install methods 117# Call this function from your pkg_setup, src_compile, src_install etc. if you
123# if you need to know where the PHP binaries are installed and their data 118# need to know which PHP version is being used and where the PHP binaries/data
124 119# are installed.
125has_php() { 120has_php() {
126 # If PHP_PKG is already set, then we have remembered our PHP settings
127 # from last time
128 if [[ -n ${PHP_PKG} ]] ; then
129 return
130 fi
131
132 if [[ -z ${PHP_VERSION} ]] ; then
133 # Detect which PHP version we have installed 121 # Detect which PHP version we have installed
134 if has_version '=dev-lang/php-5*' ; then 122 if has_version '=dev-lang/php-5*' ; then
135 PHP_VERSION="5" 123 PHP_VERSION="5"
136 elif has_version '=dev-lang/php-4*' ; then
137 PHP_VERSION="4"
138 else 124 else
139 die "Unable to find an installed dev-lang/php package" 125 die "Unable to find an installed dev-lang/php package"
140 fi
141 fi 126 fi
142 127
143 # If we get here, then PHP_VERSION tells us which version of PHP we 128 # If we get here, then PHP_VERSION tells us which version of PHP we
144 # want to use 129 # want to use
145 uses_php${PHP_VERSION} 130 uses_php${PHP_VERSION}
146} 131}
147 132
133# @FUNCTION: require_php_sapi_from
134# @USAGE: <list of SAPIs>
135# @DESCRIPTION:
148# Call this function from pkg_setup if your package only works with 136# Call this function from pkg_setup if your package only works with
149# specific SAPIs 137# specific SAPI(s) and specify a list of PHP SAPI USE flags that are
138# required (one or more from cli, cgi, apache2) as arguments.
139# Returns if any of the listed SAPIs have been installed, dies if none
140# of them is available.
150# 141#
151# $1 ... a list of PHP SAPI USE flags (cli, cgi, apache, apache2) 142# Unfortunately, if you want to be really sure that the required SAPI is
152# 143# provided by PHP, you will have to use this function or similar ones (like
153# Returns if any one of the listed SAPIs have been installed 144# require_php_cli or require_php_cgi) in pkg_setup until we are able to
154# Dies if none of the listed SAPIs have been installed 145# depend on USE flags being enabled. The above described need_php[45]_cli
155 146# and need_php[45]_httpd functions cannot guarantee these requirements.
147# See Bug 2272 for details.
156require_php_sapi_from() { 148require_php_sapi_from() {
157 has_php 149 has_php
158 150
159 local has_sapi="0" 151 local has_sapi="0"
160 local x 152 local x
179 eerror " $@" 171 eerror " $@"
180 eerror 172 eerror
181 die "No compatible PHP SAPIs found" 173 die "No compatible PHP SAPIs found"
182} 174}
183 175
176# @FUNCTION: require_php_with_use
177# @USAGE: <list of USE flags>
178# @DESCRIPTION:
184# Call this function from pkg_setup if your package requires PHP compiled 179# Call this function from pkg_setup if your package requires PHP compiled
185# with specific USE flags 180# with specific USE flags. Returns if all of the listed USE flags are enabled.
181# Dies if any of the listed USE flags are disabled.
182
183# @VARIABLE: PHPCHECKNODIE
184# @DESCRIPTION:
185# You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple
186# require_php_with_(any)_use checks without making the ebuild die on every failure.
187# This is useful in cases when certain PHP features are only required if specific
188# USE flag(s) are enabled for that ebuild.
189# @CODE
190# Example:
186# 191#
187# $1 ... a list of USE flags 192# local flags="pcre session snmp sockets wddx"
188# 193# use mysql && flags="${flags} mysql"
189# Returns if all of the listed USE flags are enabled 194# use postgres && flags="${flags} postgres"
190# Dies if any of the listed USE flags are disabled 195# if ! PHPCHECKNODIE="yes" require_php_with_use ${flags} \
191 196# || ! PHPCHECKNODIE="yes" require_php_with_any_use gd gd-external ; then
197# die "Re-install ${PHP_PKG} with ${flags} and either gd or gd-external"
198# fi
199# @CODE
192require_php_with_use() { 200require_php_with_use() {
193 has_php 201 has_php
194 202
195 local missing_use="" 203 local missing_use=""
196 local x 204 local x
197 205
198 einfo "Checking for required PHP feature(s) ..." 206 einfo "Checking for required PHP feature(s) ..."
199 207
200 for x in $@ ; do 208 for x in $@ ; do
209 case $x in
210 pcre|spl|reflection|mhash)
211 eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
212 eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break"
213 eqawarn "if you check the USE flags against PHP 5.3 ebuilds."
214 eqawarn "Please use USE dependencies from EAPI 2 instead"
215 ;;
216 esac
217
201 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then 218 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
202 einfo " Discovered missing USE flag: ${x}" 219 einfo " Discovered missing USE flag: ${x}"
203 missing_use="${missing_use} ${x}" 220 missing_use="${missing_use} ${x}"
204 fi 221 fi
205 done 222 done
223 else 240 else
224 return 1 241 return 1
225 fi 242 fi
226} 243}
227 244
245# @FUNCTION: require_php_with_any_use
246# @USAGE: <list of USE flags>
247# @DESCRIPTION:
228# Call this function from pkg_setup if your package requires PHP compiled 248# Call this function from pkg_setup if your package requires PHP compiled with
229# with any of specified USE flags
230#
231# $1 ... a list of USE flags
232#
233# Returns if any of the listed USE flags are enabled 249# any of specified USE flags. Returns if any of the listed USE flags are enabled.
234# Dies if all of the listed USE flags are disabled 250# Dies if all of the listed USE flags are disabled.
235
236require_php_with_any_use() { 251require_php_with_any_use() {
237 has_php 252 has_php
238 253
239 local missing_use="" 254 local missing_use=""
240 local x 255 local x
275# has_*() functions 290# has_*() functions
276# 291#
277# These functions return 0 if the condition is satisfied, 1 otherwise 292# These functions return 0 if the condition is satisfied, 1 otherwise
278# ======================================================================== 293# ========================================================================
279 294
295# @FUNCTION: has_zts
296# @DESCRIPTION:
280# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled 297# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled.
281 298# @RETURN: 0 if true, 1 otherwise
282has_zts() { 299has_zts() {
283 has_php 300 has_php
284 301
285 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then 302 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then
286 return 0 303 return 0
287 fi 304 fi
288 305
289 return 1 306 return 1
290} 307}
291 308
309# @FUNCTION: has_debug
310# @DESCRIPTION:
292# Check if our PHP was built with Hardened-PHP enabled 311# Check if our PHP was built with debug support enabled.
293 312# @RETURN: 0 if true, 1 otherwise
294has_hardenedphp() { 313has_debug() {
295 has_php 314 has_php
296 315
297 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then 316 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
298 return 0 317 return 0
299 fi 318 fi
300 319
301 return 1 320 return 1
302} 321}
303 322
323# @FUNCTION: has_concurrentmodphp
324# @DESCRIPTION:
304# Check if our PHP was built with debug support enabled 325# Check if our PHP was built with the concurrentmodphp support enabled.
305 326# @RETURN: 0 if true, 1 otherwise
306has_debug() { 327has_concurrentmodphp() {
307 has_php 328 has_php
308 329
309 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then 330 if built_with_use =${PHP_PKG} apache2 concurrentmodphp || phpconfutils_built_with_use =${PHP_PKG} apache2 concurrentmodphp ; then
310 return 0 331 return 0
311 fi 332 fi
312 333
313 return 1 334 return 1
314} 335}
317# require_*() functions 338# require_*() functions
318# 339#
319# These functions die() if PHP was built without the required features 340# These functions die() if PHP was built without the required features
320# ======================================================================== 341# ========================================================================
321 342
343# @FUNCTION: require_pdo
344# @DESCRIPTION:
322# Require a PHP built with PDO support (PHP5 only) 345# Require a PHP built with PDO support (PHP5 only).
323 346# This function is now redundant and DEPRECATED since
347# pdo-external use flag and pecl-pdo-* ebuilds were removed.
348# You should use require_php_with_use pdo instead now.
349# @RETURN: die if feature is missing
324require_pdo() { 350require_pdo() {
325 has_php 351 has_php
326
327 # Do we have PHP5 installed?
328 if [[ "${PHP_VERSION}" == "4" ]] ; then
329 eerror
330 eerror "This package requires PDO."
331 eerror "PDO is only available for PHP 5."
332 eerror "You must install =dev-lang/php-5.0* with"
333 eerror "the 'pdo-external' USE flag or you must"
334 eerror "install >=dev-lang/php-5.1 with either"
335 eerror "the 'pdo' or the 'pdo-external' USE flags"
336 eerror "turned on."
337 eerror
338 die "PHP 5 not installed"
339 fi
340 352
341 # Was PHP5 compiled with internal PDO support? 353 # Was PHP5 compiled with internal PDO support?
342 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then 354 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then
343 return 355 return
344 fi 356 else
345
346 # Ok, maybe PDO was built as an external extension?
347 if ( built_with_use =${PHP_PKG} pdo-external || phpconfutils_built_with_use =${PHP_PKG} pdo-external ) && has_version 'dev-php5/pecl-pdo' ; then
348 return
349 fi
350
351 # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
352 if has_version 'dev-php5/pecl-pdo' ; then
353 return
354 fi
355
356 # If we get here, then we have no PDO support
357 eerror 357 eerror
358 eerror "No PDO extension for PHP found." 358 eerror "No PDO extension for PHP found."
359 eerror "Please note that PDO only exists for PHP 5." 359 eerror "Please note that PDO only exists for PHP 5."
360 eerror "Please install a PDO extension for PHP 5," 360 eerror "Please install a PDO extension for PHP 5."
361 eerror "you must install =dev-lang/php-5.0* with" 361 eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"."
362 eerror "the 'pdo-external' USE flag or you must"
363 eerror "install >=dev-lang/php-5.1 with either"
364 eerror "the 'pdo' or the 'pdo-external' USE flags"
365 eerror "turned on."
366 eerror 362 eerror
367 die "No PDO extension for PHP 5 found" 363 die "No PDO extension for PHP 5 found"
364 fi
368} 365}
369 366
367# @FUNCTION: require_php_cli
368# @DESCRIPTION:
370# Determines which installed PHP version has the CLI SAPI enabled, 369# Determines which installed PHP version has the CLI SAPI enabled.
371# useful for PEAR stuff, or anything which needs to run PHP 370# Useful for PEAR stuff, or anything which needs to run PHP script
372# scripts depending on the CLI SAPI 371# depending on the CLI SAPI.
373 372# @RETURN: die if feature is missing
374require_php_cli() { 373require_php_cli() {
375 # If PHP_PKG is set, then we have remembered our PHP settings 374 # If PHP_PKG is set, then we have remembered our PHP settings
376 # from last time 375 # from last time
377 if [[ -n ${PHP_PKG} ]] ; then 376 if [[ -n ${PHP_PKG} ]] ; then
378 return 377 return
379 fi 378 fi
380 379
381 local PHP_PACKAGE_FOUND="" 380 local PHP_PACKAGE_FOUND=""
382 381
383 # Detect which PHP version we have installed
384 if has_version '=dev-lang/php-4*' ; then
385 PHP_PACKAGE_FOUND="1"
386 pkg="`best_version '=dev-lang/php-4*'`"
387 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
388 PHP_VERSION="4"
389 fi
390 fi
391
392 if has_version '=dev-lang/php-5*' ; then 382 if has_version '=dev-lang/php-5*' ; then
393 PHP_PACKAGE_FOUND="1" 383 PHP_PACKAGE_FOUND="1"
394 pkg="`best_version '=dev-lang/php-5*'`" 384 pkg="$(best_version '=dev-lang/php-5*')"
395 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then 385 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
396 PHP_VERSION="5" 386 PHP_VERSION="5"
397 fi 387 fi
398 fi 388 fi
399 389
400 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 390 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
401 die "Unable to find an installed dev-lang/php package" 391 die "Unable to find an installed dev-lang/php package"
402 fi 392 fi
403 393
404 if [[ -z ${PHP_VERSION} ]] ; then 394 if [[ -z ${PHP_VERSION} ]] ; then
405 die "No PHP CLI installed" 395 die "No PHP CLI installed. Re-emerge dev-lang/php with USE=cli."
406 fi 396 fi
407 397
408 # If we get here, then PHP_VERSION tells us which version of PHP we 398 # If we get here, then PHP_VERSION tells us which version of PHP we
409 # want to use 399 # want to use
410 uses_php${PHP_VERSION} 400 uses_php${PHP_VERSION}
411} 401}
412 402
403# @FUNCTION: require_php_cgi
404# @DESCRIPTION:
413# Determines which installed PHP version has the CGI SAPI enabled, 405# Determines which installed PHP version has the CGI SAPI enabled.
414# useful for anything which needs to run PHP scripts 406# Useful for anything which needs to run PHP scripts depending on the CGI SAPI.
415# depending on the CGI SAPI 407# @RETURN: die if feature is missing
416
417require_php_cgi() { 408require_php_cgi() {
418 # If PHP_PKG is set, then we have remembered our PHP settings 409 # If PHP_PKG is set, then we have remembered our PHP settings
419 # from last time 410 # from last time
420 if [[ -n ${PHP_PKG} ]] ; then 411 if [[ -n ${PHP_PKG} ]] ; then
421 return 412 return
422 fi 413 fi
423 414
424 local PHP_PACKAGE_FOUND="" 415 local PHP_PACKAGE_FOUND=""
425 416
426 # Detect which PHP version we have installed
427 if has_version '=dev-lang/php-4*' ; then
428 PHP_PACKAGE_FOUND="1"
429 pkg="`best_version '=dev-lang/php-4*'`"
430 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
431 PHP_VERSION="4"
432 fi
433 fi
434
435 if has_version '=dev-lang/php-5*' ; then 417 if has_version '=dev-lang/php-5*' ; then
436 PHP_PACKAGE_FOUND="1" 418 PHP_PACKAGE_FOUND="1"
437 pkg="`best_version '=dev-lang/php-5*'`" 419 pkg="$(best_version '=dev-lang/php-5*')"
438 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then 420 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
439 PHP_VERSION="5" 421 PHP_VERSION="5"
440 fi 422 fi
441 fi 423 fi
442 424
443 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 425 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
444 die "Unable to find an installed dev-lang/php package" 426 die "Unable to find an installed dev-lang/php package"
445 fi 427 fi
446 428
447 if [[ -z ${PHP_VERSION} ]] ; then 429 if [[ -z ${PHP_VERSION} ]] ; then
448 die "No PHP CGI installed" 430 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
449 fi 431 fi
450 432
451 # If we get here, then PHP_VERSION tells us which version of PHP we 433 # If we get here, then PHP_VERSION tells us which version of PHP we
452 # want to use 434 # want to use
453 uses_php${PHP_VERSION} 435 uses_php${PHP_VERSION}
454} 436}
455 437
438# @FUNCTION: require_sqlite
439# @DESCRIPTION:
456# Require a PHP built with SQLite support 440# Require a PHP built with SQLite support
457 441# @RETURN: die if feature is missing
458require_sqlite() { 442require_sqlite() {
459 has_php 443 has_php
460 444
461 # Has our PHP been built with SQLite support? 445 # Has our PHP been built with SQLite support?
462 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then 446 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then
463 return 447 return
464 fi
465
466 # Do we have pecl-sqlite installed for PHP4?
467 if [[ "${PHP_VERSION}" == "4" ]] ; then
468 if has_version 'dev-php4/pecl-sqlite' ; then
469 return
470 fi
471 fi 448 fi
472 449
473 # If we get here, then we don't have any SQLite support for PHP installed 450 # If we get here, then we don't have any SQLite support for PHP installed
474 eerror 451 eerror
475 eerror "No SQLite extension for PHP found." 452 eerror "No SQLite extension for PHP found."
478 eerror "'sqlite' USE flag when emerging dev-lang/php." 455 eerror "'sqlite' USE flag when emerging dev-lang/php."
479 eerror 456 eerror
480 die "No SQLite extension for PHP found" 457 die "No SQLite extension for PHP found"
481} 458}
482 459
460# @FUNCTION: require_gd
461# @DESCRIPTION:
483# Require a PHP built with GD support 462# Require a PHP built with GD support
484 463# @RETURN: die if feature is missing
485require_gd() { 464require_gd() {
486 has_php 465 has_php
487 466
488 # Do we have the internal GD support installed? 467 # Do we have the internal GD support installed?
489 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then 468 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then
510# Misc functions 489# Misc functions
511# 490#
512# These functions provide miscellaneous checks and functionality. 491# These functions provide miscellaneous checks and functionality.
513# ======================================================================== 492# ========================================================================
514 493
494# @FUNCTION: php_binary_extension
495# @DESCRIPTION:
515# Executes some checks needed when installing a binary PHP extension 496# Executes some checks needed when installing a binary PHP extension.
516
517php_binary_extension() { 497php_binary_extension() {
518 has_php 498 has_php
519 499
520 local PUSE_ENABLED="" 500 local PUSE_ENABLED=""
521 501
522 # Binary extensions do not support the change of PHP 502 # Binary extensions do not support the change of PHP
523 # API version, so they can't be installed when USE flags 503 # API version, so they can't be installed when USE flags
524 # are enabled which change the PHP API version, they also 504 # are enabled which change the PHP API version, they also
525 # don't provide correctly versioned symbols for our use 505 # don't provide correctly versioned symbols for our use
526 506
527 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then 507 if has_debug ; then
528 eerror
529 eerror "You cannot install binary PHP extensions"
530 eerror "when the 'hardenedphp' USE flag is enabled!"
531 eerror "Please reemerge dev-lang/php with the"
532 eerror "'hardenedphp' USE flag turned off."
533 eerror
534 PUSE_ENABLED="1"
535 fi
536
537 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
538 eerror 508 eerror
539 eerror "You cannot install binary PHP extensions" 509 eerror "You cannot install binary PHP extensions"
540 eerror "when the 'debug' USE flag is enabled!" 510 eerror "when the 'debug' USE flag is enabled!"
541 eerror "Please reemerge dev-lang/php with the" 511 eerror "Please reemerge dev-lang/php with the"
542 eerror "'debug' USE flag turned off." 512 eerror "'debug' USE flag turned off."
543 eerror 513 eerror
544 PUSE_ENABLED="1" 514 PUSE_ENABLED="1"
545 fi 515 fi
546 516
547 if built_with_use =${PHP_PKG} concurrentmodphp || phpconfutils_built_with_use =${PHP_PKG} concurrentmodphp ; then 517 if has_concurrentmodphp ; then
548 eerror 518 eerror
549 eerror "You cannot install binary PHP extensions when" 519 eerror "You cannot install binary PHP extensions when"
550 eerror "the 'concurrentmodphp' USE flag is enabled!" 520 eerror "the 'concurrentmodphp' USE flag is enabled!"
551 eerror "Please reemerge dev-lang/php with the" 521 eerror "Please reemerge dev-lang/php with the"
552 eerror "'concurrentmodphp' USE flag turned off." 522 eerror "'concurrentmodphp' USE flag turned off."
553 eerror 523 eerror
554 PUSE_ENABLED="1" 524 PUSE_ENABLED="1"
555 fi 525 fi
556 526
557 if [[ -n ${PUSE_ENABLED} ]] ; then 527 if [[ -n ${PUSE_ENABLED} ]] ; then
558 die "'hardenedphp' and/or 'debug' and/or 'concurrentmodphp' USE flags turned on!" 528 die "'debug' and/or 'concurrentmodphp' USE flags turned on!"
559 fi 529 fi
560} 530}
561 531
532# @FUNCTION: dodoc-php
533# @USAGE: <list of docs>
534# @DESCRIPTION:
562# Alternative to dodoc function for use in our PHP eclasses and 535# Alternative to dodoc function for use in our PHP eclasses and ebuilds.
563# ebuilds.
564# Stored here because depend.php gets always sourced everywhere 536# Stored here because depend.php gets always sourced everywhere in the PHP
565# in the PHP ebuilds and eclasses.
566# It simply is dodoc with a changed path to the docs. 537# ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
567# NOTE: no support for docinto is given! 538# NOTE: No support for docinto is provided!
568
569dodoc-php() { 539dodoc-php() {
570if [[ $# -lt 1 ]] ; then 540if [[ $# -lt 1 ]] ; then
571 echo "$0: at least one argument needed" 1>&2 541 echo "$0: at least one argument needed" 1>&2
572 exit 1 542 exit 1
573fi 543fi
574 544
575phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/" 545phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
576
577if [[ ! -d "${phpdocdir}" ]] ; then
578 install -d "${phpdocdir}"
579fi
580 546
581for x in $@ ; do 547for x in $@ ; do
582 if [[ -s "${x}" ]] ; then 548 if [[ -s "${x}" ]] ; then
583 install -m0644 "${x}" "${phpdocdir}" 549 insinto "${phpdocdir}"
550 doins "${x}"
584 gzip -f -9 "${phpdocdir}/${x##*/}" 551 gzip -f -9 "${D}/${phpdocdir}/${x##*/}"
585 elif [[ ! -e "${x}" ]] ; then 552 elif [[ ! -e "${x}" ]] ; then
586 echo "dodoc-php: ${x} does not exist" 1>&2 553 echo "dodoc-php: ${x} does not exist" 1>&2
587 fi 554 fi
588done 555done
589} 556}
557
558# @FUNCTION: dohtml-php
559# @USAGE: <list of html docs>
560# @DESCRIPTION:
561# Alternative to dohtml function for use in our PHP eclasses and ebuilds.
562# Stored here because depend.php gets always sourced everywhere in the PHP
563# ebuilds and eclasses. It simply is dohtml with a changed path to the docs.
564# NOTE: No support for [-a|-A|-p|-x] options is provided!
565dohtml-php() {
566if [[ $# -lt 1 ]] ; then
567 echo "$0: at least one argument needed" 1>&2
568 exit 1
569fi
570
571phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
572
573for x in $@ ; do
574 if [[ -s "${x}" ]] ; then
575 insinto "${phphtmldir}"
576 doins "${x}"
577 elif [[ ! -e "${x}" ]] ; then
578 echo "dohtml-php: ${x} does not exist" 1>&2
579 fi
580done
581}

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.20