[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AM_CPPFLAGS best practice
From: |
Eric Blake |
Subject: |
Re: AM_CPPFLAGS best practice |
Date: |
Thu, 02 Feb 2012 13:55:49 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 |
On 02/02/2012 01:43 PM, Jim Meyering wrote:
>> And coreutils has a bug, for forgetting the builddir version (which
>> means it will build in an in-tree build, but probably fail in a VPATH
>> build):
>> AM_CPPFLAGS = -I$(top_srcdir)/lib
>
> "forgetting"? ;-) Nah.
> On the contrary, I vaguely recall deliberately removing the
> explicit (and then-redundant) -I... option back when I noticed
> that automake handled that part for us.
>
> In the case of coreutils, DEFAULT_INCLUDES covers that:
>
> $ grep DEFAULT_INCLUDES.= src/Makefile
> DEFAULT_INCLUDES = -I. -I$(top_builddir)/lib
Ah, so automake favors builddir over srcdir. From the automake manual:
> Automake already provides some @option{-I} options automatically, in a
> separate variable that is also passed to every compilation that invokes
> the C preprocessor. In particular it generates @samp{-I.},
> @samp{-I$(srcdir)}, and a @option{-I} pointing to the directory holding
> @file{config.h} (if you've used @code{AC_CONFIG_HEADERS} or
> @code{AM_CONFIG_HEADER}). You can disable the default @option{-I}
> options using the @option{nostdinc} option.
...
> Note that the reference to the build tree should come before the
> reference to the source tree, so that accidentally leftover generated
> files in the source directory are ignored.
Meanwhile, m4 was using:
AUTOMAKE_OPTIONS = nostdinc
precisely to avoid the DEFAULT_INCLUDES, but then m4 had to provide
srcdir itself, and did so prior to builddir; so I guess the bug is in m4.
And we might as well improve the gnulib manual to document the hack of:
>
>>From what I recall, that's by virtue of our putting config.h in lib
> via this line from configure.ac:
>
> AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
as a way to get config.h to live in gnulib's builddir, for one less
listing in AM_CPPFLAGS if you are okay with DEFAULT_INCLUDES.
I'm also wondering if it is worth writing things as an automake
conditional that avoid redundant listing for in-tree builds, while still
giving correct results for VPATH builds.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature