* configure.in: Bump version to 1.7.2c.
[automake.git] / tests / defs.in
blob08e9c788b04bd2cfd779198895a9bf17b5205d55
1 # -*- shell-script -*-
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)
10 # any later version.
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.
26 test -f ./defs || {
27    echo "defs: not found in current directory" 1>&2
28    exit 1
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
34    # compute $srcdir.
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
42    exit 1
45 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
47 # See how redirections should work.  User can set VERBOSE to see all
48 # output.
49 test -z "$VERBOSE" && {
50    exec > /dev/null 2>&1
53 SHELL='@SHELL@'
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"
62 then
63   for tool in $required
64   do
65     # Check that each required tool is present.
66     case $tool in
67       bison)
68         # Since bison is required, we pick YACC for ./configure.
69         YACC='bison -y'
70         export YACC
71         echo "$me: running bison --version"
72         ( bison --version ) || exit 77
73         ;;
74       GNUmake)
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
78         ;;
79       gcc)
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.
84         CC=gcc
85         export CC
86         echo "$me: running $CC --version"
87         ( $CC --version ) || exit 77
88         ;;
89       g++)
90         CXX=g++
91         export CXX
92         echo "$me: running $CXX --version"
93         ( $CXX --version ) || exit 77
94         ;;
95       icc)
96         CC=icc
97         export CC
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
104         ;;
105       makedepend)
106         echo "$me: running makedepend -f-"
107         ( makedepend -f- ) || exit 77
108         ;;
109       non-root)
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
116         overwrite_status=$?
117         rm -f $priv_check_temp
118         test $overwrite_status = 0 && exit 77
119         ;;
120       python)
121         # Python doesn't support --version, it has -V
122         echo "$me: running python -V"
123         ( python -V ) || exit 77
124         ;;
125       tex)
126         # No all versions of Tex support `--version', so we use
127         # a configure check.
128         test -n "@TEX@" || exit 77
129         ;;
130       texi2dvi-o)
131         # Texi2dvi supports `-o' since Texinfo 4.1.
132         echo "$me: running texi2dvi -o /dev/null --version"
133         ( texi2dvi -o /dev/null --version ) || exit 77
134         ;;
135       # Generic case: the tool must support --version.
136       *)
137         echo "$me: running $tool --version"
138         ( $tool --version ) || exit 77
139         ;;
140     esac
141     # Additional variables to define if some $tool is required.
142     case $tool in
143       gcc)
144         ;;
145     esac
146   done
149 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
150 # of the test dir just won't work.
151 case "$srcdir" in
152  [\\/]* | ?:[\\/]*)
153     ;;
155  *)
156     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
157     ;;
158 esac
160 chmod -R a+rwx testSubDir > /dev/null 2>&1
161 rm -rf testSubDir > /dev/null 2>&1
162 mkdir testSubDir
164 # Copy in some files we need.
165 for file in install-sh mkinstalldirs missing depcomp; do
166    cp $srcdir/../lib/$file testSubDir/$file || exit 1
167 done
169 cd ./testSubDir
171 # Build appropriate environment in test directory.  Eg create
172 # configure.in, touch all necessary files, etc.
173 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
174 # still produces a valid configure.ac.  But then, tests running
175 # config.status really need to append AC_OUTPUT.
176 cat > configure.in << END
177 AC_INIT([$me], [1.0])
178 AM_INIT_AUTOMAKE
179 AC_CONFIG_FILES([Makefile])
182 # Unset some MAKE... variables that may cause $MAKE to act like a
183 # recursively invoked sub-make.  Any $MAKE invocation in a test is
184 # conceptually an independent invocation, not part of the main
185 # 'automake' build.
186 unset MFLAGS
187 unset MAKEFLAGS
188 unset MAKELEVEL
189 unset DESTDIR
191 echo "=== Running test $0"
193 # See how Automake should be run.  We put --foreign as the default
194 # strictness to avoid having to create lots and lots of files.  A test
195 # can override this by specifying a different strictness.
196 if test -z "$AUTOMAKE"; then
197    perllibdir=$srcdir/../lib
198    export perllibdir
199    # Use -Wall -Werror by default.  Tests for which this is inappropriate
200    # (e.g. when testing that a warning is enabled by a specific switch)
201    # should use -Wnone or/and -Wno-error
202    AUTOMAKE="$PERL `pwd`/../../automake --libdir=$srcdir/../lib --foreign -Werror -Wall"
205 # See how aclocal should be run.
206 if test -z "$ACLOCAL"; then
207    perllibdir=$srcdir/../lib
208    export perllibdir
209    # Most of the files are in $srcdir/../m4.  However amversion.m4 is
210    # generated in ../m4, so we include that directory in the search
211    # path too.
212    ACLOCAL="$PERL `pwd`/../../aclocal -I `pwd`/../../m4 --acdir=$srcdir/../m4"
215 # We might need extra macros, e.g., from Libtool or Gettext.
216 # Find them on the system.
217 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
218 # other `-I' directories added for libtool and gettext might contain
219 # files from an old version of Automake that we don't want to use.
220 aclocaldir='@prefix@/share/aclocal'
221 extra_includes=""
222 if [ -f $aclocaldir/dirlist ] ; then
223    extra_includes=`(tmp_inc=""
224    while read LINE ; do
225       tmp_inc="$tmp_inc -I $LINE"
226    done
227    echo $tmp_inc) < $aclocaldir/dirlist`
229 case $required in
230   *libtool* )
231     libtool_found=no
232     for d in $extra_includes $aclocaldir ; do
233        if [ "x$d" != "x-I" ] && [ -f "$d/libtool.m4" ] ; then
234           libtool_found=yes
235        fi
236     done
237     test "x$libtool_found" = "xyes" || exit 77
238     ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
239     ;;
240   *gettext* )
241     gettext_found=no
242     for d in $extra_includes $aclocaldir ; do
243        if [ "x$d" != "x-I" ] && [ -f "$d/gettext.m4" ] ; then
244           gettext_found=yes
245        fi
246     done
247     test "x$gettext_found" = "xyes" || exit 77
248     ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
249     ;;
250 esac
252 # Export AUTOMAKE and ACLOCAL so that rebuild rules in Makefiles
253 # generated for the tests do not use the installed tools.
254 export AUTOMAKE ACLOCAL
256 # POSIX no longer requires 'egrep' and 'fgrep',
257 # but some hosts lack 'grep -E' and 'grep -F'.
258 EGREP='@EGREP@'
259 FGREP='@FGREP@'
261 # On Windows '95, '98 and ME, files modifications have 2-seconds
262 # granularity and can be up to 3 seconds in the future w.r.t. the
263 # system clock.  When it is important to ensure one file is older
264 # than another we wait at least 5 seconds between creations.
265 sleep='sleep 5'
267 # The tests call `make -e' but we do not want $srcdir from the evironment
268 # to override the definition from the Makefile.
269 testsrcdir=$srcdir
270 unset srcdir
272 # Turn on shell traces when VERBOSE=x.
273 if test "x$VERBOSE" = xx; then
274   set -x
275 else
276   :