| 1 | # Copyright 1999-2006 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/phpconfutils.eclass,v 1.4 2006/07/14 16:02:36 chtekk Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/phpconfutils.eclass,v 1.10 2011/08/22 04:46:32 vapier Exp $ |
| 4 | # |
4 | |
| 5 | # ######################################################################## |
5 | # @ECLASS: phpconfutils.eclass |
| 6 | # |
6 | # @MAINTAINER: |
| 7 | # eclass/phpconfutils.eclass |
7 | # Gentoo PHP team <php-bugs@gentoo.org> |
| 8 | # Utility functions to help with configuring PHP |
8 | # @AUTHOR: |
| 9 | # |
|
|
| 10 | # Based on Stuart's work on the original confutils eclass |
9 | # Based on Stuart's work on the original confutils eclass |
| 11 | # |
10 | # Luca Longinotti <chtekk@gentoo.org> |
| 12 | # Author(s) Luca Longinotti |
11 | # @BLURB: Provides utility functions to help with configuring PHP. |
| 13 | # <chtekk@gentoo.org> |
12 | # @DESCRIPTION: |
| 14 | # |
13 | # This eclass provides utility functions to help with configuring PHP. |
| 15 | # Maintained by the PHP Herd <php-bugs@gentoo.org> |
14 | # It is only used by other php eclasses currently and the functions |
| 16 | # |
15 | # are not generally intended for direct use in ebuilds. |
| 17 | # ======================================================================== |
16 | |
| 18 | |
17 | |
| 19 | # ======================================================================== |
18 | # ======================================================================== |
| 20 | # List of USE flags that need deps that aren't yet in Portage |
19 | # List of USE flags that need deps that aren't yet in Portage |
| 21 | # or that can't be (fex. certain commercial apps) |
20 | # or that can't be (fex. certain commercial apps) |
| 22 | # |
21 | # |
| … | |
… | |
| 28 | # Sort and remove duplicates of the auto-enabled USE flags |
27 | # Sort and remove duplicates of the auto-enabled USE flags |
| 29 | # |
28 | # |
| 30 | |
29 | |
| 31 | phpconfutils_sort_flags() { |
30 | phpconfutils_sort_flags() { |
| 32 | # Sort the list of auto-magically enabled USE flags |
31 | # Sort the list of auto-magically enabled USE flags |
| 33 | PHPCONFUTILS_AUTO_USE="`echo ${PHPCONFUTILS_AUTO_USE} | tr '\040\010' '\012\012' | sort -u`" |
32 | PHPCONFUTILS_AUTO_USE="$(echo ${PHPCONFUTILS_AUTO_USE} | tr '\040\010' '\012\012' | sort -u)" |
| 34 | } |
33 | } |
| 35 | |
34 | |
| 36 | # ======================================================================== |
35 | # ======================================================================== |
| 37 | # phpconfutils_init() |
36 | # phpconfutils_init() |
| 38 | # |
37 | # |
| … | |
… | |
| 40 | # this eclass first |
39 | # this eclass first |
| 41 | # |
40 | # |
| 42 | |
41 | |
| 43 | phpconfutils_init() { |
42 | phpconfutils_init() { |
| 44 | # Define wheter we shall support shared extensions or not |
43 | # Define wheter we shall support shared extensions or not |
| 45 | if useq "sharedext" ; then |
44 | if use "sharedext" ; then |
| 46 | shared="=shared" |
45 | shared="=shared" |
| 47 | else |
46 | else |
| 48 | shared="" |
47 | shared="" |
| 49 | fi |
48 | fi |
| 50 | |
49 | |
| … | |
… | |
| 91 | local required_flags="$@" |
90 | local required_flags="$@" |
| 92 | local default_flag="$1" |
91 | local default_flag="$1" |
| 93 | local success="0" |
92 | local success="0" |
| 94 | |
93 | |
| 95 | while [[ -n "$1" ]] ; do |
94 | while [[ -n "$1" ]] ; do |
| 96 | if useq "$1" ; then |
95 | if use "$1" ; then |
| 97 | einfo "${success_msg} $1" |
96 | einfo "${success_msg} $1" |
| 98 | success="1" |
97 | success="1" |
| 99 | else |
98 | else |
| 100 | ewarn "${fail_msg} $1" |
99 | einfo "${fail_msg} $1" |
| 101 | fi |
100 | fi |
| 102 | shift |
101 | shift |
| 103 | done |
102 | done |
| 104 | |
103 | |
| 105 | # Did we find what we are looking for? |
104 | # Did we find what we are looking for? |
| … | |
… | |
| 131 | # |
130 | # |
| 132 | |
131 | |
| 133 | phpconfutils_use_conflict() { |
132 | phpconfutils_use_conflict() { |
| 134 | phpconfutils_sort_flags |
133 | phpconfutils_sort_flags |
| 135 | |
134 | |
| 136 | if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then |
135 | if ! use "$1" && ! phpconfutils_usecheck "$1" ; then |
| 137 | return |
136 | return |
| 138 | fi |
137 | fi |
| 139 | |
138 | |
| 140 | local my_flag="$1" |
139 | local my_flag="$1" |
| 141 | shift |
140 | shift |
| 142 | |
141 | |
| 143 | local my_present="" |
142 | local my_present="" |
| 144 | local my_remove="" |
143 | local my_remove="" |
| 145 | |
144 | |
| 146 | while [[ "$1+" != "+" ]] ; do |
145 | while [[ "$1+" != "+" ]] ; do |
| 147 | if useq "$1" || phpconfutils_usecheck "$1" ; then |
146 | if use "$1" || phpconfutils_usecheck "$1" ; then |
| 148 | my_present="${my_present} $1" |
147 | my_present="${my_present} $1" |
| 149 | my_remove="${my_remove} -$1" |
148 | my_remove="${my_remove} -$1" |
| 150 | fi |
149 | fi |
| 151 | shift |
150 | shift |
| 152 | done |
151 | done |
| … | |
… | |
| 175 | # |
174 | # |
| 176 | |
175 | |
| 177 | phpconfutils_use_depend_all() { |
176 | phpconfutils_use_depend_all() { |
| 178 | phpconfutils_sort_flags |
177 | phpconfutils_sort_flags |
| 179 | |
178 | |
| 180 | if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then |
179 | if ! use "$1" && ! phpconfutils_usecheck "$1" ; then |
| 181 | return |
180 | return |
| 182 | fi |
181 | fi |
| 183 | |
182 | |
| 184 | local my_flag="$1" |
183 | local my_flag="$1" |
| 185 | shift |
184 | shift |
| 186 | |
185 | |
| 187 | local my_missing="" |
186 | local my_missing="" |
| 188 | |
187 | |
| 189 | while [[ "$1+" != "+" ]] ; do |
188 | while [[ "$1+" != "+" ]] ; do |
| 190 | if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then |
189 | if ! use "$1" && ! phpconfutils_usecheck "$1" ; then |
| 191 | my_missing="${my_missing} $1" |
190 | my_missing="${my_missing} $1" |
| 192 | fi |
191 | fi |
| 193 | shift |
192 | shift |
| 194 | done |
193 | done |
| 195 | |
194 | |
| … | |
… | |
| 219 | # |
218 | # |
| 220 | |
219 | |
| 221 | phpconfutils_use_depend_any() { |
220 | phpconfutils_use_depend_any() { |
| 222 | phpconfutils_sort_flags |
221 | phpconfutils_sort_flags |
| 223 | |
222 | |
| 224 | if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then |
223 | if ! use "$1" && ! phpconfutils_usecheck "$1" ; then |
| 225 | return |
224 | return |
| 226 | fi |
225 | fi |
| 227 | |
226 | |
| 228 | local my_flag="$1" |
227 | local my_flag="$1" |
| 229 | shift |
228 | shift |
| … | |
… | |
| 233 | |
232 | |
| 234 | local my_found="" |
233 | local my_found="" |
| 235 | local my_missing="" |
234 | local my_missing="" |
| 236 | |
235 | |
| 237 | while [[ "$1+" != "+" ]] ; do |
236 | while [[ "$1+" != "+" ]] ; do |
| 238 | if useq "$1" || phpconfutils_usecheck "$1" ; then |
237 | if use "$1" || phpconfutils_usecheck "$1" ; then |
| 239 | my_found="${my_found} $1" |
238 | my_found="${my_found} $1" |
| 240 | else |
239 | else |
| 241 | my_missing="${my_missing} $1" |
240 | my_missing="${my_missing} $1" |
| 242 | fi |
241 | fi |
| 243 | shift |
242 | shift |
| … | |
… | |
| 267 | # $2 - USE flag |
266 | # $2 - USE flag |
| 268 | # $3 - optional message to einfo() to the user |
267 | # $3 - optional message to einfo() to the user |
| 269 | # |
268 | # |
| 270 | |
269 | |
| 271 | phpconfutils_extension_disable() { |
270 | phpconfutils_extension_disable() { |
| 272 | if ! useq "$2" && ! phpconfutils_usecheck "$2" ; then |
271 | if ! use "$2" && ! phpconfutils_usecheck "$2" ; then |
| 273 | my_conf="${my_conf} --disable-$1" |
272 | my_conf="${my_conf} --disable-$1" |
| 274 | [[ -n "$3" ]] && einfo " Disabling $1" |
273 | [[ -n "$3" ]] && einfo " Disabling $1" |
| 275 | else |
274 | else |
| 276 | [[ -n "$3" ]] && einfo " Enabling $1" |
275 | [[ -n "$3" ]] && einfo " Enabling $1" |
| 277 | fi |
276 | fi |
| … | |
… | |
| 307 | if [[ "$4+" != "+" ]] ; then |
306 | if [[ "$4+" != "+" ]] ; then |
| 308 | my_shared="=$4" |
307 | my_shared="=$4" |
| 309 | fi |
308 | fi |
| 310 | fi |
309 | fi |
| 311 | |
310 | |
| 312 | if useq "$2" || phpconfutils_usecheck "$2" ; then |
311 | if use "$2" || phpconfutils_usecheck "$2" ; then |
| 313 | my_conf="${my_conf} --enable-$1${my_shared}" |
312 | my_conf="${my_conf} --enable-$1${my_shared}" |
| 314 | einfo " Enabling $1" |
313 | einfo " Enabling $1" |
| 315 | else |
314 | else |
| 316 | my_conf="${my_conf} --disable-$1" |
315 | my_conf="${my_conf} --disable-$1" |
| 317 | einfo " Disabling $1" |
316 | einfo " Disabling $1" |
| … | |
… | |
| 329 | # $2 - USE flag |
328 | # $2 - USE flag |
| 330 | # $3 - optional message to einfo() to the user |
329 | # $3 - optional message to einfo() to the user |
| 331 | # |
330 | # |
| 332 | |
331 | |
| 333 | phpconfutils_extension_without() { |
332 | phpconfutils_extension_without() { |
| 334 | if ! useq "$2" && ! phpconfutils_usecheck "$2" ; then |
333 | if ! use "$2" && ! phpconfutils_usecheck "$2" ; then |
| 335 | my_conf="${my_conf} --without-$1" |
334 | my_conf="${my_conf} --without-$1" |
| 336 | einfo " Disabling $1" |
335 | einfo " Disabling $1" |
| 337 | else |
336 | else |
| 338 | einfo " Enabling $1" |
337 | einfo " Enabling $1" |
| 339 | fi |
338 | fi |
| … | |
… | |
| 368 | if [[ "$4+" != "+" ]] ; then |
367 | if [[ "$4+" != "+" ]] ; then |
| 369 | my_shared="=$4" |
368 | my_shared="=$4" |
| 370 | fi |
369 | fi |
| 371 | fi |
370 | fi |
| 372 | |
371 | |
| 373 | if useq "$2" || phpconfutils_usecheck "$2" ; then |
372 | if use "$2" || phpconfutils_usecheck "$2" ; then |
| 374 | my_conf="${my_conf} --with-$1${my_shared}" |
373 | my_conf="${my_conf} --with-$1${my_shared}" |
| 375 | einfo " Enabling $1" |
374 | einfo " Enabling $1" |
| 376 | else |
375 | else |
| 377 | my_conf="${my_conf} --without-$1" |
376 | my_conf="${my_conf} --without-$1" |
| 378 | einfo " Disabling $1" |
377 | einfo " Disabling $1" |
| … | |
… | |
| 391 | |
390 | |
| 392 | local x |
391 | local x |
| 393 | local my_found="0" |
392 | local my_found="0" |
| 394 | |
393 | |
| 395 | for x in ${PHPCONFUTILS_MISSING_DEPS} ; do |
394 | for x in ${PHPCONFUTILS_MISSING_DEPS} ; do |
| 396 | if useq "${x}" || phpconfutils_usecheck "${x}" ; then |
395 | if use "${x}" || phpconfutils_usecheck "${x}" ; then |
| 397 | ewarn "USE flag ${x} enables support for software not present in Portage!" |
396 | ewarn "USE flag ${x} enables support for software not present in Portage!" |
| 398 | my_found="1" |
397 | my_found="1" |
| 399 | fi |
398 | fi |
| 400 | done |
399 | done |
| 401 | |
400 | |