config headers: don't emit rules for headers not generated by autoheader
[automake.git] / t / autohdr-subdir-pr12495.sh
blob77d2522bcc05eacb4c20a23e7bcb48495d6323b9
1 #! /bin/sh
2 # Copyright (C) 2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Related to automake bug#12495: Automake shouldn't generate useless
18 # remake rules for AC_CONFIG_HEADERS arguments after the first one,
19 # not even when subdirs are involved.
21 . ./defs || exit 1
23 cat >> configure.ac << 'END'
24 AC_CONFIG_HEADERS([a.h b.h sub/c.h])
25 AC_CONFIG_FILES([sub/Makefile])
26 AC_OUTPUT
27 END
29 mkdir sub
30 echo SUBDIRS = sub > Makefile.am
31 : > sub/Makefile.am
33 $ACLOCAL
34 $AUTOCONF
35 $AUTOHEADER
36 # Even if an AC_CONFIG_HEADERS invocation is passed several files in
37 # the first argument, only the first one is considered by autoheader
38 # for automatic generation. Otherwise, the present test case would
39 test -f a.h.in && test ! -f c.h.in && test ! -f sub/c.h.in \
40 || fatal_ "unexpected autoheader behavior with multiple" \
41 "AC_CONFIG_HEADERS arguments"
42 # Automake should require the missing headers though.
43 AUTOMAKE_fails -Wno-error -Wnone
44 grep "^configure\.ac:4:.* required file 'b.h.in' not found" stderr
45 grep "^configure\.ac:4:.* required file 'sub/c.h.in' not found" stderr
46 : > b.h.in
47 : > sub/c.h.in
48 $AUTOMAKE
50 ./configure
52 # Automake should regenerate this.
53 grep '^$(srcdir)/a\.h\.in:' Makefile.in
54 # But not these.
55 grep '[bc]\.h\.in.*:' Makefile.in sub/Makefile.in && exit 1
57 test -f a.h && test -f b.h && test -f sub/c.h \
58 || fatal_ "unexpected ./configure behavior with multiple" \
59 "AC_CONFIG_HEADERS arguments"
61 rm -f a.h.in a.h
62 $MAKE
63 test -f a.h.in
64 test -f a.h
66 ocwd=$(pwd)
67 for x in b c; do
68 test $x = b || cd sub
69 rm -f $x.h.in
70 $MAKE $x.h.in 2>stderr && { cat stderr >&2; exit 1; }
71 cat stderr >&2
72 test ! -f $x.h.in
73 if using_gmake; then
74 grep "No rule to make target [\`\"']$x\.h\.in[\`\"']" stderr
76 : > $x.h.in
77 cd "$ocwd" || fatal_ "cannot chdir back"
78 done