tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / autohdr-subdir-pr12495.sh
blob063d5250a6edaba83a9693a0ea629f4a4ceb2ee5
1 #! /bin/sh
2 # Copyright (C) 2012-2018 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 <https://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 . test-init.sh
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 # We might need to grep the output of GNU make for error messages.
67 LANG=C LANGUAGE=C LC_ALL=C
68 export LANG LANGUAGE LC_ALL
70 ocwd=$(pwd)
71 for x in b c; do
72 test $x = b || cd sub
73 rm -f $x.h.in
74 run_make -E -e FAIL $x.h.in
75 test ! -f $x.h.in
76 if using_gmake; then
77 grep "No rule to make target [\`\"']$x\.h\.in[\`\"']" stderr
79 : > $x.h.in
80 cd "$ocwd" || fatal_ "cannot chdir back"
81 done