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

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

 



Hello,

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,
right?

You could try the following:

# Does the user want to build netcdf-4?
AC_ARG_ENABLE([netcdf-4],
              [AS_HELP_STRING([--enable-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])
fi
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
correctly.

If you need to have it defined, youhave to place

#ifndef USE_NETCDF4
# define USE_NETCDF4 0
#endif

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
this:

case $enable_netcdf_4 in
yes) ac_use_netcdf4_num=1;;
*) ac_use_netcdf4_num=0;;
esac
AC_DEFINE_UNQUOTED([USE_NETCDF4], [$ac_use_netcdf4_num], 
		   [if true, build netCDF-4])

Hope this helps,
	Stepan Kasal


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux