tests: fix some botched/outdated comments
[platform/upstream/automake.git] / t / autodist-subdir.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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 # 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.sh'.
26
27 . test-init.sh
28
29 cat >> configure.ac <<'END'
30 AC_CONFIG_FILES([sub/Makefile])
31 AC_OUTPUT
32 END
33
34 $ACLOCAL
35 $AUTOCONF
36
37 # The automake manual states that the list of automatically-distributed
38 # files should be given by 'automake --help'.
39 list=$($AUTOMAKE --help \
40          | sed -n '/^Files.*automatically distributed.*if found.*always/,/^ *$/p' \
41          | sed 1d)
42 # Normalize whitespace, just in case.
43 list=$(echo $list)
44
45 test -n "$list"
46
47 cat > Makefile.am <<'END'
48 SUBDIRS = sub
49 check-local:
50 ## For debugging.
51         @echo DIST_COMMON:
52         @for f in $(DIST_COMMON); do echo "  $$f"; done
53         @echo DISTDIR:
54         @ls -l $(distdir) | sed 's/^/  /'
55 ## Now the checks.
56         @for f in $(autodist_list); do \
57           echo "file: sub/$$f"; \
58           test -f $(distdir)/sub/$$f \
59             || { echo $$f: distdir fail >&2; exit 1; }; \
60         done
61 END
62
63 mkdir sub
64
65 cat > sub/Makefile.am <<'END'
66 include distfiles.am
67 check-local:
68 ## For debugging.
69         @echo DIST_COMMON:
70         @for f in $(DIST_COMMON); do echo "  $$f"; done
71         @echo DISTDIR:
72         @ls -l $(distdir) | sed 's/^/  /'
73 ## Now the checks.
74         @for f in $(autodist_list); do \
75           echo "file: $$f"; \
76 ## Some filenames might contain dots, but this won't cause spurious
77 ## failures, and "spurious successes" are so unlikely that they're
78 ## not worth worrying about.
79           echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
80             || { echo $$f: distcom fail >&2; exit 1; }; \
81         done
82 END
83
84 : First try listing the automatically-distributed files in proper
85 : targets in Makefile.am
86
87 echo "MAINTAINERCLEANFILES = $list" > sub/distfiles.am
88 for f in $list; do echo "$f :; touch $f"; done >> sub/distfiles.am
89
90 cat sub/distfiles.am # For debugging.
91
92 $AUTOMAKE -a
93
94 ./configure
95
96 $MAKE distdir
97 autodist_list="$list" $MAKE check
98
99 $MAKE maintainer-clean
100 test ! -e sub/README    # Sanity check.
101 rm -rf $me-1.0          # Remove $(distdir).
102
103 : Now try creating the automatically-distributed files before
104 : running automake.
105
106 : > sub/distfiles.am
107 for f in $list; do
108   echo dummy > sub/$f
109 done
110
111 ls -l # For debugging.
112
113 $AUTOMAKE
114
115 ./configure
116
117 $MAKE distdir
118 autodist_list="$list" $MAKE check
119
120 :