autoconf
[Top][All Lists]
Advanced

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

Re: how to check that TidyLib is new enough?


From: Brian Dessent
Subject: Re: how to check that TidyLib is new enough?
Date: Sat, 06 Sep 2008 14:12:16 -0700

Jack Bates wrote:

> This module builds against TidyLib, so I use AC_CHECK_HEADER() to check
> for buffio.h, and checkout the TidyLib source code from SourceForge
> using CVS if it is not found:
> http://mod-atom.googlecode.com/svn/trunk/configure.ac

Oh, this is evil and horrible:

save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I/usr/include/tidy"
AC_CHECK_HEADER([buffio.h], [
  MODULE_LDFLAGS="$MODULE_LDFLAGS -ltidy"
], [
  CPPFLAGS="$save_CPPFLAGS"

  AC_MSG_NOTICE([Fetching TidyLib...])
  cvs -z3 -d:pserver:address@hidden:/cvsroot/tidy co
-P tidy
  (cd tidy; sh build/gnuauto/setup.sh)
  AC_CONFIG_SUBDIRS([tidy])

  CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/tidy/include"
  MODULE_LDFLAGS="$MODULE_LDFLAGS \$(top_srcdir)/tidy/src/*.lo"
])

There are so many things wrong with this: It's evil to assume the
library is installed in /usr/include.  This breaks the ability to use a
non-system version of the lib.  It also breaks cross compilation. 
Moreover, automatically checking something out of CVS is questionable
behavior for running a configure script.  Give the user a pointer as to
what's required in an error message if you want.

The proper way to handle this is to accept --with-tidylib= (see
AC_ARG_WITH), and then adds -I$with_tidylib/include/tidy to CPPFLAGS and
-L$with_tidylib/lib to LDFLAGS.  You can default the value to /usr if it
is not set or equals yes, if you want.

> What is the "correct" way to use autoconf to check that version of
> TidyLib it finds is new enough?

You write checks that test the specific things you are interested in. 
So, for example you write an AC_TRY_COMPILE that tries to use type
TidyAllocator and if it fails you either disable tidylib support (if
it's optional) or print an error message that says the version is too
old.

Brian




reply via email to

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