/
2010-12-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46540
	* configure.ac: Add --disable-libquadmath and
	--disable-libquadmath-support.
	* configure: Regenerate.
gcc/
2010-12-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46540
	* configure.ac: Handle --disable-libquadmath-support.
	* doc/install.texi: Document --disable-libquadmath and
	--disable-libquadmath-support
	* configure: Regenerate.
	* config.in: Regenerate.

gcc/fortran/
2010-12-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46540
	* trans-types.c (gfc_init_kinds): Handle
	--disable-libquadmath-support.

libgfortran/
2010-12-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46540
	* acinclude.m4 (LIBGFOR_CHECK_FLOAT128): Honour
	--disable-libquadmath-support.
	* configure.ac: Handle --disable-libquadmath-support.
	* configure: Regenerate.

diff --git a/configure.ac b/configure.ac
index fcf5ba2..03f15df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -458,6 +458,27 @@ case "${host}" in
 esac
 
 
+AC_ARG_ENABLE(libquadmath,
+AS_HELP_STRING([--disable-libquadmath],
+  [do not build libquadmath directory]),
+ENABLE_LIBQUADMATH=$enableval,
+ENABLE_LIBQUADMATH=yes)
+if test "${ENABLE_LIBQUADMATH}" = "no" ; then
+  noconfigdirs="$noconfigdirs target-libquadmath"
+fi
+
+
+AC_ARG_ENABLE(libquadmath-support,
+AS_HELP_STRING([--disable-libquadmath-support],
+  [disable libquadmath support for Fortran]),
+ENABLE_LIBQUADMATH_SUPPORT=$enableval,
+ENABLE_LIBQUADMATH_SUPPORT=yes)
+enable_libquadmath_support=
+if test "${ENABLE_LIBQUADMATH_SUPPORT}" = "no" ; then
+  enable_libquadmath_support=no
+fi
+
+
 AC_ARG_ENABLE(libada,
 [  --enable-libada         build libada directory],
 ENABLE_LIBADA=$enableval,
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b2fd641..468e430 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4781,6 +4781,18 @@ if test x"$enable_plugin" = x"yes"; then
   AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.])
 fi
 
+
+AC_ARG_ENABLE(libquadmath-support,
+AS_HELP_STRING([--disable-libquadmath-support],
+  [disable libquadmath support for Fortran]),
+ENABLE_LIBQUADMATH_SUPPORT=$enableval,
+ENABLE_LIBQUADMATH_SUPPORT=yes)
+if test "${ENABLE_LIBQUADMATH_SUPPORT}" != "no" ; then
+  AC_DEFINE(USE_LIBQUADMATH_SUPPORT, 1,
+            [Define to 1 to enable libquadmath support])
+fi
+
+
 # Configure the subdirectories
 # AC_CONFIG_SUBDIRS($subdirs)
 
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index fbb2d4c..abe80aa 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1337,6 +1337,16 @@ do a @samp{make -C gcc gnatlib_and_tools}.
 Specify that the run-time libraries for stack smashing protection
 should not be built.
 
+@item --disable-libquadmath
+Specify that the GCC quad-precision math library should not be build.
+On some systems, the library is required to be linkable when building
+the Fortran front end, unless @option{--disable-libquadmath-support}
+is used.
+
+@item --disable-libquadmath-support
+Specify that the Fortran front end and @code{libgfortran} do not add
+support for @code{libquadmath} on systems supporting it.
+
 @item --disable-libgomp
 Specify that the run-time libraries used by GOMP should not be built.
 
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 771b582..c5aac3e 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -415,12 +415,11 @@ gfc_init_kinds (void)
 
       /* Only let float, double, long double and __float128 go through.
 	 Runtime support for others is not provided, so they would be
-	 useless.  TODO: TFmode support should be enabled once libgfortran
-	 support is done.  */
+	 useless.  */
 	if (mode != TYPE_MODE (float_type_node)
 	    && (mode != TYPE_MODE (double_type_node))
 	    && (mode != TYPE_MODE (long_double_type_node))
-#ifdef LIBGCC2_HAS_TF_MODE
+#if defined(LIBGCC2_HAS_TF_MODE) && defined(USE_LIBQUADMATH_SUPPORT)
 	    && (mode != TFmode)
 #endif
 	   )
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index cb016f1..9873d9f 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -279,6 +279,9 @@ esac])
 dnl Check whether we have a __float128 type
 AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
   LIBQUADSPEC=
+
+  if test "x$enable_libquadmath_support" != xno; then
+
   AC_CACHE_CHECK([whether we have a usable __float128 type],
                  libgfor_cv_have_float128, [
     AC_TRY_LINK([
@@ -341,6 +344,12 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
       LIBQUADINCLUDE=
     fi
   fi
+  else
+    # for --disable-quadmath
+    LIBQUADLIB=
+    LIBQUADLIB_DEP=
+    LIBQUADINCLUDE=
+  fi
 
   dnl For the spec file
   AC_SUBST(LIBQUADSPEC)
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 4c3daf4..7b28f12 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -12,7 +12,8 @@ GCC_TOPLEV_SUBDIRS
 
 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
 AC_ARG_ENABLE(version-specific-runtime-libs,
-[  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
+AS_HELP_STRING([--enable-version-specific-runtime-libs],
+  [specify that runtime libraries should be installed in a compiler-specific directory]),
 [case "$enableval" in
  yes) version_specific_libs=yes ;;
  no)  version_specific_libs=no ;;
@@ -24,7 +25,7 @@ AC_MSG_RESULT($version_specific_libs)
 # Build with intermodule optimisations
 AC_MSG_CHECKING([for --enable-intermodule])
 AC_ARG_ENABLE(intermodule,
-[  --enable-intermodule    build the library in one step],
+AS_HELP_STRING([--enable-intermodule],[build the library in one step]),
 [case "$enable_intermodule" in
   yes) onestep="-onestep";;
     *) onestep="";;
@@ -463,7 +464,18 @@ LIBGFOR_CHECK_MINGW_SNPRINTF
 # Check for a broken powf implementation
 LIBGFOR_CHECK_FOR_BROKEN_POWF
 
-# Check whether we have a __float128 type
+# Check whether libquadmath should be used
+AC_ARG_ENABLE(libquadmath-support,
+AS_HELP_STRING([--disable-libquadmath-support],
+  [disable libquadmath support for Fortran]),
+ENABLE_LIBQUADMATH_SUPPORT=$enableval,
+ENABLE_LIBQUADMATH_SUPPORT=yes)
+enable_libquadmath_support=
+if test "${ENABLE_LIBQUADMATH_SUPPORT}" = "no" ; then
+  enable_libquadmath_support=no
+fi
+
+# Check whether we have a __float128 type, depends on enable_libquadmath_support
 LIBGFOR_CHECK_FLOAT128
 
 # Check for GNU libc feenableexcept
