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

Contents of /eclass/confutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Fri Aug 6 16:54:51 2004 UTC (9 years, 8 months ago) by robbat2
Branch: MAIN
Changes since 1.7: +2 -2 lines
MCVE support now fully in the tree.

1 # Copyright 1999-2004 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.7 2004/08/06 02:59:47 robbat2 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 IUSE="$IUSE shared"
16
17 # ========================================================================
18
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 cpdflib db2 dbmaker empress empress-bcs esoob filepro frontbase hyperwave-api informix ingres interbase mnogosearch msession msql oci8 oracle7 ovrimos pfpro sapdb solid sybase sybase-ct"
23
24 # ========================================================================
25 # 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 # $2 .. - the flags that must be set for $1 to be valid
87
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 # $2 .. - flags that must be set for $1 to be valid
129
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 if [ "$shared+" != "+" ]; then
194 my_shared="${shared}"
195 if [ "$4+" != "+" ]; then
196 my_shared="${my_shared},$4"
197 fi
198 fi
199 else
200 if [ "$4+" != "+" ]; then
201 my_shared="=$4"
202 fi
203 fi
204
205 if useq $2 ; then
206 my_conf="${my_conf} --enable-$1$my_shared"
207 else
208 my_conf="${my_conf} --disable-$1"
209 fi
210 }
211
212 # ========================================================================
213 # enable_extension_without ()
214 #
215 # Use this function to disable an extension that is enabled by default
216 # This function is provided for those rare configure scripts that support
217 # --without but not the corresponding --with
218 #
219 # $1 - extension name
220 # $2 - USE flag
221
222 enable_extension_without () {
223 if ! useq "$2" ; then
224 my_conf="${my_conf} --without-$1"
225 fi
226 }
227
228 # ========================================================================
229 # enable_extension_with ()
230 #
231 # This function is a replacement for use_with. It supports building
232 # extensions as shared libraries,
233
234 # $1 - extension name
235 # $2 - USE flag
236 # $3 - 1 = support shared, 0 = never support shared
237 # $4 - additional setting for configure
238
239 enable_extension_with () {
240 local my_shared
241
242 if [ "$3" == "1" ]; then
243 if [ "$shared+" != "+" ]; then
244 my_shared="${shared}"
245 if [ "$4+" != "+" ]; then
246 my_shared="${my_shared},$4"
247 fi
248 fi
249 else
250 if [ "$4+" != "+" ]; then
251 my_shared="=$4"
252 fi
253 fi
254
255 if useq $2 ; then
256 my_conf="${my_conf} --with-$1$my_shared"
257 else
258 my_conf="${my_conf} --without-$1"
259 fi
260 }
261
262 # ========================================================================
263 # confutils_warn_about_external_deps
264
265 confutils_warn_about_missing_deps ()
266 {
267 local x
268 local my_found=0
269
270 for x in $CONFUTILS_MISSING_DEPS ; do
271 if useq $x ; then
272 ewarn "USE flag $x enables support for software not in Portage"
273 my_found=1
274 fi
275 done
276
277 if [ "$my_found" = "1" ]; then
278 ewarn
279 ewarn "This ebuild will continue, but if you haven't already installed the"
280 ewarn "software required to satisfy the list above, this package will probably"
281 ewarn "fail to compile."
282 ewarn
283 sleep 5
284 fi
285 }

  ViewVC Help
Powered by ViewVC 1.1.20