Merge branch 'msvc'
[platform/upstream/automake.git] / tests / defs.in
1 # -*- shell-script -*-
2 # @configure_input@
3 #
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 #
7 # This program 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 # This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 # Defines for Automake testing environment.
21 # Tom Tromey <tromey@cygnus.com>
22
23 # Absolutely necessary variable(s).
24 srcdir=${srcdir-'@abs_srcdir@'}
25
26 # Protect this file against multiple inclusion, useful for generated tests.
27 if test x"$am_skip_defs" = xyes; then
28   unset am_skip_defs
29
30 else # Do proper testcase setup.
31
32 # Be more Bourne compatible.
33 # (Snippet copied from configure's initialization in Autoconf 2.64)
34 DUALCASE=1; export DUALCASE # for MKS sh
35 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
36   emulate sh
37   NULLCMD=:
38   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
39   # is contrary to our usage.  Disable this feature.
40   alias -g '${1+"$@"}'='"$@"'
41   setopt NO_GLOB_SUBST
42 else
43   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
44 fi
45
46 # Ensure we are running from the right directory.
47 test -f ./defs || {
48    echo "defs: not found in current directory" 1>&2
49    exit 1
50 }
51
52 # Ensure $srcdir is set correctly.
53 test -f "$srcdir/defs.in" || {
54    echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
55    exit 1
56 }
57
58 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
59
60 # Make sure we override the user shell.
61 SHELL='@SHELL@'
62 export SHELL
63 # User can override various tools used.
64 test -z "$PERL" && PERL='@PERL@'
65 test -z "$MAKE" && MAKE=make
66 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
67 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
68 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
69 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
70 # Use -Werror because this also turns some Perl warnings into error.
71 # (Tests for which this is inappropriate should use -Wno-error.)
72 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
73 # Extra flags to pass to aclocal before all other flags added by this script.
74 ACLOCAL_TESTSUITE_FLAGS=
75 export ACLOCAL_TESTSUITE_FLAGS
76
77 # See how Automake should be run.  We put --foreign as the default
78 # strictness to avoid having to create lots and lots of files.  A test
79 # can override this by specifying a different strictness.  Use -Wall
80 # -Werror by default.  Tests for which this is inappropriate
81 # (e.g. when testing that a warning is enabled by a specific switch)
82 # should use -Wnone or/and -Wno-error
83 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
84
85 PATH="`pwd`@PATH_SEPARATOR@$PATH"
86 echo "$PATH"
87 # Some shells forget to export modified environment variables.
88 # (See note about `export' in the Autoconf manual.)
89 export PATH
90
91 for tool in : $required
92 do
93   # Check that each required tool is present.
94   case $tool in
95     :) ;;
96     bison)
97       # Since bison is required, we pick YACC for ./configure.
98       YACC='bison -y'
99       export YACC
100       echo "$me: running bison --version"
101       ( bison --version ) || exit 77
102       ;;
103     bzip2)
104       # Do not use --version, bzip2 still tries to compress stdin.
105       echo "$me: running bzip2 --help"
106       ( bzip2 --help ) || exit 77
107       ;;
108     cl)
109       CC=cl
110       export CC
111       echo "$me: running $CC -?"
112       ( $CC -? ) || exit 77
113       ;;
114     etags)
115       # Exuberant Ctags will create a TAGS file even
116       # when asked for --help or --version.  (Emacs's etags
117       # does not have such problem.)  Use -o /dev/null
118       # to make sure we do not pollute the tests/ directory.
119       echo "$me: running etags --version -o /dev/null"
120       ( etags --version -o /dev/null ) || exit 77
121       ;;
122     GNUmake)
123       # Use --version AND -v, because SGI Make doesn't fail on --version.
124       # Also grep for GNU because newer versions of FreeBSD make do
125       # not complain about `--version' (they seem to silently ignore it).
126       echo "$me: running $MAKE --version -v | grep GNU"
127       ( $MAKE --version -v | grep GNU ) || exit 77
128       ;;
129     gcc)
130       # When gcc is required, export `CC=gcc' so that ./configure
131       # always use it.  This is important only when the user
132       # has defined CC in his environment, otherwise ./configure will
133       # prefer gcc to other compilers.
134       CC=gcc
135       export CC
136       echo "$me: running $CC --version"
137       ( $CC --version ) || exit 77
138       ;;
139     gcj)
140       GCJ=gcj
141       export GCJ
142       echo "$me: running $GCJ --version"
143       ( $GCJ --version ) || exit 77
144       ( $GCJ -v ) || exit 77
145       ;;
146     g++)
147       CXX=g++
148       export CXX
149       echo "$me: running $CXX --version"
150       ( $CXX --version ) || exit 77
151       ;;
152     icc)
153       CC=icc
154       export CC
155       # There is no way to ask *only* the compiler's version.
156       # This tool always wants to do something (by default
157       # it will try link *nothing* and complain it cannot find
158       # main(); funny).  Use -help so it does not try linking anything.
159       echo "$me: running $CC -V -help"
160       ( $CC -V -help ) || exit 77
161       ;;
162     makedepend)
163       echo "$me: running makedepend -f-"
164       ( makedepend -f- ) || exit 77
165       ;;
166     makeinfo-html)
167       # Make sure makeinfo understands --html.
168       echo "$me: running makeinfo --html --version"
169       ( makeinfo --html --version ) || exit 77
170       ;;
171     non-root)
172       # Skip this test case if the user is root.
173       # We try to append to a read-only file to detect this.
174       priv_check_temp=priv-check.$$
175       touch $priv_check_temp || exit 1
176       chmod a-w $priv_check_temp || exit 1
177       (echo foo >> $priv_check_temp) >/dev/null 2>&1
178       overwrite_status=$?
179       rm -f $priv_check_temp
180       test $overwrite_status = 0 && exit 77
181       ;;
182     perl-threads)
183       # Skip with Devel::Cover: it cannot cope with threads.
184       test "$WANT_NO_THREADS" = yes && exit 77
185       ;;
186     python)
187       # Python doesn't support --version, it has -V
188       echo "$me: running python -V"
189       ( python -V ) || exit 77
190       ;;
191     ro-dir)
192       # Skip this test case if read-only directories aren't supported
193       # (e.g., under DOS.)
194       ro_dir_temp=ro_dir.$$
195       mkdir $ro_dir_temp || exit 1
196       chmod a-w $ro_dir_temp || exit 1
197       (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
198       create_status=$?
199       rm -rf $ro_dir_temp
200       test $create_status = 0 && exit 77
201       ;;
202     rst2html)
203       # Try the variants that are tried in check.am.
204       while :; do
205         for r2h in $RST2HTML rst2html rst2html.py; do
206           echo "$me: running $r2h --version"
207           $r2h --version && break 2
208         done
209         exit 77
210       done
211       ;;
212     runtest)
213       # DejaGnu's runtest program. We rely on being able to specify
214       # the program on the runtest command-line. This requires
215       # DejaGnu 1.4.3 or later.
216       echo "$me: running runtest --version"
217       (runtest SOMEPROGRAM=someprogram --version) || exit 77
218       ;;
219     tex)
220       # No all versions of Tex support `--version', so we use
221       # a configure check.
222       test -n "@TEX@" || exit 77
223       ;;
224     texi2dvi-o)
225       # Texi2dvi supports `-o' since Texinfo 4.1.
226       echo "$me: running texi2dvi -o /dev/null --version"
227       ( texi2dvi -o /dev/null --version ) || exit 77
228       ;;
229     # Generic case: the tool must support --version.
230     *)
231       echo "$me: running $tool --version"
232       ( $tool --version ) || exit 77
233       ;;
234   esac
235 done
236
237
238 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
239 # of the test dir just won't work.
240 case "$srcdir" in
241  [\\/]* | ?:[\\/]*)
242     ;;
243
244  *)
245     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
246     ;;
247 esac
248
249 # We use a trap below for cleanup.  This requires us to go through
250 # hoops to get the right exit status transported through the signal.
251 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
252 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
253 # sh inside this function.
254 Exit ()
255 {
256   set +e
257   (exit $1)
258   exit $1
259 }
260
261 curdir=`pwd`
262 testSubDir=$me.dir
263 test ! -d $testSubDir || {
264   find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
265   rm -rf $testSubDir
266 }
267 mkdir $testSubDir
268
269 sh_errexit_works=@sh_errexit_works@
270 if test "$sh_errexit_works" = yes; then
271   trap 'exit_status=$?
272     set +e
273     cd "$curdir"
274     case $exit_status,$keep_testdirs in
275     0,)
276       find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
277       rm -rf $testSubDir
278       ;;
279     esac
280     test "$signal" != 0 &&
281       echo "$me: caught signal $signal"
282     echo "$me: exit $exit_status"
283     exit $exit_status
284   ' 0
285   for signal in 1 2 13 15; do
286     trap 'signal='$signal'; { Exit 1; }' $signal
287   done
288 fi
289 signal=0
290
291 # Copy in some files we need.
292 for file in install-sh missing depcomp; do
293    cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
294 done
295
296 cd ./$testSubDir
297
298 # Build appropriate environment in test directory.  Eg create
299 # configure.in, touch all necessary files, etc.
300 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
301 # still produces a valid configure.ac.  But then, tests running
302 # config.status really need to append AC_OUTPUT.
303 {
304   echo "AC_INIT([$me], [1.0])"
305   if test x"$parallel_tests" = x"yes"; then
306     echo "AM_INIT_AUTOMAKE([parallel-tests])"
307   else
308     echo "AM_INIT_AUTOMAKE"
309   fi
310   echo "AC_CONFIG_FILES([Makefile])"
311 } >configure.in
312
313 # Unset some MAKE... variables that may cause $MAKE to act like a
314 # recursively invoked sub-make.  Any $MAKE invocation in a test is
315 # conceptually an independent invocation, not part of the main
316 # 'automake' build.
317 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
318 # Unset verbosity flag.
319 unset V
320 # Also unset variables that will let `make -e install' divert
321 # files into unwanted directories.
322 unset DESTDIR
323 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
324 unset htmldir includedir infodir libdir libexecdir localedir mandir
325 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
326 # Also unset variables that control our test driver.  While not
327 # conceptually independent, they cause some changed semantics we
328 # need to control (and test for) in some of the tests to ensure
329 # backward-compatible behavior.
330 unset DISABLE_HARD_ERRORS
331 unset TESTS
332 unset TEST_LOG_COMPILER
333 unset TEST_LOGS
334 unset RECHECK_LOGS
335 unset VERBOSE
336
337 echo "=== Running test $0"
338
339 # We might need extra macros, e.g., from Libtool or Gettext.
340 # Find them on the system.
341 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
342 # other `-I' directories added for libtool and gettext might contain
343 # files from an old version of Automake that we don't want to use.
344 # Use `-Wno-syntax' because we do not want our test suite to fail because
345 # some third-party .m4 file is underquoted.
346 case $required in
347   *libtool* | *gettext* )
348     aclocaldir='@prefix@/share/aclocal'
349     extra_includes=""
350     if test -f $aclocaldir/dirlist; then
351        extra_includes=`
352        <$aclocaldir/dirlist \
353        sed  's/#.*//;s/[         ][      ]*$//g' \
354        | while read dir; do test ! -d "$dir" || echo "-I $dir"; done`
355     else :; fi
356
357     libtool_found=no
358     gettext_found=no
359     for d in $extra_includes $aclocaldir ; do
360        test "x$d" != x-I || continue
361        if test -f "$d/libtool.m4"; then
362           libtool_found=yes
363        fi
364        if test -f "$d/gettext.m4"; then
365           gettext_found=yes
366        fi
367     done
368     case $required in
369       *libtool* ) test $libtool_found = yes || Exit 77 ;;
370       *gettext* ) test $gettext_found = yes || Exit 77 ;;
371     esac
372     # Libtool cannot cope with spaces in the build tree.  Our testsuite setup
373     # cannot cope with spaces in the source tree name for Libtool and gettext
374     # tests.
375     case $srcdir,`pwd` in
376       *\ * | *\ *) Exit 77 ;;
377     esac
378     ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
379     ;;
380 esac
381
382 testaclocaldir='@abs_top_srcdir@/m4'
383
384 # POSIX no longer requires 'egrep' and 'fgrep',
385 # but some hosts lack 'grep -E' and 'grep -F'.
386 EGREP='@EGREP@'
387 FGREP='@FGREP@'
388
389 # The amount we should wait after modifying files depends on the platform.
390 # For instance, Windows '95, '98 and ME have 2-second granularity
391 # and can be up to 3 seconds in the future w.r.t. the system clock.
392 sleep='sleep @MODIFICATION_DELAY@'
393
394 # The tests call `make -e' but we do not want $srcdir from the environment
395 # to override the definition from the Makefile.
396 testsrcdir=$srcdir
397 unset srcdir
398
399 # An old timestamp that can be given to a file, in "touch -t" format.
400 # The time stamp should be portable to all file systems of interest.
401 # Just for fun, choose the exact time of the announcement of the GNU project
402 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
403 old_timestamp=198309271735.59
404
405 # is_newest FILE FILES
406 # --------------------
407 # Return false if any file in FILES is newer than FILE.
408 # Resolve ties in favor of FILE.
409 is_newest ()
410 {
411   is_newest_files=`find "$@" -newer "$1"`
412   test -z "$is_newest_files"
413 }
414
415
416 # AUTOMAKE_run status [options...]
417 # --------------------------------
418 # Run Automake with OPTIONS, and fail if automake
419 # does not exit with STATUS.
420 AUTOMAKE_run ()
421 {
422   expected_exitcode=$1
423   shift
424   exitcode=0
425   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
426   cat stderr >&2
427   cat stdout
428   test $exitcode = $expected_exitcode || Exit 1
429 }
430
431 # AUTOMAKE_fails [options...]
432 # ---------------------------
433 # Run Automake with OPTIONS, and fail if automake
434 # does not exit with STATUS.
435 AUTOMAKE_fails ()
436 {
437   AUTOMAKE_run 1 ${1+"$@"}
438 }
439
440 # Turn on shell traces.
441 set -x
442
443 pwd
444
445 fi # Proper testcase setup.