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

Contents of /eclass/confutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed Jul 14 21:24:06 2004 UTC (10 years, 7 months ago) by stuart
Branch: MAIN
Changes since 1.1: +35 -5 lines
Added confutils_warn_about_missing_deps

1 stuart 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 stuart 1.2 # $Header: /var/cvsroot/gentoo-x86/eclass/confutils.eclass,v 1.1 2004/06/27 16:05:26 stuart Exp $
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     IUSE="$IUSE shared"
16    
17     # ========================================================================
18 stuart 1.2
19     # list of USE flags that need deps that aren't yet in Portage
20     # this list was originally added for PHP
21    
22     CONFUTILS_MISSING_DEPS="adabas birdstep qdbm empress empress-bcs frontbase hyperwave-api informix ingres interbase mcve mnogosearch msession msql oci8 oracle7 ovirmos pfpro sapdb"
23    
24     # ========================================================================
25 stuart 1.1 # confutils_init ()
26     #
27     # Call this function from your src_compile() function to initialise
28     # this eclass first
29    
30     confutils_init () {
31     if useq shared ; then
32     shared="=shared"
33     else
34     shared=
35     fi
36     }
37    
38     # ========================================================================
39     # confutils_use_conflict ()
40     #
41     # Use this function to automatically complain to the user if conflicting
42     # USE flags have been enabled
43     #
44     # $1 - flag that depends on other flags
45     # $2 .. - flags that conflict
46    
47     confutils_use_conflict () {
48     if ! useq $1 ; then
49     return
50     fi
51    
52     local my_flag="$1"
53     shift
54    
55     local my_present=
56     local my_remove=
57    
58     while [ "$1+" != "+" ]; do
59     if useq $1 ; then
60     my_present="${my_present} $1"
61     my_remove="${my_remove} -$1"
62     fi
63     shift
64     done
65    
66     if [ -n "$my_present" ]; then
67     echo
68     eerror "USE flag '$my_flag' conflicts with these USE flag(s):"
69     eerror " $my_present"
70     eerror
71     eerror "You must disable these conflicting flags before you can emerge this package."
72     eerror "You can do this by disabling these flags in /etc/portage/package.use:"
73     eerror " =$CATEGORY/$PN-$PVR: $my_remove"
74     eerror
75     die "Conflicting USE flags"
76     fi
77     }
78    
79     # ========================================================================
80     # confutils_use_depend_all ()
81     #
82     # Use this function to automatically complain to the user if a USE flag
83     # depends on another USE flag that hasn't been enabled
84     #
85     # $1 - flag that depends on other flags
86 stuart 1.2 # $2 .. - the flags that must be set for $1 to be valid
87 stuart 1.1
88     confutils_use_depend_all () {
89     if ! useq $1 ; then
90     return
91     fi
92    
93     local my_flag="$1"
94     shift
95    
96     local my_missing=
97    
98     while [ "$1+" != "+" ]; do
99     if ! useq $1 ; then
100     my_missing="${my_missing} $1"
101     fi
102     shift
103     done
104    
105     if [ -n "$my_missing" ]; then
106     echo
107     eerror "USE flag '$my_flag' needs these additional flag(s) set:"
108     eerror " $my_missing"
109     eerror
110     eerror "You can do this by enabling these flags in /etc/portage/package.use:"
111     eerror " =$CATEGORY/$PN-$PVR: $my_missing"
112     eerror
113     eerror "You could disable this flag instead in /etc/portage/package.use:"
114     eerror " =$CATEGORY/$PN-$PVR: -$my_flag"
115     echo
116    
117     die "Need missing USE flags"
118     fi
119     }
120    
121     # ========================================================================
122     # confutils_use_depend_any ()
123     #
124     # Use this function to automatically complain to the user if a USE flag
125     # depends on another USE flag that hasn't been enabled
126     #
127     # $1 - flag that depends on other flags
128 stuart 1.2 # $2 .. - flags that must be set for $1 to be valid
129 stuart 1.1
130     confutils_use_depend_any () {
131     if ! useq $1 ; then
132     return
133     fi
134    
135     local my_flag="$1"
136     shift
137    
138     local my_found=
139     local my_missing=
140    
141     while [ "$1+" != "+" ]; do
142     if useq $1 ; then
143     my_found="${my_found} $1"
144     else
145     my_missing="${my_missing} $1"
146     fi
147     shift
148     done
149    
150     if [ -z "$my_found" ]; then
151     echo
152     eerror "USE flag '$my_flag' needs one of these additional flag(s) set:"
153     eerror " $my_missing"
154     eerror
155     eerror "You can do this by enabling one of these flags in /etc/portage/package.use"
156     eerror
157     die "Need missing USE flag"
158     fi
159     }
160    
161     # ========================================================================
162     # enable_extension_disable ()
163     #
164     # Use this function to disable an extension that is enabled by default.
165     # This is provided for those rare configure scripts that don't support
166     # a --enable for the corresponding --disable
167     #
168     # $1 - extension name
169     # $2 - USE flag
170    
171     enable_extension_disable () {
172     if ! useq "$2" ; then
173     my_conf="${my_conf} --disable-$1"
174     fi
175     }
176    
177     # ========================================================================
178     # enable_extension_enable ()
179     #
180     # This function is like use_enable(), except that it knows about
181     # enabling modules as shared libraries, and it supports passing
182     # additional data with the switch
183     #
184     # $1 - extension name
185     # $2 - USE flag
186     # $3 - 1 = support shared, 0 = never support shared
187     # $4 - additional setting for configure
188    
189     enable_extension_enable () {
190     local my_shared
191    
192     if [ "$3" == "1" ]; then
193     my_shared="$shared"
194     if [ "$4+" != "+" ]; then
195     my_shared="${my_shared},$4"
196     fi
197     else
198     if [ "$4+" != "+" ]; then
199     my_shared="=$4"
200     fi
201     fi
202    
203     if useq $2 ; then
204     my_conf="${my_conf} --enable-$1$my_shared"
205     else
206     my_conf="${my_conf} --disable-$1"
207     fi
208     }
209    
210     # ========================================================================
211     # enable_extension_without ()
212     #
213     # Use this function to disable an extension that is enabled by default
214     # This function is provided for those rare configure scripts that support
215     # --without but not the corresponding --with
216     #
217     # $1 - extension name
218     # $2 - USE flag
219    
220     enable_extension_without () {
221     if ! useq "$2" ; then
222     my_conf="${my_conf} --without-$1"
223     fi
224     }
225    
226     # ========================================================================
227     # enable_extension_with ()
228     #
229     # This function is a replacement for use_with. It supports building
230     # extensions as shared libraries,
231    
232     # $1 - extension name
233     # $2 - USE flag
234     # $3 - 1 = support shared, 0 = never support shared
235     # $4 - additional setting for configure
236    
237     enable_extension_with () {
238     local my_shared
239    
240     if [ "$3" == "1" ]; then
241     my_shared="$shared"
242     if [ "$4+" != "+" ]; then
243     my_shared="${my_shared},$4"
244     fi
245     else
246     if [ "$4+" != "+" ]; then
247     my_shared="=$4"
248     fi
249     fi
250    
251     if useq $2 ; then
252     my_conf="${my_conf} --with-$1$my_shared"
253     else
254     my_conf="${my_conf} --without-$1"
255     fi
256     }
257 stuart 1.2
258     # ========================================================================
259     # confutils_warn_about_external_deps
260    
261     confutils_warn_about_missing_deps ()
262     {
263     local x
264     local my_found=0
265    
266     for x in $CONFUTILS_MISSING_DEPS ; do
267     if useq $x ; then
268     ewarn "USE flag $x enables support for software not in Portage"
269     my_found=1
270     fi
271     done
272    
273     if [ "$my_found" = "1" ]; then
274     ewarn
275     ewarn "This ebuild will continue, but if you haven't already installed the"
276     ewarn "software required to satisfy the list above, this package will probably"
277     ewarn "fail to compile."
278     ewarn
279     sleep 5
280     fi
281     }

  ViewVC Help
Powered by ViewVC 1.1.20