[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
Re: this AC_ARG_ENABLE stuff works, but I suspect I'm not doing this the best way...
Mon, 24 Jan 2005 17:49:42 +0100
On Mon, Jan 24, 2005 at 09:26:40AM -0700, Ed Hartnett wrote:
> AC_MSG_CHECKING([whether netCDF-4 is to be built])
I wouldn't use this. You are not performing any time consuming check,
with program compilation and such.
ac_cv_* means ``cached value'' -- you don't intend to work with the cache,
You could try the following:
# Does the user want to build netcdf-4?
[build with netcdf-4 (HDF5 is required)])])
if test x$enable_netcdf_4 = xyes; then
AC_DEFINE([USE_NETCDF4], 1, [if true, build netCDF-4])
AM_CONDITIONAL(USE_NETCDF4, [test x$enable_netcdf_4 = xyes])
> In 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?
The above code leaves it undefined if the feature is not enabled.
This should work both with #ifdef and #if conditions, if I understand it
If you need to have it defined, youhave to place
# define USE_NETCDF4 0
somewhere in your code. Either put it to the end of your config.h
(see the autoconf manual how to acomplish this), or do this in your
main header, just after including config.h.
Or you can leave there your original code, it's not bad. Perhaps like
case $enable_netcdf_4 in
[if true, build netCDF-4])
Hope this helps,