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

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.20