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

Contents of /eclass/confutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations) (download)
Thu Nov 22 21:51:16 2007 UTC (6 years, 4 months ago) by drac
Branch: MAIN
Changes since 1.19: +19 -17 lines
useq -> use, missing inherit eutils (Jakub Moc)

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

  ViewVC Help
Powered by ViewVC 1.1.20