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

Contents of /eclass/confutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (hide annotations) (download)
Sun Sep 4 10:54:53 2005 UTC (8 years, 10 months ago) by stuart
Branch: MAIN
Changes since 1.17: +111 -4 lines
New & updated eclasses for new PHP packages

1 stuart 1.18 # Copyright 1999-2005 Gentoo Foundation
2 stuart 1.1 # Distributed under the terms of the GNU General Public License v2
3 stuart 1.18 # $Header: $
4 stuart 1.1 #
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 stuart 1.18 if [[ ${EBUILD_SUPPORTS_SHAREDEXT} == 1 ]]; then
16     IUSE="sharedext"
17     fi
18 stuart 1.1
19     # ========================================================================
20 stuart 1.2
21     # list of USE flags that need deps that aren't yet in Portage
22     # this list was originally added for PHP
23 stuart 1.16 #
24     # your eclass must define CONFUTILS_MISSING_DEPS if you need this
25 stuart 1.2
26     # ========================================================================
27 stuart 1.1 # confutils_init ()
28     #
29     # Call this function from your src_compile() function to initialise
30     # this eclass first
31    
32     confutils_init () {
33 stuart 1.18 if [[ ${EBUILD_SUPPORTS_SHAREDEXT} == 1 ]] && useq sharedext ; then
34 stuart 1.1 shared="=shared"
35     else
36     shared=
37     fi
38     }
39    
40     # ========================================================================
41 stuart 1.18 # 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    
51     confutils_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"
85     }
86    
87     # ========================================================================
88 stuart 1.1 # confutils_use_conflict ()
89     #
90     # Use this function to automatically complain to the user if conflicting
91     # USE flags have been enabled
92     #
93     # $1 - flag that depends on other flags
94     # $2 .. - flags that conflict
95    
96     confutils_use_conflict () {
97     if ! useq $1 ; then
98     return
99     fi
100    
101     local my_flag="$1"
102     shift
103    
104     local my_present=
105     local my_remove=
106    
107     while [ "$1+" != "+" ]; do
108     if useq $1 ; then
109     my_present="${my_present} $1"
110     my_remove="${my_remove} -$1"
111     fi
112     shift
113     done
114    
115     if [ -n "$my_present" ]; then
116     echo
117     eerror "USE flag '$my_flag' conflicts with these USE flag(s):"
118     eerror " $my_present"
119     eerror
120     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:"
122 robbat2 1.10 eerror " =$CATEGORY/$PN-$PVR $my_remove"
123 stuart 1.1 eerror
124     die "Conflicting USE flags"
125     fi
126     }
127    
128     # ========================================================================
129     # confutils_use_depend_all ()
130     #
131     # Use this function to automatically complain to the user if a USE flag
132     # depends on another USE flag that hasn't been enabled
133     #
134     # $1 - flag that depends on other flags
135 stuart 1.2 # $2 .. - the flags that must be set for $1 to be valid
136 stuart 1.1
137     confutils_use_depend_all () {
138     if ! useq $1 ; then
139     return
140     fi
141    
142     local my_flag="$1"
143     shift
144    
145     local my_missing=
146    
147     while [ "$1+" != "+" ]; do
148     if ! useq $1 ; then
149     my_missing="${my_missing} $1"
150     fi
151     shift
152     done
153    
154     if [ -n "$my_missing" ]; then
155     echo
156     eerror "USE flag '$my_flag' needs these additional flag(s) set:"
157     eerror " $my_missing"
158     eerror
159     eerror "You can do this by enabling these flags in /etc/portage/package.use:"
160 stuart 1.11 eerror " =$CATEGORY/$PN-$PVR $my_missing"
161 stuart 1.1 eerror
162     eerror "You could disable this flag instead in /etc/portage/package.use:"
163 stuart 1.11 eerror " =$CATEGORY/$PN-$PVR -$my_flag"
164 stuart 1.1 echo
165    
166     die "Need missing USE flags"
167     fi
168     }
169    
170     # ========================================================================
171     # confutils_use_depend_any ()
172     #
173     # Use this function to automatically complain to the user if a USE flag
174     # depends on another USE flag that hasn't been enabled
175     #
176     # $1 - flag that depends on other flags
177 stuart 1.2 # $2 .. - flags that must be set for $1 to be valid
178 stuart 1.1
179     confutils_use_depend_any () {
180     if ! useq $1 ; then
181     return
182     fi
183    
184     local my_flag="$1"
185     shift
186    
187     local my_found=
188     local my_missing=
189    
190     while [ "$1+" != "+" ]; do
191     if useq $1 ; then
192     my_found="${my_found} $1"
193     else
194     my_missing="${my_missing} $1"
195     fi
196     shift
197     done
198    
199     if [ -z "$my_found" ]; then
200     echo
201     eerror "USE flag '$my_flag' needs one of these additional flag(s) set:"
202     eerror " $my_missing"
203     eerror
204     eerror "You can do this by enabling one of these flags in /etc/portage/package.use"
205     eerror
206     die "Need missing USE flag"
207     fi
208     }
209    
210     # ========================================================================
211     # enable_extension_disable ()
212     #
213     # Use this function to disable an extension that is enabled by default.
214     # This is provided for those rare configure scripts that don't support
215     # a --enable for the corresponding --disable
216     #
217     # $1 - extension name
218     # $2 - USE flag
219 stuart 1.13 # $3 - optional message to einfo() to the user
220 stuart 1.1
221     enable_extension_disable () {
222     if ! useq "$2" ; then
223     my_conf="${my_conf} --disable-$1"
224 stuart 1.14 [ -n "$3" ] && einfo " Disabling $1"
225 stuart 1.13 else
226 stuart 1.14 [ -n "$3" ] && einfo " Enabling $1"
227 stuart 1.1 fi
228     }
229    
230     # ========================================================================
231 swegener 1.17 # enable_extension_enable ()
232 stuart 1.1 #
233     # This function is like use_enable(), except that it knows about
234     # enabling modules as shared libraries, and it supports passing
235     # additional data with the 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 stuart 1.13 # $5 - additional message to einfo out to the user
242 stuart 1.1
243     enable_extension_enable () {
244     local my_shared
245    
246 stuart 1.4 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 stuart 1.12 elif [ "$4+" != "+" ]; then
253     my_shared="=$4"
254 stuart 1.1 fi
255     else
256     if [ "$4+" != "+" ]; then
257     my_shared="=$4"
258     fi
259     fi
260    
261     if useq $2 ; then
262     my_conf="${my_conf} --enable-$1$my_shared"
263 stuart 1.14 einfo " Enabling $1"
264 stuart 1.1 else
265     my_conf="${my_conf} --disable-$1"
266 stuart 1.14 einfo " Disabling $1"
267 stuart 1.1 fi
268     }
269    
270     # ========================================================================
271 swegener 1.17 # enable_extension_enableonly ()
272 stuart 1.13 #
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    
283     enable_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"
294     fi
295     else
296     if [ "$4+" != "+" ]; then
297     my_shared="=$4"
298     fi
299     fi
300    
301     if useq $2 ; then
302     my_conf="${my_conf} --enable-$1$my_shared"
303 stuart 1.14 einfo " Enabling $1"
304 stuart 1.13 else
305     # note: we deliberately do *not* use a --disable switch here
306 stuart 1.14 einfo " Disabling $1"
307 stuart 1.13 fi
308     }
309     # ========================================================================
310 stuart 1.1 # enable_extension_without ()
311     #
312     # Use this function to disable an extension that is enabled by default
313     # This function is provided for those rare configure scripts that support
314     # --without but not the corresponding --with
315     #
316     # $1 - extension name
317     # $2 - USE flag
318 stuart 1.13 # $3 - optional message to einfo() to the user
319 stuart 1.1
320     enable_extension_without () {
321     if ! useq "$2" ; then
322     my_conf="${my_conf} --without-$1"
323 stuart 1.14 einfo " Disabling $1"
324 stuart 1.13 else
325 stuart 1.14 einfo " Enabling $1"
326 stuart 1.1 fi
327     }
328    
329     # ========================================================================
330     # enable_extension_with ()
331     #
332     # This function is a replacement for use_with. It supports building
333     # extensions as shared libraries,
334    
335     # $1 - extension name
336     # $2 - USE flag
337     # $3 - 1 = support shared, 0 = never support shared
338     # $4 - additional setting for configure
339 stuart 1.13 # $5 - optional message to einfo() out to the user
340 stuart 1.1
341     enable_extension_with () {
342     local my_shared
343    
344 stuart 1.4 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 stuart 1.12 elif [ "$4+" != "+" ]; then
351     my_shared="=$4"
352 stuart 1.1 fi
353     else
354     if [ "$4+" != "+" ]; then
355     my_shared="=$4"
356     fi
357     fi
358    
359     if useq $2 ; then
360     my_conf="${my_conf} --with-$1$my_shared"
361 stuart 1.14 einfo " Enabling $1"
362 stuart 1.1 else
363     my_conf="${my_conf} --without-$1"
364 stuart 1.14 einfo " Disabling $1"
365 stuart 1.13 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    
380     enable_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"
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 stuart 1.14 einfo " Enabling $1"
401 stuart 1.13 else
402     # note - we deliberately do *not* use --without here
403 stuart 1.14 einfo " Disabling $1"
404 stuart 1.1 fi
405     }
406 stuart 1.2
407     # ========================================================================
408     # confutils_warn_about_external_deps
409    
410     confutils_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 stuart 1.18
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    
445     enable_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    
474     enable_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     }

  ViewVC Help
Powered by ViewVC 1.1.20