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

Contents of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun Sep 4 10:54:53 2005 UTC (9 years ago) by stuart
Branch: MAIN
New & updated eclasses for new PHP packages

1 # Copyright 1999-2005 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
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 # ========================================================================
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 #
122 # returns if any one of the listed SAPIs has been installed
123 # dies if none of the listed SAPIs has been installed
124
125 require_php_sapi_from() {
126 has_php
127
128 local has_sapi=0
129 local x
130
131 einfo "Checking for compatible SAPI(s)"
132
133 for x in $@ ; do
134 if built_with_use =${PHP_PKG} ${x} ; then
135 einfo " Discovered compatible SAPI ${x}"
136 has_sapi=1
137 fi
138 done
139
140 if [[ ${has_sapi} == 1 ]]; then
141 return
142 fi
143
144 eerror
145 eerror "${PHP_PKG} needs to be re-installed with one of the following"
146 eerror "USE flags enabled:"
147 eerror
148 eerror " $@"
149 eerror
150 die "Re-install ${PHP_PKG}"
151 }
152
153 # call this function from pkg_setup if your package requires PHP compiled
154 # with specific USE flags
155 #
156 # this function will disappear when USE-based deps are supported by
157 # Portage
158 #
159 # $1 ... a list of USE flags
160 #
161 # returns if all of the listed USE flags are set
162 # dies if any of the listed USE flags are not set
163
164 require_php_with_use() {
165 has_php
166
167 local missing_use=
168 local x
169
170 einfo "Checking for required PHP feature(s):"
171
172 for x in $@ ; do
173 if ! built_with_use =${PHP_PKG} ${x} ; then
174 einfo " Discovered missing USE flag ${x}"
175 missing_use="${missing_use} ${x}"
176 fi
177 done
178
179 if [[ -z ${missing_use} ]]; then
180 return
181 fi
182
183 eerror
184 eerror "${PHP_PKG} needs to be re-installed with all of the following"
185 eerror "USE flags enabled:"
186 eerror
187 eerror " $@"
188 eerror
189 die "Re-install ${PHP_PKG}"
190 }
191
192 # call this function from your src_compile & src_install methods
193 # if you need to know where the PHP binaries are installed
194
195 has_php()
196 {
197 # if PHP_PKG is set, then we have remembered our PHP settings
198 # from last time
199 if [[ -n ${PHP_PKG} ]]; then
200 return
201 fi
202
203 if [[ -z ${PHP_VERSION} ]]; then
204 # detect which PHP version installed
205 if has_version '=dev-lang/php-5*' ; then
206 PHP_VERSION=5
207 elif has_version '=dev-lang/php-4*' ; then
208 PHP_VERSION=4
209 else
210 die "Unable to find an installed dev-lang/php package"
211 fi
212 fi
213
214 # if we get here, then PHP_VERSION tells us which version of PHP we
215 # want to use
216
217 uses_php${PHP_VERSION}
218 }
219
220 # ========================================================================
221 # has_*() functions
222 #
223 # these functions return 0 if the condition is satisfied, or 1 otherwise
224 # ========================================================================
225
226 has_zts()
227 {
228 has_php
229
230 if built_with_use =${PHP_PKG} apache2 threads ; then
231 return 0
232 fi
233
234 return 1
235 }
236
237 # ========================================================================
238 # require_*() functions
239 #
240 # These functions die() if PHP was built without the required USE flag(s)
241 # ========================================================================
242
243 require_pdo()
244 {
245 has_php
246
247 # do we have php5.1 installed?
248
249 if [[ ${PHP_VERSION} == 4 ]] ; then
250 eerror
251 eerror "This package requires PDO. PDO is only available for PHP 5."
252 eerror "Please install dev-lang/php-5*"
253 eerror
254 die "PHP 5 not installed"
255 fi
256
257 # was php5 compiled w/ pdo support?
258
259 if built_with_use =${PHP_PKG} pdo ; then
260 return
261 fi
262
263 # ok, maybe PDO was built as an external extension?
264
265 if built_with_use =${PHP_PKG} pdo-external && has_version dev-php5/pecl-pdo ; then
266 return
267 fi
268
269 # it suffices that pecl-pdo was installed to have PDO support
270
271 if has_version dev-php5/pecl-pdo ; then
272 return
273 fi
274
275 # if we get here, then we have no PDO support :(
276
277 eerror
278 eerror "No PDO extension for PHP found."
279 eerror "Please note that PDO only exists for PHP 5."
280 eerror "Please install a PDO extension for PHP 5,"
281 eerror "you must install dev-lang/php-5.0* with"
282 eerror "the 'pdo-external' USE flag or you must"
283 eerror "install dev-lang/php-5.1* with either"
284 eerror "the 'pdo' or the 'pdo-external' USE flags"
285 eerror "turned on."
286 eerror
287 die "No PDO extension found for PHP"
288 }
289
290 # determines which installed PHP version has the CLI sapi
291 # useful for PEAR eclass, or anything which needs to run PHP
292 # scripts
293
294 require_php_cli()
295 {
296 # if PHP_PKG is set, then we have remembered our PHP settings
297 # from last time
298 if [[ -n ${PHP_PKG} ]]; then
299 return
300 fi
301
302 # detect which PHP version installed
303 if has_version '=dev-lang/php-5*' ; then
304 pkg="`best_version '=dev-lang/php-5*'`"
305 if built_with_use =${pkg} cli ; then
306 PHP_VERSION=5
307 fi
308 elif has_version '=dev-lang/php-4*' ; then
309 pkg="`best_version '=dev-lang/php-4*'`"
310 if built_with_use =${pkg} cli ; then
311 PHP_VERSION=4
312 fi
313 else
314 die "Unable to find an installed dev-lang/php package"
315 fi
316
317 if [[ -z ${PHP_VERSION} ]]; then
318 die "No PHP CLI installed"
319 fi
320
321 # if we get here, then PHP_VERSION tells us which version of PHP we
322 # want to use
323 uses_php${PHP_VERSION}
324 }
325
326 # require a PHP built with sqlite support
327
328 require_sqlite()
329 {
330 has_php
331
332 # has our PHP been built w/ sqlite?
333 if built_with_use =${PHP_PKG} sqlite ; then
334 return
335 fi
336
337 # do we have pecl-sqlite installed for PHP4?
338 if [[ ${PHP_VERSION} == 4 ]] ; then
339 if has_version dev-php4/pecl-sqlite ; then
340 return
341 fi
342 fi
343
344 # if we get here, then we don't have any php/sqlite support installed
345 eerror
346 eerror "No sqlite extension for PHP found."
347 eerror "Please install an sqlite extension for PHP,"
348 eerror "this is done best by simply adding the"
349 eerror "'sqlite' USE flag when emerging dev-lang/php."
350 eerror
351 die "No sqlite extension for PHP found"
352 }

  ViewVC Help
Powered by ViewVC 1.1.20