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

Contents of /eclass/confutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations) (download)
Tue Aug 24 20:55:43 2004 UTC (10 years, 2 months ago) by stuart
Branch: MAIN
Changes since 1.11: +5 -1 lines
Added fix for when shared USE flag not defined

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.11 2004/08/21 09:46:18 stuart 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 db2 dbmaker empress empress-bcs esoob 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 elif [ "$4+" != "+" ]; then
199 my_shared="=$4"
200 fi
201 else
202 if [ "$4+" != "+" ]; then
203 my_shared="=$4"
204 fi
205 fi
206
207 if useq $2 ; then
208 my_conf="${my_conf} --enable-$1$my_shared"
209 else
210 my_conf="${my_conf} --disable-$1"
211 fi
212 }
213
214 # ========================================================================
215 # enable_extension_without ()
216 #
217 # Use this function to disable an extension that is enabled by default
218 # This function is provided for those rare configure scripts that support
219 # --without but not the corresponding --with
220 #
221 # $1 - extension name
222 # $2 - USE flag
223
224 enable_extension_without () {
225 if ! useq "$2" ; then
226 my_conf="${my_conf} --without-$1"
227 fi
228 }
229
230 # ========================================================================
231 # enable_extension_with ()
232 #
233 # This function is a replacement for use_with. It supports building
234 # extensions as shared libraries,
235
236 # $1 - extension name
237 # $2 - USE flag
238 # $3 - 1 = support shared, 0 = never support shared
239 # $4 - additional setting for configure
240
241 enable_extension_with () {
242 local my_shared
243
244 if [ "$3" == "1" ]; then
245 if [ "$shared+" != "+" ]; then
246 my_shared="${shared}"
247 if [ "$4+" != "+" ]; then
248 my_shared="${my_shared},$4"
249 fi
250 elif [ "$4+" != "+" ]; then
251 my_shared="=$4"
252 fi
253 else
254 if [ "$4+" != "+" ]; then
255 my_shared="=$4"
256 fi
257 fi
258
259 if useq $2 ; then
260 my_conf="${my_conf} --with-$1$my_shared"
261 else
262 my_conf="${my_conf} --without-$1"
263 fi
264 }
265
266 # ========================================================================
267 # confutils_warn_about_external_deps
268
269 confutils_warn_about_missing_deps ()
270 {
271 local x
272 local my_found=0
273
274 for x in $CONFUTILS_MISSING_DEPS ; do
275 if useq $x ; then
276 ewarn "USE flag $x enables support for software not in Portage"
277 my_found=1
278 fi
279 done
280
281 if [ "$my_found" = "1" ]; then
282 ewarn
283 ewarn "This ebuild will continue, but if you haven't already installed the"
284 ewarn "software required to satisfy the list above, this package will probably"
285 ewarn "fail to compile."
286 ewarn
287 sleep 5
288 fi
289 }

  ViewVC Help
Powered by ViewVC 1.1.20