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

Diff of /eclass/depend.php.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.30
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.1 2005/09/04 10:54:53 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/depend.php.eclass,v 1.30 2011/08/22 04:46:31 vapier Exp $
4# 4
5# ========================================================================
6#
7# depend.php.eclass 5# @ECLASS: depend.php.eclass
8# functions to allow ebuilds to depend on php4 and/or php5 6# @MAINTAINER:
9# 7# Gentoo PHP team <php-bugs@gentoo.org>
10# Author: Stuart Herbert 8# @AUTHOR:
11# (stuart@gentoo.org) 9# Author: Stuart Herbert <stuart@gentoo.org>
12# 10# Author: Luca Longinotti <chtekk@gentoo.org>
13# ======================================================================== 11# Author: Jakub Moc <jakub@gentoo.org> (documentation)
12# @BLURB: Functions to allow ebuilds to depend on php5 and check for specific features.
13# @DESCRIPTION:
14# This eclass provides functions that allow ebuilds to depend on php5 and check
15# for specific PHP features, SAPIs etc. Also provides dodoc-php wrapper to install
16# documentation for PHP packages to php-specific location.
14 17
15inherit eutils 18inherit eutils phpconfutils
16 19
20# PHP5-only depend functions
21
22# @FUNCTION: need_php5_cli
23# @DESCRIPTION:
24# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
25# with cli SAPI.
17need_php4_cli() 26need_php5_cli() {
18{
19 DEPEND="${DEPEND} =virtual/php-4*"
20 RDEPEND="${RDEPEND} =virtual/php-4*"
21 PHP_VERSION=4
22}
23
24need_php4_httpd()
25{
26 DEPEND="${DEPEND} =virtual/httpd-php-4*"
27 RDEPEND="${RDEPEND} =virtual/httpd-php-4*"
28 PHP_VERSION=4
29}
30
31need_php4()
32{
33 DEPEND="${DEPEND} =dev-lang/php-4*" 27 DEPEND="${DEPEND} =dev-lang/php-5*"
34 RDEPEND="${RDEPEND} =dev-lang/php-4*" 28 RDEPEND="${RDEPEND} =dev-lang/php-5*"
35 PHP_VERSION=4
36 PHP_SHARED_CAT="php4"
37}
38
39# common settings go in here
40uses_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
57need_php5_cli()
58{
59 DEPEND="${DEPEND} =virtual/php-5*"
60 RDEPEND="${RDEPEND} =virtual/php-5*"
61 PHP_VERSION=5 29 PHP_VERSION="5"
62} 30}
63 31
32# @FUNCTION: need_php5_httpd
33# @DESCRIPTION:
34# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
35# with either cgi or apache2 SAPI.
64need_php5_httpd() 36need_php5_httpd() {
65{
66 DEPEND="${DEPEND} =virtual/httpd-php-5*" 37 DEPEND="${DEPEND} =virtual/httpd-php-5*"
67 RDEPEND="${RDEPEND} =virtual/httpd-php-5*" 38 RDEPEND="${RDEPEND} =virtual/httpd-php-5*"
68 PHP_VERSION=5 39 PHP_VERSION="5"
69} 40}
70 41
42# @FUNCTION: need_php5
43# @DESCRIPTION:
44# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP5
45# (with any SAPI).
71need_php5() 46need_php5() {
72{
73 DEPEND="${DEPEND} =dev-lang/php-5*" 47 DEPEND="${DEPEND} =dev-lang/php-5*"
74 RDEPEND="${RDEPEND} =dev-lang/php-5*" 48 RDEPEND="${RDEPEND} =dev-lang/php-5*"
75 PHP_VERSION=5 49 PHP_VERSION="5"
76 PHP_SHARED_CAT="php5" 50 PHP_SHARED_CAT="php5"
77} 51}
78 52
79# common settings go in here 53# common settings go in here
80uses_php5() 54uses_php5() {
81{
82 # cache this 55 # cache this
83 libdir=$(get_libdir) 56 libdir=$(get_libdir)
84 57
85 PHPIZE="/usr/${libdir}/php5/bin/phpize" 58 PHPIZE="/usr/${libdir}/php5/bin/phpize"
86 PHPCONFIG="/usr/${libdir}/php5/bin/php-config" 59 PHPCONFIG="/usr/${libdir}/php5/bin/php-config"
87 PHPCLI="/usr/${libdir}/php5/bin/php" 60 PHPCLI="/usr/${libdir}/php5/bin/php"
88 PHPCGI="/usr/${libdir}/php5/bin/php-cgi" 61 PHPCGI="/usr/${libdir}/php5/bin/php-cgi"
89 PHP_PKG="`best_version =dev-lang/php-5*`" 62 PHP_PKG="$(best_version =dev-lang/php-5*)"
90 PHPPREFIX="/usr/${libdir}/php5" 63 PHPPREFIX="/usr/${libdir}/php5"
64 EXT_DIR="$(${PHPCONFIG} --extension-dir 2>/dev/null)"
91 65
92 einfo 66 einfo
93 einfo "Using ${PHP_PKG}" 67 einfo "Using ${PHP_PKG}"
94 einfo 68 einfo
95} 69}
96 70
71# general PHP depend functions
72
73# @FUNCTION: need_php_cli
74# @DESCRIPTION:
75# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
76# (any version) with cli SAPI.
77need_php_cli() {
78 DEPEND="${DEPEND} dev-lang/php"
79 RDEPEND="${RDEPEND} dev-lang/php"
80}
81
82# @FUNCTION: need_php_httpd
83# @DESCRIPTION:
84# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
85# (any version) with either cgi or apache2 SAPI.
86need_php_httpd() {
87 DEPEND="${DEPEND} virtual/httpd-php"
88 RDEPEND="${RDEPEND} virtual/httpd-php"
89}
90
91# @FUNCTION: need_php
92# @DESCRIPTION:
93# Set this after setting DEPEND/RDEPEND in your ebuild if the ebuild requires PHP
94# (any version with any SAPI).
97need_php() 95need_php() {
98{
99 DEPEND="${DEPEND} dev-lang/php" 96 DEPEND="${DEPEND} dev-lang/php"
100 RDEPEND="${RDEPEND} dev-lang/php" 97 RDEPEND="${RDEPEND} dev-lang/php"
101 PHP_SHARED_CAT="php" 98 PHP_SHARED_CAT="php"
102} 99}
103 100
101# @FUNCTION: need_php_by_category
102# @DESCRIPTION:
103# Set this after setting DEPEND/RDEPEND in your ebuild to depend on PHP version
104# determined by ${CATEGORY} - any PHP version or PHP5 for dev-php or
105# dev-php5, respectively.
104need_php_by_category() 106need_php_by_category() {
105{
106 case "${CATEGORY}" in 107 case "${CATEGORY}" in
107 dev-php) need_php ;; 108 dev-php) need_php ;;
108 dev-php4) need_php4 ;;
109 dev-php5) need_php5 ;; 109 dev-php5) need_php5 ;;
110 *) die "I don't know which version of PHP packages in ${CATEGORY} require" 110 *) die "Version of PHP required by packages in category ${CATEGORY} unknown"
111 esac 111 esac
112} 112}
113 113
114
115# @FUNCTION: has_php
116# @DESCRIPTION:
117# Call this function from your pkg_setup, src_compile, src_install etc. if you
118# need to know which PHP version is being used and where the PHP binaries/data
119# are installed.
120has_php() {
121 # Detect which PHP version we have installed
122 if has_version '=dev-lang/php-5*' ; then
123 PHP_VERSION="5"
124 else
125 die "Unable to find an installed dev-lang/php package"
126 fi
127
128 # If we get here, then PHP_VERSION tells us which version of PHP we
129 # want to use
130 uses_php${PHP_VERSION}
131}
132
133# @FUNCTION: require_php_sapi_from
134# @USAGE: <list of SAPIs>
135# @DESCRIPTION:
114# call this function from pkg_setup if your PHP extension only works with 136# Call this function from pkg_setup if your package only works with
115# specific SAPIs 137# specific SAPI(s) and specify a list of PHP SAPI USE flags that are
138# required (one or more from cli, cgi, apache2) as arguments.
139# Returns if any of the listed SAPIs have been installed, dies if none
140# of them is available.
116# 141#
117# this function will disappear when USE-based deps are supported by 142# Unfortunately, if you want to be really sure that the required SAPI is
118# Portage 143# provided by PHP, you will have to use this function or similar ones (like
119# 144# require_php_cli or require_php_cgi) in pkg_setup until we are able to
120# $1 ... a list of SAPI USE flags (eg cli, cgi, apache2) 145# depend on USE flags being enabled. The above described need_php[45]_cli
121# 146# and need_php[45]_httpd functions cannot guarantee these requirements.
122# returns if any one of the listed SAPIs has been installed 147# See Bug 2272 for details.
123# dies if none of the listed SAPIs has been installed
124
125require_php_sapi_from() { 148require_php_sapi_from() {
126 has_php 149 has_php
127 150
128 local has_sapi=0 151 local has_sapi="0"
129 local x 152 local x
130 153
131 einfo "Checking for compatible SAPI(s)" 154 einfo "Checking for compatible SAPI(s)"
132 155
133 for x in $@ ; do 156 for x in $@ ; do
134 if built_with_use =${PHP_PKG} ${x} ; then 157 if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
135 einfo " Discovered compatible SAPI ${x}" 158 einfo " Discovered compatible SAPI ${x}"
136 has_sapi=1 159 has_sapi="1"
137 fi 160 fi
138 done 161 done
139 162
140 if [[ ${has_sapi} == 1 ]]; then 163 if [[ "${has_sapi}" == "1" ]] ; then
141 return 164 return
142 fi 165 fi
143 166
144 eerror 167 eerror
145 eerror "${PHP_PKG} needs to be re-installed with one of the following" 168 eerror "${PHP_PKG} needs to be re-installed with one of the following"
146 eerror "USE flags enabled:" 169 eerror "USE flags enabled:"
147 eerror 170 eerror
148 eerror " $@" 171 eerror " $@"
149 eerror 172 eerror
150 die "Re-install ${PHP_PKG}" 173 die "No compatible PHP SAPIs found"
151} 174}
152 175
176# @FUNCTION: require_php_with_use
177# @USAGE: <list of USE flags>
178# @DESCRIPTION:
153# call this function from pkg_setup if your package requires PHP compiled 179# Call this function from pkg_setup if your package requires PHP compiled
154# with specific USE flags 180# with specific USE flags. Returns if all of the listed USE flags are enabled.
181# Dies if any of the listed USE flags are disabled.
182
183# @VARIABLE: PHPCHECKNODIE
184# @DESCRIPTION:
185# You can set PHPCHECKNODIE to non-empty value in your ebuild to chain multiple
186# require_php_with_(any)_use checks without making the ebuild die on every failure.
187# This is useful in cases when certain PHP features are only required if specific
188# USE flag(s) are enabled for that ebuild.
189# @CODE
190# Example:
155# 191#
156# this function will disappear when USE-based deps are supported by 192# local flags="pcre session snmp sockets wddx"
157# Portage 193# use mysql && flags="${flags} mysql"
158# 194# use postgres && flags="${flags} postgres"
159# $1 ... a list of USE flags 195# if ! PHPCHECKNODIE="yes" require_php_with_use ${flags} \
160# 196# || ! PHPCHECKNODIE="yes" require_php_with_any_use gd gd-external ; then
161# returns if all of the listed USE flags are set 197# die "Re-install ${PHP_PKG} with ${flags} and either gd or gd-external"
162# dies if any of the listed USE flags are not set 198# fi
163 199# @CODE
164require_php_with_use() { 200require_php_with_use() {
165 has_php 201 has_php
166 202
167 local missing_use= 203 local missing_use=""
168 local x 204 local x
169 205
170 einfo "Checking for required PHP feature(s):" 206 einfo "Checking for required PHP feature(s) ..."
171 207
172 for x in $@ ; do 208 for x in $@ ; do
173 if ! built_with_use =${PHP_PKG} ${x} ; then 209 case $x in
210 pcre|spl|reflection|mhash)
211 eqawarn "require_php_with_use MUST NOT check for the pcre, spl, mhash or reflection USE flag."
212 eqawarn "These USE flags are removed from >=dev-lang/php-5.3 and your ebuild will break"
213 eqawarn "if you check the USE flags against PHP 5.3 ebuilds."
214 eqawarn "Please use USE dependencies from EAPI 2 instead"
215 ;;
216 esac
217
218 if ! built_with_use =${PHP_PKG} ${x} && ! phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
174 einfo " Discovered missing USE flag ${x}" 219 einfo " Discovered missing USE flag: ${x}"
175 missing_use="${missing_use} ${x}" 220 missing_use="${missing_use} ${x}"
176 fi 221 fi
177 done 222 done
178 223
179 if [[ -z ${missing_use} ]]; then 224 if [[ -z "${missing_use}" ]] ; then
225 if [[ -z "${PHPCHECKNODIE}" ]] ; then
180 return 226 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
195has_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 227 else
210 die "Unable to find an installed dev-lang/php package" 228 return 0
211 fi
212 fi 229 fi
230 fi
213 231
214 # if we get here, then PHP_VERSION tells us which version of PHP we 232 if [[ -z "${PHPCHECKNODIE}" ]] ; then
215 # want to use 233 eerror
234 eerror "${PHP_PKG} needs to be re-installed with all of the following"
235 eerror "USE flags enabled:"
236 eerror
237 eerror " $@"
238 eerror
239 die "Missing PHP USE flags found"
240 else
241 return 1
242 fi
243}
216 244
217 uses_php${PHP_VERSION} 245# @FUNCTION: require_php_with_any_use
246# @USAGE: <list of USE flags>
247# @DESCRIPTION:
248# Call this function from pkg_setup if your package requires PHP compiled with
249# any of specified USE flags. Returns if any of the listed USE flags are enabled.
250# Dies if all of the listed USE flags are disabled.
251require_php_with_any_use() {
252 has_php
253
254 local missing_use=""
255 local x
256
257 einfo "Checking for required PHP feature(s) ..."
258
259 for x in $@ ; do
260 if built_with_use =${PHP_PKG} ${x} || phpconfutils_built_with_use =${PHP_PKG} ${x} ; then
261 einfo " USE flag ${x} is enabled, ok ..."
262 return
263 else
264 missing_use="${missing_use} ${x}"
265 fi
266 done
267
268 if [[ -z "${missing_use}" ]] ; then
269 if [[ -z "${PHPCHECKNODIE}" ]] ; then
270 return
271 else
272 return 0
273 fi
274 fi
275
276 if [[ -z "${PHPCHECKNODIE}" ]] ; then
277 eerror
278 eerror "${PHP_PKG} needs to be re-installed with any of the following"
279 eerror "USE flags enabled:"
280 eerror
281 eerror " $@"
282 eerror
283 die "Missing PHP USE flags found"
284 else
285 return 1
286 fi
218} 287}
219 288
220# ======================================================================== 289# ========================================================================
221# has_*() functions 290# has_*() functions
222# 291#
223# these functions return 0 if the condition is satisfied, or 1 otherwise 292# These functions return 0 if the condition is satisfied, 1 otherwise
224# ======================================================================== 293# ========================================================================
225 294
295# @FUNCTION: has_zts
296# @DESCRIPTION:
297# Check if our PHP was compiled with ZTS (Zend Thread Safety) enabled.
298# @RETURN: 0 if true, 1 otherwise
226has_zts() 299has_zts() {
227{
228 has_php 300 has_php
229 301
230 if built_with_use =${PHP_PKG} apache2 threads ; then 302 if built_with_use =${PHP_PKG} apache2 threads || phpconfutils_built_with_use =${PHP_PKG} apache2 threads ; then
303 return 0
304 fi
305
306 return 1
307}
308
309# @FUNCTION: has_debug
310# @DESCRIPTION:
311# Check if our PHP was built with debug support enabled.
312# @RETURN: 0 if true, 1 otherwise
313has_debug() {
314 has_php
315
316 if built_with_use =${PHP_PKG} debug || phpconfutils_built_with_use =${PHP_PKG} debug ; then
317 return 0
318 fi
319
320 return 1
321}
322
323# @FUNCTION: has_concurrentmodphp
324# @DESCRIPTION:
325# Check if our PHP was built with the concurrentmodphp support enabled.
326# @RETURN: 0 if true, 1 otherwise
327has_concurrentmodphp() {
328 has_php
329
330 if built_with_use =${PHP_PKG} apache2 concurrentmodphp || phpconfutils_built_with_use =${PHP_PKG} apache2 concurrentmodphp ; then
231 return 0 331 return 0
232 fi 332 fi
233 333
234 return 1 334 return 1
235} 335}
236 336
237# ======================================================================== 337# ========================================================================
238# require_*() functions 338# require_*() functions
239# 339#
240# These functions die() if PHP was built without the required USE flag(s) 340# These functions die() if PHP was built without the required features
241# ======================================================================== 341# ========================================================================
242 342
343# @FUNCTION: require_pdo
344# @DESCRIPTION:
345# Require a PHP built with PDO support (PHP5 only).
346# This function is now redundant and DEPRECATED since
347# pdo-external use flag and pecl-pdo-* ebuilds were removed.
348# You should use require_php_with_use pdo instead now.
349# @RETURN: die if feature is missing
243require_pdo() 350require_pdo() {
244{
245 has_php 351 has_php
246 352
247 # do we have php5.1 installed? 353 # Was PHP5 compiled with internal PDO support?
248 354 if built_with_use =${PHP_PKG} pdo || phpconfutils_built_with_use =${PHP_PKG} pdo ; then
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 355 return
261 fi 356 else
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 357 eerror
278 eerror "No PDO extension for PHP found." 358 eerror "No PDO extension for PHP found."
279 eerror "Please note that PDO only exists for PHP 5." 359 eerror "Please note that PDO only exists for PHP 5."
280 eerror "Please install a PDO extension for PHP 5," 360 eerror "Please install a PDO extension for PHP 5."
281 eerror "you must install dev-lang/php-5.0* with" 361 eerror "You must install >=dev-lang/php-5.1 with USE=\"pdo\"."
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 362 eerror
287 die "No PDO extension found for PHP" 363 die "No PDO extension for PHP 5 found"
364 fi
288} 365}
289 366
367# @FUNCTION: require_php_cli
368# @DESCRIPTION:
290# determines which installed PHP version has the CLI sapi 369# Determines which installed PHP version has the CLI SAPI enabled.
291# useful for PEAR eclass, or anything which needs to run PHP 370# Useful for PEAR stuff, or anything which needs to run PHP script
292# scripts 371# depending on the CLI SAPI.
293 372# @RETURN: die if feature is missing
294require_php_cli() 373require_php_cli() {
295{
296 # if PHP_PKG is set, then we have remembered our PHP settings 374 # If PHP_PKG is set, then we have remembered our PHP settings
297 # from last time 375 # from last time
298 if [[ -n ${PHP_PKG} ]]; then 376 if [[ -n ${PHP_PKG} ]] ; then
299 return 377 return
300 fi 378 fi
301 379
302 # detect which PHP version installed 380 local PHP_PACKAGE_FOUND=""
381
303 if has_version '=dev-lang/php-5*' ; then 382 if has_version '=dev-lang/php-5*' ; then
383 PHP_PACKAGE_FOUND="1"
304 pkg="`best_version '=dev-lang/php-5*'`" 384 pkg="$(best_version '=dev-lang/php-5*')"
305 if built_with_use =${pkg} cli ; then 385 if built_with_use =${pkg} cli || phpconfutils_built_with_use =${pkg} cli ; then
306 PHP_VERSION=5 386 PHP_VERSION="5"
387 fi
307 fi 388 fi
308 elif has_version '=dev-lang/php-4*' ; then 389
309 pkg="`best_version '=dev-lang/php-4*'`" 390 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
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" 391 die "Unable to find an installed dev-lang/php package"
315 fi 392 fi
316 393
317 if [[ -z ${PHP_VERSION} ]]; then 394 if [[ -z ${PHP_VERSION} ]] ; then
318 die "No PHP CLI installed" 395 die "No PHP CLI installed. Re-emerge dev-lang/php with USE=cli."
319 fi 396 fi
320 397
321 # if we get here, then PHP_VERSION tells us which version of PHP we 398 # If we get here, then PHP_VERSION tells us which version of PHP we
322 # want to use 399 # want to use
323 uses_php${PHP_VERSION} 400 uses_php${PHP_VERSION}
324} 401}
325 402
326# require a PHP built with sqlite support 403# @FUNCTION: require_php_cgi
327 404# @DESCRIPTION:
328require_sqlite() 405# Determines which installed PHP version has the CGI SAPI enabled.
329{ 406# Useful for anything which needs to run PHP scripts depending on the CGI SAPI.
330 has_php 407# @RETURN: die if feature is missing
331 408require_php_cgi() {
332 # has our PHP been built w/ sqlite? 409 # If PHP_PKG is set, then we have remembered our PHP settings
333 if built_with_use =${PHP_PKG} sqlite ; then 410 # from last time
334 return 411 if [[ -n ${PHP_PKG} ]] ; then
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 412 return
341 fi 413 fi
414
415 local PHP_PACKAGE_FOUND=""
416
417 if has_version '=dev-lang/php-5*' ; then
418 PHP_PACKAGE_FOUND="1"
419 pkg="$(best_version '=dev-lang/php-5*')"
420 if built_with_use =${pkg} cgi || phpconfutils_built_with_use =${pkg} cgi ; then
421 PHP_VERSION="5"
342 fi 422 fi
423 fi
343 424
425 if [[ -z ${PHP_PACKAGE_FOUND} ]] ; then
426 die "Unable to find an installed dev-lang/php package"
427 fi
428
429 if [[ -z ${PHP_VERSION} ]] ; then
430 die "No PHP CGI installed. Re-emerge dev-lang/php with USE=cgi."
431 fi
432
433 # If we get here, then PHP_VERSION tells us which version of PHP we
434 # want to use
435 uses_php${PHP_VERSION}
436}
437
438# @FUNCTION: require_sqlite
439# @DESCRIPTION:
440# Require a PHP built with SQLite support
441# @RETURN: die if feature is missing
442require_sqlite() {
443 has_php
444
445 # 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 return
448 fi
449
344 # if we get here, then we don't have any php/sqlite support installed 450 # If we get here, then we don't have any SQLite support for PHP installed
345 eerror 451 eerror
346 eerror "No sqlite extension for PHP found." 452 eerror "No SQLite extension for PHP found."
347 eerror "Please install an sqlite extension for PHP," 453 eerror "Please install an SQLite extension for PHP,"
348 eerror "this is done best by simply adding the" 454 eerror "this is done best by simply adding the"
349 eerror "'sqlite' USE flag when emerging dev-lang/php." 455 eerror "'sqlite' USE flag when emerging dev-lang/php."
350 eerror 456 eerror
351 die "No sqlite extension for PHP found" 457 die "No SQLite extension for PHP found"
352} 458}
459
460# @FUNCTION: require_gd
461# @DESCRIPTION:
462# Require a PHP built with GD support
463# @RETURN: die if feature is missing
464require_gd() {
465 has_php
466
467 # Do we have the internal GD support installed?
468 if built_with_use =${PHP_PKG} gd || phpconfutils_built_with_use =${PHP_PKG} gd ; then
469 return
470 fi
471
472 # Ok, maybe GD was built using the external library support?
473 if built_with_use =${PHP_PKG} gd-external || phpconfutils_built_with_use =${PHP_PKG} gd-external ; then
474 return
475 fi
476
477 # If we get here, then we have no GD support
478 eerror
479 eerror "No GD support for PHP found."
480 eerror "Please install the GD support for PHP,"
481 eerror "you must install dev-lang/php with either"
482 eerror "the 'gd' or the 'gd-external' USE flags"
483 eerror "turned on."
484 eerror
485 die "No GD support found for PHP"
486}
487
488# ========================================================================
489# Misc functions
490#
491# These functions provide miscellaneous checks and functionality.
492# ========================================================================
493
494# @FUNCTION: php_binary_extension
495# @DESCRIPTION:
496# Executes some checks needed when installing a binary PHP extension.
497php_binary_extension() {
498 has_php
499
500 local PUSE_ENABLED=""
501
502 # Binary extensions do not support the change of PHP
503 # API version, so they can't be installed when USE flags
504 # are enabled which change the PHP API version, they also
505 # don't provide correctly versioned symbols for our use
506
507 if has_debug ; then
508 eerror
509 eerror "You cannot install binary PHP extensions"
510 eerror "when the 'debug' USE flag is enabled!"
511 eerror "Please reemerge dev-lang/php with the"
512 eerror "'debug' USE flag turned off."
513 eerror
514 PUSE_ENABLED="1"
515 fi
516
517 if has_concurrentmodphp ; then
518 eerror
519 eerror "You cannot install binary PHP extensions when"
520 eerror "the 'concurrentmodphp' USE flag is enabled!"
521 eerror "Please reemerge dev-lang/php with the"
522 eerror "'concurrentmodphp' USE flag turned off."
523 eerror
524 PUSE_ENABLED="1"
525 fi
526
527 if [[ -n ${PUSE_ENABLED} ]] ; then
528 die "'debug' and/or 'concurrentmodphp' USE flags turned on!"
529 fi
530}
531
532# @FUNCTION: dodoc-php
533# @USAGE: <list of docs>
534# @DESCRIPTION:
535# Alternative to dodoc function for use in our PHP eclasses and ebuilds.
536# Stored here because depend.php gets always sourced everywhere in the PHP
537# ebuilds and eclasses. It simply is dodoc with a changed path to the docs.
538# NOTE: No support for docinto is provided!
539dodoc-php() {
540if [[ $# -lt 1 ]] ; then
541 echo "$0: at least one argument needed" 1>&2
542 exit 1
543fi
544
545phpdocdir="/usr/share/doc/${CATEGORY}/${PF}/"
546
547for x in $@ ; do
548 if [[ -s "${x}" ]] ; then
549 insinto "${phpdocdir}"
550 doins "${x}"
551 gzip -f -9 "${D}/${phpdocdir}/${x##*/}"
552 elif [[ ! -e "${x}" ]] ; then
553 echo "dodoc-php: ${x} does not exist" 1>&2
554 fi
555done
556}
557
558# @FUNCTION: dohtml-php
559# @USAGE: <list of html docs>
560# @DESCRIPTION:
561# Alternative to dohtml function for use in our PHP eclasses and ebuilds.
562# Stored here because depend.php gets always sourced everywhere in the PHP
563# ebuilds and eclasses. It simply is dohtml with a changed path to the docs.
564# NOTE: No support for [-a|-A|-p|-x] options is provided!
565dohtml-php() {
566if [[ $# -lt 1 ]] ; then
567 echo "$0: at least one argument needed" 1>&2
568 exit 1
569fi
570
571phphtmldir="/usr/share/doc/${CATEGORY}/${PF}/html"
572
573for x in $@ ; do
574 if [[ -s "${x}" ]] ; then
575 insinto "${phphtmldir}"
576 doins "${x}"
577 elif [[ ! -e "${x}" ]] ; then
578 echo "dohtml-php: ${x} does not exist" 1>&2
579 fi
580done
581}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.20