/[gentoo-x86]/eclass/depend.php.eclass
Gentoo

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Fri May 5 21:42:16 2006 UTC (7 years, 11 months ago) by chtekk
Branch: MAIN
Changes since 1.13: +4 -4 lines
Fix punctuation.

1 stuart 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 chtekk 1.14 # $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.13 2006/04/20 12:15:35 chtekk Exp $
4 stuart 1.1 #
5     # ========================================================================
6     #
7     # depend.php.eclass
8     # functions to allow ebuilds to depend on php4 and/or php5
9     #
10     # Author: Stuart Herbert
11 chtekk 1.7 # <stuart@gentoo.org>
12     #
13     # Author: Luca Longinotti
14     # <chtekk@gentoo.org>
15     #
16     # Maintained by the PHP Herd <php-bugs@gentoo.org>
17 stuart 1.1 #
18     # ========================================================================
19    
20 chtekk 1.12 inherit eutils phpconfutils
21 stuart 1.1
22 trapni 1.4 # PHP4-only depend functions
23 chtekk 1.12 need_php4_cli() {
24 stuart 1.1 DEPEND="${DEPEND} =virtual/php-4*"
25     RDEPEND="${RDEPEND} =virtual/php-4*"
26 chtekk 1.12 PHP_VERSION="4"
27 stuart 1.1 }
28    
29 chtekk 1.12 need_php4_httpd() {
30 stuart 1.1 DEPEND="${DEPEND} =virtual/httpd-php-4*"
31     RDEPEND="${RDEPEND} =virtual/httpd-php-4*"
32 chtekk 1.12 PHP_VERSION="4"
33 stuart 1.1 }
34    
35 chtekk 1.12 need_php4() {
36 stuart 1.1 DEPEND="${DEPEND} =dev-lang/php-4*"
37     RDEPEND="${RDEPEND} =dev-lang/php-4*"
38 chtekk 1.12 PHP_VERSION="4"
39 stuart 1.1 PHP_SHARED_CAT="php4"
40     }
41    
42     # common settings go in here
43 chtekk 1.12 uses_php4() {
44 stuart 1.1 # 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 trapni 1.4 # PHP5-only depend functions
60 chtekk 1.12 need_php5_cli() {
61 stuart 1.1 DEPEND="${DEPEND} =virtual/php-5*"
62     RDEPEND="${RDEPEND} =virtual/php-5*"
63 chtekk 1.12 PHP_VERSION="5"
64 stuart 1.1 }
65    
66 chtekk 1.12 need_php5_httpd() {
67 stuart 1.1 DEPEND="${DEPEND} =virtual/httpd-php-5*"
68     RDEPEND="${RDEPEND} =virtual/httpd-php-5*"
69 chtekk 1.12 PHP_VERSION="5"
70 stuart 1.1 }
71    
72 chtekk 1.12 need_php5() {
73 stuart 1.1 DEPEND="${DEPEND} =dev-lang/php-5*"
74     RDEPEND="${RDEPEND} =dev-lang/php-5*"
75 chtekk 1.12 PHP_VERSION="5"
76 stuart 1.1 PHP_SHARED_CAT="php5"
77     }
78    
79     # common settings go in here
80 chtekk 1.12 uses_php5() {
81 stuart 1.1 # cache this
82     libdir=$(get_libdir)
83    
84     PHPIZE="/usr/${libdir}/php5/bin/phpize"
85     PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
86     PHPCLI="/usr/${libdir}/php5/bin/php"
87     PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
88     PHP_PKG="`best_version =dev-lang/php-5*`"
89     PHPPREFIX="/usr/${libdir}/php5"
90    
91     einfo
92     einfo "Using ${PHP_PKG}"
93     einfo
94     }
95    
96 trapni 1.4 # general PHP depend functions
97 chtekk 1.12 need_php_cli() {
98 trapni 1.4 DEPEND="${DEPEND} virtual/php"
99     RDEPEND="${RDEPEND} virtual/php"
100     }
101    
102 chtekk 1.12 need_php_httpd() {
103 trapni 1.4 DEPEND="${DEPEND} virtual/httpd-php"
104     RDEPEND="${RDEPEND} virtual/httpd-php"
105     }
106    
107 chtekk 1.12 need_php() {
108 stuart 1.1 DEPEND="${DEPEND} dev-lang/php"
109     RDEPEND="${RDEPEND} dev-lang/php"
110     PHP_SHARED_CAT="php"
111     }
112    
113 chtekk 1.12 need_php_by_category() {
114 stuart 1.1 case "${CATEGORY}" in
115     dev-php) need_php ;;
116     dev-php4) need_php4 ;;
117     dev-php5) need_php5 ;;
118     *) die "I don't know which version of PHP packages in ${CATEGORY} require"
119     esac
120     }
121    
122 chtekk 1.12 # Call this function from your pkg_setup, src_compile and src_install methods
123     # if you need to know where the PHP binaries are installed and their data
124    
125     has_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
134     if has_version '=dev-lang/php-5*' ; then
135     PHP_VERSION="5"
136     elif has_version '=dev-lang/php-4*' ; then
137     PHP_VERSION="4"
138     else
139     die "Unable to find an installed dev-lang/php package"
140     fi
141     fi
142    
143     # If we get here, then PHP_VERSION tells us which version of PHP we
144     # want to use
145     uses_php${PHP_VERSION}
146     }
147    
148     # Call this function from pkg_setup if your package only works with
149 stuart 1.1 # specific SAPIs
150     #
151 chtekk 1.12 # $1 ... a list of PHP SAPI USE flags (cli, cgi, apache, apache2)
152 stuart 1.1 #
153 chtekk 1.12 # Returns if any one of the listed SAPIs have been installed
154     # Dies if none of the listed SAPIs have been installed
155 stuart 1.1
156 chtekk 1.12 require_php_sapi_from() {
157 stuart 1.1 has_php
158    
159 chtekk 1.12 local has_sapi="0"
160 stuart 1.1 local x
161    
162     einfo "Checking for compatible SAPI(s)"
163    
164     for x in $@ ; do
165 chtekk 1.13 if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
166 stuart 1.1 einfo " Discovered compatible SAPI ${x}"
167 chtekk 1.12 has_sapi="1"
168 stuart 1.1 fi
169     done
170    
171 chtekk 1.12 if [[ "${has_sapi}" == "1" ]] ; then
172 stuart 1.1 return
173     fi
174    
175     eerror
176     eerror "${PHP_PKG} needs to be re-installed with one of the following"
177     eerror "USE flags enabled:"
178     eerror
179     eerror " $@"
180     eerror
181 chtekk 1.12 die "No compatible PHP SAPIs found"
182 stuart 1.1 }
183    
184 chtekk 1.12 # Call this function from pkg_setup if your package requires PHP compiled
185 stuart 1.1 # with specific USE flags
186     #
187     # $1 ... a list of USE flags
188 swegener 1.8 #
189 chtekk 1.12 # Returns if all of the listed USE flags are enabled
190     # Dies if any of the listed USE flags are disabled
191 stuart 1.1
192 chtekk 1.12 require_php_with_use() {
193 stuart 1.1 has_php
194    
195 chtekk 1.11 local missing_use=""
196 stuart 1.1 local x
197    
198 chtekk 1.14 einfo "Checking for required PHP feature(s) ..."
199 stuart 1.1
200     for x in $@ ; do
201 chtekk 1.12 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
202 chtekk 1.14 einfo " Discovered missing USE flag: ${x}"
203 stuart 1.1 missing_use="${missing_use} ${x}"
204     fi
205     done
206    
207 chtekk 1.11 if [[ -z ${missing_use} ]] ; then
208 stuart 1.1 return
209     fi
210    
211     eerror
212     eerror "${PHP_PKG} needs to be re-installed with all of the following"
213     eerror "USE flags enabled:"
214     eerror
215     eerror " $@"
216     eerror
217 chtekk 1.12 die "Missing PHP USE flags found"
218 stuart 1.1 }
219    
220 chtekk 1.12 # Call this function from pkg_setup if your package requires PHP compiled
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
226     # Dies if all of the listed USE flags are disabled
227    
228     require_php_with_any_use() {
229     has_php
230 stuart 1.1
231 chtekk 1.12 local missing_use=""
232     local x
233 hollow 1.3
234 chtekk 1.14 einfo "Checking for required PHP feature(s) ..."
235 stuart 1.1
236 chtekk 1.12 for x in $@ ; do
237     if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
238     einfo " USE flag ${x} is enabled, ok ..."
239     return
240 stuart 1.1 else
241 chtekk 1.12 missing_use="${missing_use} ${x}"
242 stuart 1.1 fi
243 chtekk 1.12 done
244    
245     if [[ -z ${missing_use} ]] ; then
246     return
247 stuart 1.1 fi
248    
249 chtekk 1.12 eerror
250     eerror "${PHP_PKG} needs to be re-installed with any of the following"
251     eerror "USE flags enabled:"
252     eerror
253     eerror " $@"
254     eerror
255     die "Missing PHP USE flags found"
256 stuart 1.1 }
257    
258     # ========================================================================
259     # has_*() functions
260     #
261 chtekk 1.12 # These functions return 0 if the condition is satisfied, 1 otherwise
262 stuart 1.1 # ========================================================================
263    
264 chtekk 1.12 # Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled
265 hollow 1.3
266 chtekk 1.12 has_zts() {
267 stuart 1.1 has_php
268    
269 chtekk 1.13 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then
270 stuart 1.1 return 0
271     fi
272    
273     return 1
274     }
275    
276 chtekk 1.12 # Check if our PHP was built with Hardened-PHP enabled
277 hollow 1.3
278 chtekk 1.12 has_hardenedphp() {
279 hollow 1.3 has_php
280    
281 chtekk 1.13 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then
282 hollow 1.3 return 0
283     fi
284    
285     return 1
286     }
287    
288 chtekk 1.12 # Check if our PHP was built with debug support enabled
289    
290     has_debug() {
291     has_php
292    
293 chtekk 1.13 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
294 chtekk 1.12 return 0
295     fi
296    
297     return 1
298     }
299    
300 stuart 1.1 # ========================================================================
301     # require_*() functions
302     #
303 chtekk 1.12 # These functions die() if PHP was built without the required features
304 stuart 1.1 # ========================================================================
305    
306 chtekk 1.12 # Require a PHP built with PDO support (PHP5 only)
307 hollow 1.3
308 chtekk 1.12 require_pdo() {
309 stuart 1.1 has_php
310    
311 chtekk 1.12 # Do we have PHP5 installed?
312     if [[ "${PHP_VERSION}" == "4" ]] ; then
313 stuart 1.1 eerror
314 hollow 1.3 eerror "This package requires PDO."
315     eerror "PDO is only available for PHP 5."
316 chtekk 1.11 eerror "You must install =dev-lang/php-5.0* 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"
320     eerror "turned on."
321 stuart 1.1 eerror
322     die "PHP 5 not installed"
323     fi
324    
325 chtekk 1.12 # Was PHP5 compiled with internal PDO support?
326 chtekk 1.13 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then
327 stuart 1.1 return
328     fi
329    
330 chtekk 1.12 # Ok, maybe PDO was built as an external extension?
331 chtekk 1.13 if ( built_with_use =${PHP_PKG} pdo-external || phpconfutils_built_with_use =${PHP_PKG} pdo-external ) && has_version 'dev-php5/pecl-pdo' ; then
332 stuart 1.1 return
333     fi
334    
335 chtekk 1.12 # Ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
336     if has_version 'dev-php5/pecl-pdo' ; then
337 stuart 1.1 return
338     fi
339    
340 chtekk 1.12 # If we get here, then we have no PDO support
341 stuart 1.1 eerror
342     eerror "No PDO extension for PHP found."
343     eerror "Please note that PDO only exists for PHP 5."
344     eerror "Please install a PDO extension for PHP 5,"
345 chtekk 1.11 eerror "you must install =dev-lang/php-5.0* with"
346 stuart 1.1 eerror "the 'pdo-external' USE flag or you must"
347 chtekk 1.11 eerror "install >=dev-lang/php-5.1 with either"
348 stuart 1.1 eerror "the 'pdo' or the 'pdo-external' USE flags"
349     eerror "turned on."
350     eerror
351 chtekk 1.12 die "No PDO extension for PHP 5 found"
352 stuart 1.1 }
353    
354 chtekk 1.12 # Determines which installed PHP version has the CLI SAPI enabled,
355     # useful for PEAR stuff, or anything which needs to run PHP
356     # scripts depending on the CLI SAPI
357 stuart 1.1
358 chtekk 1.12 require_php_cli() {
359     # If PHP_PKG is set, then we have remembered our PHP settings
360 stuart 1.1 # from last time
361 chtekk 1.11 if [[ -n ${PHP_PKG} ]] ; then
362 stuart 1.1 return
363     fi
364    
365 chtekk 1.12 local PHP_PACKAGE_FOUND=""
366    
367     # Detect which PHP version we have installed
368 chtekk 1.6 if has_version '=dev-lang/php-4*' ; then
369 chtekk 1.12 PHP_PACKAGE_FOUND="1"
370 chtekk 1.6 pkg="`best_version '=dev-lang/php-4*'`"
371 chtekk 1.13 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
372 chtekk 1.12 PHP_VERSION="4"
373 chtekk 1.6 fi
374 sebastian 1.10 fi
375    
376     if has_version '=dev-lang/php-5*' ; then
377 chtekk 1.12 PHP_PACKAGE_FOUND="1"
378 stuart 1.1 pkg="`best_version '=dev-lang/php-5*'`"
379 chtekk 1.13 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
380 chtekk 1.12 PHP_VERSION="5"
381 stuart 1.1 fi
382 sebastian 1.10 fi
383    
384 chtekk 1.11 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
385 stuart 1.1 die "Unable to find an installed dev-lang/php package"
386     fi
387    
388 chtekk 1.11 if [[ -z ${PHP_VERSION} ]] ; then
389 stuart 1.1 die "No PHP CLI installed"
390     fi
391    
392 chtekk 1.12 # If we get here, then PHP_VERSION tells us which version of PHP we
393 stuart 1.1 # want to use
394 hollow 1.3 uses_php${PHP_VERSION}
395     }
396    
397 chtekk 1.12 # Determines which installed PHP version has the CGI SAPI enabled,
398 hollow 1.3 # useful for anything which needs to run PHP scripts
399 chtekk 1.12 # depending on the CGI SAPI
400 hollow 1.3
401 chtekk 1.12 require_php_cgi() {
402     # If PHP_PKG is set, then we have remembered our PHP settings
403 hollow 1.3 # from last time
404 chtekk 1.11 if [[ -n ${PHP_PKG} ]] ; then
405 hollow 1.3 return
406     fi
407    
408 chtekk 1.12 local PHP_PACKAGE_FOUND=""
409    
410     # Detect which PHP version we have installed
411 chtekk 1.6 if has_version '=dev-lang/php-4*' ; then
412 chtekk 1.12 PHP_PACKAGE_FOUND="1"
413 chtekk 1.6 pkg="`best_version '=dev-lang/php-4*'`"
414 chtekk 1.13 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
415 chtekk 1.12 PHP_VERSION="4"
416 chtekk 1.6 fi
417 sebastian 1.9 fi
418    
419     if has_version '=dev-lang/php-5*' ; then
420 chtekk 1.12 PHP_PACKAGE_FOUND="1"
421 hollow 1.3 pkg="`best_version '=dev-lang/php-5*'`"
422 chtekk 1.13 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
423 chtekk 1.12 PHP_VERSION="5"
424 hollow 1.3 fi
425 sebastian 1.9 fi
426 chtekk 1.11
427     if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
428 hollow 1.3 die "Unable to find an installed dev-lang/php package"
429     fi
430    
431 chtekk 1.11 if [[ -z ${PHP_VERSION} ]] ; then
432 hollow 1.3 die "No PHP CGI installed"
433     fi
434    
435 chtekk 1.12 # If we get here, then PHP_VERSION tells us which version of PHP we
436 hollow 1.3 # want to use
437 stuart 1.1 uses_php${PHP_VERSION}
438     }
439    
440 chtekk 1.12 # Require a PHP built with SQLite support
441 stuart 1.1
442 chtekk 1.12 require_sqlite() {
443 stuart 1.1 has_php
444    
445 chtekk 1.12 # Has our PHP been built with SQLite support?
446     if built_with_use =${PHP_PKG} sqlite || phpconfutils_built_with_use =${PHP_PKG} sqlite ; then
447 stuart 1.1 return
448     fi
449    
450 chtekk 1.12 # Do we have pecl-sqlite installed for PHP4?
451     if [[ "${PHP_VERSION}" == "4" ]] ; then
452     if has_version 'dev-php4/pecl-sqlite' ; then
453 stuart 1.1 return
454     fi
455     fi
456    
457 chtekk 1.12 # If we get here, then we don't have any SQLite support for PHP installed
458 stuart 1.1 eerror
459 chtekk 1.12 eerror "No SQLite extension for PHP found."
460     eerror "Please install an SQLite extension for PHP,"
461 stuart 1.1 eerror "this is done best by simply adding the"
462     eerror "'sqlite' USE flag when emerging dev-lang/php."
463     eerror
464 chtekk 1.12 die "No SQLite extension for PHP found"
465 stuart 1.1 }
466 hollow 1.3
467 chtekk 1.12 # Require a PHP built with GD support
468 chtekk 1.6
469 chtekk 1.12 require_gd() {
470 hollow 1.3 has_php
471    
472 chtekk 1.12 # Do we have the internal GD support installed?
473     if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then
474 hollow 1.3 return
475     fi
476    
477 chtekk 1.12 # Ok, maybe GD was built using the external library support?
478     if built_with_use =${PHP_PKG} gd-external || phpconfutils_built_with_use =${PHP_PKG} gd-external ; then
479 hollow 1.3 return
480     fi
481    
482 chtekk 1.12 # If we get here, then we have no GD support
483 hollow 1.3 eerror
484     eerror "No GD support for PHP found."
485     eerror "Please install the GD support for PHP,"
486     eerror "you must install dev-lang/php with either"
487     eerror "the 'gd' or the 'gd-external' USE flags"
488     eerror "turned on."
489     eerror
490     die "No GD support found for PHP"
491     }
492 chtekk 1.6
493     # ========================================================================
494     # Misc functions
495     #
496     # These functions provide miscellaneous checks and functionality.
497     # ========================================================================
498    
499 chtekk 1.12 # Executes some checks needed when installing a binary PHP extension
500 chtekk 1.6
501     php_binary_extension() {
502     has_php
503    
504 chtekk 1.12 local PUSE_ENABLED=""
505    
506     # Binary extensions do not support the change of PHP
507 chtekk 1.6 # API version, so they can't be installed when USE flags
508     # are enabled wich change the PHP API version
509    
510 chtekk 1.13 if built_with_use =${PHP_PKG} hardenedphp || phpconfutils_built_with_use =${PHP_PKG} hardenedphp ; then
511 chtekk 1.6 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 chtekk 1.12 PUSE_ENABLED="1"
518 chtekk 1.6 fi
519    
520 chtekk 1.13 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
521 chtekk 1.6 eerror
522     eerror "You cannot install binary PHP extensions"
523     eerror "when the 'debug' USE flag is enabled!"
524     eerror "Please reemerge dev-lang/php with the"
525     eerror "'debug' USE flag turned off."
526     eerror
527 chtekk 1.12 PUSE_ENABLED="1"
528     fi
529    
530     if [[ -n ${PUSE_ENABLED} ]] ; then
531     die "'hardenedphp' and/or 'debug' USE flags turned on"
532 chtekk 1.6 fi
533     }
534    
535 chtekk 1.12 # Alternative to dodoc function for use in our PHP eclasses and
536     # ebuilds.
537     # Stored here because depend.php gets always sourced everywhere
538     # in the PHP ebuilds and eclasses.
539     # It simply is dodoc with a changed path to the docs.
540     # NOTE: no support for docinto is given!
541 chtekk 1.6
542 chtekk 1.12 dodoc-php() {
543     if [[ $# -lt 1 ]] ; then
544 chtekk 1.6 echo "$0: at least one argument needed" 1>&2
545     exit 1
546     fi
547    
548     phpdocdir="${D}/usr/share/doc/${CATEGORY}/${PF}/"
549    
550 chtekk 1.12 if [[ ! -d "${phpdocdir}" ]] ; then
551 chtekk 1.6 install -d "${phpdocdir}"
552     fi
553    
554 chtekk 1.12 for x in $@ ; do
555     if [[ -s "${x}" ]] ; then
556 chtekk 1.6 install -m0644 "${x}" "${phpdocdir}"
557     gzip -f -9 "${phpdocdir}/${x##*/}"
558 chtekk 1.12 elif [[ ! -e "${x}" ]] ; then
559 chtekk 1.6 echo "dodoc-php: ${x} does not exist" 1>&2
560     fi
561     done
562     }

  ViewVC Help
Powered by ViewVC 1.1.20