autoconf
[Top][All Lists]
Advanced

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

Re: CONDITINAL DEFINE


From: Eric Blake
Subject: Re: CONDITINAL DEFINE
Date: Mon, 13 Jun 2011 08:34:42 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110419 Red Hat/3.1.10-1.el6_0 Mnenhy/0.8.3 Thunderbird/3.1.10

On 06/11/2011 03:32 AM, Luca Formaggia wrote:
> Dear all,
> 
> I am rather new to Autoconf and I could not find an answer to this
> question in the manual. I would like to know if there is a command to
> produce
> conditional defines. Something that from
> 
> AC_CONDEFINE(FOO,  "1")
> 
> would produce
> 
> #ifndef FOO
> #define FOO 1
> #endif

According to the manual, doing this directly in config.h is discouraged;
you should instead strive to make config.h self-contained (perhaps by
having your separate libraries define separate macro names, then in a
non-config.h header you can probe all of those macro names to determine
whether to define FOO).

http://www.gnu.org/software/autoconf/manual/autoconf.html#Header-Templates

However, it is indeed possible to use AH_VERBATIM to produce a template
that looks like:

#ifndef FOO
# undef FOO
#endif

for inclusion into config.h.in; at which point the #undef FOO line will
be replaced with either a comment or a #define FOO value line by
config.status.

Gnulib's size_max.m4 is an example of this idiom:

http://git.savannah.gnu.org/cgit/gnulib.git/tree/m4/size_max.m4

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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