* configure.in, NEWS: Bump version to 1.8.3.
[automake.git] / tests / defs.in
blobd18829e370e3fd1e8eb6cc156d83a23e7d1b76c1
1 # -*- shell-script -*-
2 # @configure_input@
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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)
12 # any later version.
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., 59 Temple Place - Suite 330,
22 # Boston, MA 02111-1307, 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
30   emulate sh
31   NULLCMD=:
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
36   set -o posix
39 # Ensure we are running from the right directory.
40 test -f ./defs || {
41    echo "defs: not found in current directory" 1>&2
42    exit 1
45 # If srcdir is not set, then we are not running from `make check', be verbose.
46 if test -z "$srcdir"; then
47    test -z "$VERBOSE" && VERBOSE=x
48    # compute $srcdir.
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
56    exit 1
59 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
61 # See how redirections should work.  User can set VERBOSE to see all
62 # output.
63 test -z "$VERBOSE" && {
64    exec > /dev/null 2>&1
67 # Make sure we override the user shell.
68 SHELL='@SHELL@'
69 export 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="@AUTOCONF@"
74 test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
75 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
76 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
77 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@"
78 # See how Automake should be run.  We put --foreign as the default
79 # strictness to avoid having to create lots and lots of files.  A test
80 # can override this by specifying a different strictness.  Use -Wall
81 # -Werror by default.  Tests for which this is inappropriate
82 # (e.g. when testing that a warning is enabled by a specific switch)
83 # should use -Wnone or/and -Wno-error
84 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
86 PATH=`pwd`:$PATH
87 echo $PATH
89 if test -n "$required"
90 then
91   for tool in $required
92   do
93     # Check that each required tool is present.
94     case $tool in
95       bison)
96         # Since bison is required, we pick YACC for ./configure.
97         YACC='bison -y'
98         export YACC
99         echo "$me: running bison --version"
100         ( bison --version ) || exit 77
101         ;;
102       bzip2)
103         # Do not use --version, bzip2 still tries to compress stdin.
104         echo "$me: running bzip2 --help"
105         ( bzip2 --help ) || exit 77
106         ;;
107       etags)
108         # Exuberant Ctags will create a TAGS file even
109         # when asked for --help or --version.  (Emacs's etags
110         # does not have such problem.)  Use -o /dev/null
111         # to make sure we do not pollute the tests/ directory.
112         echo "$me: running etags --version -o /dev/null"
113         ( etags --version -o /dev/null ) || exit 77
114         ;;
115       GNUmake)
116         # Use --version and -v, because SGI Make doesn't fail on --version.
117         echo "$me: running $MAKE --version -v"
118         ( $MAKE --version -v ) || exit 77
119         ;;
120       gcc)
121         # When gcc is required, export `CC=gcc' so that ./configure
122         # always use it.  This is important only when the user
123         # has defined CC in his environment, otherwise ./configure will
124         # prefer gcc to other compilers.
125         CC=gcc
126         export CC
127         echo "$me: running $CC --version"
128         ( $CC --version ) || exit 77
129         ;;
130       g++)
131         CXX=g++
132         export CXX
133         echo "$me: running $CXX --version"
134         ( $CXX --version ) || exit 77
135         ;;
136       icc)
137         CC=icc
138         export CC
139         # There is no way to ask *only* the compiler's version.
140         # This tool always want to do something (by default
141         # it will try link *nothing* and complain it cannot find
142         # main(); funny).  -dryrun is a workaround.
143         echo "$me: running $CC -V -dryrun"
144         ( $CC -V -dryrun ) || exit 77
145         ;;
146       makedepend)
147         echo "$me: running makedepend -f-"
148         ( makedepend -f- ) || exit 77
149         ;;
150       makeinfo-html)
151         # Make sure makeinfo understands --html.
152         echo "$me: running makeinfo --html --version"
153         ( makeinfo --html --version ) || exit 77
154         ;;
155       non-root)
156         # Skip this test case if the user is root.
157         # We try to append to a read-only file to detect this.
158         priv_check_temp=priv-check.$$
159         touch $priv_check_temp || exit 1
160         chmod a-w $priv_check_temp || exit 1
161         (echo foo >> $priv_check_temp) >/dev/null 2>&1
162         overwrite_status=$?
163         rm -f $priv_check_temp
164         test $overwrite_status = 0 && exit 77
165         ;;
166       python)
167         # Python doesn't support --version, it has -V
168         echo "$me: running python -V"
169         ( python -V ) || exit 77
170         ;;
171       ro-dir)
172         # Skip this test case if read-only directories aren't supported
173         # (e.g., under DOS.)
174         ro_dir_temp=ro_dir.$$
175         mkdir $ro_dir_temp || exit 1
176         chmod a-w $ro_dir_temp || exit 1
177         (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
178         create_status=$?
179         rm -rf $ro_dir_temp
180         test $create_status = 0 && exit 77
181         ;;
182       runtest)
183         # DejaGnu's runtest program. We rely on being able to specify
184         # the program on the runtest command-line. This requires
185         # DejaGnu 1.4.3 or later.
186         echo "$me: running runtest --version"
187         (runtest SOMEPROGRAM=someprogram --version) || exit 77
188         ;;
189       tex)
190         # No all versions of Tex support `--version', so we use
191         # a configure check.
192         test -n "@TEX@" || exit 77
193         ;;
194       texi2dvi-o)
195         # Texi2dvi supports `-o' since Texinfo 4.1.
196         echo "$me: running texi2dvi -o /dev/null --version"
197         ( texi2dvi -o /dev/null --version ) || exit 77
198         ;;
199       # Generic case: the tool must support --version.
200       *)
201         echo "$me: running $tool --version"
202         ( $tool --version ) || exit 77
203         ;;
204     esac
205     # Additional variables to define if some $tool is required.
206     case $tool in
207       gcc)
208         ;;
209     esac
210   done
213 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
214 # of the test dir just won't work.
215 case "$srcdir" in
216  [\\/]* | ?:[\\/]*)
217     ;;
219  *)
220     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
221     ;;
222 esac
224 chmod -R a+rwx testSubDir > /dev/null 2>&1
225 rm -rf testSubDir > /dev/null 2>&1
226 mkdir testSubDir
228 # Copy in some files we need.
229 for file in install-sh missing depcomp; do
230    cp $srcdir/../lib/$file testSubDir/$file || exit 1
231 done
233 cd ./testSubDir
235 # Build appropriate environment in test directory.  Eg create
236 # configure.in, touch all necessary files, etc.
237 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
238 # still produces a valid configure.ac.  But then, tests running
239 # config.status really need to append AC_OUTPUT.
240 cat > configure.in << END
241 AC_INIT([$me], [1.0])
242 AM_INIT_AUTOMAKE
243 AC_CONFIG_FILES([Makefile])
246 # Unset some MAKE... variables that may cause $MAKE to act like a
247 # recursively invoked sub-make.  Any $MAKE invocation in a test is
248 # conceptually an independent invocation, not part of the main
249 # 'automake' build.
250 unset MFLAGS
251 unset MAKEFLAGS
252 unset MAKELEVEL
253 unset DESTDIR
255 echo "=== Running test $0"
257 # We might need extra macros, e.g., from Libtool or Gettext.
258 # Find them on the system.
259 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
260 # other `-I' directories added for libtool and gettext might contain
261 # files from an old version of Automake that we don't want to use.
262 aclocaldir='@prefix@/share/aclocal'
263 extra_includes=""
264 if [ -f $aclocaldir/dirlist ] ; then
265    extra_includes=`(tmp_inc=""
266    while read LINE ; do
267       tmp_inc="$tmp_inc -I $LINE"
268    done
269    echo $tmp_inc) < $aclocaldir/dirlist`
271 case $required in
272   *libtool* )
273     libtool_found=no
274     for d in $extra_includes $aclocaldir ; do
275        if [ "x$d" != "x-I" ] && [ -f "$d/libtool.m4" ] ; then
276           libtool_found=yes
277        fi
278     done
279     test "x$libtool_found" = "xyes" || exit 77
280     ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
281     ;;
282   *gettext* )
283     gettext_found=no
284     for d in $extra_includes $aclocaldir ; do
285        if [ "x$d" != "x-I" ] && [ -f "$d/gettext.m4" ] ; then
286           gettext_found=yes
287        fi
288     done
289     test "x$gettext_found" = "xyes" || exit 77
290     ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
291     ;;
292 esac
294 # POSIX no longer requires 'egrep' and 'fgrep',
295 # but some hosts lack 'grep -E' and 'grep -F'.
296 EGREP='@EGREP@'
297 FGREP='@FGREP@'
299 # The amount we should wait after modifying files depends on the platform.
300 # For instance, Windows '95, '98 and ME have 2-second granularity
301 # and can be up to 3 seconds in the future w.r.t. the system clock.
302 sleep='sleep @MODIFICATION_DELAY@'
304 # The tests call `make -e' but we do not want $srcdir from the environment
305 # to override the definition from the Makefile.
306 testsrcdir=$srcdir
307 unset srcdir
309 # AUTOMAKE_run status [options...]
310 # --------------------------------
311 # Run Automake with OPTIONS, and fail if automake
312 # does not exit with STATUS.
313 AUTOMAKE_run ()
315   expected_exitcode=$1
316   shift
317   exitcode=0
318   $AUTOMAKE ${1+"$@"} 2>stderr >stdout || exitcode=$?
319   cat stderr
320   cat stdout
321   test $exitcode = $expected_exitcode || exit 1
324 # AUTOMAKE_fails [options...]
325 # ---------------------------
326 # Run Automake with OPTIONS, and fail if automake
327 # does not exit with STATUS.
328 AUTOMAKE_fails ()
330   AUTOMAKE_run 1 ${1+"$@"}
333 # Turn on shell traces when VERBOSE=x.
334 if test "x$VERBOSE" = xx; then
335   set -x
336 else
337   :