2 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 # Free Software Foundation, Inc.
5 # This file is part of GNU Automake.
7 # GNU Automake is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # GNU Automake is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with autoconf; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 # Boston, MA 02111-1307, USA.
22 # Defines for Automake testing environment.
23 # Tom Tromey <tromey@cygnus.com>
25 # Be Bourne compatible.
26 # (Snippet copied from configure's initialization in Autoconf 2.57.)
27 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
30 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
31 # is contrary to our usage. Disable this feature.
32 alias -g '${1+"$@"}'='"$@"'
33 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
37 # Ensure we are running from the right directory.
39 echo "defs: not found in current directory" 1>&2
43 # If srcdir is not set, then we are not running from `make check', be verbose.
44 if test -z "$srcdir"; then
45 test -z "$VERBOSE" && VERBOSE=x
47 srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
48 test $srcdir = $0 && srcdir=.
51 # Ensure $srcdir is set correctly.
52 test -f $srcdir/defs.in || {
53 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
57 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
59 # See how redirections should work. User can set VERBOSE to see all
61 test -z "$VERBOSE" && {
66 # User can override various tools used.
67 test -z "$PERL" && PERL='@PERL@'
68 test -z "$MAKE" && MAKE=make
69 test -z "$AUTOCONF" && AUTOCONF="@AUTOCONF@"
70 test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
71 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
73 if test -n "$required"
77 # Check that each required tool is present.
80 # Since bison is required, we pick YACC for ./configure.
83 echo "$me: running bison --version"
84 ( bison --version ) || exit 77
87 # Exuberant Ctags will create a TAGS file even
88 # when asked for --help or --version. (Emacs's etags
89 # does not have such problem.) Use -o /dev/null
90 # to make sure we do not pollute the tests/ directory.
91 echo "$me: running etags --version -o /dev/null"
92 ( etags --version -o /dev/null ) || exit 77
95 # Use --version and -v, because SGI Make doesn't fail on --version.
96 echo "$me: running $MAKE --version -v"
97 ( $MAKE --version -v ) || exit 77
100 # When gcc is required, export `CC=gcc' so that ./configure
101 # always use it. This is important only when the user
102 # has defined CC in his environment, otherwise ./configure will
103 # prefer gcc to other compilers.
106 echo "$me: running $CC --version"
107 ( $CC --version ) || exit 77
112 echo "$me: running $CXX --version"
113 ( $CXX --version ) || exit 77
118 # There is no way to ask *only* the compiler's version.
119 # This tool always want to do something (by default
120 # it will try link *nothing* and complain it cannot find
121 # main(); funny). -dryrun is a workaround.
122 echo "$me: running $CC -V -dryrun"
123 ( $CC -V -dryrun ) || exit 77
126 echo "$me: running makedepend -f-"
127 ( makedepend -f- ) || exit 77
130 # Make sure makeinfo understands --html.
131 echo "$me: running makeinfo --html --version"
132 ( makeinfo --html --version ) || exit 77
135 # Skip this test case if the user is root.
136 # We try to append to a read-only file to detect this.
137 priv_check_temp=priv-check.$$
138 touch $priv_check_temp || exit 1
139 chmod a-w $priv_check_temp || exit 1
140 (echo foo >> $priv_check_temp) >/dev/null 2>&1
142 rm -f $priv_check_temp
143 test $overwrite_status = 0 && exit 77
146 # Python doesn't support --version, it has -V
147 echo "$me: running python -V"
148 ( python -V ) || exit 77
151 # Skip this test case if read-only directories aren't supported
153 ro_dir_temp=ro_dir.$$
154 mkdir $ro_dir_temp || exit 1
155 chmod a-w $ro_dir_temp || exit 1
156 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
159 test $create_status = 0 && exit 77
162 # DejaGnu's runtest program.
163 echo "$me: running runtest --version"
164 (runtest --version) || exit 77
167 # No all versions of Tex support `--version', so we use
169 test -n "@TEX@" || exit 77
172 # Texi2dvi supports `-o' since Texinfo 4.1.
173 echo "$me: running texi2dvi -o /dev/null --version"
174 ( texi2dvi -o /dev/null --version ) || exit 77
176 # Generic case: the tool must support --version.
178 echo "$me: running $tool --version"
179 ( $tool --version ) || exit 77
182 # Additional variables to define if some $tool is required.
190 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
191 # of the test dir just won't work.
197 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
201 chmod -R a+rwx testSubDir > /dev/null 2>&1
202 rm -rf testSubDir > /dev/null 2>&1
205 # Copy in some files we need.
206 for file in install-sh mkinstalldirs missing depcomp; do
207 cp $srcdir/../lib/$file testSubDir/$file || exit 1
212 # Build appropriate environment in test directory. Eg create
213 # configure.in, touch all necessary files, etc.
214 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
215 # still produces a valid configure.ac. But then, tests running
216 # config.status really need to append AC_OUTPUT.
217 cat > configure.in << END
218 AC_INIT([$me], [1.0])
220 AC_CONFIG_FILES([Makefile])
223 # Unset some MAKE... variables that may cause $MAKE to act like a
224 # recursively invoked sub-make. Any $MAKE invocation in a test is
225 # conceptually an independent invocation, not part of the main
232 echo "=== Running test $0"
234 # See how Automake should be run. We put --foreign as the default
235 # strictness to avoid having to create lots and lots of files. A test
236 # can override this by specifying a different strictness.
237 if test -z "$AUTOMAKE"; then
238 perllibdir=`pwd`/../../lib:$srcdir/../lib
240 # Use -Wall -Werror by default. Tests for which this is inappropriate
241 # (e.g. when testing that a warning is enabled by a specific switch)
242 # should use -Wnone or/and -Wno-error
243 AUTOMAKE="$PERL `pwd`/../../automake --libdir=$srcdir/../lib --foreign -Werror -Wall"
246 # See how aclocal should be run.
247 if test -z "$ACLOCAL"; then
248 perllibdir=`pwd`/../../lib:$srcdir/../lib
250 # Most of the files are in $srcdir/../m4. However amversion.m4 is
251 # generated in ../m4, so we include that directory in the search
253 ACLOCAL="$PERL `pwd`/../../aclocal -I `pwd`/../../m4 --acdir=$srcdir/../m4"
256 # We might need extra macros, e.g., from Libtool or Gettext.
257 # Find them on the system.
258 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
259 # other `-I' directories added for libtool and gettext might contain
260 # files from an old version of Automake that we don't want to use.
261 aclocaldir='@prefix@/share/aclocal'
263 if [ -f $aclocaldir/dirlist ] ; then
264 extra_includes=`(tmp_inc=""
266 tmp_inc="$tmp_inc -I $LINE"
268 echo $tmp_inc) < $aclocaldir/dirlist`
273 for d in $extra_includes $aclocaldir ; do
274 if [ "x$d" != "x-I" ] && [ -f "$d/libtool.m4" ] ; then
278 test "x$libtool_found" = "xyes" || exit 77
279 ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
283 for d in $extra_includes $aclocaldir ; do
284 if [ "x$d" != "x-I" ] && [ -f "$d/gettext.m4" ] ; then
288 test "x$gettext_found" = "xyes" || exit 77
289 ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
293 # Export AUTOMAKE and ACLOCAL so that rebuild rules in Makefiles
294 # generated for the tests do not use the installed tools.
295 export AUTOMAKE ACLOCAL
297 # POSIX no longer requires 'egrep' and 'fgrep',
298 # but some hosts lack 'grep -E' and 'grep -F'.
302 # The amount we should wait after modifying files depends on the platform.
303 # For instance, Windows '95, '98 and ME have 2-second granularity
304 # and can be up to 3 seconds in the future w.r.t. the system clock.
305 sleep='sleep @MODIFICATION_DELAY@'
307 # The tests call `make -e' but we do not want $srcdir from the evironment
308 # to override the definition from the Makefile.
312 # AUTOMAKE_run status [options...]
313 # --------------------------------
314 # Run Automake with OPTIONS, and fail if automake
315 # does not exit with STATUS.
321 $AUTOMAKE ${1+"$@"} 2>stderr >stdout || exitcode=$?
324 test $exitcode = $expected_exitcode || exit 1
327 # AUTOMAKE_fails [options...]
328 # ---------------------------
329 # Run Automake with OPTIONS, and fail if automake
330 # does not exit with STATUS.
333 AUTOMAKE_run 1 ${1+"$@"}
336 # Turn on shell traces when VERBOSE=x.
337 if test "x$VERBOSE" = xx; then