testsuite: be more cross-compile friendly
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 15 May 2011 12:30:43 +0000 (14:30 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 15 May 2011 13:27:04 +0000 (15:27 +0200)
* tests/defs.in (cross_compiling): New subroutine.
(am__tool_prefix): New internal variable.
(gcc, g++, gcj): Force the use of the correct "tool prefix"
when cross compiling.
(gfortran, g77, non-cross): New requirements.

ChangeLog
tests/defs.in

index b9c71f3..333e3ab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-05-15  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       testsuite: be more cross-compile friendly
+       * tests/defs.in (cross_compiling): New subroutine.
+       (am__tool_prefix): New internal variable.
+       (gcc, g++, gcj): Force the use of the correct "tool prefix"
+       when cross compiling.
+       (gfortran, g77, non-cross): New requirements.
+
 2011-05-07  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests: fix spurious failure of txinfo21.test on FreeBSD
index 8f9534e..736a394 100644 (file)
@@ -148,6 +148,23 @@ fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
 skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
 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.
@@ -195,24 +212,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
@@ -251,6 +292,9 @@ do
       rm -f $priv_check_temp
       test $overwrite_status = 0 && exit 77
       ;;
+    non-cross)
+      cross_compiling && skip_ "doesn't work in cross-compile mode"
+      ;;
     python)
       # Python doesn't support --version, it has -V
       echo "$me: running python -V"