autoconf
[Top][All Lists]
Advanced

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

Re: this AC_ARG_ENABLE stuff works, but I suspect I'm not doing this the


From: Ralf Wildenhues
Subject: Re: this AC_ARG_ENABLE stuff works, but I suspect I'm not doing this the best way...
Date: Mon, 24 Jan 2005 17:38:33 +0100
User-agent: Mutt/1.4.1i

* Ed Hartnett wrote on Mon, Jan 24, 2005 at 05:26:40PM CET:
> 
> Here's how I do it, but I'm sure there must be a better way. In

I don't think it works..

> particular, how do I set the macro USE_NETCDF4 to 1, when
> AC_ARG_ENABLE sets ac_cv_use_netcdf4 to either "yes" or "no."
> 
> The way I do it is to introduce a new variable, ac_use_netcdf4_num,
> which I set to 0 or 1. Is there a better way to do this?
> 
> # Does the user want to build netcdf-4?
> AC_MSG_CHECKING([whether netCDF-4 is to be built])
> AC_ARG_ENABLE([netcdf-4],
>               [AS_HELP_STRING([--enable-netcdf-4],
>                               [build with netcdf-4 (HDF5 is required)])],
>               [ac_cv_use_netcdf4=$enableval], 
>             [ac_cv_use_netcdf4=no])
> AC_MSG_RESULT($ac_cv_use_netcdf4)
> AM_CONDITIONAL(USE_NETCDF4, [test x$ac_cv_use_netcdf4 != xno])
> if test x$ac_cv_use_netcdf4 == xyes; 

You only want `=' here, not `=='.  See the manual for test.
(It works by chance with bash but, e.g., not with ash.)
I would also put $ac_cv_use_netcdf4 in double quotes here.

> then ac_use_netcdf4_num=1
> else ac_use_netcdf4_num=0
> fi
> AC_DEFINE_UNQUOTED([USE_NETCDF4], [$ac_use_netcdf4_num], 
>                  [if true, build netCDF-4])

As for length: you could elide the last two arguments to AC_ARG_ENABLE
and work with the variable names autoconf creates.  I would not do that,
just leave it as-is.  If you have many macros of this form, you can
write a macro to create them...

Regards,
Ralf




reply via email to

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