autoconf
[Top][All Lists]
Advanced

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

question about whether to set CFLAGS in configure.ac


From: John W. Eaton
Subject: question about whether to set CFLAGS in configure.ac
Date: Tue, 29 Nov 2005 12:03:17 -0500

On 29-Nov-2005, Ed Hartnett wrote:

| I believe the common consensus is that one should not set CFLAGS in
| configure.ac.
| 
| However, I have a problem that seems to call for it. Is there a better
| way to get this working then messing with CFLAGS?
| 
| My configure allows the user to specify a location for a library, the
| HDF5 library. So they can do --with-hdf5=/some/location. I do it like
| this:

I thought the proper way to do this was something like

  configure CPPFLAGS=-I/location/of/hdf5/headers \
            LDFLAGS=-L/location/of/hdf5/libs \
            --with-hdf5=hdf5

BTW, here is what Octave uses:

  ### Check for ZLIB library.

  WITH_ZLIB=true
  AC_ARG_WITH(zlib,
    [  --without-zlib          don't use zlib],
    with_zlib=$withval, with_zlib=yes)

  zlib_lib=
  if test "$with_zlib" = yes; then
    zlib_lib="z"
  elif test "$with_zlib" != no; then
    zlib_lib="$with_zlib"
  fi

  ZLIB_LIBS=
  WITH_ZLIB=false
  if test -n "$zlib_lib"; then
    AC_CHECK_LIB($zlib_lib, gzclearerr, [
        AC_CHECK_HEADERS(zlib.h, [
          WITH_ZLIB=true
          ZLIB_LIBS="-l$zlib_lib"
          LIBS="$ZLIB_LIBS $LIBS"
          AC_DEFINE(HAVE_ZLIB, 1, [Define if ZLIB is available.])])])
  fi

  if $WITH_ZLIB; then
    ### Check for HDF5 library.

    WITH_HDF5=true
    AC_ARG_WITH(hdf5,
      [  --without-hdf5          don't use HDF5],
      with_hdf5=$withval, with_hdf5=yes)

    hdf5_lib=
    if test "$with_hdf5" = yes; then
      hdf5_lib="hdf5"
    elif test "$with_hdf5" != no; then
      hdf5_lib="$with_hdf5"
    fi

    HDF5_LIBS=
    WITH_HDF5=false
    if test -n "$hdf5_lib"; then
      AC_CHECK_LIB($hdf5_lib, H5Pcreate, [
        AC_CHECK_HEADERS(hdf5.h, [
          WITH_HDF5=true
          HDF5_LIBS="-l$hdf5_lib"
          LIBS="$HDF5_LIBS $LIBS"
          AC_DEFINE(HAVE_HDF5, 1, [Define if HDF5 is available.])
          AC_CHECK_LIB($hdf5_lib, H5Gget_num_objs, [
            AC_DEFINE(HAVE_H5GGET_NUM_OBJS, 1, [Define if HDF5 has 
H5Gget_num_objs.])])])])
    fi

    if $WITH_HDF5; then
      true
    else
      warn_hdf5="HDF5 library not found.  Octave will not be able to save or 
load HDF5 data files."
    fi
  else
    warn_zlib="ZLIB library not found.  Octave will not be able to save or load 
compressed data files or HDF5 files."
  fi


The part about HAVE_H5GGET_NUM_OBJS is specific to a feature Octave
needs.

If this is not the right way to do things, then I would also
appreciate some tips.

Perhaps we should agree on an approach that could go in the autoconf
macro archive?  Octave also has checks for glpk and fftw that might be
candidates for the archive.

Thanks,

jwe




reply via email to

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