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

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Fri Sep 16 20:25:21 2005 UTC (8 years, 11 months ago) by trapni
Branch: MAIN
Changes since 1.3: +15 -0 lines
merging to upstream (from overlay) - containing two new functions: need_php_httpd() and need_php_cli()

1 stuart 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 hollow 1.3 # $Header: $
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     # (stuart@gentoo.org)
12     #
13     # ========================================================================
14    
15     inherit eutils
16    
17 trapni 1.4 # PHP4-only depend functions
18 stuart 1.1 need_php4_cli()
19     {
20     DEPEND="${DEPEND} =virtual/php-4*"
21     RDEPEND="${RDEPEND} =virtual/php-4*"
22     PHP_VERSION=4
23     }
24    
25     need_php4_httpd()
26     {
27     DEPEND="${DEPEND} =virtual/httpd-php-4*"
28     RDEPEND="${RDEPEND} =virtual/httpd-php-4*"
29     PHP_VERSION=4
30     }
31    
32     need_php4()
33     {
34     DEPEND="${DEPEND} =dev-lang/php-4*"
35     RDEPEND="${RDEPEND} =dev-lang/php-4*"
36     PHP_VERSION=4
37     PHP_SHARED_CAT="php4"
38     }
39    
40     # common settings go in here
41     uses_php4()
42     {
43     # cache this
44     libdir=$(get_libdir)
45    
46     PHPIZE="/usr/${libdir}/php4/bin/phpize"
47     PHPCONFIG="/usr/${libdir}/php4/bin/php-config"
48     PHPCLI="/usr/${libdir}/php4/bin/php"
49     PHPCGI="/usr/${libdir}/php4/bin/php-cgi"
50     PHP_PKG="`best_version =dev-lang/php-4*`"
51     PHPPREFIX="/usr/${libdir}/php4"
52    
53     einfo
54     einfo "Using ${PHP_PKG}"
55     einfo
56     }
57    
58 trapni 1.4 # PHP5-only depend functions
59 stuart 1.1 need_php5_cli()
60     {
61     DEPEND="${DEPEND} =virtual/php-5*"
62     RDEPEND="${RDEPEND} =virtual/php-5*"
63     PHP_VERSION=5
64     }
65    
66     need_php5_httpd()
67     {
68     DEPEND="${DEPEND} =virtual/httpd-php-5*"
69     RDEPEND="${RDEPEND} =virtual/httpd-php-5*"
70     PHP_VERSION=5
71     }
72    
73     need_php5()
74     {
75     DEPEND="${DEPEND} =dev-lang/php-5*"
76     RDEPEND="${RDEPEND} =dev-lang/php-5*"
77     PHP_VERSION=5
78     PHP_SHARED_CAT="php5"
79     }
80    
81     # common settings go in here
82     uses_php5()
83     {
84     # cache this
85     libdir=$(get_libdir)
86    
87     PHPIZE="/usr/${libdir}/php5/bin/phpize"
88     PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
89     PHPCLI="/usr/${libdir}/php5/bin/php"
90     PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
91     PHP_PKG="`best_version =dev-lang/php-5*`"
92     PHPPREFIX="/usr/${libdir}/php5"
93    
94     einfo
95     einfo "Using ${PHP_PKG}"
96     einfo
97     }
98    
99 trapni 1.4 # general PHP depend functions
100     need_php_cli()
101     {
102     DEPEND="${DEPEND} virtual/php"
103     RDEPEND="${RDEPEND} virtual/php"
104     }
105    
106     need_php_httpd()
107     {
108     DEPEND="${DEPEND} virtual/httpd-php"
109     RDEPEND="${RDEPEND} virtual/httpd-php"
110     }
111    
112 stuart 1.1 need_php()
113     {
114     DEPEND="${DEPEND} dev-lang/php"
115     RDEPEND="${RDEPEND} dev-lang/php"
116     PHP_SHARED_CAT="php"
117     }
118    
119     need_php_by_category()
120     {
121     case "${CATEGORY}" in
122     dev-php) need_php ;;
123     dev-php4) need_php4 ;;
124     dev-php5) need_php5 ;;
125     *) die "I don't know which version of PHP packages in ${CATEGORY} require"
126     esac
127     }
128    
129     # call this function from pkg_setup if your PHP extension only works with
130     # specific SAPIs
131     #
132     # this function will disappear when USE-based deps are supported by
133     # Portage
134     #
135     # $1 ... a list of SAPI USE flags (eg cli, cgi, apache2)
136 hollow 1.3 #
137 stuart 1.1 # returns if any one of the listed SAPIs has been installed
138     # dies if none of the listed SAPIs has been installed
139    
140 hollow 1.3 require_php_sapi_from()
141     {
142 stuart 1.1 has_php
143    
144     local has_sapi=0
145     local x
146    
147     einfo "Checking for compatible SAPI(s)"
148    
149     for x in $@ ; do
150     if built_with_use =${PHP_PKG} ${x} ; then
151     einfo " Discovered compatible SAPI ${x}"
152     has_sapi=1
153     fi
154     done
155    
156     if [[ ${has_sapi} == 1 ]]; then
157     return
158     fi
159    
160     eerror
161     eerror "${PHP_PKG} needs to be re-installed with one of the following"
162     eerror "USE flags enabled:"
163     eerror
164     eerror " $@"
165     eerror
166     die "Re-install ${PHP_PKG}"
167     }
168    
169     # call this function from pkg_setup if your package requires PHP compiled
170     # with specific USE flags
171     #
172     # this function will disappear when USE-based deps are supported by
173     # Portage
174     #
175     # $1 ... a list of USE flags
176 hollow 1.3 #
177 stuart 1.1 # returns if all of the listed USE flags are set
178     # dies if any of the listed USE flags are not set
179    
180 hollow 1.3 require_php_with_use()
181     {
182 stuart 1.1 has_php
183    
184     local missing_use=
185     local x
186    
187     einfo "Checking for required PHP feature(s):"
188    
189     for x in $@ ; do
190     if ! built_with_use =${PHP_PKG} ${x} ; then
191     einfo " Discovered missing USE flag ${x}"
192     missing_use="${missing_use} ${x}"
193     fi
194     done
195    
196     if [[ -z ${missing_use} ]]; then
197     return
198     fi
199    
200     eerror
201     eerror "${PHP_PKG} needs to be re-installed with all of the following"
202     eerror "USE flags enabled:"
203     eerror
204     eerror " $@"
205     eerror
206     die "Re-install ${PHP_PKG}"
207     }
208    
209 hollow 1.3 # call this function from your pkg_setup, src_compile & src_install methods
210     # if you need to know where the PHP binaries are installed and their data
211 stuart 1.1
212     has_php()
213     {
214     # if PHP_PKG is set, then we have remembered our PHP settings
215     # from last time
216 hollow 1.3
217 stuart 1.1 if [[ -n ${PHP_PKG} ]]; then
218     return
219     fi
220    
221     if [[ -z ${PHP_VERSION} ]]; then
222     # detect which PHP version installed
223     if has_version '=dev-lang/php-5*' ; then
224     PHP_VERSION=5
225     elif has_version '=dev-lang/php-4*' ; then
226     PHP_VERSION=4
227     else
228     die "Unable to find an installed dev-lang/php package"
229     fi
230     fi
231    
232     # if we get here, then PHP_VERSION tells us which version of PHP we
233     # want to use
234    
235     uses_php${PHP_VERSION}
236     }
237    
238     # ========================================================================
239     # has_*() functions
240     #
241     # these functions return 0 if the condition is satisfied, or 1 otherwise
242     # ========================================================================
243    
244 hollow 1.3 # check if our PHP was compiled with ZTS (Zend Thread Safety)
245    
246 stuart 1.1 has_zts()
247     {
248     has_php
249    
250     if built_with_use =${PHP_PKG} apache2 threads ; then
251     return 0
252     fi
253    
254     return 1
255     }
256    
257 hollow 1.3 # check if our PHP was built with Hardened-PHP active
258    
259     has_hardenedphp()
260     {
261     has_php
262    
263     if built_with_use =${PHP_PKG} hardenedphp ; then
264     return 0
265     fi
266    
267     return 1
268     }
269    
270 stuart 1.1 # ========================================================================
271     # require_*() functions
272     #
273     # These functions die() if PHP was built without the required USE flag(s)
274     # ========================================================================
275    
276 hollow 1.3 # require a PHP built with PDO support for PHP5
277    
278 stuart 1.1 require_pdo()
279     {
280     has_php
281    
282     # do we have php5.1 installed?
283    
284     if [[ ${PHP_VERSION} == 4 ]] ; then
285     eerror
286 hollow 1.3 eerror "This package requires PDO."
287     eerror "PDO is only available for PHP 5."
288 stuart 1.1 eerror "Please install dev-lang/php-5*"
289     eerror
290     die "PHP 5 not installed"
291     fi
292    
293     # was php5 compiled w/ pdo support?
294    
295     if built_with_use =${PHP_PKG} pdo ; then
296     return
297     fi
298    
299     # ok, maybe PDO was built as an external extension?
300    
301     if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then
302     return
303     fi
304    
305 hollow 1.3 # ok, as last resort, it suffices that pecl-pdo was installed to have PDO support
306 stuart 1.1
307     if has_version dev-php5/pecl-pdo ; then
308     return
309     fi
310    
311 hollow 1.3 # if we get here, then we have no PDO support
312 stuart 1.1
313     eerror
314     eerror "No PDO extension for PHP found."
315     eerror "Please note that PDO only exists for PHP 5."
316     eerror "Please install a PDO extension for PHP 5,"
317     eerror "you must install dev-lang/php-5.0* with"
318     eerror "the 'pdo-external' USE flag or you must"
319     eerror "install dev-lang/php-5.1* with either"
320     eerror "the 'pdo' or the 'pdo-external' USE flags"
321     eerror "turned on."
322     eerror
323 hollow 1.3 die "No PDO extension found for PHP 5"
324 stuart 1.1 }
325    
326     # determines which installed PHP version has the CLI sapi
327     # useful for PEAR eclass, or anything which needs to run PHP
328 hollow 1.3 # scripts depending on the cli sapi
329 stuart 1.1
330     require_php_cli()
331     {
332     # if PHP_PKG is set, then we have remembered our PHP settings
333     # from last time
334 hollow 1.3
335 stuart 1.1 if [[ -n ${PHP_PKG} ]]; then
336     return
337     fi
338    
339     # detect which PHP version installed
340     if has_version '=dev-lang/php-5*' ; then
341     pkg="`best_version '=dev-lang/php-5*'`"
342     if built_with_use =${pkg} cli ; then
343     PHP_VERSION=5
344     fi
345     elif has_version '=dev-lang/php-4*' ; then
346     pkg="`best_version '=dev-lang/php-4*'`"
347     if built_with_use =${pkg} cli ; then
348     PHP_VERSION=4
349     fi
350     else
351     die "Unable to find an installed dev-lang/php package"
352     fi
353    
354     if [[ -z ${PHP_VERSION} ]]; then
355     die "No PHP CLI installed"
356     fi
357    
358     # if we get here, then PHP_VERSION tells us which version of PHP we
359     # want to use
360 hollow 1.3
361     uses_php${PHP_VERSION}
362     }
363    
364     # determines which installed PHP version has the CGI sapi
365     # useful for anything which needs to run PHP scripts
366     # depending on the cgi sapi
367    
368     require_php_cgi()
369     {
370     # if PHP_PKG is set, then we have remembered our PHP settings
371     # from last time
372    
373     if [[ -n ${PHP_PKG} ]]; then
374     return
375     fi
376    
377     # detect which PHP version installed
378     if has_version '=dev-lang/php-5*' ; then
379     pkg="`best_version '=dev-lang/php-5*'`"
380     if built_with_use =${pkg} cgi ; then
381     PHP_VERSION=5
382     fi
383     elif has_version '=dev-lang/php-4*' ; then
384     pkg="`best_version '=dev-lang/php-4*'`"
385     if built_with_use =${pkg} cgi ; then
386     PHP_VERSION=4
387     fi
388     else
389     die "Unable to find an installed dev-lang/php package"
390     fi
391    
392     if [[ -z ${PHP_VERSION} ]]; then
393     die "No PHP CGI installed"
394     fi
395    
396     # if we get here, then PHP_VERSION tells us which version of PHP we
397     # want to use
398    
399 stuart 1.1 uses_php${PHP_VERSION}
400     }
401    
402     # require a PHP built with sqlite support
403    
404     require_sqlite()
405     {
406     has_php
407    
408 hollow 1.3 # has our PHP been built with sqlite?
409    
410 stuart 1.1 if built_with_use =${PHP_PKG} sqlite ; then
411     return
412     fi
413    
414 hollow 1.3 # do we have pecl-sqlite installed for PHP 4?
415    
416 stuart 1.1 if [[ ${PHP_VERSION} == 4 ]] ; then
417     if has_version dev-php4/pecl-sqlite ; then
418     return
419     fi
420     fi
421    
422 hollow 1.3 # if we get here, then we don't have any sqlite support for PHP installed
423    
424 stuart 1.1 eerror
425     eerror "No sqlite extension for PHP found."
426     eerror "Please install an sqlite extension for PHP,"
427     eerror "this is done best by simply adding the"
428     eerror "'sqlite' USE flag when emerging dev-lang/php."
429     eerror
430     die "No sqlite extension for PHP found"
431     }
432 hollow 1.3
433     require_gd()
434     {
435     has_php
436    
437     # do we have the internal GD support installed?
438    
439     if built_with_use =${PHP_PKG} gd ; then
440     return
441     fi
442    
443     # ok, maybe GD was built using the external support?
444    
445     if built_with_use =${PHP_PKG} gd-external ; then
446     return
447     fi
448    
449     # if we get here, then we have no GD support
450    
451     eerror
452     eerror "No GD support for PHP found."
453     eerror "Please install the GD support for PHP,"
454     eerror "you must install dev-lang/php with either"
455     eerror "the 'gd' or the 'gd-external' USE flags"
456     eerror "turned on."
457     eerror
458     die "No GD support found for PHP"
459     }

  ViewVC Help
Powered by ViewVC 1.1.20