2 # Copyright (C) 2011-2013 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'
67 $ACLOCAL || framework_failure_ "cannot pre-compute aclocal.m4"
69 rm -rf configure.ac autom4te*.cache
70 mv aclocal.m4 aclocal.stub
78 # This is hacky and ugly and complex, but allow us to organize our tests
79 # below in a more "declarative fashion". All in all, a good trade-off.
82 set +x # Temporary disable shell traces to remove noise from log files.
83 check_count=$(($check_count + 1))
84 echo check count: $check_count
88 while test $# -gt 0; do
90 --override) override=yes;;
91 --run-aclocal) run_aclocal=yes;;
92 --fetch-file) fetch_file=$2; shift;;
93 *) framework_failure_ "check_: invalid argument '$1'";;
97 mkdir testdir-$check_count
98 cd testdir-$check_count
99 # Directory for common data files (specific to the current test, but
100 # shared by its "subtests").
104 if test $override = yes; then
107 cp "$ocwd"/configure.stub configure.ac
109 test -z "$fetch_file" || cp "$ocwd/$fetch_file" .
110 # Read description of "test scenario" from standard input.
111 what= line= name= files=
114 '== Name ==') what=NAME;;
115 '== Makefile.am ==') what=Makefile.am;;
116 '== configure.ac ==') what=configure.ac;;
117 '== Files ==') what=LIST;;
118 '==*') framework_failure_ "invalid input line: $line";;
119 ''|'#%'*) : Empty line or ad-hoc comment, ignore. ;;
121 if test $what = LIST; then
123 elif test $what = NAME; then
126 printf '%s\n' "$line" >> "$what"
131 test -n "$name" || fatal_ "name of a test case not specified"
132 if test $run_aclocal = yes; then
134 ok_ "[$name] aclocal.m4 rebuilt"
135 echo == aclocal.m4 ==
138 not_ok_ "[$name] aclocal failure, aclocal.m4 not rebuilt"
141 cp "$ocwd"/aclocal.stub aclocal.m4
143 echo == Makefile.am ==
145 echo == configure.ac ==
147 echo Expected files: $files
150 # End of "test scenario" setup.
151 set -x # Re-enable shell traces.
154 # Test once with '--copy', once without.
155 for action in link copy; do
157 link) opts='--add-missing';;
158 copy) opts='-a --copy';;
159 *) fatal_ "invalid value '$action' for \$action";;
161 pfx="[$action $name]"
162 cp -R generic $action
164 # If the required auxiliary files are missing, and automake is
165 # not told to install them, it should complain and error out,
166 # and also give a useful suggestion.
167 AUTOMAKE_fails -d "$pfx missing files, automake fails"
170 "$pfx warn about missing file $f" \
171 $FGREP "required file '$build_aux/$f' not found" stderr
172 # Suggest the user to use '--add-missing'.
174 "$pfx suggest --add-missing for $f" \
175 grep ".*--add-missing.* install .*'$f'" stderr
177 # No files should be automatically installed by automake if it
179 if ls "$build_aux" | grep .; then r='not ok'; else r=ok; fi
180 result_ "$r" "$pfx no extra files installed"
181 AUTOMAKE_run -d "$pfx automake run successfully" -- $opts
183 # The expected files should get installed correctly (e.g., no
187 "$pfx file $f installed" \
188 test -f $build_aux/$f
190 # Automake should inform about which files it's installing.
193 "$pfx report installation of $f" \
194 $FGREP ": installing '$build_aux/$f'" stderr
196 # Only the expected files should be installed. But automake always
197 # require 'missing' and 'install-sh', so account for them.
198 all_files="install-sh missing $files"
199 for f in $all_files; do echo $f; done | sort | uniq > files.exp
200 (cd $build_aux && ls) | sort > files.got
204 "$pfx all and only expected files installed" \
205 $am_diff files.exp files.got
206 # The files should be copied by '--copy' and symlinked otherwise.
207 # But these checks make no sense on systems like MSYS/MinGW where
208 # there are no true symlinks ('ln -s' behaves like 'cp -p'), so be
209 # ready to skip the checks in that case. See automake bug#10441.
211 if test $have_true_symlinks = no; then
212 skip_ -r "system lacks true symlinks" "$pfx $f is a symlink or not"
214 if test -h $build_aux/$f; then
219 case $action,$is_symlink in
220 link,yes) ok_ "$pfx $f has been symlinked" ;;
221 link,no) not_ok_ "$pfx $f has not been symlinked" ;;
222 copy,yes) not_ok_ "$pfx $f has been symlinked" ;;
223 copy,no) ok_ "$pfx $f has not been symlinked" ;;
224 *) fatal_ "invalid condition in case" ;;
228 # Now that the required auxiliary files have been installed, automake
229 # should not complain anymore even if the '--add-missing' option is
231 AUTOMAKE_run -d "$pfx automake finds all added files"
233 done # for action in link copy
234 cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
237 # Automake should always and unconditionally require the 'missing'
238 # and 'install-sh' scripts.
270 check_ --run-aclocal <<'END'
276 # Using AC_PROG_CC in configure.ac should be enough.
277 # No need to also define, say, xxx_PROGRAMS in Makefile.am.
281 # For config.guess and config.sub.
282 for mach in build host target system; do
283 MACH=$(echo "$mach" | LC_ALL=C tr '[a-z]' '[A-Z]')
305 AUTOMAKE_OPTIONS = no-dependencies
320 AUTOMAKE_OPTIONS = no-dependencies
325 echo '@setfilename foo.info' > foo.texi
326 check_ --fetch-file foo.texi <<'END'
332 info_TEXINFOS = foo.texi
335 echo '@include version.texi' >> foo.texi
336 check_ --fetch-file foo.texi <<'END'
343 info_TEXINFOS = foo.texi
356 python_PYTHON = foo.py
359 # Try few unrelated auxiliary scripts together.
375 pythondir = $(prefix)/py
378 foo_SOURCES = bar.yxx baz.c++
379 python_PYTHON = zardoz.py