[Top][All Lists]

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

same variable name for different headers / Re: AC_CHECK_HEADERS oddity

From: Guido Draheim
Subject: same variable name for different headers / Re: AC_CHECK_HEADERS oddity
Date: Sat, 23 Aug 2003 13:18:51 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313

Clinton Roy wrote:
Hey folks,

I'm looking for an ndbm header file, Solaris has <ndbm.h>, Redhat uses
<gdbm/ndbm.h> and Debian has <gdbm-ndbm.h>, so the call to

AC_CHECK_HEADERS(ndbm.h gdbm/ndbm.h gdbm-ndbm.h)

However, the generated configure script seems to think gdbm/ndbm.h and
gdbm-ndbm.h are the same:

checking ndbm.h usability... no
checking ndbm.h presence... no
checking for ndbm.h... no
checking gdbm/ndbm.h usability... no
checking gdbm/ndbm.h presence... no
checking for gdbm/ndbm.h... no
checking for gdbm-ndbm.h... (cached) no

Is there anything I'm missing?

wwwoooowww, cunning. Quick answer: your way of using the macro is quite
right but autoconf can not handle this kind of thing. And probably it
can not do that (ever) so you have to start using some kind of workaround.

The result of each test is memorized in a "cache". Since we are in plain
shell that "cache" is not an object or special container or something,
it fact the term is rather virtual, and such an object does not exist.
Instead, autoconf will flatten the test strings gdbm/ndbm.h and
gdbm-ndbm.h to a symbol that can be used as a shell variable, and also
prepend a prefix that say "this is a cache variable". In effect, we see:

 ------- test call --------            ------ cache variable used ------
AC_CHECK_HEADER(ndbm.h)                ac_cv_header_ndbm_h=${result}
AC_CHECK_HEADER(gdbm/ndbm.h)           ac_cv_header_gdbm_ndbm_h=${result}
AC_CHECK_HEADER(gdbm-ndbm.h)           ac_cv_header_gdbm_ndbm_h=${result}

see? and if you put these out to a it would be

/* Define to 1 if you have the <ndbm.h> header file */
#undef HAVE_NDBM_H

/* Define to 1 if you have the <gdbm/ndbm.h> header file */

/* Define to 1 if you have the <gdbm-ndbm.h> header file */

see? You can not make use of that in your programs simply because all
the test strings do need to be changed over into a symbol - both
for usage inside the `configure` script itself and for usage inside
your program sources via `config.h`

Before starting out an anything, send a message to the redhat and
debian maintainers of that package and inform them of the situation.
I repeat, send a message - autoconf testing is very very important
for gnuish software, so they _will_ listen. And if they don't,
come back and we'll get out the big guns - this situation is not
acceptable, stop.

If you want to start hacking now, you have to deploy a nasty
workaround. Check the definition of AC_CHECK_HEADER (without
the final "S"). It has an ACTION-IF-FOUND and ACTION-IF-NOT-FOUND
part. Therefore,

AC_CACHE_CHECK(for redhat gdbm/ndbm.h,ac_cv_header_redhat_gdbm_ndbm_h,[
unset ac_cv_header_gdbm_ndbm_h

AC_CACHE_CHECK(for debian gdbm-ndbm.h,ac_cv_header_debian_gdbm_ndbm_h,[
unset ac_cv_header_gdbm_ndbm_h

warning: the code above is not tested, I've just written it up
from memory. It is a demonstration how such an ugly hack would
be done. Again, contact the debian and redhat maintainers, and
tell them. This mail is more for giving you a chance to refer
them to a point explaining the technical heart of the problem.
(or otherwise we would need to memorize this ugly mess in its
 own ac-macro and ship it around - and I do _not_ want that)

good luck,
-- guido                        
GCS/E/S/P C++/++++$ ULHS L++w- N++@ d(+-) s+a- r+@>+++ y++ 5++X-

reply via email to

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