OSDN Git Service

2001-01-02 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
index 80a534e..66a0bcc 100644 (file)
@@ -173,14 +173,19 @@ dnl specific precautions need to be taken.
 dnl 
 dnl GLIBCPP_CHECK_COMPILER_VERSION
 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
-  # Sanity check that g++ is capable of dealing with v-3.
-  AC_MSG_CHECKING([for g++ that will successfully compile this code])
-  AC_EGREP_CPP([ok], [
-  #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 
+if test ! -f stamp-sanity-compiler; then
+  AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  AC_EGREP_CPP(ok, [
+  #if (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 
     ok
   #endif
   ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to gcc-2.95 or above]))
+  AC_LANG_RESTORE
   AC_MSG_RESULT($gpp_satisfactory)
+  touch stamp-sanity-compiler
+fi
 ])
 
 
@@ -225,7 +230,7 @@ AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
     # this is the suspicious part
     CXXFLAGS=''
   fi
-  if test "$ac_gabydiags" = "yes"; then
+  if test x"$ac_gabydiags" = x"yes"; then
     WFMT_FLAGS='-fdiagnostics-show-location=once'
   fi
   AC_MSG_RESULT($ac_gabydiags)
@@ -241,7 +246,7 @@ AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
     # this is the suspicious part
     CXXFLAGS=''
   fi
-  if test "$ac_fdsections" = "yes"; then
+  if test x"$ac_fdsections" = x"yes" && test x"$enable_debug" = x"no"; then
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
   fi
   AC_MSG_RESULT($ac_fdsections)
@@ -271,7 +276,7 @@ AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
   AC_REQUIRE([AC_PROG_LD])
 
   # Set --gc-sections.
-  if test "$ac_cv_prog_gnu_ld" = "broken"; then
+  if test "$ac_cv_prog_gnu_ld" = "notbroken"; then
     # GNU ld it is!  Joy and bunny rabbits!
 
     # All these tests are for C++; save the language and the compiler flags.
@@ -309,7 +314,7 @@ AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
   fi
 
   # Set linker optimization flags.
-  if test "$ac_cv_prog_gnu_ld" = "yes"; then
+  if test x"$ac_cv_prog_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
     OPT_LDFLAGS='-Wl,-O1'
   fi
 
@@ -332,14 +337,16 @@ dnl
 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
   AC_MSG_CHECKING([for $1 declaration])
-  AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
-    AC_LANG_SAVE
-    AC_LANG_CPLUSPLUS
-    AC_TRY_COMPILE([#include <math.h>], 
-                   [ $1(0);], 
-                   [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
-    AC_LANG_RESTORE
-  ])
+  if test x${glibcpp_cv_func_$1_use+set} != xset; then
+    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
+      AC_LANG_SAVE
+      AC_LANG_CPLUSPLUS
+      AC_TRY_COMPILE([#include <math.h>], 
+                     [ $1(0);], 
+                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
+      AC_LANG_RESTORE
+    ])
+  fi
   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
   if test x$glibcpp_cv_func_$1_use = x"yes"; then
     AC_CHECK_FUNCS($1)    
@@ -361,14 +368,16 @@ dnl
 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
   AC_MSG_CHECKING([for $1 declaration])
-  AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
-    AC_LANG_SAVE
-    AC_LANG_CPLUSPLUS
-    AC_TRY_COMPILE([#include <math.h>], 
-                   [ $1(0, 0);], 
-                   [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
-    AC_LANG_RESTORE
-  ])
+  if test x${glibcpp_cv_func_$1_use+set} != xset; then
+    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
+      AC_LANG_SAVE
+      AC_LANG_CPLUSPLUS
+      AC_TRY_COMPILE([#include <math.h>], 
+                     [ $1(0, 0);], 
+                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
+      AC_LANG_RESTORE
+    ])
+  fi
   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
   if test x$glibcpp_cv_func_$1_use = x"yes"; then
     AC_CHECK_FUNCS($1)    
@@ -390,14 +399,16 @@ dnl
 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
   AC_MSG_CHECKING([for $1 declaration])
-  AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
-    AC_LANG_SAVE
-    AC_LANG_CPLUSPLUS
-    AC_TRY_COMPILE([#include <math.h>], 
-                   [ $1(0, 0, 0);], 
-                   [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
-    AC_LANG_RESTORE
-  ])
+  if test x${glibcpp_cv_func_$1_use+set} != xset; then
+    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
+      AC_LANG_SAVE
+      AC_LANG_CPLUSPLUS
+      AC_TRY_COMPILE([#include <math.h>], 
+                     [ $1(0, 0, 0);], 
+                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
+      AC_LANG_RESTORE
+    ])
+  fi
   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
   if test x$glibcpp_cv_func_$1_use = x"yes"; then
     AC_CHECK_FUNCS($1)    
@@ -420,14 +431,16 @@ dnl
 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
   AC_MSG_CHECKING([for $1 declaration])
-  AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
-    AC_LANG_SAVE
-    AC_LANG_CPLUSPLUS
-    AC_TRY_COMPILE([#include <stdlib.h>], 
-                   [ $1(0, 0);], 
-                   [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
-    AC_LANG_RESTORE
-  ])
+  if test x${glibcpp_cv_func_$1_use+set} != xset; then
+    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
+      AC_LANG_SAVE
+      AC_LANG_CPLUSPLUS
+      AC_TRY_COMPILE([#include <stdlib.h>], 
+                     [ $1(0, 0);], 
+                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
+      AC_LANG_RESTORE
+    ])
+  fi
   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
   if test x$glibcpp_cv_func_$1_use = x"yes"; then
     AC_CHECK_FUNCS($1)    
@@ -451,22 +464,26 @@ dnl
 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
   AC_MSG_CHECKING([for $1 declaration])
-  AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
-    AC_LANG_SAVE
-    AC_LANG_CPLUSPLUS
-    AC_TRY_COMPILE([#include <math.h>], 
-                   [ $1(0);], 
-                   [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
-    AC_LANG_RESTORE
-  ])
+  if test x${glibcpp_cv_func_$1_use+set} != xset; then
+    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
+      AC_LANG_SAVE
+      AC_LANG_CPLUSPLUS
+      AC_TRY_COMPILE([#include <math.h>], 
+                     [ $1(0);], 
+                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
+      AC_LANG_RESTORE
+    ])
+  fi
   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
   if test x$glibcpp_cv_func_$1_use = x"yes"; then
     AC_MSG_CHECKING([for $1 linkage])
-    AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
-      AC_TRY_LINK([#include <math.h>], 
-                  [ $1(0);], 
-                  [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
-    ])
+    if test x${glibcpp_cv_func_$1_link+set} != xset; then
+      AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
+        AC_TRY_LINK([#include <math.h>], 
+                    [ $1(0);], 
+                    [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
+      ])
+    fi
     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
     if test x$glibcpp_cv_func_$1_link = x"yes"; then
       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
@@ -600,11 +617,9 @@ AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(acosf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(asinf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(atanf)
-  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(ceilf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(cosf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(coshf)
-  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(floorf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
@@ -669,11 +684,9 @@ AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_acosf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_asinf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_atanf)
-  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_atan2f)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_ceilf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_cosf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_coshf)
-  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_expf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_fabsf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_floorf)
   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_fmodf)
@@ -735,12 +748,8 @@ dnl
 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
   dnl Check for complex versions of math functions of platform.
-  AC_CHECK_HEADERS([complex.h])
   AC_CHECK_LIB(m, main)
-  AC_REPLACE_MATHFUNCS(cabs cabsf ccos ccosf ccosh ccoshf cexp cexpf \
-  c_log c_logf clog10 clog10f cpow cpowf csin csinf csinh csinhf csqrt \
-  csqrtf ctan ctanf ctanh ctanhf carg cargf nan hypot hypotf atan2f expf \
-  copysignf)
+  AC_REPLACE_MATHFUNCS(nan hypot hypotf atan2f expf copysignf)
 
   dnl Compile the long double complex functions only if the function 
   dnl provides the non-complex long double functions that are needed.
@@ -750,8 +759,7 @@ AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
   if test x$ac_cv_func_atan2l = x"yes" \
      && test x$ac_cv_func_copysignl = x"yes"; then
     USE_COMPLEX_LONG_DOUBLE=yes
-    AC_REPLACE_MATHFUNCS(cabsl ccoshl ccosl cexpl cpowl csinhl csinl \
-    csqrtl ctanhl ctanl cargl hypotl signbitl c_logl clog10l)
+    AC_REPLACE_MATHFUNCS(hypotl signbitl)
   fi
 
   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
@@ -812,7 +820,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE_SUPPORT, [
     ctype_bsd=yes, ctype_bsd=no)
     AC_MSG_RESULT($ctype_bsd)
     if test $ctype_bsd = "yes"; then
-      ctype_include_dir="config/os/bsd"
+      ctype_include_dir="config/os/bsd/freebsd"
       ctype_default=no
     fi
     fi
@@ -828,7 +836,23 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE_SUPPORT, [
     ctype_freebsd34=yes, ctype_freebsd34=no)
     AC_MSG_RESULT($ctype_freebsd34)
     if test $ctype_freebsd34 = "yes"; then
-      ctype_include_dir="config/os/bsd"
+      ctype_include_dir="config/os/bsd/freebsd"
+      ctype_default=no
+    fi
+    fi
+
+    dnl Test for <ctype> functionality -- NetBSD
+    if test $ctype_default = "yes"; then
+    AC_MSG_CHECKING([<ctype> for NetBSD])
+    AC_TRY_COMPILE([#include <ctype.h>],
+    [int
+    foo (int a)
+    { return _S + _C + _U + _L \
+      + _N + _P + _X + _tolower_tab_[a] + _toupper_tab_[a];}], \
+    ctype_netbsd=yes, ctype_netbsd=no)
+    AC_MSG_RESULT($ctype_netbsd)
+    if test $ctype_netbsd = "yes"; then
+      ctype_include_dir="config/os/bsd/netbsd"
       ctype_default=no
     fi
     fi
@@ -924,7 +948,7 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE_SUPPORT, [
     ctype_newlib=yes, ctype_newlib=no)
     AC_MSG_RESULT($ctype_newlib)
     if test $ctype_newlib = "yes"; then
-      ctype_include_dir="config/newlib"
+      ctype_include_dir="config/os/newlib"
       ctype_default=no
     fi
     fi
@@ -933,13 +957,6 @@ AC_DEFUN(GLIBCPP_CHECK_CTYPE_SUPPORT, [
       ctype_include_dir="config/os/generic"
       AC_MSG_WARN("Using default ctype headers.")
     fi
-
-    AC_LINK_FILES($ctype_include_dir/bits/ctype_base.h, 
-    include/bits/ctype_base.h)
-    AC_LINK_FILES($ctype_include_dir/bits/ctype_inline.h, 
-    include/bits/ctype_inline.h)
-    AC_LINK_FILES($ctype_include_dir/bits/ctype_noninline.h, \
-    include/bits/ctype_noninline.h)
   ])
 ])
 
@@ -950,105 +967,102 @@ dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
 dnl must have been previously checked.)
 dnl
 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
-dnl Define _GLIBCPP_NEED_MBSTATE_T if mbstate_t is not in wchar.h
+dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
 dnl
 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
-  if test x$enable_c_mbchar != xno; then
-
-    dnl Sanity check for existence of ISO C9X headers for extended encoding.
-    AC_CHECK_HEADER(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
-    AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
-          
-    dnl Only continue checking if the ISO C9X headers exist.
-    if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes; then
+
+  dnl Test wchar.h for mbstate_t, which is needed for char_traits and
+  dnl others even if wchar_t support is not on.
+  AC_MSG_CHECKING([for mbstate_t])
+  AC_TRY_COMPILE([#include <wchar.h>],
+  [mbstate_t teststate;], 
+  have_mbstate_t=yes, have_mbstate_t=no)
+  AC_MSG_RESULT($have_mbstate_t)
+  if test x"$have_mbstate_t" = xyes; then
+    AC_DEFINE(HAVE_MBSTATE_T)
+  fi
+
+  dnl Sanity check for existence of ISO C99 headers for extended encoding.
+  AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
+  AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
   
-      dnl Test wchar.h for mbstate_t, which is needed for char_traits
-      dnl and others.
-      AC_MSG_CHECKING([for mbstate_t])
-      AC_TRY_COMPILE([#include <wchar.h>],
-      [mbstate_t teststate;], 
-      use_native_mbstatet=yes, use_native_mbstatet=no)
-      AC_MSG_RESULT($use_native_mbstatet)
-      if test x"$use_native_mbstatet" = xno; then
-        AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
-      fi
+  dnl Only continue checking if the ISO C99 headers exist and support is on.
+  if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes \
+     && test x"$enable_c_mbchar" != xno; then
+      
+    dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
+    dnl numeric_limits can instantiate type_traits<wchar_t>
+    AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
+    AC_TRY_COMPILE([#include <wchar.h>],
+    [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
+    has_wchar_minmax=yes, has_wchar_minmax=no)
+    AC_MSG_RESULT($has_wchar_minmax)
     
-      dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
-      dnl numeric_limits can instantiate type_traits<wchar_t>
-      AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
-      AC_TRY_COMPILE([#include <wchar.h>],
-      [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
-      has_wchar_minmax=yes, has_wchar_minmax=no)
-      AC_MSG_RESULT($has_wchar_minmax)
-    
-      dnl Test wchar.h for WEOF, which is what we use to determine whether
-      dnl to specialize for char_traits<wchar_t> or not.
-      AC_MSG_CHECKING([for WEOF])
-      AC_TRY_COMPILE([
-        #include <wchar.h>
-        #include <stddef.h>],
-      [wint_t i = WEOF;],
-      has_weof=yes, has_weof=no)
-      AC_MSG_RESULT($has_weof)
-  
-      dnl Tests for wide character functions used in char_traits<wchar_t>.
-      AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \
-      wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no)
+    dnl Test wchar.h for WEOF, which is what we use to determine whether
+    dnl to specialize for char_traits<wchar_t> or not.
+    AC_MSG_CHECKING([for WEOF])
+    AC_TRY_COMPILE([
+      #include <wchar.h>
+      #include <stddef.h>],
+    [wint_t i = WEOF;],
+    has_weof=yes, has_weof=no)
+    AC_MSG_RESULT($has_weof)
   
-      AC_MSG_CHECKING([for ISO C9X wchar_t support])
-      if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
-         && test x"$ac_wfuncs" = xyes; then
-        ac_isoC9X_wchar_t=yes
-      else
-        ac_isoC9X_wchar_t=no
-      fi
-      AC_MSG_RESULT($ac_isoC9X_wchar_t)
+    dnl Tests for wide character functions used in char_traits<wchar_t>.
+    AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset \
+    wcsrtombs mbsrtowcs, ac_wfuncs=yes, ac_wfuncs=no)
   
-      dnl Use iconv for wchar_t to char conversions. As such, check for 
-      dnl X/Open Portability Guide, version 2 features (XPG2).
-      AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
-      AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
-
-      dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
-      AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
-      ac_save_LIBS="$LIBS"
-      LIBS="$LIBS $libiconv"
-
-      AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
-      ac_XPG2funcs=yes, ac_XPG2funcs=no)
+    AC_MSG_CHECKING([for ISO C99 wchar_t support])
+    if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes \
+       && test x"$ac_wfuncs" = xyes; then
+      ac_isoC99_wchar_t=yes
+    else
+      ac_isoC99_wchar_t=no
+    fi
+    AC_MSG_RESULT($ac_isoC99_wchar_t)
   
-      AC_MSG_CHECKING([for XPG2 wchar_t support])
-      if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
-         && test x"$ac_XPG2funcs" = xyes; then
-        ac_XPG2_wchar_t=yes
-      else
-        ac_XPG2_wchar_t=no
-      fi
-      AC_MSG_RESULT($ac_XPG2_wchar_t)
+    dnl Use iconv for wchar_t to char conversions. As such, check for 
+    dnl X/Open Portability Guide, version 2 features (XPG2).
+    AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
+    AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
+
+    dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
+    AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $libiconv"
+
+    AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
+    ac_XPG2funcs=yes, ac_XPG2funcs=no)
   
-      dnl At the moment, only enable wchar_t specializations if all the
-      dnl above support is present.
-      AC_MSG_CHECKING([for enabled wchar_t specializations])
-      if test x"$ac_isoC9X_wchar_t" = xyes \
-         && test x"$ac_XPG2_wchar_t" = xyes; then
-        libinst_wstring_la="libinst-wstring.la"
-        AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
-        AC_MSG_RESULT("yes")
-      else
-        libinst_wstring_la=""
-        AC_MSG_RESULT("no")
-      fi
-      AC_SUBST(libinst_wstring_la)
+    LIBS="$ac_save_LIBS"
+
+    AC_MSG_CHECKING([for XPG2 wchar_t support])
+    if test x"$ac_has_iconv_h" = xyes && test x"$ac_has_langinfo_h" = xyes \
+       && test x"$ac_XPG2funcs" = xyes; then
+      ac_XPG2_wchar_t=yes
+    else
+      ac_XPG2_wchar_t=no
+    fi
+    AC_MSG_RESULT($ac_XPG2_wchar_t)
   
+    dnl At the moment, only enable wchar_t specializations if all the
+    dnl above support is present.
+    AC_MSG_CHECKING([for enabled wchar_t specializations])
+    if test x"$ac_isoC99_wchar_t" = xyes \
+       && test x"$ac_XPG2_wchar_t" = xyes; then
+      libinst_wstring_la="libinst-wstring.la"
+      AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
+      AC_MSG_RESULT("yes")
     else
-      AC_MSG_WARN([<wchar.h> not found])
-      AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
+      libinst_wstring_la=""
+      AC_MSG_RESULT("no")
     fi
-
+    AC_SUBST(libinst_wstring_la)
+  
   else
-    dnl Wide characters disabled by the user.  Maybe print a warning?
-    :
+    dnl Wide characters disabled by the user. 
+    AC_MSG_WARN([wchar_t support disabled.])
   fi
 ])
 
@@ -1151,7 +1165,7 @@ dnl Option parsed, now set things appropriately
 case "${enable_debug}" in
     yes) 
         DEBUG_FLAGS='-O0 -ggdb3'                        
-        ;;
+        ;; 
     no)   
         DEBUG_FLAGS='-g'
         ;;
@@ -1169,9 +1183,9 @@ dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
 dnl     Somehow this same set of flags must be passed when [re]building
 dnl     libgcc.
 dnl --disable-cxx-flags passes nothing.
-dnl  +  See http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00131.html
-dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00284.html
-dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q1/msg00035.html
+dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
+dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
+dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
 dnl       If "default flags" is an empty string (or "none"), the effect is
 dnl       the same as --disable or --enable=no.
@@ -1220,24 +1234,24 @@ dnl
 dnl GLIBCPP_ENABLE_CSTDIO
 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
 dnl 
-dnl default is libio
+dnl default is stdio
 dnl
 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
   AC_MSG_CHECKING([for cstdio to use])
   AC_ARG_ENABLE(cstdio,
-  [  --enable-cstdio        enable GNU libio for target io package. (default)
-     --enable-cstdio=LIB    use LIB target-speific io package.], 
+  [  --enable-cstdio        enable stdio for target io package. 
+     --enable-cstdio=LIB    use LIB target-speific io package. [default=stdio]
+  ], 
   if test x$enable_cstdio = xno; then
-     enable_cstdio=libio
+     enable_cstdio=stdio
   fi,
-     enable_cstdio=libio)
+     enable_cstdio=stdio)
 
   enable_cstdio_flag=$enable_cstdio
 
   dnl Check if a valid I/O package
   case x${enable_cstdio_flag} in
-    xlibio | x | xno | xnone | xyes)
-      # default
+    xlibio)
       CSTDIO_H=config/c_io_libio.h
       CSTDIO_CC=config/c_io_libio.cc
       AC_MSG_RESULT(libio)
@@ -1292,12 +1306,17 @@ AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
          fi
       fi
       ;;
-    xstdio)
+    xstdio | x | xno | xnone | xyes)
+      # default
       CSTDIO_H=config/c_io_stdio.h
       CSTDIO_CC=config/c_io_stdio.cc
       AC_MSG_RESULT(stdio)
 
+      # We're not using stdio.
       need_libio=no
+      need_wlibio=no
+      # Wide characters are not supported with this package.
+      enable_c_mbchar=no
       ;;
     *)
       echo "$enable_cstdio is an unknown io package" 1>&2
@@ -1312,8 +1331,16 @@ AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
   AC_LINK_FILES($CCODECVT_C, libio/c_codecvt.c)
   # 2000-08-04 bkoz hack
 
+  AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
+                 test "$need_libio" = yes || test "$need_wlibio" = yes)
   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
   AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
+  if test "$need_libio" = yes || test "$need_wlibio" = yes; then
+    libio_la=../libio/libio.la
+  else
+    libio_la=
+  fi
+  AC_SUBST(libio_la)
 ])
 
 
@@ -1331,8 +1358,9 @@ AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
   dnl Efforts should be made to keep this in sync.
   AC_MSG_CHECKING([for threads package to use])
   AC_ARG_ENABLE(threads,
-  [  --enable-threads        enable thread usage for target GCC.
-     --enable-threads=LIB    use LIB thread package for target GCC.],
+  [  --enable-threads       enable thread usage for target GCC.
+     --enable-threads=LIB   use LIB thread package for target GCC. [default=no]
+  ],
   if test x$enable_threads = xno; then
     enable_threads=''
   fi,
@@ -1389,18 +1417,10 @@ dnl Enable atomic locking
 dnl GLIBCPP_ENABLE_ATOMICITY
 AC_DEFUN(GLIBCPP_ENABLE_ATOMICITY, [
     AC_MSG_CHECKING([for atomicity.h])
-    case "$target" in
-      *-*-linux* | sparc*-*-* | *-*-freebsd*)
-        ATOMICITYH=$cpu_include_dir
-        ;;    
-      *-*-aix* | *-*-irix*)
-        ATOMICITYH=$os_include_dir
-        ;;
-      *)
-        # bit of overkill on this text...
-        AC_MSG_ERROR([Atomic locking requested, but $enable_threads is an unknown thread package and atomic operations are not present in the CPU])
-        ;;
-    esac
+    # We have ATOMICITY already from GLIBCPP_CONFIGURE
+    if test "$ATOMICITYH" = "config/cpu/generic"; then
+      AC_MSG_WARN([No ATOMICITY settings found, using generic atomic ops.])
+    fi
     AC_MSG_RESULT($ATOMICITYH/bits/atomicity.h)
     AC_LINK_FILES($ATOMICITYH/bits/atomicity.h, include/bits/atomicity.h)
 ])
@@ -1431,62 +1451,93 @@ AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
    esac],
   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
+  # Allow use of os-dependent settings, so that macros that turn on
+  # C99 capabilities can be defined and used in a consistent way.
+  OS_INC_PATH=${srcdir}/$os_include_dir
+  ac_test_CFLAGS="${CFLAGS+set}"
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="-I$OS_INC_PATH"
 
-  # Check for the existance of functions used if long long is enabled.
+  # Check for the existence of functions used if long long is enabled.
   AC_CHECK_FUNC(strtoll,,ac_strtoll=no)
   AC_CHECK_FUNC(strtoull,,ac_strtoull=no)
 
+  # Check for lldiv_t, et. al.
+  AC_MSG_CHECKING([for lldiv_t declaration])
+  AC_CACHE_VAL(glibcpp_lldiv_t_use, [
+  AC_TRY_COMPILE([#include <bits/os_defines.h>
+                  #include <stdlib.h>], 
+                   [ lldiv_t mydivt;], 
+                   [glibcpp_lldiv_t_use=yes], [glibcpp_lldiv_t_use=no])
+  ])
+  AC_MSG_RESULT($glibcpp_lldiv_t_use)
+  if test x$glibcpp_lldiv_t_use = x"yes"; then
+    AC_DEFINE(HAVE_LLDIV_T)
+  fi
+
   AC_MSG_CHECKING([for enabled long long])
   if test x"$ac_strtoll" = xno || test x"$ac_strtoull" = xno; then 
     enable_long_long=no; 
   fi; 
   AC_MSG_RESULT($enable_long_long)
 
-  dnl Option parsed, now set things appropriately
+  # Option parsed, now set things appropriately
   if test x"$enable_long_long" = xyes; then
     AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
   fi
+
+  # Reset CFLAGS
+  CFLAGS="$ac_save_CFLAGS"
 ])
 
 
 dnl
-dnl Check for whether or not to do shadowed C headers.
+dnl Check for what kind of C headers to use.
 dnl
-dnl GLIBCPP_ENABLE_SHADOW
-dnl --enable-cshadow-headers [does stuff].
-dnl --disable-cshadow-headers [does not do stuff].
-dnl  +  This will eventually need to be on by default.
-dnl  +  Usage:  GLIBCPP_ENABLE_SHADOW[(DEFAULT)]
-dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
-dnl       defaults to `no'.
-AC_DEFUN(GLIBCPP_ENABLE_SHADOW, [dnl
-define([GLIBCPP_ENABLE_SHADOW_DEFAULT], ifelse($1, yes, yes, no))dnl
-AC_MSG_CHECKING([for enabled cshadow headers])
-AC_ARG_ENABLE(cshadow-headers,
+dnl GLIBCPP_ENABLE_CHEADERS
+dnl --enable-cheaders= [does stuff].
+dnl --disable-cheaders [does not do anything, really].
+dnl  +  This will eventually need to be 'c_shadow' by default.
+dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
+dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
+dnl       If ommitted, it defaults to `c_std'.
+AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
+define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
+AC_MSG_CHECKING([for c header strategy to use])
+AC_ARG_ENABLE(cheaders,
 changequote(<<, >>)dnl
-<<  --enable-cshadow-headers construct "shadowed" C header files for
-                           g++ [default=>>GLIBCPP_ENABLE_SHADOW_DEFAULT],
+<<  --enable-cheaders construct "C" header files for
+                           g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
 changequote([, ])
   [case "$enableval" in
-   yes) enable_cshadow_headers=yes 
+   c) 
+       enable_cheaders=c 
+        ;;
+   c_std)  
+       enable_cheaders=c_std 
         ;;
-   no)  enable_cshadow_headers=no 
+   c_shadow)  
+       enable_cheaders=c_shadow 
         ;;
-   *)   AC_MSG_ERROR([Unknown argument to enable/disable shadowed C headers]) 
+   *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
         ;;
   esac],
-  enable_cshadow_headers=GLIBCPP_ENABLE_SHADOW_DEFAULT)
-  AC_MSG_RESULT($enable_cshadow_headers)
+  enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
+  AC_MSG_RESULT($enable_cheaders)
 
   dnl Option parsed, now set things appropriately
-  dnl NB: these things may be duplicated in c++config.h as well.
-  case "$enable_cshadow_headers" in
-    yes) 
+  case "$enable_cheaders" in
+    c_shadow) 
         CSHADOW_FLAGS="-fno-builtin"
-        C_INCLUDE_DIR='${top_srcdir}/include/c_std'
+        C_INCLUDE_DIR='${top_srcdir}/include/c_shadow'
         AC_DEFINE(_GLIBCPP_USE_SHADOW_HEADERS)
         ;;
-    no)   
+    c_std)   
+        CSHADOW_FLAGS=""
+        C_INCLUDE_DIR='${top_srcdir}/include/c_std'
+        ;;
+    c)   
         CSHADOW_FLAGS=""
         C_INCLUDE_DIR='${top_srcdir}/include/c'
         ;;
@@ -1494,7 +1545,7 @@ changequote([, ])
 
   AC_SUBST(CSHADOW_FLAGS)
   AC_SUBST(C_INCLUDE_DIR)
-  AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cshadow_headers" = yes)
+  AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cheaders" = c_shadow)
 ])
 
 
@@ -1542,10 +1593,12 @@ AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
 
   # Can either use include/c or include/c_std to grab "C" headers. This
   # variable is set to the include directory currently in use.
-  # set with C_INCLUDE_DIR in GLIBCPP_ENABLE_SHADOW
+  # set with C_INCLUDE_DIR in GLIBCPP_ENABLE_CHEADERS
    
-  # Passed down for cross compilers, canadian crosses.
-  TOPLEVEL_INCLUDES='-I$(includedir)'
+  # Passed down for canadian crosses.
+  if  test x"$CANADIAN" = xyes; then
+    TOPLEVEL_INCLUDES='-I$(includedir)'
+  fi
 
   LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
 
@@ -1561,7 +1614,7 @@ AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
   #  CSHADOW_INCLUDES='-I$(GLIBCPP_INCLUDE_DIR)/std -I$(C_INCLUDE_DIR) \
   #                   -I$(top_blddir)/cshadow'
   #else
-  CSHADOW_INCLUDES='-I$(GLIBCPP_INCLUDE_DIR)/std -I$(C_INCLUDE_DIR)'
+  CSTD_INCLUDES='-I$(GLIBCPP_INCLUDE_DIR)/std -I$(C_INCLUDE_DIR)'
   #endif
 
   # Now, export this to all the little Makefiles....
@@ -1570,7 +1623,7 @@ AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
   AC_SUBST(LIBMATH_INCLUDES)
   AC_SUBST(LIBSUPCXX_INCLUDES)
   AC_SUBST(LIBIO_INCLUDES)
-  AC_SUBST(CSHADOW_INCLUDES)
+  AC_SUBST(CSTD_INCLUDES)
 ])
 
 
@@ -1599,15 +1652,16 @@ AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
 
 # serial 1
 
-AC_DEFUN(AC_LC_MESSAGES,
-  [if test $ac_cv_header_locale_h = yes; then
+AC_DEFUN(AC_LC_MESSAGES, [
+  AC_CHECK_HEADER(locale.h, [
     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
     if test $ac_cv_val_LC_MESSAGES = yes; then
       AC_DEFINE(HAVE_LC_MESSAGES)
     fi
-  fi])
+  ])
+])
 
 
 # Check for functions in math library.