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

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

  ViewVC Help
Powered by ViewVC 1.1.20