| 1 | # Copyright 1999-2007 Gentoo Foundation |
1 | # Copyright 1999-2012 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.24 2008/02/11 20:47:35 armin76 Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.32 2012/06/02 19:16:31 zmedico Exp $ |
| 4 | |
4 | |
|
|
5 | # @ECLASS: depend.php.eclass |
|
|
6 | # @MAINTAINER: |
|
|
7 | # Gentoo PHP team <php-bugs@gentoo.org> |
|
|
8 | # @AUTHOR: |
| 5 | # Author: Stuart Herbert <stuart@gentoo.org> |
9 | # Author: Stuart Herbert <stuart@gentoo.org> |
| 6 | # Author: Luca Longinotti <chtekk@gentoo.org> |
10 | # Author: Luca Longinotti <chtekk@gentoo.org> |
| 7 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
11 | # Author: Jakub Moc <jakub@gentoo.org> (documentation) |
| 8 | |
|
|
| 9 | # @ECLASS: depend.php.eclass |
|
|
| 10 | # @MAINTAINER: |
|
|
| 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 | |
|
|
| 19 | inherit eutils phpconfutils |
18 | inherit eutils multilib 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 | |
19 | |
| 72 | # PHP5-only depend functions |
20 | # PHP5-only depend functions |
| 73 | |
21 | |
| 74 | # @FUNCTION: need_php5_cli |
22 | # @FUNCTION: need_php5_cli |
| 75 | # @DESCRIPTION: |
23 | # @DESCRIPTION: |
| 76 | # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5 |
24 | # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5 |
| 77 | # with cli SAPI. |
25 | # with cli SAPI. |
| 78 | need_php5_cli() { |
26 | need_php5_cli() { |
| 79 | DEPEND="${DEPEND} =virtual/php-5*" |
27 | DEPEND="${DEPEND} =dev-lang/php-5*" |
| 80 | RDEPEND="${RDEPEND} =virtual/php-5*" |
28 | RDEPEND="${RDEPEND} =dev-lang/php-5*" |
| 81 | PHP_VERSION="5" |
29 | PHP_VERSION="5" |
| 82 | } |
30 | } |
| 83 | |
31 | |
| 84 | # @FUNCTION: need_php5_httpd |
32 | # @FUNCTION: need_php5_httpd |
| 85 | # @DESCRIPTION: |
33 | # @DESCRIPTION: |
| … | |
… | |
| 125 | # @FUNCTION: need_php_cli |
73 | # @FUNCTION: need_php_cli |
| 126 | # @DESCRIPTION: |
74 | # @DESCRIPTION: |
| 127 | # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP |
75 | # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP |
| 128 | # (any version) with cli SAPI. |
76 | # (any version) with cli SAPI. |
| 129 | need_php_cli() { |
77 | need_php_cli() { |
| 130 | DEPEND="${DEPEND} virtual/php" |
78 | DEPEND="${DEPEND} dev-lang/php" |
| 131 | RDEPEND="${RDEPEND} virtual/php" |
79 | RDEPEND="${RDEPEND} dev-lang/php" |
| 132 | } |
80 | } |
| 133 | |
81 | |
| 134 | # @FUNCTION: need_php_httpd |
82 | # @FUNCTION: need_php_httpd |
| 135 | # @DESCRIPTION: |
83 | # @DESCRIPTION: |
| 136 | # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP |
84 | # Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP |
| … | |
… | |
| 151 | } |
99 | } |
| 152 | |
100 | |
| 153 | # @FUNCTION: need_php_by_category |
101 | # @FUNCTION: need_php_by_category |
| 154 | # @DESCRIPTION: |
102 | # @DESCRIPTION: |
| 155 | # Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version |
103 | # 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 |
104 | # determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or |
| 157 | # dev-php5, respectively. |
105 | # dev-php5, respectively. |
| 158 | need_php_by_category() { |
106 | need_php_by_category() { |
| 159 | case "${CATEGORY}" in |
107 | case "${CATEGORY}" in |
| 160 | dev-php) need_php ;; |
108 | dev-php) need_php ;; |
| 161 | dev-php4) need_php4 ;; |
|
|
| 162 | dev-php5) need_php5 ;; |
|
|
| 163 | *) die "Version of PHP required by packages in category ${CATEGORY} unknown" |
109 | *) die "Version of PHP required by packages in category ${CATEGORY} unknown" |
| 164 | esac |
110 | esac |
| 165 | } |
111 | } |
| 166 | |
112 | |
| 167 | |
113 | |
| … | |
… | |
| 169 | # @DESCRIPTION: |
115 | # @DESCRIPTION: |
| 170 | # Call this function from your pkg_setup, src_compile, src_install etc. if you |
116 | # Call this function from your pkg_setup, src_compile, src_install etc. if you |
| 171 | # need to know which PHP version is being used and where the PHP binaries/data |
117 | # need to know which PHP version is being used and where the PHP binaries/data |
| 172 | # are installed. |
118 | # are installed. |
| 173 | has_php() { |
119 | has_php() { |
| 174 | # If PHP_PKG is already set, then we have remembered our PHP settings |
|
|
| 175 | # from last time |
|
|
| 176 | if [[ -n ${PHP_PKG} ]] ; then |
|
|
| 177 | return |
|
|
| 178 | fi |
|
|
| 179 | |
|
|
| 180 | if [[ -z ${PHP_VERSION} ]] ; then |
|
|
| 181 | # Detect which PHP version we have installed |
120 | # Detect which PHP version we have installed |
| 182 | if has_version '=dev-lang/php-5*' ; then |
121 | if has_version '=dev-lang/php-5*' ; then |
| 183 | PHP_VERSION="5" |
122 | PHP_VERSION="5" |
| 184 | elif has_version '=dev-lang/php-4*' ; then |
|
|
| 185 | PHP_VERSION="4" |
|
|
| 186 | else |
123 | else |
| 187 | die "Unable to find an installed dev-lang/php package" |
124 | die "Unable to find an installed dev-lang/php package" |
| 188 | fi |
|
|
| 189 | fi |
125 | fi |
| 190 | |
126 | |
| 191 | # If we get here, then PHP_VERSION tells us which version of PHP we |
127 | # If we get here, then PHP_VERSION tells us which version of PHP we |
| 192 | # want to use |
128 | # want to use |
| 193 | uses_php${PHP_VERSION} |
129 | uses_php${PHP_VERSION} |
| … | |
… | |
| 267 | local x |
203 | local x |
| 268 | |
204 | |
| 269 | einfo "Checking for required PHP feature(s) ..." |
205 | einfo "Checking for required PHP feature(s) ..." |
| 270 | |
206 | |
| 271 | for x in $@ ; do |
207 | for x in $@ ; do |
|
|
208 | case $x in |
|
|
209 | pcre|spl|reflection|mhash) |
|
|
210 | eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag." |
|
|
211 | eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break" |
|
|
212 | eqawarn "if you check the USE flags against PHP 5.3 ebuilds." |
|
|
213 | eqawarn "Please use USE dependencies from EAPI 2 instead" |
|
|
214 | ;; |
|
|
215 | esac |
|
|
216 | |
| 272 | if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then |
217 | if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then |
| 273 | einfo " Discovered missing USE flag: ${x}" |
218 | einfo " Discovered missing USE flag: ${x}" |
| 274 | missing_use="${missing_use} ${x}" |
219 | missing_use="${missing_use} ${x}" |
| 275 | fi |
220 | fi |
| 276 | done |
221 | done |
| … | |
… | |
| 401 | # pdo-external use flag and pecl-pdo-* ebuilds were removed. |
346 | # pdo-external use flag and pecl-pdo-* ebuilds were removed. |
| 402 | # You should use require_php_with_use pdo instead now. |
347 | # You should use require_php_with_use pdo instead now. |
| 403 | # @RETURN: die if feature is missing |
348 | # @RETURN: die if feature is missing |
| 404 | require_pdo() { |
349 | require_pdo() { |
| 405 | has_php |
350 | has_php |
| 406 | |
|
|
| 407 | # Do we have PHP5 installed? |
|
|
| 408 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
|
|
| 409 | eerror |
|
|
| 410 | eerror "This package requires PDO." |
|
|
| 411 | eerror "PDO is only available for PHP 5." |
|
|
| 412 | eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"." |
|
|
| 413 | eerror "pdo USE flags turned on." |
|
|
| 414 | eerror |
|
|
| 415 | die "PHP 5 not installed" |
|
|
| 416 | fi |
|
|
| 417 | |
351 | |
| 418 | # Was PHP5 compiled with internal PDO support? |
352 | # Was PHP5 compiled with internal PDO support? |
| 419 | if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then |
353 | if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then |
| 420 | return |
354 | return |
| 421 | else |
355 | else |
| … | |
… | |
| 442 | return |
376 | return |
| 443 | fi |
377 | fi |
| 444 | |
378 | |
| 445 | local PHP_PACKAGE_FOUND="" |
379 | local PHP_PACKAGE_FOUND="" |
| 446 | |
380 | |
| 447 | # Detect which PHP version we have installed |
|
|
| 448 | if has_version '=dev-lang/php-4*' ; then |
|
|
| 449 | PHP_PACKAGE_FOUND="1" |
|
|
| 450 | pkg="$(best_version '=dev-lang/php-4*')" |
|
|
| 451 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
|
|
| 452 | PHP_VERSION="4" |
|
|
| 453 | fi |
|
|
| 454 | fi |
|
|
| 455 | |
|
|
| 456 | if has_version '=dev-lang/php-5*' ; then |
381 | if has_version '=dev-lang/php-5*' ; then |
| 457 | PHP_PACKAGE_FOUND="1" |
382 | PHP_PACKAGE_FOUND="1" |
| 458 | pkg="$(best_version '=dev-lang/php-5*')" |
383 | pkg="$(best_version '=dev-lang/php-5*')" |
| 459 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
384 | if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then |
| 460 | PHP_VERSION="5" |
385 | PHP_VERSION="5" |
| … | |
… | |
| 486 | return |
411 | return |
| 487 | fi |
412 | fi |
| 488 | |
413 | |
| 489 | local PHP_PACKAGE_FOUND="" |
414 | local PHP_PACKAGE_FOUND="" |
| 490 | |
415 | |
| 491 | # Detect which PHP version we have installed |
|
|
| 492 | if has_version '=dev-lang/php-4*' ; then |
|
|
| 493 | PHP_PACKAGE_FOUND="1" |
|
|
| 494 | pkg="$(best_version '=dev-lang/php-4*')" |
|
|
| 495 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
|
|
| 496 | PHP_VERSION="4" |
|
|
| 497 | fi |
|
|
| 498 | fi |
|
|
| 499 | |
|
|
| 500 | if has_version '=dev-lang/php-5*' ; then |
416 | if has_version '=dev-lang/php-5*' ; then |
| 501 | PHP_PACKAGE_FOUND="1" |
417 | PHP_PACKAGE_FOUND="1" |
| 502 | pkg="$(best_version '=dev-lang/php-5*')" |
418 | pkg="$(best_version '=dev-lang/php-5*')" |
| 503 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
419 | if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then |
| 504 | PHP_VERSION="5" |
420 | PHP_VERSION="5" |
| … | |
… | |
| 526 | has_php |
442 | has_php |
| 527 | |
443 | |
| 528 | # Has our PHP been built with SQLite support? |
444 | # Has our PHP been built with SQLite support? |
| 529 | if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then |
445 | if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then |
| 530 | return |
446 | return |
| 531 | fi |
|
|
| 532 | |
|
|
| 533 | # Do we have pecl-sqlite installed for PHP4? |
|
|
| 534 | if [[ "${PHP_VERSION}" == "4" ]] ; then |
|
|
| 535 | if has_version 'dev-php4/pecl-sqlite' ; then |
|
|
| 536 | return |
|
|
| 537 | fi |
|
|
| 538 | fi |
447 | fi |
| 539 | |
448 | |
| 540 | # If we get here, then we don't have any SQLite support for PHP installed |
449 | # If we get here, then we don't have any SQLite support for PHP installed |
| 541 | eerror |
450 | eerror |
| 542 | eerror "No SQLite extension for PHP found." |
451 | eerror "No SQLite extension for PHP found." |