[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Small warning, automake 1.10 incompatible change in DEFAULT_INCLUDES
From: |
Ralf Wildenhues |
Subject: |
Re: Small warning, automake 1.10 incompatible change in DEFAULT_INCLUDES |
Date: |
Fri, 9 Nov 2007 21:29:24 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Hello Kent,
Thank you for the report.
* Kent Boortz wrote on Fri, Nov 09, 2007 at 04:27:38PM CET:
>
> In case you have several headers with the same name in your source
> tree you might get problems from that in automake 1.10 the default
> header search order will differ a bit if doing a build inside the
> source tree, or from a separate directory. I.e. if you do a builds
> where $(srcdir) is the same as $(builddir)
[...]
> The problem is the automatically generated variable DEFAULT_INCLUDES,
> that is filled in by automake with the path to the directory where it
> will put the generated "config.h", and the paths to the "current
> source directory". Earlier it was set like
>
> DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include
>
> ensuring that your "current source directory", independent on if one
> or the other of the build methods above, would come first. Now in
> automake 1.10 it is like
>
> DEFAULT_INCLUDES = -I. -I$(top_builddir)/include -I$(srcdir)
>
> that in the case that you build outside the source directory, will
> search for include files first in the current build directory, then
> another location, and last the current source directory.
>
> I'm sure the risk of having problems caused by this is small, why name
> headers the same to begin with?!
But you just seemed to have hit it, with:
> Ref: http://bugs.mysql.com/bug.php?id=24809
This was introduced by
<http://git.savannah.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=8ae25d96fddea93d469d9b86c78519245dc911d8;hp=f83d84f889456cdce7e9741d5e87d8f305b631d1>
IIRC, back then, Alexandre introduced this upon request by Paul to
shorten compile command lines: omit `-I$(srcdir)' if srcdir is `.'. The
changed ordering happened as a side effect, unintended, I presume.
The question is which order makes more sense. Since `$(srcdir)' may be
`.', thus we cannot guarantee that the location of the config header
appears before the source tree (-I. must always come first), I'm
inclined to treat this as a regression and restore the previous order.
I'll apply this patch to master and branch-1-10, and putting you, Kent,
in THANKS. Testsuite is still running.
Cheers, and thanks,
Ralf
Fix default includes ordering to be `-I. -I$(srcdir) ...' again.
* automake.in (handle_compile): Put -I$(srcdir) before include
paths for config headers, as was done before Automake 1.10, but
keep uniquified list without multiple adjacent spaces.
* doc/automake.texi (Program variables): List include paths
in order.
* NEWS: Mention 1.10 regression.
* tests/stdinc.test: New test.
* tests/Makefile.am: Adjust.
* THANKS: Update.
Report by Kent Boortz.
diff --git a/NEWS b/NEWS
index 79a3dea..d4f81b1 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,9 @@ Bugs fixed in 1.10a:
- $(EXEEXT) is automatically appended to filenames of XFAIL_TESTS
that have been declared as programs in the same Makefile.
This is for consistency with the analogous change to TESTS in 1.10.
+
+ - Fix order of standard includes to again be `-I. -I$(srcdir)',
+ followed by directories containing config headers.
New in 1.10:
diff --git a/automake.in b/automake.in
index 127a607..ee1391f 100755
--- a/automake.in
+++ b/automake.in
@@ -2312,7 +2312,7 @@ sub handle_compile ()
my $default_includes = '';
if (! option 'nostdinc')
{
- my @incs = ('-I.');
+ my @incs = ('-I.', subst ('am__isrc'));
my $var = var 'CONFIG_HEADER';
if ($var)
@@ -2326,8 +2326,9 @@ sub handle_compile ()
# and unaesthetic in non-VPATH builds. We use address@hidden@`
# instead. It will be replaced by '-I.' or '-I. -I$(srcdir)'.
# Items in CONFIG_HEADER are never in $(srcdir) so it is safe
- # to just append @address@hidden
- $default_includes = ' ' . uniq (@incs) . subst ('am__isrc');
+ # to just put @am__isrc@ right after `-I.', without a space.
+ ($default_includes = ' ' . uniq (@incs)) =~ s/ @/@/;
+ print "D: $default_includes";
}
my (@mostly_rms, @dist_rms);
diff --git a/doc/automake.texi b/doc/automake.texi
index 2a39ec1..3b70557 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -5748,8 +5748,8 @@ instance, @option{-I} and @option{-D} options should be
listed here.
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$(srcdir)},
address@hidden, and a @option{-I} pointing to the directory holding
+the C preprocessor. In particular it generates @samp{-I.},
address@hidden(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.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 79a89d0..81a0382 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -501,6 +501,7 @@ spell2.test \
spell3.test \
spelling.test \
spy.test \
+stdinc.test \
stamph2.test \
stdlib.test \
stdlib2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index e0e30ca..999ed24 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -649,6 +649,7 @@ spell2.test \
spell3.test \
spelling.test \
spy.test \
+stdinc.test \
stamph2.test \
stdlib.test \
stdlib2.test \
diff --git a/tests/stdinc.test b/tests/stdinc.test
new file mode 100755
index 0000000..04301be
--- /dev/null
+++ b/tests/stdinc.test
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test to make sure the standard include order is stable.
+# Report by Kent Boortz.
+
+. ./defs || exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_CONFIG_HEADERS([sub/config.h])
+AC_CONFIG_FILES([sub/bar.h])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = bar.h
+END
+
+mkdir sub
+
+cat >foo.c <<'END'
+#include <config.h>
+#include <bar.h>
+int main() { return bar (); }
+END
+cat >bar.h <<'END'
+int bar () { return 0; }
+END
+cat >sub/bar.h.in <<'END'
+choke me
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+mkdir build
+cd build
+../configure -C
+$MAKE
+
+cd ..
+./configure -C
+$MAKE