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

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (show annotations) (download)
Mon Aug 7 07:10:16 2006 UTC (8 years, 3 months ago) by chtekk
Branch: MAIN
Changes since 1.15: +14 -3 lines
Fix binary extension checks wrt concurrentmodphp.

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

  ViewVC Help
Powered by ViewVC 1.1.20