Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / distcom5.test
1 #! /bin/sh
2 # Copyright (C) 2003, 2006, 2010 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.test performs the same
20 # test without Makefile in the directory.
21
22 . ./defs || Exit 1
23
24 set -e
25
26 extract_distcommon ()
27 {
28   sed -n -e '/^DIST_COMMON =.*\\$/ {
29     :loop
30     p
31     n
32     t clear
33     :clear
34     s/\\$/\\/
35     t loop
36     p
37     n
38     }' -e '/^DIST_COMMON =/ p' ${1+"$@"}
39 }
40
41 cat >> configure.in << 'END'
42    AC_CONFIG_FILES([tests/autoconf:tests/wrapper.in],
43                    [chmod +x tests/autoconf])
44    AC_CONFIG_FILES([tests/autoheader:tests/wrapper.in],
45                    [chmod +x tests/autoheader])
46    AC_CONFIG_FILES([tests/autom4te:tests/wrapper.in],
47                    [chmod +x tests/autom4te])
48    AC_CONFIG_FILES([tests/autoreconf:tests/wrapper.in],
49                    [chmod +x tests/autoreconf])
50    AC_CONFIG_FILES([tests/autoscan:tests/wrapper.in],
51                    [chmod +x tests/autoscan])
52    AC_CONFIG_FILES([tests/autoupdate:tests/wrapper.in],
53                    [chmod +x tests/autoupdate])
54    AC_CONFIG_FILES([tests/ifnames:tests/wrapper.in],
55                    [chmod +x tests/ifnames])
56    AC_CONFIG_FILES([tests/Makefile])
57    AC_OUTPUT
58 END
59
60 mkdir tests
61 : > tests/wrapper.in
62 : > tests/Makefile.am
63 cat > Makefile.am << 'END'
64 SUBDIRS = tests
65 .PHONY: test
66 test: distdir
67         test -f $(distdir)/tests/wrapper.in
68 END
69
70 $ACLOCAL
71 $AUTOCONF
72 $AUTOMAKE --add-missing
73 ./configure
74 $MAKE test
75
76 extract_distcommon Makefile.in > top.txt
77 extract_distcommon tests/Makefile.in > inner.txt
78
79 # might be useful for debugging
80 cat top.txt
81 cat inner.txt
82
83 test 0 = `grep tests top.txt | wc -l`
84 test 1 = `grep wrapper inner.txt | wc -l`
85
86 :