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