/[gentoo-x86]/eclass/phpconfutils.eclass
Gentoo

Diff of /eclass/phpconfutils.eclass

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

Revision 1.2 Revision 1.9
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2007 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.2 2006/04/18 12:21:14 chtekk Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/phpconfutils.eclass,v 1.9 2008/01/06 19:30:24 swegener Exp $
4# 4#
5# ######################################################################## 5# ########################################################################
6# 6#
7# eclass/phpconfutils.eclass
8# Utility functions to help with configuring PHP
9#
10# Based on stuart's work on the original confutils eclass 7# Based on Stuart's work on the original confutils eclass
11# 8#
12# Author(s) Luca Longinotti 9# Author(s): Luca Longinotti <chtekk@gentoo.org>
13# <chtekk@gentoo.org>
14# 10#
15# Maintained by the PHP Herd <php-bugs@gentoo.org>
16#
17# ======================================================================== 11# ========================================================================
18 12
19if [[ "${EBUILD_SUPPORTS_SHAREDEXT}" == "1" ]] ; then 13# @ECLASS: phpconfutils.eclass
20 IUSE="sharedext" 14# @MAINTAINER:
21fi 15# Gentoo PHP team <php-bugs@gentoo.org>
16# @BLURB: Provides utility functions to help with configuring PHP.
17# @DESCRIPTION:
18# This eclass provides utility functions to help with configuring PHP.
19# It is only used by other php eclasses currently and the functions
20# are not generally intended for direct use in ebuilds.
21
22 22
23# ======================================================================== 23# ========================================================================
24# List of USE flags that need deps that aren't yet in Portage 24# List of USE flags that need deps that aren't yet in Portage
25# or that can't be (fex. certain commercial apps) 25# or that can't be (fex. certain commercial apps)
26# 26#
27# You must define CONFUTILS_MISSING_DEPS if you need this 27# You must define PHPCONFUTILS_MISSING_DEPS if you need this
28 28
29# ======================================================================== 29# ========================================================================
30# phpconfutils_sort_flags() 30# phpconfutils_sort_flags()
31# 31#
32# Sort and remove duplicates of the auto-enabled USE flags 32# Sort and remove duplicates of the auto-enabled USE flags
33# 33#
34 34
35phpconfutils_sort_flags() { 35phpconfutils_sort_flags() {
36 # Sort the list of auto-magically enabled USE flags 36 # Sort the list of auto-magically enabled USE flags
37 PHPCONFUTILS_AUTO_USE="`echo ${PHPCONFUTILS_AUTO_USE} | tr '\040\010' '\012\012' | sort -u`" 37 PHPCONFUTILS_AUTO_USE="$(echo ${PHPCONFUTILS_AUTO_USE} | tr '\040\010' '\012\012' | sort -u)"
38} 38}
39 39
40# ======================================================================== 40# ========================================================================
41# phpconfutils_init() 41# phpconfutils_init()
42# 42#
44# this eclass first 44# this eclass first
45# 45#
46 46
47phpconfutils_init() { 47phpconfutils_init() {
48 # Define wheter we shall support shared extensions or not 48 # Define wheter we shall support shared extensions or not
49 if [[ "${EBUILD_SUPPORTS_SHAREDEXT}" == "1" ]] && useq "sharedext" ; then 49 if use "sharedext" ; then
50 shared="=shared" 50 shared="=shared"
51 else 51 else
52 shared="" 52 shared=""
53 fi 53 fi
54 54
91 shift 91 shift
92 local fail_msg="$1" 92 local fail_msg="$1"
93 shift 93 shift
94 94
95 local required_flags="$@" 95 local required_flags="$@"
96 local default_flag="$1"
96 local success="0" 97 local success="0"
97 98
98 while [[ -n "$1" ]] ; do 99 while [[ -n "$1" ]] ; do
99 if useq "$1" ; then 100 if use "$1" ; then
100 einfo "${success_msg} $1" 101 einfo "${success_msg} $1"
101 success="1" 102 success="1"
102 else 103 else
103 ewarn "${fail_msg} $1" 104 einfo "${fail_msg} $1"
104 fi 105 fi
105 shift 106 shift
106 done 107 done
107 108
108 # Did we find what we are looking for? 109 # Did we find what we are looking for?
110 return 111 return
111 fi 112 fi
112 113
113 # If we get here, then none of the required USE flags were enabled 114 # If we get here, then none of the required USE flags were enabled
114 eerror 115 eerror
115 eerror "You *must* enable one or more of the following USE flags:" 116 eerror "You should enable one or more of the following USE flags:"
116 eerror " ${required_flags}" 117 eerror " ${required_flags}"
117 eerror 118 eerror
118 eerror "You can do this by enabling these flags in /etc/portage/package.use:" 119 eerror "You can do this by enabling these flags in /etc/portage/package.use:"
119 eerror " =${CATEGORY}/${PN}-${PVR} ${required_flags}" 120 eerror " =${CATEGORY}/${PN}-${PVR} ${required_flags}"
120 eerror 121 eerror
121 die "Missing USE flags found" 122 eerror "The ${default_flag} USE flag was automatically enabled now."
123 eerror
124 PHPCONFUTILS_AUTO_USE="${PHPCONFUTILS_AUTO_USE} ${default_flag}"
122} 125}
123 126
124# ======================================================================== 127# ========================================================================
125# phpconfutils_use_conflict() 128# phpconfutils_use_conflict()
126# 129#
132# 135#
133 136
134phpconfutils_use_conflict() { 137phpconfutils_use_conflict() {
135 phpconfutils_sort_flags 138 phpconfutils_sort_flags
136 139
137 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 140 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
138 return 141 return
139 fi 142 fi
140 143
141 local my_flag="$1" 144 local my_flag="$1"
142 shift 145 shift
143 146
144 local my_present="" 147 local my_present=""
145 local my_remove="" 148 local my_remove=""
146 149
147 while [[ "$1+" != "+" ]] ; do 150 while [[ "$1+" != "+" ]] ; do
148 if useq "$1" || phpconfutils_usecheck "$1" ; then 151 if use "$1" || phpconfutils_usecheck "$1" ; then
149 my_present="${my_present} $1" 152 my_present="${my_present} $1"
150 my_remove="${my_remove} -$1" 153 my_remove="${my_remove} -$1"
151 fi 154 fi
152 shift 155 shift
153 done 156 done
176# 179#
177 180
178phpconfutils_use_depend_all() { 181phpconfutils_use_depend_all() {
179 phpconfutils_sort_flags 182 phpconfutils_sort_flags
180 183
181 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 184 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
182 return 185 return
183 fi 186 fi
184 187
185 local my_flag="$1" 188 local my_flag="$1"
186 shift 189 shift
187 190
188 local my_missing="" 191 local my_missing=""
189 192
190 while [[ "$1+" != "+" ]] ; do 193 while [[ "$1+" != "+" ]] ; do
191 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 194 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
192 my_missing="${my_missing} $1" 195 my_missing="${my_missing} $1"
193 fi 196 fi
194 shift 197 shift
195 done 198 done
196 199
220# 223#
221 224
222phpconfutils_use_depend_any() { 225phpconfutils_use_depend_any() {
223 phpconfutils_sort_flags 226 phpconfutils_sort_flags
224 227
225 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 228 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
226 return 229 return
227 fi 230 fi
228 231
229 local my_flag="$1" 232 local my_flag="$1"
230 shift 233 shift
234 237
235 local my_found="" 238 local my_found=""
236 local my_missing="" 239 local my_missing=""
237 240
238 while [[ "$1+" != "+" ]] ; do 241 while [[ "$1+" != "+" ]] ; do
239 if useq "$1" || phpconfutils_usecheck "$1" ; then 242 if use "$1" || phpconfutils_usecheck "$1" ; then
240 my_found="${my_found} $1" 243 my_found="${my_found} $1"
241 else 244 else
242 my_missing="${my_missing} $1" 245 my_missing="${my_missing} $1"
243 fi 246 fi
244 shift 247 shift
268# $2 - USE flag 271# $2 - USE flag
269# $3 - optional message to einfo() to the user 272# $3 - optional message to einfo() to the user
270# 273#
271 274
272phpconfutils_extension_disable() { 275phpconfutils_extension_disable() {
273 if ! useq "$2" && ! phpconfutils_usecheck "$2" ; then 276 if ! use "$2" && ! phpconfutils_usecheck "$2" ; then
274 my_conf="${my_conf} --disable-$1" 277 my_conf="${my_conf} --disable-$1"
275 [[ -n "$3" ]] && einfo " Disabling $1" 278 [[ -n "$3" ]] && einfo " Disabling $1"
276 else 279 else
277 [[ -n "$3" ]] && einfo " Enabling $1" 280 [[ -n "$3" ]] && einfo " Enabling $1"
278 fi 281 fi
308 if [[ "$4+" != "+" ]] ; then 311 if [[ "$4+" != "+" ]] ; then
309 my_shared="=$4" 312 my_shared="=$4"
310 fi 313 fi
311 fi 314 fi
312 315
313 if useq "$2" || phpconfutils_usecheck "$2" ; then 316 if use "$2" || phpconfutils_usecheck "$2" ; then
314 my_conf="${my_conf} --enable-$1${my_shared}" 317 my_conf="${my_conf} --enable-$1${my_shared}"
315 einfo " Enabling $1" 318 einfo " Enabling $1"
316 else 319 else
317 my_conf="${my_conf} --disable-$1" 320 my_conf="${my_conf} --disable-$1"
318 einfo " Disabling $1" 321 einfo " Disabling $1"
330# $2 - USE flag 333# $2 - USE flag
331# $3 - optional message to einfo() to the user 334# $3 - optional message to einfo() to the user
332# 335#
333 336
334phpconfutils_extension_without() { 337phpconfutils_extension_without() {
335 if ! useq "$2" && ! phpconfutils_usecheck "$2" ; then 338 if ! use "$2" && ! phpconfutils_usecheck "$2" ; then
336 my_conf="${my_conf} --without-$1" 339 my_conf="${my_conf} --without-$1"
337 einfo " Disabling $1" 340 einfo " Disabling $1"
338 else 341 else
339 einfo " Enabling $1" 342 einfo " Enabling $1"
340 fi 343 fi
369 if [[ "$4+" != "+" ]] ; then 372 if [[ "$4+" != "+" ]] ; then
370 my_shared="=$4" 373 my_shared="=$4"
371 fi 374 fi
372 fi 375 fi
373 376
374 if useq "$2" || phpconfutils_usecheck "$2" ; then 377 if use "$2" || phpconfutils_usecheck "$2" ; then
375 my_conf="${my_conf} --with-$1${my_shared}" 378 my_conf="${my_conf} --with-$1${my_shared}"
376 einfo " Enabling $1" 379 einfo " Enabling $1"
377 else 380 else
378 my_conf="${my_conf} --without-$1" 381 my_conf="${my_conf} --without-$1"
379 einfo " Disabling $1" 382 einfo " Disabling $1"
391 phpconfutils_sort_flags 394 phpconfutils_sort_flags
392 395
393 local x 396 local x
394 local my_found="0" 397 local my_found="0"
395 398
396 for x in ${CONFUTILS_MISSING_DEPS} ; do 399 for x in ${PHPCONFUTILS_MISSING_DEPS} ; do
397 if useq "${x}" || phpconfutils_usecheck "${x}" ; then 400 if use "${x}" || phpconfutils_usecheck "${x}" ; then
398 ewarn "USE flag ${x} enables support for software not present in Portage!" 401 ewarn "USE flag ${x} enables support for software not present in Portage!"
399 my_found="1" 402 my_found="1"
400 fi 403 fi
401 done 404 done
402 405
407 ewarn "fail to compile later on." 410 ewarn "fail to compile later on."
408 ewarn "*DO NOT* file bugs about compile failures or issues you're having" 411 ewarn "*DO NOT* file bugs about compile failures or issues you're having"
409 ewarn "when using one of those flags, as we aren't able to support them." 412 ewarn "when using one of those flags, as we aren't able to support them."
410 ewarn "|=|=|=|=|=|=| You are on your own if you use them! |=|=|=|=|=|=|" 413 ewarn "|=|=|=|=|=|=| You are on your own if you use them! |=|=|=|=|=|=|"
411 ewarn 414 ewarn
412 sleep 5 415 ebeep 5
413 fi 416 fi
414} 417}
415 418
416# ======================================================================== 419# ========================================================================
417# phpconfutils_built_with_use() 420# phpconfutils_built_with_use()

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20