b82f4eb9d48b683fbe9c2e5a7122b609af1225b8
[platform/upstream/automake.git] / tests / defs.in
1 # -*- shell-script -*-
2 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 # Free Software Foundation, Inc.
4 #
5 # This file is part of GNU Automake.
6 #
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.
11 #
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.
16 #
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.
21
22 # Defines for Automake testing environment.
23 # Tom Tromey <tromey@cygnus.com>
24
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
29 }
30
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=.
37 fi
38
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
43 }
44
45 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
46
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
51 }
52
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
60
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       ro-dir)
126         # Skip this test case if read-only directories aren't supported
127         # (e.g., under DOS.)
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
132         create_status=$?
133         rm -rf $ro_dir_temp
134         test $create_status = 0 && exit 77
135         ;;
136       tex)
137         # No all versions of Tex support `--version', so we use
138         # a configure check.
139         test -n "@TEX@" || exit 77
140         ;;
141       texi2dvi-o)
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
145         ;;
146       # Generic case: the tool must support --version.
147       *)
148         echo "$me: running $tool --version"
149         ( $tool --version ) || exit 77
150         ;;
151     esac
152     # Additional variables to define if some $tool is required.
153     case $tool in
154       gcc)
155         ;;
156     esac
157   done
158 fi
159
160 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
161 # of the test dir just won't work.
162 case "$srcdir" in
163  [\\/]* | ?:[\\/]*)
164     ;;
165
166  *)
167     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
168     ;;
169 esac
170
171 chmod -R a+rwx testSubDir > /dev/null 2>&1
172 rm -rf testSubDir > /dev/null 2>&1
173 mkdir testSubDir
174
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
178 done
179
180 cd ./testSubDir
181
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])
189 AM_INIT_AUTOMAKE
190 AC_CONFIG_FILES([Makefile])
191 END
192
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
196 # 'automake' build.
197 unset MFLAGS
198 unset MAKEFLAGS
199 unset MAKELEVEL
200 unset DESTDIR
201
202 echo "=== Running test $0"
203
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
209    export perllibdir
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"
214 fi
215
216 # See how aclocal should be run.
217 if test -z "$ACLOCAL"; then
218    perllibdir=$srcdir/../lib
219    export perllibdir
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
222    # path too.
223    ACLOCAL="$PERL `pwd`/../../aclocal -I `pwd`/../../m4 --acdir=$srcdir/../m4"
224 fi
225
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'
232 extra_includes=""
233 if [ -f $aclocaldir/dirlist ] ; then
234    extra_includes=`(tmp_inc=""
235    while read LINE ; do
236       tmp_inc="$tmp_inc -I $LINE"
237    done
238    echo $tmp_inc) < $aclocaldir/dirlist`
239 fi
240 case $required in
241   *libtool* )
242     libtool_found=no
243     for d in $extra_includes $aclocaldir ; do
244        if [ "x$d" != "x-I" ] && [ -f "$d/libtool.m4" ] ; then
245           libtool_found=yes
246        fi
247     done
248     test "x$libtool_found" = "xyes" || exit 77
249     ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
250     ;;
251   *gettext* )
252     gettext_found=no
253     for d in $extra_includes $aclocaldir ; do
254        if [ "x$d" != "x-I" ] && [ -f "$d/gettext.m4" ] ; then
255           gettext_found=yes
256        fi
257     done
258     test "x$gettext_found" = "xyes" || exit 77
259     ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
260     ;;
261 esac
262
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
266
267 # POSIX no longer requires 'egrep' and 'fgrep',
268 # but some hosts lack 'grep -E' and 'grep -F'.
269 EGREP='@EGREP@'
270 FGREP='@FGREP@'
271
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.
276 sleep='sleep 5'
277
278 # The tests call `make -e' but we do not want $srcdir from the evironment
279 # to override the definition from the Makefile.
280 testsrcdir=$srcdir
281 unset srcdir
282
283 # Turn on shell traces when VERBOSE=x.
284 if test "x$VERBOSE" = xx; then
285   set -x
286 else
287   :
288 fi
289 pwd