Merge branch 'maint' into msvc
[platform/upstream/automake.git] / tests / defs.in
index da744c3..2959f8b 100644 (file)
@@ -2,7 +2,7 @@
 # @configure_input@
 #
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# 2005, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -34,6 +34,18 @@ else
   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
 fi
 
+# A single whitespace character.
+sp=' '
+# A tabulation character.
+tab='  '
+# A newline character.
+nl='
+'
+
+# As autoconf-generated configure scripts do, ensure that IFS
+# is defined initially, so that saving and restoring $IFS works.
+IFS=$sp$tab$nl
+
 # Ensure we are running from the right directory.
 test -f ./defs || {
    echo "defs: not found in current directory" 1>&2
@@ -52,7 +64,32 @@ test -f "$srcdir/defs.in" || {
    exit 1
 }
 
-me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
+# The name of the current test (without the `.test' suffix).
+# Test scripts can override it if they need to (but this should
+# be done carefully, and *before* including ./defs).
+if test -z "$me"; then
+  me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
+elif env | grep '^me=' >/dev/null; then
+  echo "$0: variable \`me' is set in the environment: this is unsafe" >&2
+  exit 99
+fi
+
+# Check that the environment is properly sanitized.
+for var in required parallel_tests; do
+  if env | grep "^$var=" >/dev/null; then
+    echo "$me: variable \`$var' is set in the environment:" \
+         "this is unsafe" >&2
+    exit 99
+  fi
+done
+unset var
+
+# This might be used in testcases checking distribution-related features.
+# Test scripts are free to override this if they need to.
+distdir=$me-1.0
+
+APIVERSION='@APIVERSION@'
+PATH_SEPARATOR='@PATH_SEPARATOR@'
 
 # Make sure we override the user shell.
 SHELL='@SHELL@'
@@ -61,15 +98,14 @@ export SHELL
 test -z "$PERL" && PERL='@PERL@'
 test -z "$MAKE" && MAKE=make
 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
+test -z "$AUTOM4TE" && AUTOM4TE="@am_AUTOM4TE@"
+test -z "$AUTORECONF" && AUTORECONF="@am_AUTORECONF@"
 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
-test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
+test -z "$AUTOUPDATE" && AUTOUPDATE="@am_AUTOUPDATE@"
 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
 # Use -Werror because this also turns some Perl warnings into error.
 # (Tests for which this is inappropriate should use -Wno-error.)
-test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
-# Extra flags to pass to aclocal before all other flags added by this script.
-ACLOCAL_TESTSUITE_FLAGS=
-export ACLOCAL_TESTSUITE_FLAGS
+test -z "$ACLOCAL" && ACLOCAL="aclocal-$APIVERSION -Werror"
 
 # See how Automake should be run.  We put --foreign as the default
 # strictness to avoid having to create lots and lots of files.  A test
@@ -77,26 +113,80 @@ export ACLOCAL_TESTSUITE_FLAGS
 # -Werror by default.  Tests for which this is inappropriate
 # (e.g. when testing that a warning is enabled by a specific switch)
 # should use -Wnone or/and -Wno-error
-test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
+test -z "$AUTOMAKE" && AUTOMAKE="automake-$APIVERSION --foreign -Werror -Wall"
 
-PATH="`pwd`@PATH_SEPARATOR@$PATH"
+PATH="`pwd`$PATH_SEPARATOR$PATH"
 echo "$PATH"
 # Some shells forget to export modified environment variables.
 # (See note about `export' in the Autoconf manual.)
 export PATH
 
+# We use a trap below for cleanup.  This requires us to go through
+# hoops to get the right exit status transported through the signal.
+# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
+# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
+# sh inside this function.
+Exit ()
+{
+  set +e
+  (exit $1)
+  exit $1
+}
+
+# Print warnings (e.g., about skipped and failed tests) to this file
+# number.  Override by putting, say:
+#   stderr_fileno_=9; export stderr_fileno_; exec 9>&2;
+# in the definition of AM_TESTS_ENVIRONMENT.
+# This is useful when using automake's parallel tests mode, to print the
+# reason for skip/failure to console, rather than to the *.log files.
+: ${stderr_fileno_=2}
+
+# Copied from Gnulib's `tests/init.sh'.
+warn_ () { echo "$@" 1>&$stderr_fileno_; }
+fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
+skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
+fatal_ () { warn_ "$me: hard error: $@"; Exit 99; }
+framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
+
+# cross_compiling
+# ---------------
+# Tell whether we are cross-compiling.  This is especially useful to skip
+# tests (or portions of them) that requires a native compiler.
+cross_compiling ()
+{
+  test x"$host_alias" != x
+}
+
+# So that we can force the use of correct gcc, g++ etc., consistently
+# with cross-compilation settings.
+if cross_compiling; then
+  am__tool_prefix="$host_alias-"
+else
+  am__tool_prefix=
+fi
+
 for tool in : $required
 do
   # Check that each required tool is present.
   case $tool in
     :) ;;
-    bison)
+    bison|yacc)
       # Since bison is required, we pick YACC for ./configure.
       YACC='bison -y'
       export YACC
       echo "$me: running bison --version"
       ( bison --version ) || exit 77
       ;;
+    flex|lex)
+      # Since flex is required, we pick LEX for ./configure.
+      LEX=flex
+      export LEX
+      echo "$me: running flex --version"
+      flex --version || exit 77
+      ;;
+    cc|c++|fortran|fortran77)
+      echo "$me: dummy requirement '$tool', no check done"
+      ;;
     bzip2)
       # Do not use --version, bzip2 still tries to compress stdin.
       echo "$me: running bzip2 --help"
@@ -128,24 +218,48 @@ do
       # always use it.  This is important only when the user
       # has defined CC in his environment, otherwise ./configure will
       # prefer gcc to other compilers.
-      CC=gcc
+      CC=${am__tool_prefix}gcc
       export CC
       echo "$me: running $CC --version"
       ( $CC --version ) || exit 77
       ;;
     gcj)
-      GCJ=gcj
+      GCJ=${am__tool_prefix}gcj
       export GCJ
       echo "$me: running $GCJ --version"
       ( $GCJ --version ) || exit 77
       ( $GCJ -v ) || exit 77
       ;;
     g++)
-      CXX=g++
+      CXX=${am__tool_prefix}g++
       export CXX
       echo "$me: running $CXX --version"
       ( $CXX --version ) || exit 77
       ;;
+    gfortran)
+      FC=${am__tool_prefix}gfortran
+      export FC
+      echo "$me: running $FC --version"
+      $FC --version || skip_ "GNU Fortran compiler not available"
+      echo "$me: running $FC -v"
+      $FC -v || skip_ "botched installation for GNU Fortran compiler"
+      case " $required " in
+        *\ g77\ *) ;;
+        *) F77=$FC; export F77;;
+      esac
+      ;;
+    g77)
+      F77=${am__tool_prefix}g77
+      export F77
+      echo "$me: running $F77 --version"
+      $F77 --version || skip_ "GNU Fortran 77 compiler not available"
+      echo "$me: running $F77 -v"
+      $F77 -v || skip_ "botched installation for GNU Fortran 77 compiler"
+      case " $required " in
+        *\ gfortran\ *) ;;
+        *) FC=$F77; export FC;;
+      esac
+      ;;
     icc)
       CC=icc
       export CC
@@ -156,6 +270,14 @@ do
       echo "$me: running $CC -V -help"
       ( $CC -V -help ) || exit 77
       ;;
+    javac)
+      # The Java compiler from JDK 1.5 (and presumably earlier versions)
+      # cannot handle the `-version' option by itself: it bails out
+      # telling that source files are missing.  Adding also the `-help'
+      # option seems to solve the problem.
+      echo "$me: running javac -version -help"
+      javac -version -help || exit 77
+      ;;
     makedepend)
       echo "$me: running makedepend -f-"
       ( makedepend -f- ) || exit 77
@@ -176,6 +298,9 @@ do
       rm -f $priv_check_temp
       test $overwrite_status = 0 && exit 77
       ;;
+    native)
+      cross_compiling && skip_ "doesn't work in cross-compile mode"
+      ;;
     python)
       # Python doesn't support --version, it has -V
       echo "$me: running python -V"
@@ -248,22 +373,10 @@ case "$srcdir" in
     ;;
 esac
 
-# We use a trap below for cleanup.  This requires us to go through
-# hoops to get the right exit status transported through the signal.
-# So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
-# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
-# sh inside this function.
-Exit ()
-{
-  set +e
-  (exit $1)
-  exit $1
-}
-
 curdir=`pwd`
 testSubDir=$me.dir
 test ! -d $testSubDir || {
-  find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
+  find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
   rm -rf $testSubDir
 }
 mkdir $testSubDir
@@ -275,7 +388,7 @@ if test "$sh_errexit_works" = yes; then
     cd "$curdir"
     case $exit_status,$keep_testdirs in
     0,)
-      find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
+      find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
       rm -rf $testSubDir
       ;;
     esac
@@ -325,11 +438,15 @@ unset DESTDIR
 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
 unset htmldir includedir infodir libdir libexecdir localedir mandir
 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
+# Unset variables that might change the "make distcheck" behaviour.
+unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
 # Also unset variables that control our test driver.  While not
 # conceptually independent, they cause some changed semantics we
 # need to control (and test for) in some of the tests to ensure
 # backward-compatible behavior.
+unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
 unset DISABLE_HARD_ERRORS
+unset AM_COLOR_TESTS
 unset TESTS
 unset TEST_LOG_COMPILER
 unset TEST_LOGS
@@ -414,6 +531,16 @@ is_newest ()
   test -z "$is_newest_files"
 }
 
+# using_gmake
+# -----------
+# Return success if $MAKE is GNU make, return failure otherwise.
+using_gmake ()
+{
+  # Use --version AND -v, because SGI Make doesn't fail on --version.
+  # Also grep for GNU because newer versions of FreeBSD make do
+  # not complain about `--version' (they seem to silently ignore it).
+  $MAKE --version -v | grep GNU
+}
 
 # AUTOMAKE_run status [options...]
 # --------------------------------
@@ -439,6 +566,36 @@ AUTOMAKE_fails ()
   AUTOMAKE_run 1 ${1+"$@"}
 }
 
+commented_sed_unindent_prog='
+  /^$/b                    # Nothing to do for empty lines.
+  x                        # Get x<indent> into pattern space.
+  /^$/{                    # No prior x<indent>, go prepare it.
+    g                      # Copy this 1st non-blank line into pattern space.
+    s/^\(['"$tab"' ]*\).*/x\1/   # Prepare x<indent> in pattern space.
+  }                        # Now: x<indent> in pattern and <line> in hold.
+  G                        # Build x<indent>\n<line> in pattern space, and
+  h                        # duplicate it into hold space.
+  s/\n.*$//                # Restore x<indent> in pattern space, and
+  x                        # exchange with the above duplicate in hold space.
+  s/^x\(.*\)\n\1//         # Remove leading <indent> from <line>.
+  s/^x.*\n//               # Restore <line> when there is no leading <indent>.
+'
+
+# unindent [input files...]
+# -------------------------
+# Remove the "proper" amount of leading whitespace from the given files,
+# and output the result on stdout.  That amount is determined by looking
+# at the leading whitespace of the first non-blank line in the input
+# files.  If no input file is specified, standard input is implied.
+unindent ()
+{
+  if test x"$sed_unindent_prog" = x; then
+    sed_unindent_prog=`printf '%s\n' "$commented_sed_unindent_prog" | sed -e "s/  *# .*//"`
+  fi
+  sed "$sed_unindent_prog" ${1+"$@"}
+}
+sed_unindent_prog="" # Avoid interferences from the environment.
+
 # Turn on shell traces.
 set -x