Re: Finding "config.h" in VPATH builds

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

 



Hi David,

On 9/19/2009 4:43 PM, David Bruce wrote:
I have a project with all the source files in a src directory just
below trunk, which is where the top level configure.ac and Makefile.am
live.  When I run configure, config.h is created at build/config.h.
If I run configure from within trunk, make works successfully, but if
I do a VPATH build I get errors because config.h is not located.  If I
change ' #include "config.h" '  to ' #include ../config.h" ', it works
as either a VPATH build or an in-tree build.  I'm not sure this is the
right way to address this, however.

Here's a snippet from a generated Makefile in one of my simple projects where config.h is generated at the top of the build tree next to configure:

DEFAULT_INCLUDES = -I. -I$(top_builddir)
...
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
        $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

As you can see here, DEFAULT_INCLUDES is set to -I. and -I$(top_builddir). The default include path includes both the current build directory, and the top build directory. This works, whether the build directory is the source directory or not.

If you have created your configure.ac file to have autoheader build config.h in a directory other than the default -- $(top_builddir) -- by using AC_CONFIG_HEADERS([build/config.h]) or something, then Automake ensures that the DEFAULT_INCLUDES variable is set up to reference this other directory. (Note however, that this other directory *must exist* in your source tree.) Here's that same snippet after changing AC_CONFIG_HEADERS as shown above in my sample project:

DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/build
...
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
        $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

In short, I'm not sure why you're having trouble. Most of the issues covered by the paragraph you cited from the Autoconf manual are only relevant when you're writing your own Makefile.in files. Automake handles setting up DEFAULT_INCLUDES properly when you use Automake in conjunction with Autoconf.

What am I missing?

John


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux