This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Build, libgfortran, Patch] Make libgfortran's configure more cross-compile friendly


Hi all,

at the GSoC Mentor summit, I had a chat with Joel, who asked me whether he should try to crosscompile also Fortran. Well, at the end I created the attached patch (based on what one had to do for libquadmath) and he successfully build fortran to target RTEMS for i386, sparc64, powerpc, mips, and m68k.

Additionally, I have bootstrapped it on x86-64-linux.
OK for the trunk?

Tobias
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 74cfe44..2a5899a 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -51,7 +51,10 @@ AC_SUBST(onestep)
 # Do not delete or change the following two lines.  For why, see
 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
 AC_CANONICAL_SYSTEM
+ACX_NONCANONICAL_TARGET
+
 target_alias=${target_alias-$host_alias}
+AC_SUBST(target_alias)
 
 # Sets up automake.  Must come after AC_CANONICAL_SYSTEM.  Each of the
 # following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
@@ -117,6 +120,7 @@ AC_SUBST(toolexeclibdir)
 # Create a spec file, so that compile/link tests don't fail
 test -f libgfortran.spec || touch libgfortran.spec
 
+AC_LANG_C
 # Check the compiler.
 # The same as in boehm-gc and libstdc++. Have to borrow it from there.
 # We must force CC to /not/ be precious variables; otherwise
@@ -128,6 +132,10 @@ m4_define([_AC_ARG_VAR_PRECIOUS],[])
 AC_PROG_CC
 m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
 
+AC_SUBST(CFLAGS)
+
+AM_PROG_CC_C_O
+
 # Add -Wall -fno-repack-arrays -fno-underscoring if we are using GCC.
 if test "x$GCC" = "xyes"; then
   AM_FCFLAGS="-I . -Wall -Werror -fimplicit-none -fno-repack-arrays -fno-underscoring"
@@ -150,30 +158,36 @@ AS_HELP_STRING([--disable-symvers],
 gfortran_use_symver=$enableval,
 gfortran_use_symver=yes)
 if test "x$gfortran_use_symver" = xyes; then
-  save_LDFLAGS="$LDFLAGS"
-  LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
-  cat > conftest.map <<EOF
+  if test x$gcc_no_link = xyes; then
+    # If we cannot link, we cannot build shared libraries, so do not use
+    # symbol versioning.
+    gfortran_use_symver=no
+  else
+    save_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map"
+    cat > conftest.map <<EOF
 FOO_1.0 {
   global: *foo*; bar; local: *;
 };
 EOF
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]],[[]])],[gfortran_use_symver=gnu],[gfortran_use_symver=no])
-  if test x$gfortran_use_symver = xno; then
-    case "$target_os" in
-      solaris2*)
-        LDFLAGS="$save_LDFLAGS"
-        LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
-        # Sun ld cannot handle wildcards and treats all entries as undefined.
-        cat > conftest.map <<EOF
+    AC_TRY_LINK([int foo;],[],[gfortran_use_symver=gnu],[gfortran_use_symver=no])
+    if test x$gfortran_use_symver = xno; then
+      case "$target_os" in
+        solaris2*)
+          LDFLAGS="$save_LDFLAGS"
+          LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map"
+          # Sun ld cannot handle wildcards and treats all entries as undefined.
+          cat > conftest.map <<EOF
 FOO_1.0 {
   global: foo; local: *;
 };
 EOF
-        AC_LINK_IFELSE([AC_LANG_PROGRAM([[int foo;]],[[]])],[gfortran_use_symver=sun],[gfortran_use_symver=no])
-        ;;
-    esac
+          AC_TRY_LINK([int foo;],[],[gfortran_use_symver=sun],[gfortran_use_symver=no])
+          ;;
+      esac
+    fi
+    LDFLAGS="$save_LDFLAGS"
   fi
-  LDFLAGS="$save_LDFLAGS"
 fi
 AC_MSG_RESULT($gfortran_use_symver)
 AM_CONDITIONAL(LIBGFOR_USE_SYMVER, [test "x$gfortran_use_symver" != xno])

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]