/[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.10
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.2 2006/04/18 12:21:14 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# ========================================================================
18 16
19if [[ "${EBUILD_SUPPORTS_SHAREDEXT}" == "1" ]] ; then
20 IUSE="sharedext"
21fi
22 17
23# ======================================================================== 18# ========================================================================
24# 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
25# or that can't be (fex. certain commercial apps) 20# or that can't be (fex. certain commercial apps)
26# 21#
27# You must define CONFUTILS_MISSING_DEPS if you need this 22# You must define PHPCONFUTILS_MISSING_DEPS if you need this
28 23
29# ======================================================================== 24# ========================================================================
30# phpconfutils_sort_flags() 25# phpconfutils_sort_flags()
31# 26#
32# Sort and remove duplicates of the auto-enabled USE flags 27# Sort and remove duplicates of the auto-enabled USE flags
33# 28#
34 29
35phpconfutils_sort_flags() { 30phpconfutils_sort_flags() {
36 # Sort the list of auto-magically enabled USE flags 31 # Sort the list of auto-magically enabled USE flags
37 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)"
38} 33}
39 34
40# ======================================================================== 35# ========================================================================
41# phpconfutils_init() 36# phpconfutils_init()
42# 37#
44# this eclass first 39# this eclass first
45# 40#
46 41
47phpconfutils_init() { 42phpconfutils_init() {
48 # Define wheter we shall support shared extensions or not 43 # Define wheter we shall support shared extensions or not
49 if [[ "${EBUILD_SUPPORTS_SHAREDEXT}" == "1" ]] && useq "sharedext" ; then 44 if use "sharedext" ; then
50 shared="=shared" 45 shared="=shared"
51 else 46 else
52 shared="" 47 shared=""
53 fi 48 fi
54 49
91 shift 86 shift
92 local fail_msg="$1" 87 local fail_msg="$1"
93 shift 88 shift
94 89
95 local required_flags="$@" 90 local required_flags="$@"
91 local default_flag="$1"
96 local success="0" 92 local success="0"
97 93
98 while [[ -n "$1" ]] ; do 94 while [[ -n "$1" ]] ; do
99 if useq "$1" ; then 95 if use "$1" ; then
100 einfo "${success_msg} $1" 96 einfo "${success_msg} $1"
101 success="1" 97 success="1"
102 else 98 else
103 ewarn "${fail_msg} $1" 99 einfo "${fail_msg} $1"
104 fi 100 fi
105 shift 101 shift
106 done 102 done
107 103
108 # Did we find what we are looking for? 104 # Did we find what we are looking for?
110 return 106 return
111 fi 107 fi
112 108
113 # If we get here, then none of the required USE flags were enabled 109 # If we get here, then none of the required USE flags were enabled
114 eerror 110 eerror
115 eerror "You *must* enable one or more of the following USE flags:" 111 eerror "You should enable one or more of the following USE flags:"
116 eerror " ${required_flags}" 112 eerror " ${required_flags}"
117 eerror 113 eerror
118 eerror "You can do this by enabling these flags in /etc/portage/package.use:" 114 eerror "You can do this by enabling these flags in /etc/portage/package.use:"
119 eerror " =${CATEGORY}/${PN}-${PVR} ${required_flags}" 115 eerror " =${CATEGORY}/${PN}-${PVR} ${required_flags}"
120 eerror 116 eerror
121 die "Missing USE flags found" 117 eerror "The ${default_flag} USE flag was automatically enabled now."
118 eerror
119 PHPCONFUTILS_AUTO_USE="${PHPCONFUTILS_AUTO_USE} ${default_flag}"
122} 120}
123 121
124# ======================================================================== 122# ========================================================================
125# phpconfutils_use_conflict() 123# phpconfutils_use_conflict()
126# 124#
132# 130#
133 131
134phpconfutils_use_conflict() { 132phpconfutils_use_conflict() {
135 phpconfutils_sort_flags 133 phpconfutils_sort_flags
136 134
137 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 135 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
138 return 136 return
139 fi 137 fi
140 138
141 local my_flag="$1" 139 local my_flag="$1"
142 shift 140 shift
143 141
144 local my_present="" 142 local my_present=""
145 local my_remove="" 143 local my_remove=""
146 144
147 while [[ "$1+" != "+" ]] ; do 145 while [[ "$1+" != "+" ]] ; do
148 if useq "$1" || phpconfutils_usecheck "$1" ; then 146 if use "$1" || phpconfutils_usecheck "$1" ; then
149 my_present="${my_present} $1" 147 my_present="${my_present} $1"
150 my_remove="${my_remove} -$1" 148 my_remove="${my_remove} -$1"
151 fi 149 fi
152 shift 150 shift
153 done 151 done
176# 174#
177 175
178phpconfutils_use_depend_all() { 176phpconfutils_use_depend_all() {
179 phpconfutils_sort_flags 177 phpconfutils_sort_flags
180 178
181 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 179 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
182 return 180 return
183 fi 181 fi
184 182
185 local my_flag="$1" 183 local my_flag="$1"
186 shift 184 shift
187 185
188 local my_missing="" 186 local my_missing=""
189 187
190 while [[ "$1+" != "+" ]] ; do 188 while [[ "$1+" != "+" ]] ; do
191 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 189 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
192 my_missing="${my_missing} $1" 190 my_missing="${my_missing} $1"
193 fi 191 fi
194 shift 192 shift
195 done 193 done
196 194
220# 218#
221 219
222phpconfutils_use_depend_any() { 220phpconfutils_use_depend_any() {
223 phpconfutils_sort_flags 221 phpconfutils_sort_flags
224 222
225 if ! useq "$1" && ! phpconfutils_usecheck "$1" ; then 223 if ! use "$1" && ! phpconfutils_usecheck "$1" ; then
226 return 224 return
227 fi 225 fi
228 226
229 local my_flag="$1" 227 local my_flag="$1"
230 shift 228 shift
234 232
235 local my_found="" 233 local my_found=""
236 local my_missing="" 234 local my_missing=""
237 235
238 while [[ "$1+" != "+" ]] ; do 236 while [[ "$1+" != "+" ]] ; do
239 if useq "$1" || phpconfutils_usecheck "$1" ; then 237 if use "$1" || phpconfutils_usecheck "$1" ; then
240 my_found="${my_found} $1" 238 my_found="${my_found} $1"
241 else 239 else
242 my_missing="${my_missing} $1" 240 my_missing="${my_missing} $1"
243 fi 241 fi
244 shift 242 shift
268# $2 - USE flag 266# $2 - USE flag
269# $3 - optional message to einfo() to the user 267# $3 - optional message to einfo() to the user
270# 268#
271 269
272phpconfutils_extension_disable() { 270phpconfutils_extension_disable() {
273 if ! useq "$2" && ! phpconfutils_usecheck "$2" ; then 271 if ! use "$2" && ! phpconfutils_usecheck "$2" ; then
274 my_conf="${my_conf} --disable-$1" 272 my_conf="${my_conf} --disable-$1"
275 [[ -n "$3" ]] && einfo " Disabling $1" 273 [[ -n "$3" ]] && einfo " Disabling $1"
276 else 274 else
277 [[ -n "$3" ]] && einfo " Enabling $1" 275 [[ -n "$3" ]] && einfo " Enabling $1"
278 fi 276 fi
308 if [[ "$4+" != "+" ]] ; then 306 if [[ "$4+" != "+" ]] ; then
309 my_shared="=$4" 307 my_shared="=$4"
310 fi 308 fi
311 fi 309 fi
312 310
313 if useq "$2" || phpconfutils_usecheck "$2" ; then 311 if use "$2" || phpconfutils_usecheck "$2" ; then
314 my_conf="${my_conf} --enable-$1${my_shared}" 312 my_conf="${my_conf} --enable-$1${my_shared}"
315 einfo " Enabling $1" 313 einfo " Enabling $1"
316 else 314 else
317 my_conf="${my_conf} --disable-$1" 315 my_conf="${my_conf} --disable-$1"
318 einfo " Disabling $1" 316 einfo " Disabling $1"
330# $2 - USE flag 328# $2 - USE flag
331# $3 - optional message to einfo() to the user 329# $3 - optional message to einfo() to the user
332# 330#
333 331
334phpconfutils_extension_without() { 332phpconfutils_extension_without() {
335 if ! useq "$2" && ! phpconfutils_usecheck "$2" ; then 333 if ! use "$2" && ! phpconfutils_usecheck "$2" ; then
336 my_conf="${my_conf} --without-$1" 334 my_conf="${my_conf} --without-$1"
337 einfo " Disabling $1" 335 einfo " Disabling $1"
338 else 336 else
339 einfo " Enabling $1" 337 einfo " Enabling $1"
340 fi 338 fi
369 if [[ "$4+" != "+" ]] ; then 367 if [[ "$4+" != "+" ]] ; then
370 my_shared="=$4" 368 my_shared="=$4"
371 fi 369 fi
372 fi 370 fi
373 371
374 if useq "$2" || phpconfutils_usecheck "$2" ; then 372 if use "$2" || phpconfutils_usecheck "$2" ; then
375 my_conf="${my_conf} --with-$1${my_shared}" 373 my_conf="${my_conf} --with-$1${my_shared}"
376 einfo " Enabling $1" 374 einfo " Enabling $1"
377 else 375 else
378 my_conf="${my_conf} --without-$1" 376 my_conf="${my_conf} --without-$1"
379 einfo " Disabling $1" 377 einfo " Disabling $1"
391 phpconfutils_sort_flags 389 phpconfutils_sort_flags
392 390
393 local x 391 local x
394 local my_found="0" 392 local my_found="0"
395 393
396 for x in ${CONFUTILS_MISSING_DEPS} ; do 394 for x in ${PHPCONFUTILS_MISSING_DEPS} ; do
397 if useq "${x}" || phpconfutils_usecheck "${x}" ; then 395 if use "${x}" || phpconfutils_usecheck "${x}" ; then
398 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!"
399 my_found="1" 397 my_found="1"
400 fi 398 fi
401 done 399 done
402 400
407 ewarn "fail to compile later on." 405 ewarn "fail to compile later on."
408 ewarn "*DO NOT* file bugs about compile failures or issues you're having" 406 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." 407 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! |=|=|=|=|=|=|" 408 ewarn "|=|=|=|=|=|=| You are on your own if you use them! |=|=|=|=|=|=|"
411 ewarn 409 ewarn
412 sleep 5 410 ebeep 5
413 fi 411 fi
414} 412}
415 413
416# ======================================================================== 414# ========================================================================
417# phpconfutils_built_with_use() 415# phpconfutils_built_with_use()

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

  ViewVC Help
Powered by ViewVC 1.1.20