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

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

  ViewVC Help
Powered by ViewVC 1.1.20