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

Diff of /eclass/confutils.eclass

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

Revision 1.1 Revision 1.1.1.1
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2005 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/confutils.eclass,v 1.1 2004/06/27 16:05:26 stuart Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/confutils.eclass,v 1.1.1.1 2005/11/30 09:59:32 chriswhite Exp $
4# 4#
5# eclass/confutils.eclass 5# eclass/confutils.eclass
6# Utility functions to help with configuring a package 6# Utility functions to help with configuring a package
7# 7#
8# Based on Stuart's work for the PHP 5 eclass 8# Based on Stuart's work for the PHP 5 eclass
10# Author(s) Stuart Herbert 10# Author(s) Stuart Herbert
11# <stuart@gentoo.org> 11# <stuart@gentoo.org>
12# 12#
13# ======================================================================== 13# ========================================================================
14 14
15IUSE="$IUSE shared" 15if [[ ${EBUILD_SUPPORTS_SHAREDEXT} == 1 ]]; then
16 IUSE="sharedext"
17fi
18
19# ========================================================================
20
21# list of USE flags that need deps that aren't yet in Portage
22# this list was originally added for PHP
23#
24# your eclass must define CONFUTILS_MISSING_DEPS if you need this
16 25
17# ======================================================================== 26# ========================================================================
18# confutils_init () 27# confutils_init ()
19# 28#
20# Call this function from your src_compile() function to initialise 29# Call this function from your src_compile() function to initialise
21# this eclass first 30# this eclass first
22 31
23confutils_init () { 32confutils_init () {
24 if useq shared ; then 33 if [[ ${EBUILD_SUPPORTS_SHAREDEXT} == 1 ]] && useq sharedext ; then
25 shared="=shared" 34 shared="=shared"
26 else 35 else
27 shared= 36 shared=
28 fi 37 fi
38}
39
40# ========================================================================
41# confutils_require_any ()
42#
43# Use this function to ensure one or more of the specified USE flags have
44# been enabled
45#
46# $1 - message to output everytime a flag is found
47# $2 - message to output everytime a flag is not found
48# $3 .. - flags to check
49#
50
51confutils_require_any() {
52 success_msg="$1"
53 shift
54 fail_msg="$1"
55 shift
56
57 required_flags="$@"
58 success=0
59
60 while [[ -n $1 ]]; do
61 if useq $1 ; then
62 einfo "$success_msg $1"
63 success=1
64 else
65 ewarn "$fail_msg $1"
66 fi
67 shift
68 done
69
70 # did we find what we are looking for?
71 if [[ $success == 1 ]]; then
72 return
73 fi
74
75 # if we get here, then none of the required USE flags are switched on
76
77 echo
78 eerror "You *must* enable one or more of the following USE flags:"
79 eerror " $required_flags"
80 eerror
81 eerror "You can do this by enabling these flags in /etc/portage/package.use:"
82 eerror " =$CATEGORY/$PN-$PVR $required_flags"
83 eerror
84 die "Missing USE flags"
29} 85}
30 86
31# ======================================================================== 87# ========================================================================
32# confutils_use_conflict () 88# confutils_use_conflict ()
33# 89#
61 eerror "USE flag '$my_flag' conflicts with these USE flag(s):" 117 eerror "USE flag '$my_flag' conflicts with these USE flag(s):"
62 eerror " $my_present" 118 eerror " $my_present"
63 eerror 119 eerror
64 eerror "You must disable these conflicting flags before you can emerge this package." 120 eerror "You must disable these conflicting flags before you can emerge this package."
65 eerror "You can do this by disabling these flags in /etc/portage/package.use:" 121 eerror "You can do this by disabling these flags in /etc/portage/package.use:"
66 eerror " =$CATEGORY/$PN-$PVR: $my_remove" 122 eerror " =$CATEGORY/$PN-$PVR $my_remove"
67 eerror 123 eerror
68 die "Conflicting USE flags" 124 die "Conflicting USE flags"
69 fi 125 fi
70} 126}
71 127
74# 130#
75# Use this function to automatically complain to the user if a USE flag 131# Use this function to automatically complain to the user if a USE flag
76# depends on another USE flag that hasn't been enabled 132# depends on another USE flag that hasn't been enabled
77# 133#
78# $1 - flag that depends on other flags 134# $1 - flag that depends on other flags
79# $2 - error message to show 135# $2 .. - the flags that must be set for $1 to be valid
80# $3 .. -
81 136
82confutils_use_depend_all () { 137confutils_use_depend_all () {
83 if ! useq $1 ; then 138 if ! useq $1 ; then
84 return 139 return
85 fi 140 fi
100 echo 155 echo
101 eerror "USE flag '$my_flag' needs these additional flag(s) set:" 156 eerror "USE flag '$my_flag' needs these additional flag(s) set:"
102 eerror " $my_missing" 157 eerror " $my_missing"
103 eerror 158 eerror
104 eerror "You can do this by enabling these flags in /etc/portage/package.use:" 159 eerror "You can do this by enabling these flags in /etc/portage/package.use:"
105 eerror " =$CATEGORY/$PN-$PVR: $my_missing" 160 eerror " =$CATEGORY/$PN-$PVR $my_missing"
106 eerror 161 eerror
107 eerror "You could disable this flag instead in /etc/portage/package.use:" 162 eerror "You could disable this flag instead in /etc/portage/package.use:"
108 eerror " =$CATEGORY/$PN-$PVR: -$my_flag" 163 eerror " =$CATEGORY/$PN-$PVR -$my_flag"
109 echo 164 echo
110 165
111 die "Need missing USE flags" 166 die "Need missing USE flags"
112 fi 167 fi
113} 168}
117# 172#
118# Use this function to automatically complain to the user if a USE flag 173# Use this function to automatically complain to the user if a USE flag
119# depends on another USE flag that hasn't been enabled 174# depends on another USE flag that hasn't been enabled
120# 175#
121# $1 - flag that depends on other flags 176# $1 - flag that depends on other flags
122# $2 - error message to show 177# $2 .. - flags that must be set for $1 to be valid
123# $3 .. -
124 178
125confutils_use_depend_any () { 179confutils_use_depend_any () {
126 if ! useq $1 ; then 180 if ! useq $1 ; then
127 return 181 return
128 fi 182 fi
160# This is provided for those rare configure scripts that don't support 214# This is provided for those rare configure scripts that don't support
161# a --enable for the corresponding --disable 215# a --enable for the corresponding --disable
162# 216#
163# $1 - extension name 217# $1 - extension name
164# $2 - USE flag 218# $2 - USE flag
219# $3 - optional message to einfo() to the user
165 220
166enable_extension_disable () { 221enable_extension_disable () {
167 if ! useq "$2" ; then 222 if ! useq "$2" ; then
168 my_conf="${my_conf} --disable-$1" 223 my_conf="${my_conf} --disable-$1"
224 [ -n "$3" ] && einfo " Disabling $1"
225 else
226 [ -n "$3" ] && einfo " Enabling $1"
169 fi 227 fi
170} 228}
171 229
172# ======================================================================== 230# ========================================================================
173# enable_extension_enable () 231# enable_extension_enable ()
174# 232#
175# This function is like use_enable(), except that it knows about 233# This function is like use_enable(), except that it knows about
176# enabling modules as shared libraries, and it supports passing 234# enabling modules as shared libraries, and it supports passing
177# additional data with the switch 235# additional data with the switch
178# 236#
179# $1 - extension name 237# $1 - extension name
180# $2 - USE flag 238# $2 - USE flag
181# $3 - 1 = support shared, 0 = never support shared 239# $3 - 1 = support shared, 0 = never support shared
182# $4 - additional setting for configure 240# $4 - additional setting for configure
241# $5 - additional message to einfo out to the user
183 242
184enable_extension_enable () { 243enable_extension_enable () {
185 local my_shared 244 local my_shared
186 245
187 if [ "$3" == "1" ]; then 246 if [ "$3" == "1" ]; then
247 if [ "$shared+" != "+" ]; then
188 my_shared="$shared" 248 my_shared="${shared}"
189 if [ "$4+" != "+" ]; then 249 if [ "$4+" != "+" ]; then
190 my_shared="${my_shared},$4" 250 my_shared="${my_shared},$4"
251 fi
252 elif [ "$4+" != "+" ]; then
253 my_shared="=$4"
191 fi 254 fi
192 else 255 else
193 if [ "$4+" != "+" ]; then 256 if [ "$4+" != "+" ]; then
194 my_shared="=$4" 257 my_shared="=$4"
195 fi 258 fi
196 fi 259 fi
197 260
198 if useq $2 ; then 261 if useq $2 ; then
199 my_conf="${my_conf} --enable-$1$my_shared" 262 my_conf="${my_conf} --enable-$1$my_shared"
263 einfo " Enabling $1"
200 else 264 else
201 my_conf="${my_conf} --disable-$1" 265 my_conf="${my_conf} --disable-$1"
266 einfo " Disabling $1"
267 fi
268}
269
270# ========================================================================
271# enable_extension_enableonly ()
272#
273# This function is like use_enable(), except that it knows about
274# enabling modules as shared libraries, and it supports passing
275# additional data with the switch
276#
277# $1 - extension name
278# $2 - USE flag
279# $3 - 1 = support shared, 0 = never support shared
280# $4 - additional setting for configure
281# $5 - additional message to einfo out to the user
282
283enable_extension_enableonly () {
284 local my_shared
285
286 if [ "$3" == "1" ]; then
287 if [ "$shared+" != "+" ]; then
288 my_shared="${shared}"
289 if [ "$4+" != "+" ]; then
290 my_shared="${my_shared},$4"
291 fi
292 elif [ "$4+" != "+" ]; then
293 my_shared="=$4"
202 fi 294 fi
203} 295 else
296 if [ "$4+" != "+" ]; then
297 my_shared="=$4"
298 fi
299 fi
204 300
301 if useq $2 ; then
302 my_conf="${my_conf} --enable-$1$my_shared"
303 einfo " Enabling $1"
304 else
305 # note: we deliberately do *not* use a --disable switch here
306 einfo " Disabling $1"
307 fi
308}
205# ======================================================================== 309# ========================================================================
206# enable_extension_without () 310# enable_extension_without ()
207# 311#
208# Use this function to disable an extension that is enabled by default 312# Use this function to disable an extension that is enabled by default
209# This function is provided for those rare configure scripts that support 313# This function is provided for those rare configure scripts that support
210# --without but not the corresponding --with 314# --without but not the corresponding --with
211# 315#
212# $1 - extension name 316# $1 - extension name
213# $2 - USE flag 317# $2 - USE flag
318# $3 - optional message to einfo() to the user
214 319
215enable_extension_without () { 320enable_extension_without () {
216 if ! useq "$2" ; then 321 if ! useq "$2" ; then
217 my_conf="${my_conf} --without-$1" 322 my_conf="${my_conf} --without-$1"
323 einfo " Disabling $1"
324 else
325 einfo " Enabling $1"
218 fi 326 fi
219} 327}
220 328
221# ======================================================================== 329# ========================================================================
222# enable_extension_with () 330# enable_extension_with ()
226 334
227# $1 - extension name 335# $1 - extension name
228# $2 - USE flag 336# $2 - USE flag
229# $3 - 1 = support shared, 0 = never support shared 337# $3 - 1 = support shared, 0 = never support shared
230# $4 - additional setting for configure 338# $4 - additional setting for configure
339# $5 - optional message to einfo() out to the user
231 340
232enable_extension_with () { 341enable_extension_with () {
233 local my_shared 342 local my_shared
234 343
235 if [ "$3" == "1" ]; then 344 if [ "$3" == "1" ]; then
345 if [ "$shared+" != "+" ]; then
236 my_shared="$shared" 346 my_shared="${shared}"
237 if [ "$4+" != "+" ]; then 347 if [ "$4+" != "+" ]; then
238 my_shared="${my_shared},$4" 348 my_shared="${my_shared},$4"
349 fi
350 elif [ "$4+" != "+" ]; then
351 my_shared="=$4"
239 fi 352 fi
240 else 353 else
241 if [ "$4+" != "+" ]; then 354 if [ "$4+" != "+" ]; then
242 my_shared="=$4" 355 my_shared="=$4"
243 fi 356 fi
244 fi 357 fi
245 358
246 if useq $2 ; then 359 if useq $2 ; then
247 my_conf="${my_conf} --with-$1$my_shared" 360 my_conf="${my_conf} --with-$1$my_shared"
361 einfo " Enabling $1"
248 else 362 else
249 my_conf="${my_conf} --without-$1" 363 my_conf="${my_conf} --without-$1"
364 einfo " Disabling $1"
365 fi
366}
367
368# ========================================================================
369# enable_extension_withonly ()
370#
371# This function is a replacement for use_with. It supports building
372# extensions as shared libraries,
373
374# $1 - extension name
375# $2 - USE flag
376# $3 - 1 = support shared, 0 = never support shared
377# $4 - additional setting for configure
378# $5 - optional message to einfo() out to the user
379
380enable_extension_withonly () {
381 local my_shared
382
383 if [ "$3" == "1" ]; then
384 if [ "$shared+" != "+" ]; then
385 my_shared="${shared}"
386 if [ "$4+" != "+" ]; then
387 my_shared="${my_shared},$4"
388 fi
389 elif [ "$4+" != "+" ]; then
390 my_shared="=$4"
250 fi 391 fi
392 else
393 if [ "$4+" != "+" ]; then
394 my_shared="=$4"
395 fi
396 fi
397
398 if useq $2 ; then
399 my_conf="${my_conf} --with-$1$my_shared"
400 einfo " Enabling $1"
401 else
402 # note - we deliberately do *not* use --without here
403 einfo " Disabling $1"
404 fi
251} 405}
406
407# ========================================================================
408# confutils_warn_about_external_deps
409
410confutils_warn_about_missing_deps ()
411{
412 local x
413 local my_found=0
414
415 for x in $CONFUTILS_MISSING_DEPS ; do
416 if useq $x ; then
417 ewarn "USE flag $x enables support for software not in Portage"
418 my_found=1
419 fi
420 done
421
422 if [ "$my_found" = "1" ]; then
423 ewarn
424 ewarn "This ebuild will continue, but if you haven't already installed the"
425 ewarn "software required to satisfy the list above, this package will probably"
426 ewarn "fail to compile."
427 ewarn
428 sleep 5
429 fi
430}
431
432# ========================================================================
433# enable_extension_enable_built_with ()
434#
435# This function is like use_enable(), except that it knows about
436# enabling modules as shared libraries, and it supports passing
437# additional data with the switch
438#
439# $1 - pkg name
440# $2 - USE flag
441# $3 - extension name
442# $4 - additional setting for configure
443# $5 - alternative message
444
445enable_extension_enable_built_with () {
446 local msg=$3
447 [[ -n $5 ]] && msg="$5"
448
449 local param
450 [[ -n $4 ]] && msg="=$4"
451
452 if built_with_use $1 $2 ; then
453 my_conf="${my_conf} --enable-$3${param}"
454 einfo " Enabling $msg"
455 else
456 my_conf="${my_conf} --disable-$3"
457 einfo " Disabling $msg"
458 fi
459}
460
461# ========================================================================
462# enable_extension_with_built_with ()
463#
464# This function is like use_enable(), except that it knows about
465# enabling modules as shared libraries, and it supports passing
466# additional data with the switch
467#
468# $1 - pkg name
469# $2 - USE flag
470# $3 - extension name
471# $4 - additional setting for configure
472# $5 - alternative message
473
474enable_extension_with_built_with () {
475 local msg=$3
476 [[ -n $5 ]] && msg="$5"
477
478 local param
479 [[ -n $4 ]] && param="=$4"
480
481 if built_with_use $1 $2 ; then
482 my_conf="${my_conf} --with-$3${param}"
483 einfo " Enabling $msg"
484 else
485 my_conf="${my_conf} --disable-$3"
486 einfo " Disabling $msg"
487 fi
488}

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

  ViewVC Help
Powered by ViewVC 1.1.20