1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
|
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/confutils.eclass,v 1.15 2005/03/19 08:05:56 sebastian Exp $
#
# eclass/confutils.eclass
# Utility functions to help with configuring a package
#
# Based on Stuart's work for the PHP 5 eclass
#
# Author(s) Stuart Herbert
# <stuart@gentoo.org>
#
# ========================================================================
IUSE="$IUSE sharedext"
# ========================================================================
# list of USE flags that need deps that aren't yet in Portage
# this list was originally added for PHP
CONFUTILS_MISSING_DEPS="adabas birdstep db2 dbmaker empress empress-bcs esoob frontbase hyperwave-api informix ingres mnogosearch msession msql oci8 oracle7 ovrimos pfpro sapdb solid sybase sybase-ct"
# ========================================================================
# confutils_init ()
#
# Call this function from your src_compile() function to initialise
# this eclass first
confutils_init () {
if useq sharedext ; then
shared="=shared"
else
shared=
fi
}
# ========================================================================
# confutils_use_conflict ()
#
# Use this function to automatically complain to the user if conflicting
# USE flags have been enabled
#
# $1 - flag that depends on other flags
# $2 .. - flags that conflict
confutils_use_conflict () {
if ! useq $1 ; then
return
fi
local my_flag="$1"
shift
local my_present=
local my_remove=
while [ "$1+" != "+" ]; do
if useq $1 ; then
my_present="${my_present} $1"
my_remove="${my_remove} -$1"
fi
shift
done
if [ -n "$my_present" ]; then
echo
eerror "USE flag '$my_flag' conflicts with these USE flag(s):"
eerror " $my_present"
eerror
eerror "You must disable these conflicting flags before you can emerge this package."
eerror "You can do this by disabling these flags in /etc/portage/package.use:"
eerror " =$CATEGORY/$PN-$PVR $my_remove"
eerror
die "Conflicting USE flags"
fi
}
# ========================================================================
# confutils_use_depend_all ()
#
# Use this function to automatically complain to the user if a USE flag
# depends on another USE flag that hasn't been enabled
#
# $1 - flag that depends on other flags
# $2 .. - the flags that must be set for $1 to be valid
confutils_use_depend_all () {
if ! useq $1 ; then
return
fi
local my_flag="$1"
shift
local my_missing=
while [ "$1+" != "+" ]; do
if ! useq $1 ; then
my_missing="${my_missing} $1"
fi
shift
done
if [ -n "$my_missing" ]; then
echo
eerror "USE flag '$my_flag' needs these additional flag(s) set:"
eerror " $my_missing"
eerror
eerror "You can do this by enabling these flags in /etc/portage/package.use:"
eerror " =$CATEGORY/$PN-$PVR $my_missing"
eerror
eerror "You could disable this flag instead in /etc/portage/package.use:"
eerror " =$CATEGORY/$PN-$PVR -$my_flag"
echo
die "Need missing USE flags"
fi
}
# ========================================================================
# confutils_use_depend_any ()
#
# Use this function to automatically complain to the user if a USE flag
# depends on another USE flag that hasn't been enabled
#
# $1 - flag that depends on other flags
# $2 .. - flags that must be set for $1 to be valid
confutils_use_depend_any () {
if ! useq $1 ; then
return
fi
local my_flag="$1"
shift
local my_found=
local my_missing=
while [ "$1+" != "+" ]; do
if useq $1 ; then
my_found="${my_found} $1"
else
my_missing="${my_missing} $1"
fi
shift
done
if [ -z "$my_found" ]; then
echo
eerror "USE flag '$my_flag' needs one of these additional flag(s) set:"
eerror " $my_missing"
eerror
eerror "You can do this by enabling one of these flags in /etc/portage/package.use"
eerror
die "Need missing USE flag"
fi
}
# ========================================================================
# enable_extension_disable ()
#
# Use this function to disable an extension that is enabled by default.
# This is provided for those rare configure scripts that don't support
# a --enable for the corresponding --disable
#
# $1 - extension name
# $2 - USE flag
# $3 - optional message to einfo() to the user
enable_extension_disable () {
if ! useq "$2" ; then
my_conf="${my_conf} --disable-$1"
[ -n "$3" ] && einfo " Disabling $1"
else
[ -n "$3" ] && einfo " Enabling $1"
fi
}
# ========================================================================
# enable_extension_enable ()
#
# This function is like use_enable(), except that it knows about
# enabling modules as shared libraries, and it supports passing
# additional data with the switch
#
# $1 - extension name
# $2 - USE flag
# $3 - 1 = support shared, 0 = never support shared
# $4 - additional setting for configure
# $5 - additional message to einfo out to the user
enable_extension_enable () {
local my_shared
if [ "$3" == "1" ]; then
if [ "$shared+" != "+" ]; then
my_shared="${shared}"
if [ "$4+" != "+" ]; then
my_shared="${my_shared},$4"
fi
elif [ "$4+" != "+" ]; then
my_shared="=$4"
fi
else
if [ "$4+" != "+" ]; then
my_shared="=$4"
fi
fi
if useq $2 ; then
my_conf="${my_conf} --enable-$1$my_shared"
einfo " Enabling $1"
else
my_conf="${my_conf} --disable-$1"
einfo " Disabling $1"
fi
}
# ========================================================================
# enable_extension_enableonly ()
#
# This function is like use_enable(), except that it knows about
# enabling modules as shared libraries, and it supports passing
# additional data with the switch
#
# $1 - extension name
# $2 - USE flag
# $3 - 1 = support shared, 0 = never support shared
# $4 - additional setting for configure
# $5 - additional message to einfo out to the user
enable_extension_enableonly () {
local my_shared
if [ "$3" == "1" ]; then
if [ "$shared+" != "+" ]; then
my_shared="${shared}"
if [ "$4+" != "+" ]; then
my_shared="${my_shared},$4"
fi
elif [ "$4+" != "+" ]; then
my_shared="=$4"
fi
else
if [ "$4+" != "+" ]; then
my_shared="=$4"
fi
fi
if useq $2 ; then
my_conf="${my_conf} --enable-$1$my_shared"
einfo " Enabling $1"
else
# note: we deliberately do *not* use a --disable switch here
einfo " Disabling $1"
fi
}
# ========================================================================
# enable_extension_without ()
#
# Use this function to disable an extension that is enabled by default
# This function is provided for those rare configure scripts that support
# --without but not the corresponding --with
#
# $1 - extension name
# $2 - USE flag
# $3 - optional message to einfo() to the user
enable_extension_without () {
if ! useq "$2" ; then
my_conf="${my_conf} --without-$1"
einfo " Disabling $1"
else
einfo " Enabling $1"
fi
}
# ========================================================================
# enable_extension_with ()
#
# This function is a replacement for use_with. It supports building
# extensions as shared libraries,
# $1 - extension name
# $2 - USE flag
# $3 - 1 = support shared, 0 = never support shared
# $4 - additional setting for configure
# $5 - optional message to einfo() out to the user
enable_extension_with () {
local my_shared
if [ "$3" == "1" ]; then
if [ "$shared+" != "+" ]; then
my_shared="${shared}"
if [ "$4+" != "+" ]; then
my_shared="${my_shared},$4"
fi
elif [ "$4+" != "+" ]; then
my_shared="=$4"
fi
else
if [ "$4+" != "+" ]; then
my_shared="=$4"
fi
fi
if useq $2 ; then
my_conf="${my_conf} --with-$1$my_shared"
einfo " Enabling $1"
else
my_conf="${my_conf} --without-$1"
einfo " Disabling $1"
fi
}
# ========================================================================
# enable_extension_withonly ()
#
# This function is a replacement for use_with. It supports building
# extensions as shared libraries,
# $1 - extension name
# $2 - USE flag
# $3 - 1 = support shared, 0 = never support shared
# $4 - additional setting for configure
# $5 - optional message to einfo() out to the user
enable_extension_withonly () {
local my_shared
if [ "$3" == "1" ]; then
if [ "$shared+" != "+" ]; then
my_shared="${shared}"
if [ "$4+" != "+" ]; then
my_shared="${my_shared},$4"
fi
elif [ "$4+" != "+" ]; then
my_shared="=$4"
fi
else
if [ "$4+" != "+" ]; then
my_shared="=$4"
fi
fi
if useq $2 ; then
my_conf="${my_conf} --with-$1$my_shared"
einfo " Enabling $1"
else
# note - we deliberately do *not* use --without here
einfo " Disabling $1"
fi
}
# ========================================================================
# confutils_warn_about_external_deps
confutils_warn_about_missing_deps ()
{
local x
local my_found=0
for x in $CONFUTILS_MISSING_DEPS ; do
if useq $x ; then
ewarn "USE flag $x enables support for software not in Portage"
my_found=1
fi
done
if [ "$my_found" = "1" ]; then
ewarn
ewarn "This ebuild will continue, but if you haven't already installed the"
ewarn "software required to satisfy the list above, this package will probably"
ewarn "fail to compile."
ewarn
sleep 5
fi
}
|