# then use config.status to substitute the remainder where a single
# expansion is sufficient. We use a funny notation here to avoid
# configure substitutions in our text.
-do_subst = ( sed $(strip \
+do_subst = sed $(strip \
$(foreach x, data am bin doc pkgvdata script automake_ac system_ac, \
-e 's,@$(x)dir@,$($(x)dir),g')) \
-e "s,[@]configure_input@,Generated from $(<F) do not edit by hand.,g" \
-## Hack to avoid a spurious substitution in the Automake script (part 1).
- -e 's,[@]am__isrc[@],!!@!!am__isrc!!@!!,g' \
- | $(SHELL) ./config.status --file=- \
-## Hack to avoid a spurious substitution in the Automake script (part 2).
- | sed -e 's,!!@!!am__isrc!!@!!,@''am__isrc@,g' \
-) <$< >$@-t
+ <"$<" | $(SHELL) ./config.status --file=- >"$@-t"
# Generated files shouldn't contain unexpanded '@substitutions@', and
# should be made read-only, to prevent them from being edited by mistake
{
return if ! $must_handle_compiled_objects;
- # Boilerplate.
- my $default_includes = '';
- if (! option 'nostdinc')
- {
- my @incs = ('-I.', subst ('am__isrc'));
-
- my $var = var 'AM_CONFIG_HEADERS';
- if ($var)
- {
- foreach my $hdr (split (' ', $var->variable_value))
- {
- push @incs, '-I' . dirname ($hdr);
- }
- }
- # We want '-I. -I$(srcdir)', but the latter -I is redundant
- # and unaesthetic in non-VPATH builds. We use `-I.@am__isrc@`
- # instead. It will be replaced by '-I.' or '-I. -I$(srcdir)'.
- # Items in AM_CONFIG_HEADERS are never in $(srcdir) so it
- # is safe to just put @am__isrc@ right after '-I.', without a
- # space.
- ($default_includes = ' ' . uniq (@incs)) =~ s/ @/@/;
- }
-
my (@mostly_rms, @dist_rms);
foreach my $item (sort keys %compile_clean_files)
{
my ($coms, $vars, $rules) =
&file_contents_internal (1, "$libdir/am/compile.am",
new Automake::Location,
- ('DEFAULT_INCLUDES' => $default_includes,
+ ('STDINC' => ! option 'nostdinc',
'MOSTLYRMS' => join ("\n", @mostly_rms),
'DISTRMS' => join ("\n", @dist_rms)));
$output_vars .= $vars;
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
-DEFAULT_INCLUDES = %DEFAULT_INCLUDES%
+if %?STDINC%
+DEFAULT_INCLUDES = \
+ $(call am__memoize,DEFAULT_INCLUDES,$(strip \
+## We want '-I. -I$(srcdir)', but the latter -I is redundant and
+## unaesthetic in non-VPATH builds, so get rid of it if it is not
+## actually needed.
+ $(call am__uniq, -I. -I$(srcdir) \
+ $(foreach am__h, $(AM_CONFIG_HEADERS), \
+ $(patsubst %/,%,-I$(dir $(am__h)))))))
+else !%?STDINC%
+DEFAULT_INCLUDES =
+endif !%?STDINC%
mostlyclean-am: mostlyclean-compile
mostlyclean-compile:
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
if test "`cd $srcdir && pwd`" != "`pwd`"; then
- # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
- # is not polluted with repeated "-I."
- AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
- # test to see if srcdir already configured
if test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
# > How-To-Repeat:
# Use AM_CONFIG_HEADER(subdir/config.h) to place configuration
# header in subdirectory and observe that it is not included.
+# Also check that our preprocessing code is smart enough not to pass
+# repeated '-I<DIR>' options on the compiler command line.
. ./defs || Exit 1
cat >> configure.ac << 'END'
-AC_CONFIG_FILES([include/Makefile])
+AC_CONFIG_FILES([include/Makefile sub/Makefile])
AC_CONFIG_HEADERS([include/config.h])
-AC_PROG_CC
+AC_PROG_FGREP
+AC_OUTPUT
END
-cat > Makefile.am << 'END'
+mkdir include sub
+: > include/config.h.in
+
+cat > c-defs.am << 'END'
+## To bring in the definition of DEFAULT_INCLUDES
+CC = who-cares
+AUTOMAKE_OPTIONS = no-dependencies
bin_PROGRAMS = foo
-foo_SOURCES = foo.c
END
-mkdir include
-: > include/Makefile.am
-: > include/config.h.in
+cat > Makefile.am << 'END'
+include $(top_srcdir)/c-defs.am
+.PHONY: test-default-includes
+test-default-includes:
+ echo ' ' $(DEFAULT_INCLUDES) ' ' \
+ | $(FGREP) ' -I$(top_builddir)/include '
+END
+
+cp Makefile.am sub
+
+cat > include/Makefile.am << 'END'
+include $(top_srcdir)/c-defs.am
+.PHONY: test-default-includes
+test-default-includes:
+ echo ' ' $(DEFAULT_INCLUDES) ' ' | $(FGREP) ' -I. '
+ case ' $(DEFAULT_INCLUDES) ' in \
+ *'$(top_builddir)'*) exit 1;; \
+ *include*) exit 1;; \
+ *-I.*-I.*) exit 1;; \
+ *' -I. ') exit 0;; \
+ *) exit 1;; \
+ esac
+END
$ACLOCAL
+$AUTOCONF
$AUTOMAKE
-grep '^ *DEFAULT_INCLUDES *=.* -I\$(top_builddir)/include' Makefile.in
+./configure
+
+$MAKE test-default-includes
+$MAKE -C sub test-default-includes
+$MAKE -C include test-default-includes
:
$ACLOCAL
$AUTOMAKE
-$EGREP 'DEFAULT_INCLUDES|@am__isrc@|-compile|\$\(OBJEXT\)|tab\.[ch]' \
- Makefile.in && Exit 1
+$EGREP 'DEFAULT_INCLUDES|-compile|\$\(OBJEXT\)|tab\.[ch]' Makefile.in \
+ && Exit 1
:
# Test to make sure nostdinc option works correctly.
-# We don't require a C compiler explicitly, because the first part of the
-# test (where 'Makefile.in' is grepped) does not require one. Insted, we
-# just skip the rest of the test if configure fails to find a working C
-# compiler.
-
+required=cc
. ./defs || Exit 1
cat >> configure.ac << 'END'
cat > Makefile.am << 'END'
AUTOMAKE_OPTIONS = nostdinc
bin_PROGRAMS = foo
-foo_SOURCES = foo.c
END
-$ACLOCAL
-$AUTOMAKE
+cat > foo.c << 'END'
+#include <stdlib.h>
+int main (void)
+{
+ exit (0);
+}
+END
-$EGREP '(-I *\.|-I.*srcdir|am__isrc)' Makefile.in && Exit 1
+# This shouldn't be picked up.
+cat > stdlib.h << 'END'
+#error "stdlib.h from source dir included"
+choke me
+END
-# We'll test the fully-processed Makefile too.
+$ACLOCAL
$AUTOCONF
+$AUTOMAKE --add-missing
# Test with $builddir != $srcdir
mkdir build
cd build
-../configure || Exit $?
-$EGREP '.*-I *(\.|\$.srcdir.)' Makefile && Exit 1
+../configure
+$MAKE V=1 > output || { cat output; Exit 1; }
+cat output
+grep '.*-I *\.' stdout && Exit 1
+$MAKE clean
+# Shouldn't be picked up from builddir either.
+cp ../stdlib.h .
+$MAKE
+cd ..
# Test with $builddir = $srcdir
-cd ..
-./configure || Exit $?
-$EGREP '.*-I *(\.|\$.srcdir.)' Makefile && Exit 1
+./configure
+$MAKE V=1 > output || { cat output; Exit 1; }
+cat output
+grep '.*-I *\.' output && Exit 1
-Exit 0
+:
--- /dev/null
+#!/bin/sh
+# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+#
+# This program 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 2, or (at your option)
+# any later version.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that automake rules do not use repeated "-I $(srcdir)" in the
+# compiler invocation.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+echo 'bin_PROGRAMS = foo' > Makefile.am
+echo 'int main (void) { return 0; }' > foo.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Test with $builddir != $srcdir
+mkdir build
+cd build
+../configure
+$MAKE V=1 > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '.*-I *\. .*-I *\.\. ' stdout
+grep '.*-I *\. .*-I *\. ' stdout && Exit 1
+cd ..
+
+# Test with $builddir = $srcdir
+./configure
+$MAKE V=1 > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '.*-I *\. ' stdout
+grep '.*-I *\..*-I *\.' stdout && Exit 1
+
+: