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

Contents of /eclass/confutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun Jun 27 16:05:26 2004 UTC (10 years, 2 months ago) by stuart
Branch: MAIN
Initial import

1 # Copyright 1999-2004 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
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 # confutils_init ()
19 #
20 # Call this function from your src_compile() function to initialise
21 # this eclass first
22
23 confutils_init () {
24 if useq shared ; then
25 shared="=shared"
26 else
27 shared=
28 fi
29 }
30
31 # ========================================================================
32 # confutils_use_conflict ()
33 #
34 # Use this function to automatically complain to the user if conflicting
35 # USE flags have been enabled
36 #
37 # $1 - flag that depends on other flags
38 # $2 .. - flags that conflict
39
40 confutils_use_conflict () {
41 if ! useq $1 ; then
42 return
43 fi
44
45 local my_flag="$1"
46 shift
47
48 local my_present=
49 local my_remove=
50
51 while [ "$1+" != "+" ]; do
52 if useq $1 ; then
53 my_present="${my_present} $1"
54 my_remove="${my_remove} -$1"
55 fi
56 shift
57 done
58
59 if [ -n "$my_present" ]; then
60 echo
61 eerror "USE flag '$my_flag' conflicts with these USE flag(s):"
62 eerror " $my_present"
63 eerror
64 eerror "You must disable these conflicting flags before you can emerge this package."
65 eerror "You can do this by disabling these flags in /etc/portage/package.use:"
66 eerror " =$CATEGORY/$PN-$PVR: $my_remove"
67 eerror
68 die "Conflicting USE flags"
69 fi
70 }
71
72 # ========================================================================
73 # confutils_use_depend_all ()
74 #
75 # Use this function to automatically complain to the user if a USE flag
76 # depends on another USE flag that hasn't been enabled
77 #
78 # $1 - flag that depends on other flags
79 # $2 - error message to show
80 # $3 .. -
81
82 confutils_use_depend_all () {
83 if ! useq $1 ; then
84 return
85 fi
86
87 local my_flag="$1"
88 shift
89
90 local my_missing=
91
92 while [ "$1+" != "+" ]; do
93 if ! useq $1 ; then
94 my_missing="${my_missing} $1"
95 fi
96 shift
97 done
98
99 if [ -n "$my_missing" ]; then
100 echo
101 eerror "USE flag '$my_flag' needs these additional flag(s) set:"
102 eerror " $my_missing"
103 eerror
104 eerror "You can do this by enabling these flags in /etc/portage/package.use:"
105 eerror " =$CATEGORY/$PN-$PVR: $my_missing"
106 eerror
107 eerror "You could disable this flag instead in /etc/portage/package.use:"
108 eerror " =$CATEGORY/$PN-$PVR: -$my_flag"
109 echo
110
111 die "Need missing USE flags"
112 fi
113 }
114
115 # ========================================================================
116 # confutils_use_depend_any ()
117 #
118 # Use this function to automatically complain to the user if a USE flag
119 # depends on another USE flag that hasn't been enabled
120 #
121 # $1 - flag that depends on other flags
122 # $2 - error message to show
123 # $3 .. -
124
125 confutils_use_depend_any () {
126 if ! useq $1 ; then
127 return
128 fi
129
130 local my_flag="$1"
131 shift
132
133 local my_found=
134 local my_missing=
135
136 while [ "$1+" != "+" ]; do
137 if useq $1 ; then
138 my_found="${my_found} $1"
139 else
140 my_missing="${my_missing} $1"
141 fi
142 shift
143 done
144
145 if [ -z "$my_found" ]; then
146 echo
147 eerror "USE flag '$my_flag' needs one of these additional flag(s) set:"
148 eerror " $my_missing"
149 eerror
150 eerror "You can do this by enabling one of these flags in /etc/portage/package.use"
151 eerror
152 die "Need missing USE flag"
153 fi
154 }
155
156 # ========================================================================
157 # enable_extension_disable ()
158 #
159 # Use this function to disable an extension that is enabled by default.
160 # This is provided for those rare configure scripts that don't support
161 # a --enable for the corresponding --disable
162 #
163 # $1 - extension name
164 # $2 - USE flag
165
166 enable_extension_disable () {
167 if ! useq "$2" ; then
168 my_conf="${my_conf} --disable-$1"
169 fi
170 }
171
172 # ========================================================================
173 # enable_extension_enable ()
174 #
175 # This function is like use_enable(), except that it knows about
176 # enabling modules as shared libraries, and it supports passing
177 # additional data with the switch
178 #
179 # $1 - extension name
180 # $2 - USE flag
181 # $3 - 1 = support shared, 0 = never support shared
182 # $4 - additional setting for configure
183
184 enable_extension_enable () {
185 local my_shared
186
187 if [ "$3" == "1" ]; then
188 my_shared="$shared"
189 if [ "$4+" != "+" ]; then
190 my_shared="${my_shared},$4"
191 fi
192 else
193 if [ "$4+" != "+" ]; then
194 my_shared="=$4"
195 fi
196 fi
197
198 if useq $2 ; then
199 my_conf="${my_conf} --enable-$1$my_shared"
200 else
201 my_conf="${my_conf} --disable-$1"
202 fi
203 }
204
205 # ========================================================================
206 # enable_extension_without ()
207 #
208 # Use this function to disable an extension that is enabled by default
209 # This function is provided for those rare configure scripts that support
210 # --without but not the corresponding --with
211 #
212 # $1 - extension name
213 # $2 - USE flag
214
215 enable_extension_without () {
216 if ! useq "$2" ; then
217 my_conf="${my_conf} --without-$1"
218 fi
219 }
220
221 # ========================================================================
222 # enable_extension_with ()
223 #
224 # This function is a replacement for use_with. It supports building
225 # extensions as shared libraries,
226
227 # $1 - extension name
228 # $2 - USE flag
229 # $3 - 1 = support shared, 0 = never support shared
230 # $4 - additional setting for configure
231
232 enable_extension_with () {
233 local my_shared
234
235 if [ "$3" == "1" ]; then
236 my_shared="$shared"
237 if [ "$4+" != "+" ]; then
238 my_shared="${my_shared},$4"
239 fi
240 else
241 if [ "$4+" != "+" ]; then
242 my_shared="=$4"
243 fi
244 fi
245
246 if useq $2 ; then
247 my_conf="${my_conf} --with-$1$my_shared"
248 else
249 my_conf="${my_conf} --without-$1"
250 fi
251 }

  ViewVC Help
Powered by ViewVC 1.1.20