2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
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)
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.
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/>.
17 # Test that automake complains when required auxiliary files are not
18 # found, and that 'automake --add-missing' installs the files (and only
19 # the files) it's supposed to, and that these files are symlinked by
20 # default, but copied if the '--copy' option is used.
22 am_create_testdir=empty
28 ocwd=$(pwd) || fatal_ "cannot get current working directory"
30 # Try to improve readability of displayed diffs.
31 if diff -u /dev/null /dev/null; then
33 elif diff -c /dev/null /dev/null; then
39 # MinGW/MSYS lacks real symlinks, so we'll have to skip some checks
40 # on that system. More details below.
42 if ln -s foo bar && test -h bar; then
43 have_true_symlinks=yes
49 cat > configure.stub << END
51 AC_CONFIG_AUX_DIR([$build_aux])
53 AC_CONFIG_FILES([Makefile])
56 # Pre-compute aclocal.m4, in order to save several aclocal invocations.
57 cat configure.stub - > configure.ac <<'END'
66 $ACLOCAL || framework_failure_ "cannot pre-compute aclocal.m4"
68 rm -rf configure.ac autom4te*.cache
69 mv aclocal.m4 aclocal.stub
77 # This is hacky and ugly and complex, but allow us to organize our tests
78 # below in a more "declarative fashion". All in all, a good trade-off.
81 set +x # Temporary disable shell traces to remove noise from log files.
82 check_count=$(($check_count + 1))
83 echo check count: $check_count
87 while test $# -gt 0; do
89 --override) override=yes;;
90 --run-aclocal) run_aclocal=yes;;
91 --fetch-file) fetch_file=$2; shift;;
92 *) framework_failure_ "check_: invalid argument '$1'";;
96 mkdir testdir-$check_count
97 cd testdir-$check_count
98 # Directory for common data files (specific to the current test, but
99 # shared by its "subtests").
103 if test $override = yes; then
106 cp "$ocwd"/configure.stub configure.ac
108 test -z "$fetch_file" || cp "$ocwd/$fetch_file" .
109 # Read description of "test scenario" from standard input.
110 what= line= name= files=
113 '== Name ==') what=NAME;;
114 '== Makefile.am ==') what=Makefile.am;;
115 '== configure.ac ==') what=configure.ac;;
116 '== Files ==') what=LIST;;
117 '==*') framework_failure_ "invalid input line: $line";;
118 ''|'#%'*) : Empty line or ad-hoc comment, ignore. ;;
120 if test $what = LIST; then
122 elif test $what = NAME; then
125 printf '%s\n' "$line" >> "$what"
130 test -n "$name" || fatal_ "name of a test case not specified"
131 if test $run_aclocal = yes; then
133 ok_ "[$name] aclocal.m4 rebuilt"
134 echo == aclocal.m4 ==
137 not_ok_ "[$name] aclocal failure, aclocal.m4 not rebuilt"
140 cp "$ocwd"/aclocal.stub aclocal.m4
142 echo == Makefile.am ==
144 echo == configure.ac ==
146 echo Expected files: $files
149 # End of "test scenario" setup.
150 set -x # Re-enable shell traces.
153 # Test once with '--copy', once without.
154 for action in link copy; do
156 link) opts='--add-missing';;
157 copy) opts='-a --copy';;
158 *) fatal_ "invalid value '$action' for \$action";;
160 pfx="[$action $name]"
161 cp -R generic $action
163 # If the required auxiliary files are missing, and automake is
164 # not told to install them, it should complain and error out,
165 # and also give a useful suggestion.
166 AUTOMAKE_fails -d "$pfx missing files, automake fails"
169 "$pfx warn about missing file $f" \
170 $FGREP "required file '$build_aux/$f' not found" stderr
171 # Suggest the user to use '--add-missing'.
173 "$pfx suggest --add-missing for $f" \
174 grep ".*--add-missing.* install .*'$f'" stderr
176 # No files should be automatically installed by automake if it
178 if ls "$build_aux" | grep .; then r='not ok'; else r=ok; fi
179 result_ "$r" "$pfx no extra files installed"
180 AUTOMAKE_run -d "$pfx automake run successfully" -- $opts
182 # The expected files should get installed correctly (e.g., no
186 "$pfx file $f installed" \
187 test -f $build_aux/$f
189 # Automake should inform about which files it's installing.
192 "$pfx report installation of $f" \
193 $FGREP ": installing '$build_aux/$f'" stderr
195 # Only the expected files should be installed. But automake always
196 # require 'missing' and 'install-sh', so account for them.
197 all_files="install-sh missing $files"
198 for f in $all_files; do echo $f; done | sort | uniq > files.exp
199 (cd $build_aux && ls) | sort > files.got
203 "$pfx all and only expected files installed" \
204 $am_diff files.exp files.got
205 # The files should be copied by '--copy' and symlinked otherwise.
206 # But these checks make no sense on systems like MSYS/MinGW where
207 # there are no true symlinks ('ln -s' behaves like 'cp -p'), so be
208 # ready to skip the checks in that case. See automake bug#10441.
210 if test $have_true_symlinks = no; then
211 skip_ -r "system lacks true symlinks" "$pfx $f is a symlink or not"
213 if test -h $build_aux/$f; then
218 case $action,$is_symlink in
219 link,yes) ok_ "$pfx $f has been symlinked" ;;
220 link,no) not_ok_ "$pfx $f has not been symlinked" ;;
221 copy,yes) not_ok_ "$pfx $f has been symlinked" ;;
222 copy,no) ok_ "$pfx $f has not been symlinked" ;;
223 *) fatal_ "invalid condition in case" ;;
227 # Now that the required auxiliary files have been installed, automake
228 # should not complain anymore even if the '--add-missing' option is
230 AUTOMAKE_run -d "$pfx automake finds all added files"
232 done # for action in link copy
233 cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
236 # Automake should always and unconditionally require the 'missing'
237 # and 'install-sh' scripts.
268 check_ --run-aclocal <<'END'
274 # Using AM_PROG_CC_C_O in configure.ac should be enough. No need to
275 # use AC_PROG_CC too, nor to define xxx_PROGRAMS in Makefile.am.
279 # For config.guess and config.sub.
280 for mach in build host target system; do
281 MACH=$(echo "$mach" | LC_ALL=C tr '[a-z]' '[A-Z]')
302 AUTOMAKE_OPTIONS = no-dependencies
316 AUTOMAKE_OPTIONS = no-dependencies
321 echo '@setfilename foo.info' > foo.texi
322 check_ --fetch-file foo.texi <<'END'
328 info_TEXINFOS = foo.texi
331 echo '@include version.texi' >> foo.texi
332 check_ --fetch-file foo.texi <<'END'
339 info_TEXINFOS = foo.texi
363 python_PYTHON = foo.py
366 # Try few unrelated auxiliary scripts together.
382 pythondir = $(prefix)/py
385 foo_SOURCES = bar.yxx baz.c++
386 python_PYTHON = zardoz.py