/[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.13 Revision 1.21
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.13 2006/04/20 12:15:35 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.21 2007/09/01 15:58:17 jokey 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"
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"
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
197 268
198 einfo "Checking for required PHP feature(s):" 269 einfo "Checking for required PHP feature(s) ..."
199 270
200 for x in $@ ; do 271 for x in $@ ; do
201 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then 272 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
202 einfo " Discovered missing USE flag ${x}" 273 einfo " Discovered missing USE flag: ${x}"
203 missing_use="${missing_use} ${x}" 274 missing_use="${missing_use} ${x}"
204 fi 275 fi
205 done 276 done
206 277
207 if [[ -z ${missing_use} ]] ; then 278 if [[ -z "${missing_use}" ]] ; then
279 if [[ -z "${PHPCHECKNODIE}" ]] ; then
208 return 280 return
281 else
282 return 0
209 fi 283 fi
284 fi
210 285
286 if [[ -z "${PHPCHECKNODIE}" ]] ; then
211 eerror 287 eerror
212 eerror "${PHP_PKG} needs to be re-installed with all of the following" 288 eerror "${PHP_PKG} needs to be re-installed with all of the following"
213 eerror "USE flags enabled:" 289 eerror "USE flags enabled:"
214 eerror 290 eerror
215 eerror " $@" 291 eerror " $@"
216 eerror 292 eerror
217 die "Missing PHP USE flags found" 293 die "Missing PHP USE flags found"
294 else
295 return 1
296 fi
218} 297}
219 298
299# @FUNCTION: require_php_with_any_use
300# @USAGE: <list of USE flags>
301# @DESCRIPTION:
220# 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
221# with any of specified USE flags
222#
223# $1 ... a list of USE flags
224#
225# 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.
226# Dies if all of the listed USE flags are disabled 304# Dies if all of the listed USE flags are disabled.
227
228require_php_with_any_use() { 305require_php_with_any_use() {
229 has_php 306 has_php
230 307
231 local missing_use="" 308 local missing_use=""
232 local x 309 local x
233 310
234 einfo "Checking for required PHP feature(s):" 311 einfo "Checking for required PHP feature(s) ..."
235 312
236 for x in $@ ; do 313 for x in $@ ; do
237 if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then 314 if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
238 einfo " USE flag ${x} is enabled, ok ..." 315 einfo " USE flag ${x} is enabled, ok ..."
239 return 316 return
240 else 317 else
241 missing_use="${missing_use} ${x}" 318 missing_use="${missing_use} ${x}"
242 fi 319 fi
243 done 320 done
244 321
245 if [[ -z ${missing_use} ]] ; then 322 if [[ -z "${missing_use}" ]] ; then
323 if [[ -z "${PHPCHECKNODIE}" ]] ; then
246 return 324 return
325 else
326 return 0
247 fi 327 fi
328 fi
248 329
330 if [[ -z "${PHPCHECKNODIE}" ]] ; then
249 eerror 331 eerror
250 eerror "${PHP_PKG} needs to be re-installed with any of the following" 332 eerror "${PHP_PKG} needs to be re-installed with any of the following"
251 eerror "USE flags enabled:" 333 eerror "USE flags enabled:"
252 eerror 334 eerror
253 eerror " $@" 335 eerror " $@"
254 eerror 336 eerror
255 die "Missing PHP USE flags found" 337 die "Missing PHP USE flags found"
338 else
339 return 1
340 fi
256} 341}
257 342
258# ======================================================================== 343# ========================================================================
259# has_*() functions 344# has_*() functions
260# 345#
261# These functions return 0 if the condition is satisfied, 1 otherwise 346# These functions return 0 if the condition is satisfied, 1 otherwise
262# ======================================================================== 347# ========================================================================
263 348
349# @FUNCTION: has_zts
350# @DESCRIPTION:
264# 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.
265 352# @RETURN: 0 if true, 1 otherwise
266has_zts() { 353has_zts() {
267 has_php 354 has_php
268 355
269 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
270 return 0 357 return 0
271 fi 358 fi
272 359
273 return 1 360 return 1
274} 361}
275 362
363# @FUNCTION: has_debug
364# @DESCRIPTION:
276# Check if our PHP was built with Hardened-PHP enabled 365# Check if our PHP was built with debug support enabled.
277 366# @RETURN: 0 if true, 1 otherwise
278has_hardenedphp() { 367has_debug() {
279 has_php 368 has_php
280 369
281 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
282 return 0 371 return 0
283 fi 372 fi
284 373
285 return 1 374 return 1
286} 375}
287 376
377# @FUNCTION: has_concurrentmodphp
378# @DESCRIPTION:
288# Check if our PHP was built with debug support enabled 379# Check if our PHP was built with the concurrentmodphp support enabled.
289 380# @RETURN: 0 if true, 1 otherwise
290has_debug() { 381has_concurrentmodphp() {
291 has_php 382 has_php
292 383
293 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
294 return 0 385 return 0
295 fi 386 fi
296 387
297 return 1 388 return 1
298} 389}
301# require_*() functions 392# require_*() functions
302# 393#
303# These functions die() if PHP was built without the required features 394# These functions die() if PHP was built without the required features
304# ======================================================================== 395# ========================================================================
305 396
397# @FUNCTION: require_pdo
398# @DESCRIPTION:
306# Require a PHP built with PDO support (PHP5 only) 399# Require a PHP built with PDO support (PHP5 only).
307 400# @RETURN: die if feature is missing
308require_pdo() { 401require_pdo() {
309 has_php 402 has_php
310 403
311 # Do we have PHP5 installed? 404 # Do we have PHP5 installed?
312 if [[ "${PHP_VERSION}" == "4" ]] ; then 405 if [[ "${PHP_VERSION}" == "4" ]] ; then
313 eerror 406 eerror
314 eerror "This package requires PDO." 407 eerror "This package requires PDO."
315 eerror "PDO is only available for PHP 5." 408 eerror "PDO is only available for PHP 5."
316 eerror "You must install =dev-lang/php-5.0* with" 409 eerror "You must install >=dev-lang/php-5.1 with"
317 eerror "the 'pdo-external' USE flag or you must"
318 eerror "install >=dev-lang/php-5.1 with either"
319 eerror "the 'pdo' or the 'pdo-external' USE flags" 410 eerror "either the 'pdo' or the 'pdo-external'"
320 eerror "turned on." 411 eerror "USE flags turned on."
321 eerror 412 eerror
322 die "PHP 5 not installed" 413 die "PHP 5 not installed"
323 fi 414 fi
324 415
325 # Was PHP5 compiled with internal PDO support? 416 # Was PHP5 compiled with internal PDO support?
335 # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support 426 # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
336 if has_version 'dev-php5/pecl-pdo' ; then 427 if has_version 'dev-php5/pecl-pdo' ; then
337 return 428 return
338 fi 429 fi
339 430
340 # If we get here, then we have no PDO support 431 # If we get here, then we don't have PDO support
341 eerror 432 eerror
342 eerror "No PDO extension for PHP found." 433 eerror "No PDO extension for PHP found."
343 eerror "Please note that PDO only exists for PHP 5." 434 eerror "Please note that PDO only exists for PHP 5."
344 eerror "Please install a PDO extension for PHP 5," 435 eerror "Please install a PDO extension for PHP 5,"
345 eerror "you must install =dev-lang/php-5.0* with" 436 eerror "you must install >=dev-lang/php-5.1 with"
346 eerror "the 'pdo-external' USE flag or you must"
347 eerror "install >=dev-lang/php-5.1 with either"
348 eerror "the 'pdo' or the 'pdo-external' USE flags" 437 eerror "either the 'pdo' or the 'pdo-external'"
349 eerror "turned on." 438 eerror "USE flags turned on."
350 eerror 439 eerror
351 die "No PDO extension for PHP 5 found" 440 die "No PDO extension for PHP 5 found"
352} 441}
353 442
443# @FUNCTION: require_php_cli
444# @DESCRIPTION:
354# Determines which installed PHP version has the CLI SAPI enabled, 445# Determines which installed PHP version has the CLI SAPI enabled.
355# useful for PEAR stuff, or anything which needs to run PHP 446# Useful for PEAR stuff, or anything which needs to run PHP script
356# scripts depending on the CLI SAPI 447# depending on the CLI SAPI.
357 448# @RETURN: die if feature is missing
358require_php_cli() { 449require_php_cli() {
359 # If PHP_PKG is set, then we have remembered our PHP settings 450 # If PHP_PKG is set, then we have remembered our PHP settings
360 # from last time 451 # from last time
361 if [[ -n ${PHP_PKG} ]] ; then 452 if [[ -n ${PHP_PKG} ]] ; then
362 return 453 return
384 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 475 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
385 die "Unable to find an installed dev-lang/php package" 476 die "Unable to find an installed dev-lang/php package"
386 fi 477 fi
387 478
388 if [[ -z ${PHP_VERSION} ]] ; then 479 if [[ -z ${PHP_VERSION} ]] ; then
389 die "No PHP CLI installed" 480 die "No PHP CLI installed. Re-emerge dev-lang/php with USE=cli."
390 fi 481 fi
391 482
392 # If we get here, then PHP_VERSION tells us which version of PHP we 483 # If we get here, then PHP_VERSION tells us which version of PHP we
393 # want to use 484 # want to use
394 uses_php${PHP_VERSION} 485 uses_php${PHP_VERSION}
395} 486}
396 487
488# @FUNCTION: require_php_cgi
489# @DESCRIPTION:
397# Determines which installed PHP version has the CGI SAPI enabled, 490# Determines which installed PHP version has the CGI SAPI enabled.
398# useful for anything which needs to run PHP scripts 491# Useful for anything which needs to run PHP scripts depending on the CGI SAPI.
399# depending on the CGI SAPI 492# @RETURN: die if feature is missing
400
401require_php_cgi() { 493require_php_cgi() {
402 # If PHP_PKG is set, then we have remembered our PHP settings 494 # If PHP_PKG is set, then we have remembered our PHP settings
403 # from last time 495 # from last time
404 if [[ -n ${PHP_PKG} ]] ; then 496 if [[ -n ${PHP_PKG} ]] ; then
405 return 497 return
427 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then 519 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
428 die "Unable to find an installed dev-lang/php package" 520 die "Unable to find an installed dev-lang/php package"
429 fi 521 fi
430 522
431 if [[ -z ${PHP_VERSION} ]] ; then 523 if [[ -z ${PHP_VERSION} ]] ; then
432 die "No PHP CGI installed" 524 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
433 fi 525 fi
434 526
435 # If we get here, then PHP_VERSION tells us which version of PHP we 527 # If we get here, then PHP_VERSION tells us which version of PHP we
436 # want to use 528 # want to use
437 uses_php${PHP_VERSION} 529 uses_php${PHP_VERSION}
438} 530}
439 531
532# @FUNCTION: require_sqlite
533# @DESCRIPTION:
440# Require a PHP built with SQLite support 534# Require a PHP built with SQLite support
441 535# @RETURN: die if feature is missing
442require_sqlite() { 536require_sqlite() {
443 has_php 537 has_php
444 538
445 # Has our PHP been built with SQLite support? 539 # Has our PHP been built with SQLite support?
446 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then 540 if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then
462 eerror "'sqlite' USE flag when emerging dev-lang/php." 556 eerror "'sqlite' USE flag when emerging dev-lang/php."
463 eerror 557 eerror
464 die "No SQLite extension for PHP found" 558 die "No SQLite extension for PHP found"
465} 559}
466 560
561# @FUNCTION: require_gd
562# @DESCRIPTION:
467# Require a PHP built with GD support 563# Require a PHP built with GD support
468 564# @RETURN: die if feature is missing
469require_gd() { 565require_gd() {
470 has_php 566 has_php
471 567
472 # Do we have the internal GD support installed? 568 # Do we have the internal GD support installed?
473 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then 569 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then
494# Misc functions 590# Misc functions
495# 591#
496# These functions provide miscellaneous checks and functionality. 592# These functions provide miscellaneous checks and functionality.
497# ======================================================================== 593# ========================================================================
498 594
595# @FUNCTION: php_binary_extension
596# @DESCRIPTION:
499# Executes some checks needed when installing a binary PHP extension 597# Executes some checks needed when installing a binary PHP extension.
500
501php_binary_extension() { 598php_binary_extension() {
502 has_php 599 has_php
503 600
504 local PUSE_ENABLED="" 601 local PUSE_ENABLED=""
505 602
506 # Binary extensions do not support the change of PHP 603 # Binary extensions do not support the change of PHP
507 # API version, so they can't be installed when USE flags 604 # API version, so they can't be installed when USE flags
508 # are enabled wich change the PHP API version 605 # are enabled which change the PHP API version, they also
606 # don't provide correctly versioned symbols for our use
509 607
510 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then 608 if has_debug ; then
511 eerror
512 eerror "You cannot install binary PHP extensions"
513 eerror "when the 'hardenedphp' USE flag is enabled!"
514 eerror "Please reemerge dev-lang/php with the"
515 eerror "'hardenedphp' USE flag turned off."
516 eerror
517 PUSE_ENABLED="1"
518 fi
519
520 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
521 eerror 609 eerror
522 eerror "You cannot install binary PHP extensions" 610 eerror "You cannot install binary PHP extensions"
523 eerror "when the 'debug' USE flag is enabled!" 611 eerror "when the 'debug' USE flag is enabled!"
524 eerror "Please reemerge dev-lang/php with the" 612 eerror "Please reemerge dev-lang/php with the"
525 eerror "'debug' USE flag turned off." 613 eerror "'debug' USE flag turned off."
526 eerror 614 eerror
527 PUSE_ENABLED="1" 615 PUSE_ENABLED="1"
528 fi 616 fi
529 617
618 if has_concurrentmodphp ; then
619 eerror
620 eerror "You cannot install binary PHP extensions when"
621 eerror "the 'concurrentmodphp' USE flag is enabled!"
622 eerror "Please reemerge dev-lang/php with the"
623 eerror "'concurrentmodphp' USE flag turned off."
624 eerror
625 PUSE_ENABLED="1"
626 fi
627
530 if [[ -n ${PUSE_ENABLED} ]] ; then 628 if [[ -n ${PUSE_ENABLED} ]] ; then
531 die "'hardenedphp' and/or 'debug' USE flags turned on" 629 die "'debug' and/or 'concurrentmodphp' USE flags turned on!"
532 fi 630 fi
533} 631}
534 632
633# @FUNCTION: dodoc-php
634# @USAGE: <list of docs>
635# @DESCRIPTION:
535# Alternative to dodoc function for use in our PHP eclasses and 636# Alternative to dodoc function for use in our PHP eclasses and ebuilds.
536# ebuilds.
537# Stored here because depend.php gets always sourced everywhere 637# Stored here because depend.php gets always sourced everywhere in the PHP
538# in the PHP ebuilds and eclasses.
539# It simply is dodoc with a changed path to the docs. 638# ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
540# NOTE: no support for docinto is given! 639# NOTE: No support for docinto is provided!
541
542dodoc-php() { 640dodoc-php() {
543if [[ $# -lt 1 ]] ; then 641if [[ $# -lt 1 ]] ; then
544 echo "$0: at least one argument needed" 1>&2 642 echo "$0: at least one argument needed" 1>&2
545 exit 1 643 exit 1
546fi 644fi

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

  ViewVC Help
Powered by ViewVC 1.1.20