Clarify overriding of `*_DEPENDENCIES' in LIBOBJS node.
[automake/ericb.git] / tests / defs.in
blobde0c6824839805bbb1feed64ebbf90852899d5ab
1 # -*- shell-script -*-
2 # @configure_input@
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
7 # This program 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 3, or (at your option)
10 # any later version.
12 # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
20 # Defines for Automake testing environment.
21 # Tom Tromey <tromey@cygnus.com>
23 # Be Bourne compatible.
24 # (Snippet copied from configure's initialization in Autoconf 2.59c.)
25 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
26   emulate sh
27   NULLCMD=:
28   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
29   # is contrary to our usage.  Disable this feature.
30   alias -g '${1+"$@"}'='"$@"'
31 else
32   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
34 BIN_SH=xpg4; export BIN_SH # for Tru64
35 DUALCASE=1; export DUALCASE # for MKS sh
37 # Ensure we are running from the right directory.
38 test -f ./defs || {
39    echo "defs: not found in current directory" 1>&2
40    exit 1
43 # If srcdir is not set, then we are not running from `make check', be verbose.
44 if test -z "$srcdir"; then
45    VERBOSE=x
46    # compute $srcdir.
47    srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
48    test "$srcdir" = $0 && srcdir=.
49 else :; fi
51 # Ensure $srcdir is set correctly.
52 test -f "$srcdir/defs.in" || {
53    echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
54    exit 1
57 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
59 # See how redirections should work.  User can set VERBOSE to see all
60 # output.
61 test -z "$VERBOSE" && {
62    exec > /dev/null 2>&1
65 # Make sure we override the user shell.
66 SHELL='@SHELL@'
67 export SHELL
68 # User can override various tools used.
69 test -z "$PERL" && PERL='@PERL@'
70 test -z "$MAKE" && MAKE=make
71 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
72 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
73 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
74 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
75 # Use -Werror because this also turns some Perl warnings into error.
76 # (Tests for which this is inappropriate should use -Wno-error.)
77 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
78 # Extra flags to pass to aclocal before all other flags added by this script.
79 ACLOCAL_TESTSUITE_FLAGS=
80 export ACLOCAL_TESTSUITE_FLAGS
82 # See how Automake should be run.  We put --foreign as the default
83 # strictness to avoid having to create lots and lots of files.  A test
84 # can override this by specifying a different strictness.  Use -Wall
85 # -Werror by default.  Tests for which this is inappropriate
86 # (e.g. when testing that a warning is enabled by a specific switch)
87 # should use -Wnone or/and -Wno-error
88 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
90 PATH="`pwd`@PATH_SEPARATOR@$PATH"
91 echo "$PATH"
92 # Some shells forget to export modified environment variables.
93 # (See note about `export' in the Autoconf manual.)
94 export PATH
96 for tool in : $required
98   # Check that each required tool is present.
99   case $tool in
100     :) ;;
101     bison)
102       # Since bison is required, we pick YACC for ./configure.
103       YACC='bison -y'
104       export YACC
105       echo "$me: running bison --version"
106       ( bison --version ) || exit 77
107       ;;
108     bzip2)
109       # Do not use --version, bzip2 still tries to compress stdin.
110       echo "$me: running bzip2 --help"
111       ( bzip2 --help ) || exit 77
112       ;;
113     etags)
114       # Exuberant Ctags will create a TAGS file even
115       # when asked for --help or --version.  (Emacs's etags
116       # does not have such problem.)  Use -o /dev/null
117       # to make sure we do not pollute the tests/ directory.
118       echo "$me: running etags --version -o /dev/null"
119       ( etags --version -o /dev/null ) || exit 77
120       ;;
121     GNUmake)
122       # Use --version AND -v, because SGI Make doesn't fail on --version.
123       # Also grep for GNU because newer versions of FreeBSD make do
124       # not complain about `--version' (they seem to silently ignore it).
125       echo "$me: running $MAKE --version -v | grep GNU"
126       ( $MAKE --version -v | grep GNU ) || exit 77
127       ;;
128     gcc)
129       # When gcc is required, export `CC=gcc' so that ./configure
130       # always use it.  This is important only when the user
131       # has defined CC in his environment, otherwise ./configure will
132       # prefer gcc to other compilers.
133       CC=gcc
134       export CC
135       echo "$me: running $CC --version"
136       ( $CC --version ) || exit 77
137       ;;
138     gcj)
139       GCJ=gcj
140       export GCJ
141       echo "$me: running $GCJ --version"
142       ( $GCJ --version ) || exit 77
143       ( $GCJ -v ) || exit 77
144       ;;
145     g++)
146       CXX=g++
147       export CXX
148       echo "$me: running $CXX --version"
149       ( $CXX --version ) || exit 77
150       ;;
151     icc)
152       CC=icc
153       export CC
154       # There is no way to ask *only* the compiler's version.
155       # This tool always wants to do something (by default
156       # it will try link *nothing* and complain it cannot find
157       # main(); funny).  Use -help so it does not try linking anything.
158       echo "$me: running $CC -V -help"
159       ( $CC -V -help ) || exit 77
160       ;;
161     makedepend)
162       echo "$me: running makedepend -f-"
163       ( makedepend -f- ) || exit 77
164       ;;
165     makeinfo-html)
166       # Make sure makeinfo understands --html.
167       echo "$me: running makeinfo --html --version"
168       ( makeinfo --html --version ) || exit 77
169       ;;
170     non-root)
171       # Skip this test case if the user is root.
172       # We try to append to a read-only file to detect this.
173       priv_check_temp=priv-check.$$
174       touch $priv_check_temp || exit 1
175       chmod a-w $priv_check_temp || exit 1
176       (echo foo >> $priv_check_temp) >/dev/null 2>&1
177       overwrite_status=$?
178       rm -f $priv_check_temp
179       test $overwrite_status = 0 && exit 77
180       ;;
181     python)
182       # Python doesn't support --version, it has -V
183       echo "$me: running python -V"
184       ( python -V ) || exit 77
185       ;;
186     ro-dir)
187       # Skip this test case if read-only directories aren't supported
188       # (e.g., under DOS.)
189       ro_dir_temp=ro_dir.$$
190       mkdir $ro_dir_temp || exit 1
191       chmod a-w $ro_dir_temp || exit 1
192       (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
193       create_status=$?
194       rm -rf $ro_dir_temp
195       test $create_status = 0 && exit 77
196       ;;
197     runtest)
198       # DejaGnu's runtest program. We rely on being able to specify
199       # the program on the runtest command-line. This requires
200       # DejaGnu 1.4.3 or later.
201       echo "$me: running runtest --version"
202       (runtest SOMEPROGRAM=someprogram --version) || exit 77
203       ;;
204     tex)
205       # No all versions of Tex support `--version', so we use
206       # a configure check.
207       test -n "@TEX@" || exit 77
208       ;;
209     texi2dvi-o)
210       # Texi2dvi supports `-o' since Texinfo 4.1.
211       echo "$me: running texi2dvi -o /dev/null --version"
212       ( texi2dvi -o /dev/null --version ) || exit 77
213       ;;
214     # Generic case: the tool must support --version.
215     *)
216       echo "$me: running $tool --version"
217       ( $tool --version ) || exit 77
218       ;;
219   esac
220 done
223 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
224 # of the test dir just won't work.
225 case "$srcdir" in
226  [\\/]* | ?:[\\/]*)
227     ;;
229  *)
230     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
231     ;;
232 esac
234 # We use a trap below for cleanup.  This requires us to go through
235 # hoops to get the right exit status transported through the signal.
236 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
237 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
238 # sh inside this function.
239 Exit ()
241   set +e
242   (exit $1)
243   exit $1
246 curdir=`pwd`
247 testSubDir=$me.dir
248 chmod -R u+rwx $testSubDir > /dev/null 2>&1
249 rm -rf $testSubDir > /dev/null 2>&1
250 mkdir $testSubDir
252 trap 'exit_status=$?
253   cd "$curdir"
254   case $exit_status,$keep_testdirs in
255   0,)
256     chmod -R a+rwx $testSubDir > /dev/null 2>&1
257     rm -rf "$testSubDir" ;;
258   esac
259   test "$signal" != 0 &&
260     echo "$as_me: caught signal $signal"
261   echo "$as_me: exit $exit_status"
262   exit $exit_status
263 ' 0
264 for signal in 1 2 13 15; do
265   trap 'signal='$signal'; { Exit 1; }' $signal
266 done
267 signal=0
269 # Copy in some files we need.
270 for file in install-sh missing depcomp; do
271    cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
272 done
274 cd ./$testSubDir
276 # Build appropriate environment in test directory.  Eg create
277 # configure.in, touch all necessary files, etc.
278 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
279 # still produces a valid configure.ac.  But then, tests running
280 # config.status really need to append AC_OUTPUT.
281 cat > configure.in << END
282 AC_INIT([$me], [1.0])
283 AM_INIT_AUTOMAKE
284 AC_CONFIG_FILES([Makefile])
287 # Unset some MAKE... variables that may cause $MAKE to act like a
288 # recursively invoked sub-make.  Any $MAKE invocation in a test is
289 # conceptually an independent invocation, not part of the main
290 # 'automake' build.
291 unset MFLAGS
292 unset MAKEFLAGS
293 unset MAKELEVEL
294 unset DESTDIR
296 echo "=== Running test $0"
298 # We might need extra macros, e.g., from Libtool or Gettext.
299 # Find them on the system.
300 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
301 # other `-I' directories added for libtool and gettext might contain
302 # files from an old version of Automake that we don't want to use.
303 # Use `-Wno-syntax' because we do not want our test suite to fail because
304 # some third-party .m4 file is underquoted.
305 case $required in
306   *libtool* | *gettext* )
307     aclocaldir='@prefix@/share/aclocal'
308     extra_includes=""
309     if test -f $aclocaldir/dirlist; then
310        extra_includes=`
311        <$aclocaldir/dirlist \
312        sed -ne 's/#.*//;s/[      ][      ]*$//g;s/..*/ -I &/p' |
313          tr -d '\n'`
314     else :; fi
316     libtool_found=no
317     gettext_found=no
318     for d in $extra_includes $aclocaldir ; do
319        test "x$d" != x-I || continue
320        if test -f "$d/libtool.m4"; then
321           libtool_found=yes
322        fi
323        if test -f "$d/gettext.m4"; then
324           gettext_found=yes
325        fi
326     done
327     case $required in
328       *libtool* ) test $libtool_found = yes || Exit 77 ;;
329       *gettext* ) test $gettext_found = yes || Exit 77 ;;
330     esac
331     # Libtool cannot cope with spaces in the build tree.  Our testsuite setup
332     # cannot cope with spaces in the source tree name for Libtool and gettext
333     # tests.
334     case $srcdir,`pwd` in
335       *\ * | *\ *) Exit 77 ;;
336     esac
337     ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
338     ;;
339 esac
341 testaclocaldir='@abs_top_srcdir@/m4'
343 # POSIX no longer requires 'egrep' and 'fgrep',
344 # but some hosts lack 'grep -E' and 'grep -F'.
345 EGREP='@EGREP@'
346 FGREP='@FGREP@'
348 # The amount we should wait after modifying files depends on the platform.
349 # For instance, Windows '95, '98 and ME have 2-second granularity
350 # and can be up to 3 seconds in the future w.r.t. the system clock.
351 sleep='sleep @MODIFICATION_DELAY@'
353 # The tests call `make -e' but we do not want $srcdir from the environment
354 # to override the definition from the Makefile.
355 testsrcdir=$srcdir
356 unset srcdir
358 # An old timestamp that can be given to a file, in "touch -t" format.
359 # The time stamp should be portable to all file systems of interest.
360 # Just for fun, choose the exact time of the announcement of the GNU project
361 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
362 old_timestamp=198309271735.59
364 # is_newest FILE FILES
365 # --------------------
366 # Return false if any file in FILES is newer than FILE.
367 # Resolve ties in favor of FILE.
368 is_newest ()
370   is_newest_files=`find "$@" -newer "$1"`
371   test -z "$is_newest_files"
375 # AUTOMAKE_run status [options...]
376 # --------------------------------
377 # Run Automake with OPTIONS, and fail if automake
378 # does not exit with STATUS.
379 AUTOMAKE_run ()
381   expected_exitcode=$1
382   shift
383   exitcode=0
384   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
385   cat stderr >&2
386   cat stdout
387   test $exitcode = $expected_exitcode || Exit 1
390 # AUTOMAKE_fails [options...]
391 # ---------------------------
392 # Run Automake with OPTIONS, and fail if automake
393 # does not exit with STATUS.
394 AUTOMAKE_fails ()
396   AUTOMAKE_run 1 ${1+"$@"}
399 # Turn on shell traces when VERBOSE is set.
400 if test -n "$VERBOSE"; then
401   set -x
402 else
403   :