4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
5 # Free Software Foundation, Inc.
7 # This file is part of GNU Automake.
9 # GNU Automake is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
14 # GNU Automake is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with autoconf; see the file COPYING. If not, write to
21 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 # Boston, MA 02110-1301, USA.
24 # Defines for Automake testing environment.
25 # Tom Tromey <tromey@cygnus.com>
27 # Be Bourne compatible.
28 # (Snippet copied from configure's initialization in Autoconf 2.57.)
29 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
32 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
33 # is contrary to our usage. Disable this feature.
34 alias -g '${1+"$@"}'='"$@"'
35 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
39 # Ensure we are running from the right directory.
41 echo "defs: not found in current directory" 1>&2
45 # If srcdir is not set, then we are not running from `make check', be verbose.
46 if test -z "$srcdir"; then
49 srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
50 test $srcdir = $0 && srcdir=.
53 # Ensure $srcdir is set correctly.
54 test -f $srcdir/defs.in || {
55 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
59 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
61 # See how redirections should work. User can set VERBOSE to see all
63 test -z "$VERBOSE" && {
67 # Make sure we override the user shell.
70 # User can override various tools used.
71 test -z "$PERL" && PERL='@PERL@'
72 test -z "$MAKE" && MAKE=make
73 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
74 test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
75 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
76 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
77 # Use -Werror because this also turns some Perl warnings into error.
78 # (Tests for which this is inappropriate should use -Wno-error.)
79 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
80 # Extra flags to pass to aclocal before all other flags added by this script.
81 ACLOCAL_TESTSUITE_FLAGS=
82 export ACLOCAL_TESTSUITE_FLAGS
84 # See how Automake should be run. We put --foreign as the default
85 # strictness to avoid having to create lots and lots of files. A test
86 # can override this by specifying a different strictness. Use -Wall
87 # -Werror by default. Tests for which this is inappropriate
88 # (e.g. when testing that a warning is enabled by a specific switch)
89 # should use -Wnone or/and -Wno-error
90 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
92 PATH="`pwd`@PATH_SEPARATOR@$PATH"
94 # Some shells forget to export modified environment variables.
95 # (See note about `export' in the Autoconf manual.)
98 if test -n "$required"
100 for tool in $required
102 # Check that each required tool is present.
105 # Since bison is required, we pick YACC for ./configure.
108 echo "$me: running bison --version"
109 ( bison --version ) || exit 77
112 # Do not use --version, bzip2 still tries to compress stdin.
113 echo "$me: running bzip2 --help"
114 ( bzip2 --help ) || exit 77
117 # Exuberant Ctags will create a TAGS file even
118 # when asked for --help or --version. (Emacs's etags
119 # does not have such problem.) Use -o /dev/null
120 # to make sure we do not pollute the tests/ directory.
121 echo "$me: running etags --version -o /dev/null"
122 ( etags --version -o /dev/null ) || exit 77
125 # Use --version AND -v, because SGI Make doesn't fail on --version.
126 # Also grep for GNU because newer versions of FreeBSD make do
127 # not complain about `--version' (they seem to silently ignore it).
128 echo "$me: running $MAKE --version -v | grep GNU"
129 ( $MAKE --version -v | grep GNU ) || exit 77
132 # When gcc is required, export `CC=gcc' so that ./configure
133 # always use it. This is important only when the user
134 # has defined CC in his environment, otherwise ./configure will
135 # prefer gcc to other compilers.
138 echo "$me: running $CC --version"
139 ( $CC --version ) || exit 77
144 echo "$me: running $CXX --version"
145 ( $CXX --version ) || exit 77
150 # There is no way to ask *only* the compiler's version.
151 # This tool always want to do something (by default
152 # it will try link *nothing* and complain it cannot find
153 # main(); funny). Use -help so it does not try linking anything.
154 echo "$me: running $CC -V -help"
155 ( $CC -V -help ) || exit 77
158 echo "$me: running makedepend -f-"
159 ( makedepend -f- ) || exit 77
162 # Make sure makeinfo understands --html.
163 echo "$me: running makeinfo --html --version"
164 ( makeinfo --html --version ) || exit 77
167 # Skip this test case if the user is root.
168 # We try to append to a read-only file to detect this.
169 priv_check_temp=priv-check.$$
170 touch $priv_check_temp || exit 1
171 chmod a-w $priv_check_temp || exit 1
172 (echo foo >> $priv_check_temp) >/dev/null 2>&1
174 rm -f $priv_check_temp
175 test $overwrite_status = 0 && exit 77
178 # Python doesn't support --version, it has -V
179 echo "$me: running python -V"
180 ( python -V ) || exit 77
183 # Skip this test case if read-only directories aren't supported
185 ro_dir_temp=ro_dir.$$
186 mkdir $ro_dir_temp || exit 1
187 chmod a-w $ro_dir_temp || exit 1
188 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
191 test $create_status = 0 && exit 77
194 # DejaGnu's runtest program. We rely on being able to specify
195 # the program on the runtest command-line. This requires
196 # DejaGnu 1.4.3 or later.
197 echo "$me: running runtest --version"
198 (runtest SOMEPROGRAM=someprogram --version) || exit 77
201 # No all versions of Tex support `--version', so we use
203 test -n "@TEX@" || exit 77
206 # Texi2dvi supports `-o' since Texinfo 4.1.
207 echo "$me: running texi2dvi -o /dev/null --version"
208 ( texi2dvi -o /dev/null --version ) || exit 77
210 # Generic case: the tool must support --version.
212 echo "$me: running $tool --version"
213 ( $tool --version ) || exit 77
216 # Additional variables to define if some $tool is required.
224 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
225 # of the test dir just won't work.
231 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
235 chmod -R a+rwx testSubDir > /dev/null 2>&1
236 rm -rf testSubDir > /dev/null 2>&1
239 # Copy in some files we need.
240 for file in install-sh missing depcomp; do
241 cp $srcdir/../lib/$file testSubDir/$file || exit 1
246 # Build appropriate environment in test directory. Eg create
247 # configure.in, touch all necessary files, etc.
248 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
249 # still produces a valid configure.ac. But then, tests running
250 # config.status really need to append AC_OUTPUT.
251 cat > configure.in << END
252 AC_INIT([$me], [1.0])
254 AC_CONFIG_FILES([Makefile])
257 # Unset some MAKE... variables that may cause $MAKE to act like a
258 # recursively invoked sub-make. Any $MAKE invocation in a test is
259 # conceptually an independent invocation, not part of the main
266 echo "=== Running test $0"
268 # We might need extra macros, e.g., from Libtool or Gettext.
269 # Find them on the system.
270 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
271 # other `-I' directories added for libtool and gettext might contain
272 # files from an old version of Automake that we don't want to use.
273 # Use `-Wno-syntax' because we do not want our test suite to fail because
274 # some third-party .m4 file is underquoted.
275 aclocaldir='@prefix@/share/aclocal'
277 if [ -f $aclocaldir/dirlist ] ; then
278 extra_includes=`(tmp_inc=""
280 tmp_inc="$tmp_inc -I $LINE"
282 echo $tmp_inc) < $aclocaldir/dirlist`
287 for d in $extra_includes $aclocaldir ; do
288 if [ "x$d" != "x-I" ] && [ -f "$d/libtool.m4" ] ; then
292 test "x$libtool_found" = "xyes" || exit 77
293 ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
297 for d in $extra_includes $aclocaldir ; do
298 if [ "x$d" != "x-I" ] && [ -f "$d/gettext.m4" ] ; then
302 test "x$gettext_found" = "xyes" || exit 77
303 ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
307 testaclocaldir='@abs_top_srcdir@/m4'
309 # POSIX no longer requires 'egrep' and 'fgrep',
310 # but some hosts lack 'grep -E' and 'grep -F'.
314 # The amount we should wait after modifying files depends on the platform.
315 # For instance, Windows '95, '98 and ME have 2-second granularity
316 # and can be up to 3 seconds in the future w.r.t. the system clock.
317 sleep='sleep @MODIFICATION_DELAY@'
319 # The tests call `make -e' but we do not want $srcdir from the environment
320 # to override the definition from the Makefile.
324 # AUTOMAKE_run status [options...]
325 # --------------------------------
326 # Run Automake with OPTIONS, and fail if automake
327 # does not exit with STATUS.
333 $AUTOMAKE ${1+"$@"} 2>stderr >stdout || exitcode=$?
336 test $exitcode = $expected_exitcode || exit 1
339 # AUTOMAKE_fails [options...]
340 # ---------------------------
341 # Run Automake with OPTIONS, and fail if automake
342 # does not exit with STATUS.
345 AUTOMAKE_run 1 ${1+"$@"}
348 # Turn on shell traces when VERBOSE is set.
349 if test -n "$VERBOSE"; then