1 |
On Tue, Sep 13, 2011 at 06:13:10PM -0400, Mike Frysinger wrote: |
2 |
> On Tuesday, September 13, 2011 18:01:25 Alec Warner wrote: |
3 |
> > On Tue, Sep 13, 2011 at 2:56 PM, Mike Frysinger wrote: |
4 |
> > > this is so i can do: |
5 |
> > > export some_var=$(usex some_flag) |
6 |
> > > and get it set to "yes" or "no" |
7 |
> > |
8 |
> > If the intent is to use it for logic: |
9 |
> > |
10 |
> > export some_var=$(usex some_flag) |
11 |
> > |
12 |
> > if [[ $some_var == yes ]]; then |
13 |
> > # buttsex |
14 |
> > fi |
15 |
> |
16 |
> that is not the intent |
17 |
> |
18 |
> > Then I recommend making true / false the default and then doing |
19 |
> > |
20 |
> > if $some_var; then |
21 |
> > # buttsex |
22 |
> > fi |
23 |
> |
24 |
> the point is to use it to construct vars that get passed to scripts like econf |
25 |
> or programs like emake |
26 |
> |
27 |
> ac_cv_some_header=$(usex foo) \ |
28 |
> econf ... |
29 |
> |
30 |
> emake USE_POOP=$(usex poo) |
31 |
|
32 |
Making it overridable seems wiser- |
33 |
|
34 |
usex() { |
35 |
local flag="$1" |
36 |
local tval=${2-yes} |
37 |
local fval=${3-no} |
38 |
if use $flag; then |
39 |
echo "${tval}" |
40 |
else |
41 |
echo "${fval}" |
42 |
fi |
43 |
} |
44 |
|
45 |
While a bit longer, we likely can gut most of the use_* logic to |
46 |
use that, and it makes it easier to deal w/ the situations where a |
47 |
configure's options always assume --enable-blah thus don't export the |
48 |
option, but *do* export a --disable-blah. |
49 |
|
50 |
That way we can shift away from |
51 |
$(use blah && use_with blah) |
52 |
to |
53 |
$(usex blah --with-blah '') |
54 |
|
55 |
Or that's the intent at least. |
56 |
~brian |