70ec0afe58d52547a477afc2b8bfafdba998b170
[platform/upstream/automake.git] / tests / autodist.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.
19 # Related to automake bug#7819.
20 # Keep this test in sync with sister test `autodist-subdir.test'.
21
22 . ./defs || Exit 1
23
24 set -e
25
26 # Ensure we are run from the right directory.
27 # (The last thing we want is to delete some random user files.)
28 test -f ../defs
29 rm -f *
30
31 cat > configure.in <<END
32 AC_INIT([$me], [1.0])
33 AC_CONFIG_AUX_DIR([.])
34 AM_INIT_AUTOMAKE
35 ## Will avoid useless regeneration of aclocal.m4, configure, etc.
36 AM_MAINTAINER_MODE
37 AC_CONFIG_FILES([Makefile])
38 AC_OUTPUT
39 END
40
41 $ACLOCAL
42 $AUTOCONF
43
44 # The automake manual states that the list of automatically-distributed
45 # files should be given by `automake --help'.
46 list=`$AUTOMAKE --help \
47         | sed -n '/^Files .*automatically distributed.*if found/,/^ *$/p' \
48         | sed 1d`
49 list=`for f in $list; do
50         case $f in
51           configure|configure.in|configure.ac)
52             # See test 'autodist-configure-no-subdir.test'.
53             ;;
54           aclocal.m4)
55             # This file should be distributed only when it is a real
56             # dependency for configure.  Anyway, not a check to be
57             # performed in this test.
58             ;;
59           acconfig.h)
60             # Works only when it really exists, not when it is a
61             # target in Makefile.am.
62             ;;
63           stamp-vti)
64             # Works only when using info_TEXINFOS and version.texi.
65             ;;
66           config.h.bot|config.h.top)
67             # Works only when the AC_CONFIG_HADERS macro is used.
68             ;;
69           *)
70             echo $f
71             ;;
72         esac
73       done`
74 # Normalize whitespace, just in case.
75 list=`echo $list`
76
77 test -n "$list"
78
79 cat > Makefile.am <<'END'
80 include distfiles.am
81 check-local:
82 ## For debugging.
83         @echo DIST_COMMON:
84         @for f in $(DIST_COMMON); do echo "  $$f"; done
85         @echo DISTDIR:
86         @ls -l $(distdir) | sed 's/^/  /'
87 ## Now the checks.
88         @for f in $(autodist_list); do \
89           echo "file: $$f"; \
90           test -f $(distdir)/$$f \
91             || { echo $$f: distdir fail >&2; exit 1; }; \
92           ## Some filenames might contain dots, but this won't cause spurious
93           ## failures, and "spurious successes" are so unlikely that they're
94           ## not worth worrying about.
95           echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
96             || { echo $$f: distcom fail >&2; exit 1; }; \
97         done
98 END
99
100 : First try listing the automatically-distributed files in proper
101 : targets in Makefile.am
102
103 echo "MAINTAINERCLEANFILES = $list" > distfiles.am
104 for f in $list; do echo "$f :; touch $f"; done >> distfiles.am
105
106 cat distfiles.am # For debugging.
107
108 $AUTOMAKE -a
109
110 ./configure
111
112 $MAKE distdir
113 autodist_list="$list" $MAKE check
114
115 $MAKE maintainer-clean
116 test ! -f README        # Sanity check.
117 rm -rf $me-1.0          # Remove $(distdir).
118
119 : Now try creating the automatically-distributed files before
120 : running automake.
121
122 : > distfiles.am
123 for f in $list; do
124   echo dummy > $f
125 done
126
127 ls -l # For debugging.
128
129 $AUTOMAKE
130
131 ./configure
132
133 $MAKE distdir
134 autodist_list="$list" $MAKE check
135
136 :