| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2007 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.25 2008/02/26 16:26:08 armin76 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 | # Author: Stuart Herbert <stuart@gentoo.org> |
5 | # Author: Stuart Herbert <stuart@gentoo.org> |
| 6 | # Author: Luca Longinotti <chtekk@gentoo.org> |
6 | # Author: Luca Longinotti <chtekk@gentoo.org> |
| 7 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
7 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
| 8 | |
8 | |
| 9 | # @ECLASS: depend.php.eclass |
9 | # @ECLASS: depend.php.eclass |
| 10 | # @MAINTAINER: |
10 | # @MAINTAINER: |
| 11 | # Gentoo PHP team <php-bugs@gentoo.org> |
11 | # Gentoo PHP team <php-bugs@gentoo.org> |
| 12 | # @BLURB: Functions to allow ebuilds to depend on php[45] and check for specific features. |
12 | # @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features. |
| 13 | # @DESCRIPTION: |
13 | # @DESCRIPTION: |
| 14 | # This eclass provides functions that allow ebuilds to depend on php[45] and check |
14 | # This eclass provides functions that allow ebuilds to depend on php5 and check |
| 15 | # for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install |
15 | # for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install |
| 16 | # documentation for PHP packages to php-specific location. |
16 | # documentation for PHP packages to php-specific location. |
| 17 | |
17 | |
| 18 | |
18 | |
| 19 | inherit eutils phpconfutils |
19 | inherit eutils phpconfutils |
| 20 | |
|
|
| 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. |
|
|
| 27 | need_php4_cli() { |
|
|
| 28 | DEPEND="${DEPEND} =virtual/php-4*" |
|
|
| 29 | RDEPEND="${RDEPEND} =virtual/php-4*" |
|
|
| 30 | PHP_VERSION="4" |
|
|
| 31 | } |
|
|
| 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. |
|
|
| 37 | need_php4_httpd() { |
|
|
| 38 | DEPEND="${DEPEND} =virtual/httpd-php-4*" |
|
|
| 39 | RDEPEND="${RDEPEND} =virtual/httpd-php-4*" |
|
|
| 40 | PHP_VERSION="4" |
|
|
| 41 | } |
|
|
| 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). |
|
|
| 47 | need_php4() { |
|
|
| 48 | DEPEND="${DEPEND} =dev-lang/php-4*" |
|
|
| 49 | RDEPEND="${RDEPEND} =dev-lang/php-4*" |
|
|
| 50 | PHP_VERSION="4" |
|
|
| 51 | PHP_SHARED_CAT="php4" |
|
|
| 52 | } |
|
|
| 53 | |
|
|
| 54 | # common settings go in here |
|
|
| 55 | uses_php4() { |
|
|
| 56 | # cache this |
|
|
| 57 | libdir=$(get_libdir) |
|
|
| 58 | |
|
|
| 59 | PHPIZE="/usr/${libdir}/php4/bin/phpize" |
|
|
| 60 | PHPCONFIG="/usr/${libdir}/php4/bin/php-config" |
|
|
| 61 | PHPCLI="/usr/${libdir}/php4/bin/php" |
|
|
| 62 | PHPCGI="/usr/${libdir}/php4/bin/php-cgi" |
|
|
| 63 | PHP_PKG="$(best_version =dev-lang/php-4*)" |
|
|
| 64 | PHPPREFIX="/usr/${libdir}/php4" |
|
|
| 65 | EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)" |
|
|
| 66 | |
|
|
| 67 | einfo |
|
|
| 68 | einfo "Using ${PHP_PKG}" |
|
|
| 69 | einfo |
|
|
| 70 | } |
|
|
| 71 | |
20 | |
| 72 | # PHP5-only depend functions |
21 | # PHP5-only depend functions |
| 73 | |
22 | |
| 74 | # @FUNCTION: need_php5_cli |
23 | # @FUNCTION: need_php5_cli |
| 75 | # @DESCRIPTION: |
24 | # @DESCRIPTION: |
| … | |
… | |
| 151 | } |
100 | } |
| 152 | |
101 | |
| 153 | # @FUNCTION: need_php_by_category |
102 | # @FUNCTION: need_php_by_category |
| 154 | # @DESCRIPTION: |
103 | # @DESCRIPTION: |
| 155 | # Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version |
104 | # 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 |
105 | # determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or |
| 157 | # dev-php5, respectively. |
106 | # dev-php5, respectively. |
| 158 | need_php_by_category() { |
107 | need_php_by_category() { |
| 159 | case "${CATEGORY}" in |
108 | case "${CATEGORY}" in |
| 160 | dev-php) need_php ;; |
109 | dev-php) need_php ;; |
| 161 | dev-php4) need_php4 ;; |
|
|
| 162 | dev-php5) need_php5 ;; |
110 | dev-php5) need_php5 ;; |
| 163 | *) die "Version of PHP required by packages in category ${CATEGORY} unknown" |
111 | *) die "Version of PHP required by packages in category ${CATEGORY} unknown" |
| 164 | esac |
112 | esac |
| 165 | } |
113 | } |
| 166 | |
114 | |
| … | |
… | |
| 172 | # are installed. |
120 | # are installed. |
| 173 | has_php() { |
121 | has_php() { |
| 174 | # Detect which PHP version we have installed |
122 | # Detect which PHP version we have installed |
| 175 | if has_version '=dev-lang/php-5*' ; then |
123 | if has_version '=dev-lang/php-5*' ; then |
| 176 | PHP_VERSION="5" |
124 | PHP_VERSION="5" |
| 177 | elif has_version '=dev-lang/php-4*' ; then |
|
|
| 178 | PHP_VERSION="4" |
|
|
| 179 | else |
125 | else |
| 180 | die "Unable to find an installed dev-lang/php package" |
126 | die "Unable to find an installed dev-lang/php package" |
| 181 | fi |
127 | fi |
| 182 | |
128 | |
| 183 | # 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 |
| … | |
… | |
| 394 | # You should use require_php_with_use pdo instead now. |
340 | # You should use require_php_with_use pdo instead now. |
| 395 | # @RETURN: die if feature is missing |
341 | # @RETURN: die if feature is missing |
| 396 | require_pdo() { |
342 | require_pdo() { |
| 397 | has_php |
343 | has_php |
| 398 | |
344 | |
| 399 | # Do we have PHP5 installed? |
|
|
| 400 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
|
|
| 401 | eerror |
|
|
| 402 | eerror "This package requires PDO." |
|
|
| 403 | eerror "PDO is only available for PHP 5." |
|
|
| 404 | eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"." |
|
|
| 405 | eerror "pdo USE flags turned on." |
|
|
| 406 | eerror |
|
|
| 407 | die "PHP 5 not installed" |
|
|
| 408 | fi |
|
|
| 409 | |
|
|
| 410 | # Was PHP5 compiled with internal PDO support? |
345 | # Was PHP5 compiled with internal PDO support? |
| 411 | 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 |
| 412 | return |
347 | return |
| 413 | else |
348 | else |
| 414 | eerror |
349 | eerror |
| … | |
… | |
| 434 | return |
369 | return |
| 435 | fi |
370 | fi |
| 436 | |
371 | |
| 437 | local PHP_PACKAGE_FOUND="" |
372 | local PHP_PACKAGE_FOUND="" |
| 438 | |
373 | |
| 439 | # Detect which PHP version we have installed |
|
|
| 440 | if has_version '=dev-lang/php-4*' ; then |
|
|
| 441 | PHP_PACKAGE_FOUND="1" |
|
|
| 442 | pkg="$(best_version '=dev-lang/php-4*')" |
|
|
| 443 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
|
|
| 444 | PHP_VERSION="4" |
|
|
| 445 | fi |
|
|
| 446 | fi |
|
|
| 447 | |
|
|
| 448 | if has_version '=dev-lang/php-5*' ; then |
374 | if has_version '=dev-lang/php-5*' ; then |
| 449 | PHP_PACKAGE_FOUND="1" |
375 | PHP_PACKAGE_FOUND="1" |
| 450 | pkg="$(best_version '=dev-lang/php-5*')" |
376 | pkg="$(best_version '=dev-lang/php-5*')" |
| 451 | 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 |
| 452 | PHP_VERSION="5" |
378 | PHP_VERSION="5" |
| … | |
… | |
| 478 | return |
404 | return |
| 479 | fi |
405 | fi |
| 480 | |
406 | |
| 481 | local PHP_PACKAGE_FOUND="" |
407 | local PHP_PACKAGE_FOUND="" |
| 482 | |
408 | |
| 483 | # Detect which PHP version we have installed |
|
|
| 484 | if has_version '=dev-lang/php-4*' ; then |
|
|
| 485 | PHP_PACKAGE_FOUND="1" |
|
|
| 486 | pkg="$(best_version '=dev-lang/php-4*')" |
|
|
| 487 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
|
|
| 488 | PHP_VERSION="4" |
|
|
| 489 | fi |
|
|
| 490 | fi |
|
|
| 491 | |
|
|
| 492 | if has_version '=dev-lang/php-5*' ; then |
409 | if has_version '=dev-lang/php-5*' ; then |
| 493 | PHP_PACKAGE_FOUND="1" |
410 | PHP_PACKAGE_FOUND="1" |
| 494 | pkg="$(best_version '=dev-lang/php-5*')" |
411 | pkg="$(best_version '=dev-lang/php-5*')" |
| 495 | 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 |
| 496 | PHP_VERSION="5" |
413 | PHP_VERSION="5" |
| … | |
… | |
| 518 | has_php |
435 | has_php |
| 519 | |
436 | |
| 520 | # Has our PHP been built with SQLite support? |
437 | # Has our PHP been built with SQLite support? |
| 521 | 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 |
| 522 | return |
439 | return |
| 523 | fi |
|
|
| 524 | |
|
|
| 525 | # Do we have pecl-sqlite installed for PHP4? |
|
|
| 526 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
|
|
| 527 | if has_version 'dev-php4/pecl-sqlite' ; then |
|
|
| 528 | return |
|
|
| 529 | fi |
|
|
| 530 | fi |
440 | fi |
| 531 | |
441 | |
| 532 | # 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 |
| 533 | eerror |
443 | eerror |
| 534 | eerror "No SQLite extension for PHP found." |
444 | eerror "No SQLite extension for PHP found." |