[Top][All Lists]

[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: Stepan Kasal
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:49:42 +0100
User-agent: Mutt/1.4.1i


On Mon, Jan 24, 2005 at 09:26:40AM -0700, Ed Hartnett wrote:
> AC_MSG_CHECKING([whether netCDF-4 is to be built])
> AC_MSG_RESULT($ac_cv_use_netcdf4)

I wouldn't use this.  You are not performing any time consuming check,
with program compilation and such.

>             [ac_cv_use_netcdf4=no])

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

#ifndef USE_NETCDF4
# 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
yes) ac_use_netcdf4_num=1;;
*) ac_use_netcdf4_num=0;;
AC_DEFINE_UNQUOTED([USE_NETCDF4], [$ac_use_netcdf4_num], 
                   [if true, build netCDF-4])

Hope this helps,
        Stepan Kasal

reply via email to

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