How do I make an existing project (let’s say, MySQL) switch from generating a config.h that has #undef HAVE_FOO to one that generates #define HAVE_FOO 0 instead?
Why? Well, here’s why:
Testing for features should be done by including “config.h” and using #if HAVE_<feature>. Use of #if (rather than #ifdef) allows the gcc -Wundef flag to warn users about features which aren’t defined 1 or 0 in config.h.
Pingback: Dear LazyWeb, autoconf and #define HAVE_ …
Well, I bogged the problem ages ago:
http://www.mega-nerd.com/erikd/Blog/CodeHacking/autoconf_ifdef.html
To make it so, you need something like this in configure.ac:
PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.6, ac_cv_sndfile=1, ac_cv_sndfile=0)
AC_DEFINE_UNQUOTED([HAVE_SNDFILE],$ac_cv_sndfile,[Set to 1 if you have libsndfile.])
HTH :-)
Stewart, was that of any use to you?