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 # Ensure we are running from the right directory.
27 echo "defs: not found in current directory" 1>&2
31 # If srcdir is not set, then we are not running from `make check', be verbose.
32 if test -z "$srcdir"; then
33 test -z "$VERBOSE" && VERBOSE=x
35 srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
36 test $srcdir = $0 && srcdir=.
39 # Ensure $srcdir is set correctly.
40 test -f $srcdir/defs.in || {
41 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
45 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
47 # See how redirections should work. User can set VERBOSE to see all
49 test -z "$VERBOSE" && {
54 # User can override various tools used.
55 test -z "$PERL" && PERL='@PERL@'
56 test -z "$MAKE" && MAKE=make
57 test -z "$AUTOCONF" && AUTOCONF="@AUTOCONF@"
58 test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
59 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
61 if test -n "$required"
65 # Check that each required tool is present.
68 # Since bison is required, we pick YACC for ./configure.
71 echo "$me: running bison --version"
72 ( bison --version ) || exit 77
75 # Use --version and -v, because SGI Make doesn't fail on --version.
76 echo "$me: running $MAKE --version -v"
77 ( $MAKE --version -v ) || exit 77
80 # When gcc is required, export `CC=gcc' so that ./configure
81 # always use it. This is important only when the user
82 # has defined CC in his environment, otherwise ./configure will
83 # prefer gcc to other compilers.
86 echo "$me: running $CC --version"
87 ( $CC --version ) || exit 77
92 echo "$me: running $CXX --version"
93 ( $CXX --version ) || exit 77
98 # There is no way to ask *only* the compiler's version.
99 # This tool always want to do something (by default
100 # it will try link *nothing* and complain it cannot find
101 # main(); funny). -dryrun is a workaround.
102 echo "$me: running $CC -V -dryrun"
103 ( $CC -V -dryrun ) || exit 77
106 echo "$me: running makedepend -f-"
107 ( makedepend -f- ) || exit 77
110 # Skip this test case if the user is root.
111 # We try to append to a read-only file to detect this.
112 priv_check_temp=priv-check.$$
113 touch $priv_check_temp || exit 1
114 chmod a-w $priv_check_temp || exit 1
115 (echo foo >> $priv_check_temp) >/dev/null 2>&1
117 rm -f $priv_check_temp
118 test $overwrite_status = 0 && exit 77
121 # Python doesn't support --version, it has -V
122 echo "$me: running python -V"
123 ( python -V ) || exit 77
126 # Skip this test case if read-only directories aren't supported
128 ro_dir_temp=ro_dir.$$
129 mkdir $ro_dir_temp || exit 1
130 chmod a-w $ro_dir_temp || exit 1
131 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
134 test $create_status = 0 && exit 77
137 # No all versions of Tex support `--version', so we use
139 test -n "@TEX@" || exit 77
142 # Texi2dvi supports `-o' since Texinfo 4.1.
143 echo "$me: running texi2dvi -o /dev/null --version"
144 ( texi2dvi -o /dev/null --version ) || exit 77
146 # Generic case: the tool must support --version.
148 echo "$me: running $tool --version"
149 ( $tool --version ) || exit 77
152 # Additional variables to define if some $tool is required.
160 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
161 # of the test dir just won't work.
167 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
171 chmod -R a+rwx testSubDir > /dev/null 2>&1
172 rm -rf testSubDir > /dev/null 2>&1
175 # Copy in some files we need.
176 for file in install-sh mkinstalldirs missing depcomp; do
177 cp $srcdir/../lib/$file testSubDir/$file || exit 1
182 # Build appropriate environment in test directory. Eg create
183 # configure.in, touch all necessary files, etc.
184 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
185 # still produces a valid configure.ac. But then, tests running
186 # config.status really need to append AC_OUTPUT.
187 cat > configure.in << END
188 AC_INIT([$me], [1.0])
190 AC_CONFIG_FILES([Makefile])
193 # Unset some MAKE... variables that may cause $MAKE to act like a
194 # recursively invoked sub-make. Any $MAKE invocation in a test is
195 # conceptually an independent invocation, not part of the main
202 echo "=== Running test $0"
204 # See how Automake should be run. We put --foreign as the default
205 # strictness to avoid having to create lots and lots of files. A test
206 # can override this by specifying a different strictness.
207 if test -z "$AUTOMAKE"; then
208 perllibdir=$srcdir/../lib
210 # Use -Wall -Werror by default. Tests for which this is inappropriate
211 # (e.g. when testing that a warning is enabled by a specific switch)
212 # should use -Wnone or/and -Wno-error
213 AUTOMAKE="$PERL `pwd`/../../automake --libdir=$srcdir/../lib --foreign -Werror -Wall"
216 # See how aclocal should be run.
217 if test -z "$ACLOCAL"; then
218 perllibdir=$srcdir/../lib
220 # Most of the files are in $srcdir/../m4. However amversion.m4 is
221 # generated in ../m4, so we include that directory in the search
223 ACLOCAL="$PERL `pwd`/../../aclocal -I `pwd`/../../m4 --acdir=$srcdir/../m4"
226 # We might need extra macros, e.g., from Libtool or Gettext.
227 # Find them on the system.
228 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
229 # other `-I' directories added for libtool and gettext might contain
230 # files from an old version of Automake that we don't want to use.
231 aclocaldir='@prefix@/share/aclocal'
233 if [ -f $aclocaldir/dirlist ] ; then
234 extra_includes=`(tmp_inc=""
236 tmp_inc="$tmp_inc -I $LINE"
238 echo $tmp_inc) < $aclocaldir/dirlist`
243 for d in $extra_includes $aclocaldir ; do
244 if [ "x$d" != "x-I" ] && [ -f "$d/libtool.m4" ] ; then
248 test "x$libtool_found" = "xyes" || exit 77
249 ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
253 for d in $extra_includes $aclocaldir ; do
254 if [ "x$d" != "x-I" ] && [ -f "$d/gettext.m4" ] ; then
258 test "x$gettext_found" = "xyes" || exit 77
259 ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
263 # Export AUTOMAKE and ACLOCAL so that rebuild rules in Makefiles
264 # generated for the tests do not use the installed tools.
265 export AUTOMAKE ACLOCAL
267 # POSIX no longer requires 'egrep' and 'fgrep',
268 # but some hosts lack 'grep -E' and 'grep -F'.
272 # On Windows '95, '98 and ME, files modifications have 2-seconds
273 # granularity and can be up to 3 seconds in the future w.r.t. the
274 # system clock. When it is important to ensure one file is older
275 # than another we wait at least 5 seconds between creations.
278 # The tests call `make -e' but we do not want $srcdir from the evironment
279 # to override the definition from the Makefile.
283 # Turn on shell traces when VERBOSE=x.
284 if test "x$VERBOSE" = xx; then