Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / autodist-subdir.test
1 #! /bin/sh
2 # Copyright (C) 2011 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 # Check that automake really automatically distributes all the files
18 # it advertises to do, even when in subdirectories.
19 #
20 # This behavior might be suboptimal, but it has been in place for quite
21 # a long time, and it would be risky to change it now.  See also the
22 # discussion of automake bug#7819:
23 #  <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7819>
24 #
25 # Keep this test in sync with sister test `autodist.test'.
26
27 . ./defs || Exit 1
28
29 set -e
30
31 cat >> configure.in <<'END'
32 AC_CONFIG_FILES([sub/Makefile])
33 AC_OUTPUT
34 END
35
36 $ACLOCAL
37 $AUTOCONF
38
39 # The automake manual states that the list of automatically-distributed
40 # files should be given by `automake --help'.
41 list=`$AUTOMAKE --help \
42         | sed -n '/^Files.*automatically distributed.*if found.*always/,/^ *$/p' \
43         | sed 1d`
44 # Normalize whitespace, just in case.
45 list=`echo $list`
46
47 test -n "$list"
48
49 cat > Makefile.am <<'END'
50 SUBDIRS = sub
51 check-local:
52 ## For debugging.
53         @echo DIST_COMMON:
54         @for f in $(DIST_COMMON); do echo "  $$f"; done
55         @echo DISTDIR:
56         @ls -l $(distdir) | sed 's/^/  /'
57 ## Now the checks.
58         @for f in $(autodist_list); do \
59           echo "file: sub/$$f"; \
60           test -f $(distdir)/sub/$$f \
61             || { echo $$f: distdir fail >&2; exit 1; }; \
62         done
63 END
64
65 mkdir sub
66
67 cat > sub/Makefile.am <<'END'
68 include distfiles.am
69 check-local:
70 ## For debugging.
71         @echo DIST_COMMON:
72         @for f in $(DIST_COMMON); do echo "  $$f"; done
73         @echo DISTDIR:
74         @ls -l $(distdir) | sed 's/^/  /'
75 ## Now the checks.
76         @for f in $(autodist_list); do \
77           echo "file: $$f"; \
78           ## Some filenames might contain dots, but this won't cause spurious
79           ## failures, and "spurious successes" are so unlikely that they're
80           ## not worth worrying about.
81           echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
82             || { echo $$f: distcom fail >&2; exit 1; }; \
83         done
84 END
85
86 : First try listing the automatically-distributed files in proper
87 : targets in Makefile.am
88
89 echo "MAINTAINERCLEANFILES = $list" > sub/distfiles.am
90 for f in $list; do echo "$f :; touch $f"; done >> sub/distfiles.am
91
92 cat sub/distfiles.am # For debugging.
93
94 $AUTOMAKE -a
95
96 ./configure
97
98 $MAKE distdir
99 autodist_list="$list" $MAKE check
100
101 $MAKE maintainer-clean
102 test ! -f sub/README    # Sanity check.
103 rm -rf $me-1.0          # Remove $(distdir).
104
105 : Now try creating the automatically-distributed files before
106 : running automake.
107
108 : > sub/distfiles.am
109 for f in $list; do
110   echo dummy > sub/$f
111 done
112
113 ls -l # For debugging.
114
115 $AUTOMAKE
116
117 ./configure
118
119 $MAKE distdir
120 autodist_list="$list" $MAKE check
121
122 :