diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 9adf768d96dc9e10de6a50c48bcbbf25af066947..2852bbbaa8fe2326de53fdfd7fe5e249fba8ef26 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,16 @@
+2006-10-13  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	* m4/spacing.m4: Use scalbn[f,l] if ldexp[f,l] is unavailable.
+	* m4/rrspacing.m4: Ditto.
+	* generated/spacing_r4.c: Regenerated.
+	* generated/spacing_r8.c: Ditto.
+	* generated/spacing_r10.c: Ditto.
+	* generated/spacing_r16.c: Ditto.
+	* generated/rrspacing_r4.c: Ditto.
+	* generated/rrspacing_r8.c: Ditto.
+	* generated/rrspacing_r10.c: Ditto.
+	* generated/rrspacing_r16.c: Ditto.
+
 2006-10-06  Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	PR fortran/15441
diff --git a/libgfortran/generated/rrspacing_r10.c b/libgfortran/generated/rrspacing_r10.c
index 315fb1ba26c6746472895f834f9ca9a01b809c3f..2950b71941acb2452d94762fca87c0791df2f21c 100644
--- a/libgfortran/generated/rrspacing_r10.c
+++ b/libgfortran/generated/rrspacing_r10.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FABSL) && defined (HAVE_FREXPL) && defined (HAVE_LDEXPL)
+#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FABSL) && defined (HAVE_FREXPL)
 
 extern GFC_REAL_10 rrspacing_r10 (GFC_REAL_10 s, int p);
 export_proto(rrspacing_r10);
@@ -47,7 +47,12 @@ rrspacing_r10 (GFC_REAL_10 s, int p)
   if (x == 0.)
     return 0.;
   frexpl (s, &e);
+#if defined (HAVE_LDEXPL)
   return ldexpl (x, p - e);
+#else
+  return scalbnl (x, p - e);
+#endif
+
 }
 
 #endif
diff --git a/libgfortran/generated/rrspacing_r16.c b/libgfortran/generated/rrspacing_r16.c
index d18a9c3fea4cd84e10fe25a1d72e6d853d472e1e..20225d45baeea0264fad02a58d0222b14756ed95 100644
--- a/libgfortran/generated/rrspacing_r16.c
+++ b/libgfortran/generated/rrspacing_r16.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FABSL) && defined (HAVE_FREXPL) && defined (HAVE_LDEXPL)
+#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FABSL) && defined (HAVE_FREXPL)
 
 extern GFC_REAL_16 rrspacing_r16 (GFC_REAL_16 s, int p);
 export_proto(rrspacing_r16);
@@ -47,7 +47,12 @@ rrspacing_r16 (GFC_REAL_16 s, int p)
   if (x == 0.)
     return 0.;
   frexpl (s, &e);
+#if defined (HAVE_LDEXPL)
   return ldexpl (x, p - e);
+#else
+  return scalbnl (x, p - e);
+#endif
+
 }
 
 #endif
diff --git a/libgfortran/generated/rrspacing_r4.c b/libgfortran/generated/rrspacing_r4.c
index 0c7d1828e6d0c5285567282697a11d8b8f52d090..89be40b1a1cc47cf9455df96272f2c97f91a771d 100644
--- a/libgfortran/generated/rrspacing_r4.c
+++ b/libgfortran/generated/rrspacing_r4.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FABSF) && defined (HAVE_FREXPF) && defined (HAVE_LDEXPF)
+#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FABSF) && defined (HAVE_FREXPF)
 
 extern GFC_REAL_4 rrspacing_r4 (GFC_REAL_4 s, int p);
 export_proto(rrspacing_r4);
@@ -47,7 +47,12 @@ rrspacing_r4 (GFC_REAL_4 s, int p)
   if (x == 0.)
     return 0.;
   frexpf (s, &e);
+#if defined (HAVE_LDEXPF)
   return ldexpf (x, p - e);
+#else
+  return scalbnf (x, p - e);
+#endif
+
 }
 
 #endif
diff --git a/libgfortran/generated/rrspacing_r8.c b/libgfortran/generated/rrspacing_r8.c
index 3969f66941cf6412d6fae357c36d5da6105d9231..9dc87381de154eec0f4628a847258d3560462f41 100644
--- a/libgfortran/generated/rrspacing_r8.c
+++ b/libgfortran/generated/rrspacing_r8.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FABS) && defined (HAVE_FREXP) && defined (HAVE_LDEXP)
+#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FABS) && defined (HAVE_FREXP)
 
 extern GFC_REAL_8 rrspacing_r8 (GFC_REAL_8 s, int p);
 export_proto(rrspacing_r8);
@@ -47,7 +47,12 @@ rrspacing_r8 (GFC_REAL_8 s, int p)
   if (x == 0.)
     return 0.;
   frexp (s, &e);
+#if defined (HAVE_LDEXP)
   return ldexp (x, p - e);
+#else
+  return scalbn (x, p - e);
+#endif
+
 }
 
 #endif
diff --git a/libgfortran/generated/spacing_r10.c b/libgfortran/generated/spacing_r10.c
index fd11ab65964e8e83e4f8625409385edf2fe3b180..797920c60c3111e99870648163f35d1efa6993e1 100644
--- a/libgfortran/generated/spacing_r10.c
+++ b/libgfortran/generated/spacing_r10.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FREXPL) && defined (HAVE_LDEXPL)
+#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FREXPL)
 
 extern GFC_REAL_10 spacing_r10 (GFC_REAL_10 s, int p, int emin, GFC_REAL_10 tiny);
 export_proto(spacing_r10);
@@ -47,7 +47,11 @@ spacing_r10 (GFC_REAL_10 s, int p, int emin, GFC_REAL_10 tiny)
   frexpl (s, &e);
   e = e - p;
   e = e > emin ? e : emin;
+#if defined (HAVE_LDEXPL)
   return ldexpl (1., e);
+#else
+  return scalbnl (1., e);
+#endif
 }
 
 #endif
diff --git a/libgfortran/generated/spacing_r16.c b/libgfortran/generated/spacing_r16.c
index 333221a4b2ebcc3177bd53ff402cfe09563c0253..c13e9b11882f4b40262866d69632a84320ab1302 100644
--- a/libgfortran/generated/spacing_r16.c
+++ b/libgfortran/generated/spacing_r16.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FREXPL) && defined (HAVE_LDEXPL)
+#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FREXPL)
 
 extern GFC_REAL_16 spacing_r16 (GFC_REAL_16 s, int p, int emin, GFC_REAL_16 tiny);
 export_proto(spacing_r16);
@@ -47,7 +47,11 @@ spacing_r16 (GFC_REAL_16 s, int p, int emin, GFC_REAL_16 tiny)
   frexpl (s, &e);
   e = e - p;
   e = e > emin ? e : emin;
+#if defined (HAVE_LDEXPL)
   return ldexpl (1., e);
+#else
+  return scalbnl (1., e);
+#endif
 }
 
 #endif
diff --git a/libgfortran/generated/spacing_r4.c b/libgfortran/generated/spacing_r4.c
index 41cc72e9b2d4fc1a9880bdd6fad6c5eae909db94..1e09e1106c41cfd5c162f3777f70de0aaaeff5bd 100644
--- a/libgfortran/generated/spacing_r4.c
+++ b/libgfortran/generated/spacing_r4.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FREXPF) && defined (HAVE_LDEXPF)
+#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FREXPF)
 
 extern GFC_REAL_4 spacing_r4 (GFC_REAL_4 s, int p, int emin, GFC_REAL_4 tiny);
 export_proto(spacing_r4);
@@ -47,7 +47,11 @@ spacing_r4 (GFC_REAL_4 s, int p, int emin, GFC_REAL_4 tiny)
   frexpf (s, &e);
   e = e - p;
   e = e > emin ? e : emin;
+#if defined (HAVE_LDEXPF)
   return ldexpf (1., e);
+#else
+  return scalbnf (1., e);
+#endif
 }
 
 #endif
diff --git a/libgfortran/generated/spacing_r8.c b/libgfortran/generated/spacing_r8.c
index 0f925217e4232d9b594dbe1ed1949a0198e37adf..cde5d96f1fd124f4712447a288b1144987672979 100644
--- a/libgfortran/generated/spacing_r8.c
+++ b/libgfortran/generated/spacing_r8.c
@@ -33,7 +33,7 @@ Boston, MA 02110-1301, USA.  */
 #include "libgfortran.h"
 
 
-#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FREXP) && defined (HAVE_LDEXP)
+#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FREXP)
 
 extern GFC_REAL_8 spacing_r8 (GFC_REAL_8 s, int p, int emin, GFC_REAL_8 tiny);
 export_proto(spacing_r8);
@@ -47,7 +47,11 @@ spacing_r8 (GFC_REAL_8 s, int p, int emin, GFC_REAL_8 tiny)
   frexp (s, &e);
   e = e - p;
   e = e > emin ? e : emin;
+#if defined (HAVE_LDEXP)
   return ldexp (1., e);
+#else
+  return scalbn (1., e);
+#endif
 }
 
 #endif
diff --git a/libgfortran/m4/rrspacing.m4 b/libgfortran/m4/rrspacing.m4
index 6b3ccd55ec1540adc36b9ec80a601a872e1f4cf9..34ff98eb6988b8cd370d8ba279aa0154528635e6 100644
--- a/libgfortran/m4/rrspacing.m4
+++ b/libgfortran/m4/rrspacing.m4
@@ -34,7 +34,7 @@ Boston, MA 02110-1301, USA.  */
 
 include(`mtype.m4')dnl
 
-`#if defined (HAVE_'real_type`) && defined (HAVE_FABS'Q`) && defined (HAVE_FREXP'Q`) && defined (HAVE_LDEXP'Q`)'
+`#if defined (HAVE_'real_type`) && defined (HAVE_FABS'Q`) && defined (HAVE_FREXP'Q`)'
 
 extern real_type rrspacing_r`'kind (real_type s, int p);
 export_proto(rrspacing_r`'kind);
@@ -48,7 +48,12 @@ rrspacing_r`'kind (real_type s, int p)
   if (x == 0.)
     return 0.;
   frexp`'q (s, &e);
+`#if defined (HAVE_LDEXP'Q`)'
   return ldexp`'q (x, p - e);
+#else
+  return scalbn`'q (x, p - e);
+#endif
+
 }
 
 #endif
diff --git a/libgfortran/m4/spacing.m4 b/libgfortran/m4/spacing.m4
index 4aa4e19250f9997920d9a9f6eeb76f6af2db968d..77b7a38e550fe66ff13601d436ca641d7cc6b261 100644
--- a/libgfortran/m4/spacing.m4
+++ b/libgfortran/m4/spacing.m4
@@ -34,7 +34,7 @@ Boston, MA 02110-1301, USA.  */
 
 include(`mtype.m4')dnl
 
-`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`) && defined (HAVE_LDEXP'Q`)'
+`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`)'
 
 extern real_type spacing_r`'kind (real_type s, int p, int emin, real_type tiny);
 export_proto(spacing_r`'kind);
@@ -48,7 +48,11 @@ spacing_r`'kind (real_type s, int p, int emin, real_type tiny)
   frexp`'q (s, &e);
   e = e - p;
   e = e > emin ? e : emin;
+`#if defined (HAVE_LDEXP'Q`)'
   return ldexp`'q (1., e);
+#else
+  return scalbn`'q (1., e);
+#endif
 }
 
 #endif