autoconf
[Top][All Lists]
Advanced

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

Re: conditionally compiling C++ code


From: Sander Niemeijer
Subject: Re: conditionally compiling C++ code
Date: Tue, 29 Apr 2003 14:31:54 +0200

I was just wondering, but aren't the --with-PACKAGE/--enable-FEATURE options of configure meant for this?

I have a package that can optionally make use of the HDF4 library (which, if included, provides extra functionality to import/export data in HDF4 format). I dealt with this in my configure.ac as follows:

---
AC_ARG_WITH([hdf4],
[AC_HELP_STRING([--with-hdf4],[build HDF4 support into this package])],
  [ac_cv_with_hdf4=$withval],
  [AC_CACHE_CHECK([use HDF4],ac_cv_with_hdf4,ac_cv_with_hdf4=no)])

if test $ac_cv_with_hdf4 = yes ; then
... <Check for HDF4 libs and headers via environment variables that specify their location and set HAVE_HDF4 definition and ac_cv_have_hdf4> ...
  if test $ac_cv_have_hdf4 = no ; then
AC_MSG_ERR([HDF4 libraries and/or header files are not found. Try setting the appropriate environment variables.])
  fi
fi
---
This approach forces you to explicitly say that you want to make use of the HDF4 functionality and if so it will give an error if it could not find the HDF4 libs/headers.

In my view there should only be a 'required' and 'not needed' status for libraries. And if some functionality is optional (which may require one or even more libraries) this should be handled through configure options.

Just my 2 cents.

Regards,
Sander

On dinsdag, apr 29, 2003, at 12:54 Europe/Amsterdam, Patrick Welche wrote:

On Tue, Apr 29, 2003 at 06:12:15AM -0400, Thomas E. Dickey wrote:
On Mon, 28 Apr 2003, Bob Proulx wrote:

Thomas Dickey wrote:
Peter Eisentraut wrote:
...nonsense
As I read Peter's post I believe the point was that the tool was
generally considered to require readline functionality. Not having it

readline is a library (if the configure script fails, readline wouldn't
be linked except if the configure script is doubly-incorrect).

The supposedly analogous example of an external program is implausible
as well (it's common practice to distinguish between nice "optional"
stuff versus essentials - configure is properly used for the latter).

It seems that we are trying to differentiate between libraries which are
- required     (error: won't work without it)
- recommended  (warning: some usual/useful features won't work)
- optional (just don't link with it, user probably won't see the difference)

How about another variable to AC_CHECK_LIB, which
if "x$6" = "xREQUIRED" && test $ac_somelib = none; then
  AC_MSG_ERROR...
where variable is REQUIRED, RECOMMENDED, (OPTIONAL | "")

?

Cheers,

Patrick







reply via email to

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