4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007 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 3, 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.59c.)
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+"$@"}'='"$@"'
36 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
38 BIN_SH=xpg4; export BIN_SH # for Tru64
39 DUALCASE=1; export DUALCASE # for MKS sh
41 # Ensure we are running from the right directory.
43 echo "defs: not found in current directory" 1>&2
47 # If srcdir is not set, then we are not running from `make check', be verbose.
48 if test -z "$srcdir"; then
51 srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
52 test $srcdir = $0 && srcdir=.
55 # Ensure $srcdir is set correctly.
56 test -f $srcdir/defs.in || {
57 echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
61 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
63 # See how redirections should work. User can set VERBOSE to see all
65 test -z "$VERBOSE" && {
69 # Make sure we override the user shell.
72 # User can override various tools used.
73 test -z "$PERL" && PERL='@PERL@'
74 test -z "$MAKE" && MAKE=make
75 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
76 test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
77 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
78 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
79 # Use -Werror because this also turns some Perl warnings into error.
80 # (Tests for which this is inappropriate should use -Wno-error.)
81 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
82 # Extra flags to pass to aclocal before all other flags added by this script.
83 ACLOCAL_TESTSUITE_FLAGS=
84 export ACLOCAL_TESTSUITE_FLAGS
86 # See how Automake should be run. We put --foreign as the default
87 # strictness to avoid having to create lots and lots of files. A test
88 # can override this by specifying a different strictness. Use -Wall
89 # -Werror by default. Tests for which this is inappropriate
90 # (e.g. when testing that a warning is enabled by a specific switch)
91 # should use -Wnone or/and -Wno-error
92 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
94 PATH="`pwd`@PATH_SEPARATOR@$PATH"
96 # Some shells forget to export modified environment variables.
97 # (See note about `export' in the Autoconf manual.)
100 for tool in : $required
102 # Check that each required tool is present.
106 # Since bison is required, we pick YACC for ./configure.
109 echo "$me: running bison --version"
110 ( bison --version ) || exit 77
113 # Do not use --version, bzip2 still tries to compress stdin.
114 echo "$me: running bzip2 --help"
115 ( bzip2 --help ) || exit 77
118 # Exuberant Ctags will create a TAGS file even
119 # when asked for --help or --version. (Emacs's etags
120 # does not have such problem.) Use -o /dev/null
121 # to make sure we do not pollute the tests/ directory.
122 echo "$me: running etags --version -o /dev/null"
123 ( etags --version -o /dev/null ) || exit 77
126 # Use --version AND -v, because SGI Make doesn't fail on --version.
127 # Also grep for GNU because newer versions of FreeBSD make do
128 # not complain about `--version' (they seem to silently ignore it).
129 echo "$me: running $MAKE --version -v | grep GNU"
130 ( $MAKE --version -v | grep GNU ) || exit 77
133 # When gcc is required, export `CC=gcc' so that ./configure
134 # always use it. This is important only when the user
135 # has defined CC in his environment, otherwise ./configure will
136 # prefer gcc to other compilers.
139 echo "$me: running $CC --version"
140 ( $CC --version ) || exit 77
145 echo "$me: running $GCJ --version"
146 ( $GCJ --version ) || exit 77
147 ( $GCJ -v ) || exit 77
152 echo "$me: running $CXX --version"
153 ( $CXX --version ) || exit 77
158 # There is no way to ask *only* the compiler's version.
159 # This tool always want to do something (by default
160 # it will try link *nothing* and complain it cannot find
161 # main(); funny). Use -help so it does not try linking anything.
162 echo "$me: running $CC -V -help"
163 ( $CC -V -help ) || exit 77
166 echo "$me: running makedepend -f-"
167 ( makedepend -f- ) || exit 77
170 # Make sure makeinfo understands --html.
171 echo "$me: running makeinfo --html --version"
172 ( makeinfo --html --version ) || exit 77
175 # Skip this test case if the user is root.
176 # We try to append to a read-only file to detect this.
177 priv_check_temp=priv-check.$$
178 touch $priv_check_temp || exit 1
179 chmod a-w $priv_check_temp || exit 1
180 (echo foo >> $priv_check_temp) >/dev/null 2>&1
182 rm -f $priv_check_temp
183 test $overwrite_status = 0 && exit 77
186 # Python doesn't support --version, it has -V
187 echo "$me: running python -V"
188 ( python -V ) || exit 77
191 # Skip this test case if read-only directories aren't supported
193 ro_dir_temp=ro_dir.$$
194 mkdir $ro_dir_temp || exit 1
195 chmod a-w $ro_dir_temp || exit 1
196 (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
199 test $create_status = 0 && exit 77
202 # DejaGnu's runtest program. We rely on being able to specify
203 # the program on the runtest command-line. This requires
204 # DejaGnu 1.4.3 or later.
205 echo "$me: running runtest --version"
206 (runtest SOMEPROGRAM=someprogram --version) || exit 77
209 # No all versions of Tex support `--version', so we use
211 test -n "@TEX@" || exit 77
214 # Texi2dvi supports `-o' since Texinfo 4.1.
215 echo "$me: running texi2dvi -o /dev/null --version"
216 ( texi2dvi -o /dev/null --version ) || exit 77
218 # Generic case: the tool must support --version.
220 echo "$me: running $tool --version"
221 ( $tool --version ) || exit 77
227 # Always use an absolute srcdir. Otherwise symlinks made in subdirs
228 # of the test dir just won't work.
234 srcdir=`CDPATH=: && cd "$srcdir" && pwd`
240 chmod -R u+rwx $testSubDir > /dev/null 2>&1
241 rm -rf $testSubDir > /dev/null 2>&1
246 case $exit_status,$keep_testdirs in
248 chmod -R a+rwx $testSubDir > /dev/null 2>&1
249 rm -rf "$testSubDir" ;;
251 test "$signal" != 0 &&
252 echo "$as_me: caught signal $signal"
253 echo "$as_me: exit $exit_status"
256 for signal in 1 2 13 15; do
257 trap 'signal='$signal'; { (exit 1); exit 1; }' $signal
261 # Copy in some files we need.
262 for file in install-sh missing depcomp; do
263 cp $srcdir/../lib/$file $testSubDir/$file || exit 1
268 # Build appropriate environment in test directory. Eg create
269 # configure.in, touch all necessary files, etc.
270 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
271 # still produces a valid configure.ac. But then, tests running
272 # config.status really need to append AC_OUTPUT.
273 cat > configure.in << END
274 AC_INIT([$me], [1.0])
276 AC_CONFIG_FILES([Makefile])
279 # Unset some MAKE... variables that may cause $MAKE to act like a
280 # recursively invoked sub-make. Any $MAKE invocation in a test is
281 # conceptually an independent invocation, not part of the main
288 echo "=== Running test $0"
290 # We might need extra macros, e.g., from Libtool or Gettext.
291 # Find them on the system.
292 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
293 # other `-I' directories added for libtool and gettext might contain
294 # files from an old version of Automake that we don't want to use.
295 # Use `-Wno-syntax' because we do not want our test suite to fail because
296 # some third-party .m4 file is underquoted.
298 *libtool* | *gettext* )
299 aclocaldir='@prefix@/share/aclocal'
301 if test -f $aclocaldir/dirlist; then
302 extra_includes=`(tmp_inc=""
304 tmp_inc="$tmp_inc -I $LINE"
306 echo $tmp_inc) < $aclocaldir/dirlist`
311 for d in $extra_includes $aclocaldir ; do
312 test "x$d" != x-I || continue
313 if test -f "$d/libtool.m4"; then
316 if test -f "$d/gettext.m4"; then
321 *libtool* ) test $libtool_found = yes || exit 77 ;;
322 *gettext* ) test $gettext_found = yes || exit 77 ;;
324 ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
328 testaclocaldir='@abs_top_srcdir@/m4'
330 # POSIX no longer requires 'egrep' and 'fgrep',
331 # but some hosts lack 'grep -E' and 'grep -F'.
335 # The amount we should wait after modifying files depends on the platform.
336 # For instance, Windows '95, '98 and ME have 2-second granularity
337 # and can be up to 3 seconds in the future w.r.t. the system clock.
338 sleep='sleep @MODIFICATION_DELAY@'
340 # The tests call `make -e' but we do not want $srcdir from the environment
341 # to override the definition from the Makefile.
345 # An old timestamp that can be given to a file, in "touch -t" format.
346 # The time stamp should be portable to all file systems of interest.
347 # Just for fun, choose the exact time of the announcement of the GNU project
348 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
349 old_timestamp=198309271735.59
351 # is_newest FILE FILES
352 # --------------------
353 # Return false if any file in FILES is newer than FILE.
354 # Resolve ties in favor of FILE.
357 is_newest_files=`find "$@" -newer "$1"`
358 test -z "$is_newest_files"
362 # AUTOMAKE_run status [options...]
363 # --------------------------------
364 # Run Automake with OPTIONS, and fail if automake
365 # does not exit with STATUS.
371 $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
374 test $exitcode = $expected_exitcode || exit 1
377 # AUTOMAKE_fails [options...]
378 # ---------------------------
379 # Run Automake with OPTIONS, and fail if automake
380 # does not exit with STATUS.
383 AUTOMAKE_run 1 ${1+"$@"}
386 # Turn on shell traces when VERBOSE is set.
387 if test -n "$VERBOSE"; then