blob: 79ea47041340a0c6a721cda4144ca4b94ea4c2d0 (
plain)
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
|
# 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.1 2004/06/27 16:05:26 stuart 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 shared"
# ========================================================================
# confutils_init ()
#
# Call this function from your src_compile() function to initialise
# this eclass first
confutils_init () {
if useq shared ; 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 - error message to show
# $3 .. -
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 - error message to show
# $3 .. -
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
enable_extension_disable () {
if ! useq "$2" ; then
my_conf="${my_conf} --disable-$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
enable_extension_enable () {
local my_shared
if [ "$3" == "1" ]; then
my_shared="$shared"
if [ "$4+" != "+" ]; then
my_shared="${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"
else
my_conf="${my_conf} --disable-$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
enable_extension_without () {
if ! useq "$2" ; then
my_conf="${my_conf} --without-$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
enable_extension_with () {
local my_shared
if [ "$3" == "1" ]; then
my_shared="$shared"
if [ "$4+" != "+" ]; then
my_shared="${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"
else
my_conf="${my_conf} --without-$1"
fi
}
|