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