#! /bin/sh -e
 
# DP: disable all libraries except libstdc++ for biarch
 
dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p1 < $0
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p1 < $0
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0

--- src/config-ml.in.bak	2002-11-12 15:32:40.000000000 +0100
+++ src/config-ml.in	2002-11-12 15:38:55.000000000 +0100
@@ -516,6 +516,46 @@
 	  ;;
 	esac
 	;;
+s390*-*-*)
+	case " $multidirs " in
+	*" 64 "*)
+	  # We will not be able to create libraries with -m64 if
+	  # we cannot even link a trivial program.  It usually
+	  # indicates the 64bit libraries are missing.
+	  if echo 'main() {}' > conftest.c &&
+	     ${CC-gcc} -m64 conftest.c -o conftest; then
+	    echo Enable only libstdc++.
+	    old_multidirs="${multidirs}"
+	    multidirs=""
+	    for x in ${old_multidirs}; do
+	      case "$x" in
+	      *64* ) case ${ml_realsrcdir} in
+			*"libstdc++-v3" ) multidirs="${multidirs} ${x}" ;;
+			*"libf2c" ) multidirs="${multidirs} ${x}" ;;
+			*"libobjc" ) multidirs="${multidirs} ${x}" ;;
+			*"libiberty" ) multidirs="${multidirs} ${x}" ;;
+			*"zlib" ) multidirs="${multidirs} ${x}" ;;
+			*) : ;;
+		     esac 
+		     ;;
+	      *) multidirs="${multidirs} ${x}" ;;
+	      esac
+	    done
+	  else
+	    echo Could not link program with -m64, disabling it.
+	    old_multidirs="${multidirs}"
+	    multidirs=""
+	    for x in ${old_multidirs}; do
+	      case "$x" in
+	      *64* ) : ;;
+	      *) multidirs="${multidirs} ${x}" ;;
+	      esac
+	    done
+	  fi
+	  rm -f conftest.c conftest
+	  ;;
+	esac
+	;;
 esac
 
 # Remove extraneous blanks from multidirs.
