autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AC_ARG_ENABLE ambiguity


From: Joshua Kwan
Subject: AC_ARG_ENABLE ambiguity
Date: Tue, 10 Jun 2003 23:11:11 -0700
User-agent: Mutt/1.5.4i

Hi all,

I was struggling with some AC_ARG_ENABLE stuff in my project today. 
Seems like some people have done ./configure --enable-foo when the 
AC_ARG_ENABLE code was as follows: (simplified)

AC_ARG_ENABLE(foo
AC_HELP_STRING([--disable-foo], [Disable the usage of foo]),
[AC_DEFINE(USE_FOO, 1, blahjasdf)],
[AC_DEFINE(USE_FOO_ALT, 1, [Use if foo doesn't suit your platform])])

So running ./configure --enable-foo would disable foo. I could add a 
test:

AC_ARG_ENABLE(foo
AC_HELP_STRING([--disable-foo], [Disable the usage of foo]),
[
if test "$enableval" = no; then
        AC_DEFINE(USE_FOO_ALT, 1, Use the alternative to foo)
else
        AC_DEFINE(USE_REAL_FOO, 1, [Use if foo is good on your platform])
fi
],
[AC_DEFINE(USE_REAL_FOO, 1, [Use if foo is good on your platform])])

But as you can see I have had to recopy the code from the default case, 
which is effectively --enable-foo providing it worked correctly. For 
stuff where the default code is larger, it is a lot more cumbersome. I 
have been setting a "foo_disabled" variable and doing the common code 
outside of the AC_ARG_ENABLE check for the time being if that variable 
is a certain value.

What would be cool would be an AC_ARG_ENABLE as follows:

AC_ARG_ENABLE(xxxxx,
[helpstring here],
[this happens if $enableval = yes],
[this happens if $enableval = no])

And enableval is set to no by default? Who knows, there will probably be 
some holes to poke in that. But is there a more elegant solution fro my 
problem?

Please CC me as I am not subscribed to this list.

Regards
Josh

Attachment: pgpClbMm4UpEN.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]