1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
|
#! /bin/sh
# Copyright (C) 2011-2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Test that automake complains when required auxiliary files are not
# found, and that 'automake --add-missing' installs the files (and only
# the files) it's supposed to, and that these files are symlinked by
# default, but copied if the '--copy' option is used.
am_create_testdir=empty
. ./defs || Exit 1
plan_ "later"
build_aux=build-aux
ocwd=`pwd` || fatal_ "cannot get current working directory"
# Try to improve readability of displayed diffs.
if diff -u /dev/null /dev/null; then
am_diff='diff -u'
elif diff -c /dev/null /dev/null; then
am_diff='diff -c'
else
am_diff=diff
fi
# MinGW/MSYS lacks real symlinks, so we'll have to skip some checks
# on that system. More details below.
echo dummy > foo
if ln -s foo bar && test -h bar; then
have_true_symlinks=yes
else
have_true_symlinks=no
fi
rm -f foo bar
cat > configure.stub << END
AC_INIT([$me], [1.0])
AC_CONFIG_AUX_DIR([$build_aux])
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile])
END
# Pre-compute aclocal.m4, in order to save several aclocal invocations.
cat configure.stub - > configure.ac <<'END'
AC_PROG_CC
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AC_CANONICAL_SYSTEM
AM_PATH_LISPDIR
AM_PATH_PYTHON
END
$ACLOCAL || framework_failure_ "cannot pre-compute aclocal.m4"
rm -rf configure.ac autom4te*.cache
mv aclocal.m4 aclocal.stub
# For debugging.
cat configure.stub
cat aclocal.stub
check_count=0
# This is hacky and ugly and complex, but allow us to organize our tests
# below in a more "declarative fashion". All in all, a good trade-off.
check_ ()
{
set +x # Temporary disable shell traces to remove noise from log files.
incr_ check_count
echo check count: $check_count
override=no
run_aclocal=no
fetch_file=
while test $# -gt 0; do
case $1 in
--override) override=yes;;
--run-aclocal) run_aclocal=yes;;
--fetch-file) fetch_file=$2; shift;;
*) framework_failure_ "check_: invalid argument '$1'";;
esac
shift
done
mkdir testdir-$check_count
cd testdir-$check_count
# Directory for common data files (specific to the current test, but
# shared by its "subtests").
mkdir generic
cd generic
# Use 'echo > ...', not ': > ...', here and below, as Solaris 10 /bin/sh
# might not execute the latter (the Autoconf manual gives more details).
echo > Makefile.am
if test $override = yes; then
echo > configure.ac
else
cp "$ocwd"/configure.stub configure.ac
fi
test -z "$fetch_file" || cp "$ocwd/$fetch_file" .
# Read description of "test scenario" from standard input.
what= line= name= files=
while read line; do
case $line in
'== Name ==') what=NAME;;
'== Makefile.am ==') what=Makefile.am;;
'== configure.ac ==') what=configure.ac;;
'== Files ==') what=LIST;;
'==*') framework_failure_ "invalid input line: $line";;
''|'#%'*) : Empty line or ad-hoc comment, ignore. ;;
*)
if test $what = LIST; then
files="$files $line"
elif test $what = NAME; then
name=$line
else
printf '%s\n' "$line" >> "$what"
fi
;;
esac
done
test -n "$name" || fatal_ "name of a test case not specified"
if test $run_aclocal = yes; then
if $ACLOCAL; then
ok_ "[$name] aclocal.m4 rebuilt"
echo == aclocal.m4 ==
cat aclocal.m4
else
not_ok_ "[$name] aclocal failure, aclocal.m4 not rebuilt"
fi
else
cp "$ocwd"/aclocal.stub aclocal.m4
fi
echo == Makefile.am ==
cat Makefile.am
echo == configure.ac ==
cat configure.ac
echo Expected files: $files
mkdir "$build_aux"
cd ..
# End of "test scenario" setup.
set -x # Re-enable shell traces.
pwd
ls -l generic
# Test once with '--copy', once without.
for action in link copy; do
case $action in
link) opts='--add-missing';;
copy) opts='-a --copy';;
*) fatal_ "invalid value '$action' for \$action";;
esac
pfx="[$action $name]"
cp -R generic $action
cd $action
# If the required auxiliary files are missing, and automake is
# not told to install them, it should complain and error out,
# and also give a useful suggestion.
AUTOMAKE_fails -d "$pfx missing files, automake fails"
for f in $files; do
command_ok_ \
"$pfx warn about missing file $f" \
grep "required file ['\`]$build_aux/$f' not found" stderr
# Suggest the user to use '--add-missing'.
command_ok_ \
"$pfx suggest --add-missing for $f" \
grep ".*--add-missing.* install .*$f" stderr
done
# No files should be automatically installed by automake if it
# is not told to.
if ls "$build_aux" | grep .; then r='not ok'; else r=ok; fi
result_ "$r" "$pfx no extra files installed"
AUTOMAKE_run -d "$pfx automake run successfully" -- $opts
ls -l . $build_aux
# The expected files should get installed correctly (e.g., no
# broken symlinks).
for f in $files; do
command_ok_ \
"$pfx file $f installed" \
test -f $build_aux/$f
done
# Automake should inform about which files it's installing.
for f in $files; do
command_ok_ \
"$pfx report installation of $f" \
grep ": installing ['\`]$build_aux/$f'$" stderr
done
# Only the expected files should be installed. But automake always
# require 'missing' and 'install-sh', so account for them.
all_files="install-sh missing $files"
for f in $all_files; do echo $f; done | sort | uniq > files.exp
(cd $build_aux && ls) | sort > files.got
cat files.exp
cat files.got
command_ok_ \
"$pfx all and only expected files installed" \
$am_diff files.exp files.got
# The files should be copied by '--copy' and symlinked otherwise.
# But these checks make no sense on systems like MSYS/MinGW where
# there are no true symlinks ('ln -s' behaves like 'cp -p'), so be
# ready to skip the checks in that case. See automake bug#10441.
for f in $files; do
if test $have_true_symlinks = no; then
skip_ -r "system lacks true symlinks" "$pfx $f is a symlink or not"
else
if test -h $build_aux/$f; then
is_symlink=yes
else
is_symlink=no
fi
case $action,$is_symlink in
link,yes) ok_ "$pfx $f has been symlinked" ;;
link,no) not_ok_ "$pfx $f has not been symlinked" ;;
copy,yes) not_ok_ "$pfx $f has been symlinked" ;;
copy,no) ok_ "$pfx $f has not been symlinked" ;;
*) fatal_ "invalid condition in case" ;;
esac
fi
done
# Now that the required auxiliary files have been installed, automake
# should not complain anymore even if the '--add-missing' option is
# not used.
AUTOMAKE_run -d "$pfx automake finds all added files"
cd ..
done # for action in link copy
cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
}
# Automake should always and unconditionally require the 'missing'
# and 'install-sh' scripts.
check_ <<'END'
== Name ==
minimal
== Files ==
install-sh missing
END
check_ <<'END'
== Name ==
depcomp/C
== Files ==
depcomp
== configure.ac ==
AC_PROG_CC
== Makefile.am ==
bin_PROGRAMS = foo
END
check_ <<'END'
== Name ==
depcomp/C++
== Files ==
depcomp
== configure.ac ==
AC_PROG_CXX
== Makefile.am ==
bin_PROGRAMS = foo
foo_SOURCES = foo.cc
END
check_ --run-aclocal <<'END'
== Name ==
compile
== Files ==
compile
== configure.ac ==
# Using AM_PROG_CC_C_O in configure.ac should be enough. No need to
# use AC_PROG_CC too, nor to define xxx_PROGRAMS in Makefile.am.
AM_PROG_CC_C_O
END
# For config.guess and config.sub.
for mach in build host target system; do
MACH=`echo "$mach" | LC_ALL=C tr '[a-z]' '[A-Z]'`
check_ <<END
== Name ==
cfg-$mach
== Files ==
config.sub
config.guess
== configure.ac ==
AC_CANONICAL_$MACH
END
done
check_ <<'END'
== Name ==
ylwrap/Lex
== Files ==
ylwrap
== configure.ac ==
AC_PROG_CC
AC_PROG_LEX
== Makefile.am ==
AUTOMAKE_OPTIONS = no-dependencies
bin_PROGRAMS = foo
foo_SOURCES = foo.l
END
check_ <<'END'
== Name ==
ylwrap/Yacc
== Files ==
ylwrap
== configure.ac ==
AC_PROG_CC
AC_PROG_YACC
== Makefile.am ==
AUTOMAKE_OPTIONS = no-dependencies
bin_PROGRAMS = foo
foo_SOURCES = foo.y
END
echo '@setfilename foo.info' > foo.texi
check_ --fetch-file foo.texi <<'END'
== Name ==
Texinfo
== Files ==
texinfo.tex
== Makefile.am ==
info_TEXINFOS = foo.texi
END
echo '@include version.texi' >> foo.texi
check_ --fetch-file foo.texi <<'END'
== Name ==
Texinfo/mdate-sh
== Files ==
mdate-sh
texinfo.tex
== Makefile.am ==
info_TEXINFOS = foo.texi
END
rm -f foo.texi
check_ <<'END'
== Name ==
elisp-comp
== Files ==
elisp-comp
== configure.ac ==
AM_PATH_LISPDIR
== Makefile.am ==
lisp_LISP = foo.el
END
check_ <<'END'
== Name ==
py-compile
== Files ==
py-compile
== configure.ac ==
AM_PATH_PYTHON
== Makefile.am ==
python_PYTHON = foo.py
END
# Try few unrelated auxiliary scripts together.
check_ <<'END'
== Name ==
misc
== Files ==
py-compile
depcomp
ylwrap
config.sub
config.guess
== configure.ac ==
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_PROG_CXX
== Makefile.am ==
PYTHON = python
pythondir = $(prefix)/py
YACC = bison -y
bin_PROGRAMS = foo
foo_SOURCES = bar.yxx baz.c++
python_PYTHON = zardoz.py
END
:
|