[Top][All Lists]

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

Re: Searching headers mapping to the same HAVE_header variable

From: Eric Blake
Subject: Re: Searching headers mapping to the same HAVE_header variable
Date: Thu, 12 Dec 2013 14:11:31 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 12/12/2013 02:02 PM, Julien ÉLIE wrote:
> Hi all,
> When using AC_CHECK_HEADERS([filename]), a HAVE_FILENAME (with uppercase 
> chars)
> variable is defined to 1 if the filename header is found.
> Characters not suitable for a variable name in filename are mapped to 
> underscores.
> I have a question about how to deal with looking for two different headers 
> that
> lead to the same HAVE_FILENAME variable.
> For instance:  how to properly search for gdbm/ndbm.h and gdbm-ndbm.h?

Ugh, there's no clean way to do that with the standard macros.  Who
named these header files, and can they be convinced to improve their
naming in the future?

> Using:
> AC_CHECK_HEADERS([gdbm/ndbm.h gdbm-ndbm.h], [break])
> does not help much.

Unfortunately true.

> As the result of the search is cached in $ac_cv_header_filename, maybe
> using the following piece of code is the expected way to deal with the issue?

Yep, multiple AC_CHECK_HEADER with manual actions on success is the best
you can do, rather than AC_CHECK_HEADERS and its automatic actions.

> AC_CHECK_HEADER([gdbm/ndbm.h])

Unfortunately, AC_CHECK_HEADER short-circuits if the cache is already
populated.  And since the collision is not just on the HAVE_GDBM_NDBM_H
preprocessor name, but ALSO on the $ac_cv_header_gdbm_ndbm_h shell
variable, you are liable to get wrong behavior on secondary runs when
caching is enabled ('./configure -C').  To properly distinguish between
the two names, you'll have to completely ignore the pre-set cache names,
and instead wrap the check inside a cache name that you control.

> AS_IF([test x"$ac_cv_header_gdbm_ndbm_h" != xno],
>         [Define if you have the <gdbm/ndbm.h> header file.])],
>     [AS_UNSET([ac_cv_header_gdbm_ndbm_h])
>      AC_CHECK_HEADER([gdbm-ndbm.h])
>      AS_IF([test x"$ac_cv_header_gdbm_ndbm_h" != xno],
>          [AC_DEFINE([HAVE_GDBM_NDBM_H_DASH], [1],
>              [Define if you have the <gdbm-ndbm.h> header file.])])])
> If you know a better way to do that, I would be interested in hearing it.
> Thanks beforehand,

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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