tests: expose automake bug#14560
[platform/upstream/automake.git] / t / distcom5.sh
1 #! /bin/sh
2 # Copyright (C) 2003-2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Test to make sure config files are distributed, and only once.
18 # This tries to distribute a file from a subdirectory, with
19 # a Makefile in that directory.  'distcom4.sh' performs the same
20 # test without Makefile in the directory.
21
22 . test-init.sh
23
24 extract_distcommon ()
25 {
26   sed -n -e '/^DIST_COMMON =.*\\$/ {
27     :loop
28     p
29     n
30     t clear
31     :clear
32     s/\\$/\\/
33     t loop
34     p
35     n
36     }' -e '/^DIST_COMMON =/ p' ${1+"$@"}
37 }
38
39 cat >> configure.ac << 'END'
40    AC_CONFIG_FILES([tests/autoconf:tests/wrapper.in],
41                    [chmod +x tests/autoconf])
42    AC_CONFIG_FILES([tests/autoheader:tests/wrapper.in],
43                    [chmod +x tests/autoheader])
44    AC_CONFIG_FILES([tests/autom4te:tests/wrapper.in],
45                    [chmod +x tests/autom4te])
46    AC_CONFIG_FILES([tests/autoreconf:tests/wrapper.in],
47                    [chmod +x tests/autoreconf])
48    AC_CONFIG_FILES([tests/autoscan:tests/wrapper.in],
49                    [chmod +x tests/autoscan])
50    AC_CONFIG_FILES([tests/autoupdate:tests/wrapper.in],
51                    [chmod +x tests/autoupdate])
52    AC_CONFIG_FILES([tests/ifnames:tests/wrapper.in],
53                    [chmod +x tests/ifnames])
54    AC_CONFIG_FILES([tests/Makefile])
55    AC_OUTPUT
56 END
57
58 mkdir tests
59 : > tests/wrapper.in
60 : > tests/Makefile.am
61 cat > Makefile.am << 'END'
62 SUBDIRS = tests
63 .PHONY: test
64 test: distdir
65         test -f $(distdir)/tests/wrapper.in
66 END
67
68 $ACLOCAL
69 $AUTOCONF
70 $AUTOMAKE --add-missing
71 ./configure
72 $MAKE test
73
74 extract_distcommon Makefile.in > top.txt
75 extract_distcommon tests/Makefile.in > inner.txt
76
77 # Might be useful for debugging.
78 cat top.txt
79 cat inner.txt
80
81 test 0 -eq $(grep -c tests top.txt)
82 test 1 -eq $(grep -c wrapper inner.txt)
83
84 :