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

Contents of /eclass/confutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Wed Jul 14 22:33:50 2004 UTC (9 years, 11 months ago) by stuart
Branch: MAIN
Changes since 1.2: +5 -7 lines
Fixed for passing additional parameters to --enable and --with

1 stuart 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 stuart 1.3 # $Header: /var/cvsroot/gentoo-x86/eclass/confutils.eclass,v 1.2 2004/07/14 21:24:06 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 stuart 1.3 if [ "$3" == "1" -a -n "$shared" ]; then
193 stuart 1.1 if [ "$4+" != "+" ]; then
194 stuart 1.3 my_shared="${shared},$4"
195 stuart 1.1 fi
196     else
197     if [ "$4+" != "+" ]; then
198     my_shared="=$4"
199     fi
200     fi
201    
202     if useq $2 ; then
203     my_conf="${my_conf} --enable-$1$my_shared"
204     else
205     my_conf="${my_conf} --disable-$1"
206     fi
207     }
208    
209     # ========================================================================
210     # enable_extension_without ()
211     #
212     # Use this function to disable an extension that is enabled by default
213     # This function is provided for those rare configure scripts that support
214     # --without but not the corresponding --with
215     #
216     # $1 - extension name
217     # $2 - USE flag
218    
219     enable_extension_without () {
220     if ! useq "$2" ; then
221     my_conf="${my_conf} --without-$1"
222     fi
223     }
224    
225     # ========================================================================
226     # enable_extension_with ()
227     #
228     # This function is a replacement for use_with. It supports building
229     # extensions as shared libraries,
230    
231     # $1 - extension name
232     # $2 - USE flag
233     # $3 - 1 = support shared, 0 = never support shared
234     # $4 - additional setting for configure
235    
236     enable_extension_with () {
237     local my_shared
238    
239 stuart 1.3 if [ "$3" == "1" -a -n "$shared" ]; then
240 stuart 1.1 if [ "$4+" != "+" ]; then
241 stuart 1.3 my_shared="${shared},$4"
242 stuart 1.1 fi
243     else
244     if [ "$4+" != "+" ]; then
245     my_shared="=$4"
246     fi
247     fi
248    
249     if useq $2 ; then
250     my_conf="${my_conf} --with-$1$my_shared"
251     else
252     my_conf="${my_conf} --without-$1"
253     fi
254     }
255 stuart 1.2
256     # ========================================================================
257     # confutils_warn_about_external_deps
258    
259     confutils_warn_about_missing_deps ()
260     {
261     local x
262     local my_found=0
263    
264     for x in $CONFUTILS_MISSING_DEPS ; do
265     if useq $x ; then
266     ewarn "USE flag $x enables support for software not in Portage"
267     my_found=1
268     fi
269     done
270    
271     if [ "$my_found" = "1" ]; then
272     ewarn
273     ewarn "This ebuild will continue, but if you haven't already installed the"
274     ewarn "software required to satisfy the list above, this package will probably"
275     ewarn "fail to compile."
276     ewarn
277     sleep 5
278     fi
279     }

  ViewVC Help
Powered by ViewVC 1.1.20