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

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Sun Sep 11 16:39:10 2005 UTC (9 years, 3 months ago) by hollow
Branch: MAIN
Changes since 1.2: +107 -15 lines
fix pear bug + minor fixes

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

  ViewVC Help
Powered by ViewVC 1.1.20