OSDN Git Service

config/
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
index 8fe294d..c26225e 100644 (file)
@@ -170,8 +170,8 @@ AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [
 
   # Check for -ffunction-sections -fdata-sections
   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
-  CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
-  AC_TRY_COMPILE(, [int foo;], [ac_fdsections=yes], [ac_fdsections=no])
+  CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
+  AC_TRY_COMPILE([int foo; void bar() { };],, [ac_fdsections=yes], [ac_fdsections=no])
   if test "$ac_test_CXXFLAGS" = set; then
     CXXFLAGS="$ac_save_CXXFLAGS"
   else
@@ -231,14 +231,16 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
 
   # Start by getting the version number.  I think the libtool test already
   # does some of this, but throws away the result.
-  AC_MSG_CHECKING([for ld version])
-  changequote(,)
-  ldver=`$LD --version 2>/dev/null | head -1 | \
-         sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
-  changequote([,])
-  glibcxx_gnu_ld_version=`echo $ldver | \
-         $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
-  AC_MSG_RESULT($glibcxx_gnu_ld_version)
+  if test x"$with_gnu_ld" = x"yes"; then
+    AC_MSG_CHECKING([for ld version])
+    changequote(,)
+    ldver=`$LD --version 2>/dev/null | head -1 | \
+           sed -e 's/GNU ld \(version \)\{0,1\}\(([^)]*) \)\{0,1\}\([0-9.][0-9.]*\).*/\3/'`
+    changequote([,])
+    glibcxx_gnu_ld_version=`echo $ldver | \
+           $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
+    AC_MSG_RESULT($glibcxx_gnu_ld_version)
+  fi
 
   # Set --gc-sections.
   glibcxx_gcsections_min_ld=21602
@@ -249,11 +251,9 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
     # NB: This flag only works reliably after 2.16.1. Configure tests
     # for this are difficult, so hard wire a value that should work.
 
-    # All these tests are for C++, but run with the "C" compiler driver.
-    # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
     ac_test_CFLAGS="${CFLAGS+set}"
     ac_save_CFLAGS="$CFLAGS"
-    CFLAGS='-x c++ -Wl,--gc-sections'
+    CFLAGS='-Wl,--gc-sections'
 
     # Check for -Wl,--gc-sections
     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
@@ -308,53 +308,6 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
 
 
 dnl
-dnl Check to see if this target can enable the iconv specializations.
-dnl If --disable-c-mbchar was given, no wchar_t specialization is enabled.  
-dnl (This must have been previously checked, along with the rest of C99 
-dnl support.) By default, iconv support is disabled.
-dnl
-dnl Defines:
-dnl  _GLIBCXX_USE_ICONV if all the bits are found.
-dnl Substs:
-dnl  LIBICONV to a -l string containing the iconv library, if needed.
-dnl
-AC_DEFUN([GLIBCXX_CHECK_ICONV_SUPPORT], [
-
-  enable_iconv=no
-  # Only continue checking if the ISO C99 headers exist and support is on.
-  if test x"$enable_wchar_t" = xyes; then
-
-    # Use iconv for wchar_t to char conversions. As such, check for
-    # 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)
-
-    # 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_SUBST(LIBICONV)
-
-    AC_CHECK_FUNCS([iconv_open iconv_close iconv nl_langinfo],
-    [ac_XPG2funcs=yes], [ac_XPG2funcs=no])
-
-    LIBS="$ac_save_LIBS"
-
-    if test x"$ac_has_iconv_h" = xyes &&
-       test x"$ac_has_langinfo_h" = xyes &&
-       test x"$ac_XPG2funcs" = xyes;
-    then
-      AC_DEFINE([_GLIBCXX_USE_ICONV],1,
-               [Define if iconv and related functions exist and are usable.])
-      enable_iconv=yes
-    fi
-  fi
-  AC_MSG_CHECKING([for enabled iconv specializations])
-  AC_MSG_RESULT($enable_iconv)
-])
-
-
-dnl
 dnl Check for headers for, and arguments to, the setrlimit() function.
 dnl Used only in testsuite_hooks.h.  Called from GLIBCXX_CONFIGURE_TESTSUITE.
 dnl
@@ -653,8 +606,8 @@ dnl
 AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
   # Optimization flags that are probably a good idea for thrill-seekers. Just
   # uncomment the lines below and make, everything else is ready to go...
+  # Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host.
   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
-  OPTIMIZE_CXXFLAGS=
   AC_SUBST(OPTIMIZE_CXXFLAGS)
 
   WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
@@ -840,6 +793,7 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
   # This is necessary even though libstdc++ uses the builtin versions
   # of these functions, because if the builtin cannot be used, a reference
   # to the library function is emitted.
+  AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
   AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
   ac_c99_complex=no;
   if test x"$ac_has_complex_h" = x"yes"; then
@@ -1304,24 +1258,151 @@ AC_DEFUN([GLIBCXX_CHECK_RANDOM_TR1], [
 ])
 
 dnl
+dnl Check whether macros, etc are present for <system_error>
+dnl
+AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
+
+  AC_MSG_CHECKING([for EOWNERDEAD])
+  AC_CACHE_VAL(ac_system_error1, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = EOWNERDEAD; ],
+             [ac_system_error1=yes], [ac_system_error1=no])
+  ])
+  AC_MSG_RESULT($ac_system_error1)
+  if test x"$ac_system_error1" = x"yes"; then
+    AC_DEFINE(HAVE_EOWNERDEAD, 1, [Define if EOWNERDEAD exists.])
+  fi
+
+  AC_MSG_CHECKING([for ENOTRECOVERABLE])
+  AC_CACHE_VAL(ac_system_error2, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = ENOTRECOVERABLE; ],
+             [ac_system_error2=yes], [ac_system_error2=no])
+  ])
+  AC_MSG_RESULT($ac_system_error2)
+  if test x"$ac_system_error2" = x"yes"; then
+    AC_DEFINE(HAVE_ENOTRECOVERABLE, 1, [Define if ENOTRECOVERABLE exists.])
+  fi
+
+  AC_MSG_CHECKING([for ENOLINK])
+  AC_CACHE_VAL(ac_system_error3, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = ENOLINK; ],
+             [ac_system_error3=yes], [ac_system_error3=no])
+  ])
+  AC_MSG_RESULT($ac_system_error3)
+  if test x"$ac_system_error3" = x"yes"; then
+    AC_DEFINE(HAVE_ENOLINK, 1, [Define if ENOLINK exists.])
+  fi
+
+  AC_MSG_CHECKING([for EPROTO])
+  AC_CACHE_VAL(ac_system_error_4, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = EPROTO; ],
+             [ac_system_error_4=yes], [ac_system_error_4=no])
+  ])
+  AC_MSG_RESULT($ac_system_error_4)
+  if test x"$ac_system_error_4" = x"yes"; then
+    AC_DEFINE(HAVE_EPROTO, 1, [Define if EPROTO exists.])
+  fi
+
+  AC_MSG_CHECKING([for ENODATA])
+  AC_CACHE_VAL(ac_system_error_5, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = ENODATA; ],
+             [ac_system_error_5=yes], [ac_system_error_5=no])
+  ])
+  AC_MSG_RESULT($ac_system_error_5)
+  if test x"$ac_system_error_5" = x"yes"; then
+    AC_DEFINE(HAVE_ENODATA, 1, [Define if ENODATA exists.])
+  fi
+
+  AC_MSG_CHECKING([for ENOSR])
+  AC_CACHE_VAL(ac_system_error_6, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = ENOSR; ],
+             [ac_system_error_6=yes], [ac_system_error_6=no])
+  ])
+  AC_MSG_RESULT($ac_system_error_6)
+  if test x"$ac_system_error_6" = x"yes"; then
+    AC_DEFINE(HAVE_ENOSR, 1, [Define if ENOSR exists.])
+  fi
+
+  AC_MSG_CHECKING([for ENOSTR])
+  AC_CACHE_VAL(ac_system_error_7, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = ENOSTR; ],
+             [ac_system_error_7=yes], [ac_system_error_7=no])
+  ])
+  AC_MSG_RESULT($ac_system_error_7)
+  if test x"$ac_system_error_7" = x"yes"; then
+    AC_DEFINE(HAVE_ENOSTR, 1, [Define if ENOSTR exists.])
+  fi
+
+  AC_MSG_CHECKING([for ETIME])
+  AC_CACHE_VAL(ac_system_error_8, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = ETIME; ],
+             [ac_system_error_8=yes], [ac_system_error_8=no])
+  ])
+  AC_MSG_RESULT($ac_system_error_8)
+  if test x"$ac_system_error_8" = x"yes"; then
+    AC_DEFINE(HAVE_ETIME, 1, [Define if ETIME exists.])
+  fi
+
+  AC_MSG_CHECKING([for sys_nerr])
+  AC_CACHE_VAL(ac_system_error9, [
+  AC_TRY_COMPILE([#include <errno.h> ], [ int i = sys_nerr; ],
+             [ac_system_error9=yes], [ac_system_error9=no])
+  ])
+  AC_MSG_RESULT($ac_system_error9)
+  if test x"$ac_system_error9" = x"yes"; then
+    AC_DEFINE(HAVE_SYS_NERR, 1, [Define if sys_nerr exists.])
+  fi
+
+  AC_MSG_CHECKING([for EBADMSG])
+  AC_CACHE_VAL(ac_system_error_10, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = EBADMSG; ],
+             [ac_system_error_10=yes], [ac_system_error_10=no])
+  ])
+  AC_MSG_RESULT($ac_system_error_10)
+  if test x"$ac_system_error_10" = x"yes"; then
+    AC_DEFINE(HAVE_EBADMSG, 1, [Define if EBADMSG exists.])
+  fi
+
+  AC_MSG_CHECKING([for ECANCELED])
+  AC_CACHE_VAL(ac_system_error_11, [
+  AC_TRY_COMPILE([#include <errno.h>], [ int i = ECANCELED; ],
+             [ac_system_error_11=yes], [ac_system_error_11=no])
+  ])
+  AC_MSG_RESULT($ac_system_error_11)
+  if test x"$ac_system_error_11" = x"yes"; then
+    AC_DEFINE(HAVE_ECANCELED, 1, [Define if ECANCELED exists.])
+  fi
+])
+
+dnl
 dnl Check for what type of C headers to use.
 dnl
 dnl --enable-cheaders= [does stuff].
 dnl --disable-cheaders [does not do anything, really].
 dnl  +  Usage:  GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
-dnl       Where DEFAULT is either `c' or `c_std'.
+dnl       Where DEFAULT is either 'c' or 'c_std' or 'c_global'.
 dnl
 AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
   GLIBCXX_ENABLE(cheaders,$1,[=KIND],
-    [construct "C" headers for g++], [permit c|c_std])
+    [construct "C" headers for g++], [permit c|c_std|c_global])
   AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
 
   C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
 
+  # Allow overrides to configure.host here.
+  if test $enable_cheaders = c_global; then
+     c_compatibility=yes
+  fi
+
+  if test $enable_cheaders = c_global || test $enable_cheaders = c_std; then
+     c_extra=yes
+  fi
+
   AC_SUBST(C_INCLUDE_DIR)
   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
+  GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global)
   GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
+  GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_EXTRA, test $c_extra = yes)
 ])
 
 
@@ -1332,64 +1413,31 @@ dnl
 dnl Default is generic.
 dnl
 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
-  AC_MSG_CHECKING([for C locale to use])
   GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
     [use MODEL for target locale package],
     [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
+
+  # Deal with gettext issues.  Default to not using it (=no) until we detect
+  # support for it later.  Let the user turn it off via --e/d, but let that
+  # default to on for easier handling.
+  USE_NLS=no
+  AC_ARG_ENABLE(nls,
+    AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
+    [],
+    [enable_nls=yes])
   
-  # If they didn't use this option switch, or if they specified --enable
-  # with no specific model, we'll have to look for one.  If they
-  # specified --disable (???), do likewise.
+  # Either a known packaage, or "auto"
   if test $enable_clocale = no || test $enable_clocale = yes; then
      enable_clocale=auto
   fi
-
-  # Either a known package, or "auto"
   enable_clocale_flag=$enable_clocale
 
-  # Probe for locale support if no specific model is specified.
+  # Probe for locale model to use if none specified.
   # Default to "generic".
   if test $enable_clocale_flag = auto; then
     case ${target_os} in
       linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
-        AC_EGREP_CPP([_GLIBCXX_ok], [
-        #include <features.h>
-        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
-          _GLIBCXX_ok
-        #endif
-        ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
-
-        # Test for bugs early in glibc-2.2.x series
-          if test $enable_clocale_flag = gnu; then
-          AC_TRY_RUN([
-          #define _GNU_SOURCE 1
-          #include <locale.h>
-          #include <string.h>
-          #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
-          extern __typeof(newlocale) __newlocale;
-          extern __typeof(duplocale) __duplocale;
-          extern __typeof(strcoll_l) __strcoll_l;
-          #endif
-          int main()
-          {
-              const char __one[] = "Äuglein Augmen";
-              const char __two[] = "Äuglein";
-              int i;
-              int j;
-              __locale_t        loc;
-               __locale_t        loc_dup;
-              loc = __newlocale(1 << LC_ALL, "de_DE", 0);
-              loc_dup = __duplocale(loc);
-              i = __strcoll_l(__one, __two, loc);
-              j = __strcoll_l(__one, __two, loc_dup);
-              return 0;
-          }
-          ],
-          [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
-          [enable_clocale_flag=generic])
-          fi
-
-        # ... at some point put __strxfrm_l tests in as well.
+        enable_clocale_flag=gnu        
         ;;
       darwin* | freebsd*)
         enable_clocale_flag=darwin
@@ -1400,16 +1448,81 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
     esac
   fi
 
-  # Deal with gettext issues.  Default to not using it (=no) until we detect
-  # support for it later.  Let the user turn it off via --e/d, but let that
-  # default to on for easier handling.
-  USE_NLS=no
-  AC_ARG_ENABLE(nls,
-    AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
-    [],
-    [enable_nls=yes])
+  # Sanity check model, and test for special functionality.
+  if test $enable_clocale_flag = gnu; then
+    AC_EGREP_CPP([_GLIBCXX_ok], [
+    #include <features.h>
+    #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
+      _GLIBCXX_ok
+    #endif
+    ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
+
+    if test $enable_clocale = auto; then
+      # Test for bugs early in glibc-2.2.x series
+      AC_TRY_RUN([
+      #define _GNU_SOURCE 1
+      #include <locale.h>
+      #include <string.h>
+      #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
+      extern __typeof(newlocale) __newlocale;
+      extern __typeof(duplocale) __duplocale;
+      extern __typeof(strcoll_l) __strcoll_l;
+      #endif
+      int main()
+      {
+       const char __one[] = "Äuglein Augmen";
+        const char __two[] = "Äuglein";
+               int i;
+        int j;
+        __locale_t        loc;
+        __locale_t        loc_dup;
+        loc = __newlocale(1 << LC_ALL, "de_DE", 0);
+        loc_dup = __duplocale(loc);
+        i = __strcoll_l(__one, __two, loc);
+        j = __strcoll_l(__one, __two, loc_dup);
+        return 0;
+      }
+      ],
+      [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
+      [enable_clocale_flag=generic])
+    fi
+
+    # Set it to scream when it hurts.
+    ac_save_CFLAGS="$CFLAGS"   
+    CFLAGS="-Wimplicit-function-declaration -Werror"
+
+    # Use strxfrm_l if available.
+    AC_TRY_COMPILE([#define _GNU_SOURCE 1
+                   #include <string.h>
+                   #include <locale.h>],
+                   [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);], 
+                    AC_DEFINE(HAVE_STRXFRM_L, 1, 
+                    [Define if strxfrm_l is available in <string.h>.]),)
+    
+    # Use strerror_l if available.
+    AC_TRY_COMPILE([#define _GNU_SOURCE 1
+                   #include <string.h>
+                   #include <locale.h>],
+                   [__locale_t loc; strerror_l(5, loc);], 
+                    AC_DEFINE(HAVE_STRERROR_L, 1, 
+                    [Define if strerror_l is available in <string.h>.]),)
+
+    CFLAGS="$ac_save_CFLAGS"
+  fi
+
+  # Perhaps use strerror_r if available, and strerror_l isn't.
+  ac_save_CFLAGS="$CFLAGS"     
+  CFLAGS="-Wimplicit-function-declaration -Werror"
+  AC_TRY_COMPILE([#define _GNU_SOURCE 1
+                 #include <string.h>
+                 #include <locale.h>],
+                 [char s[128]; strerror_r(5, s, 128);], 
+                  AC_DEFINE(HAVE_STRERROR_R, 1, 
+                  [Define if strerror_r is available in <string.h>.]),)
+  CFLAGS="$ac_save_CFLAGS"
 
   # Set configure bits for specified locale package
+  AC_MSG_CHECKING([for C locale to use])
   case ${enable_clocale_flag} in
     generic)
       AC_MSG_RESULT(generic)
@@ -1612,6 +1725,35 @@ AC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [
   fi
 ])
 
+dnl
+dnl Check for parallel mode pre-requisites, including OpenMP support.
+dnl
+dnl  +  Usage:  GLIBCXX_ENABLE_PARALLEL
+dnl
+AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
+
+  # NB: libstdc++ may be configured before libgomp: can't check for the actual
+  # dependencies (omp.h and libgomp). 
+  enable_parallel=no;
+  if test -f $glibcxx_builddir/../libgomp/omp.h; then
+    enable_parallel=yes;
+  else
+    AC_MSG_NOTICE([$glibcxx_builddir/../libgomp/omp.h not found])
+  fi
+
+  # Check to see if it's explicitly disabled.
+#  GLIBCXX_ENABLE(libgomp,$1,,[enable code depending on libgomp],
+#      [permit yes|no])
+
+#  if test x$enable_libgomp = xno; then
+#    enable_parallel=no
+#  fi
+
+  AC_MSG_CHECKING([for parallel mode support])
+  AC_MSG_RESULT([$enable_parallel])
+  GLIBCXX_CONDITIONAL(ENABLE_PARALLEL, test $enable_parallel = yes)
+])
+
 
 dnl
 dnl Check for which I/O library to use:  stdio, or something specific.
@@ -1959,7 +2101,7 @@ AC_DEFUN([GLIBCXX_ENABLE_PCH], [
 
   GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
   if test $enable_libstdcxx_pch = yes; then
-    glibcxx_PCHFLAGS="-include bits/stdtr1c++.h"
+    glibcxx_PCHFLAGS="-include bits/stdc++.h"
   else
     glibcxx_PCHFLAGS=""
   fi
@@ -2158,7 +2300,7 @@ AC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES])
 
 # Turn a 'yes' into a suitable default.
 if test x$enable_symvers = xyes ; then
-  if test $enable_shared = no || test "x$LD" = x ; then
+  if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then
     enable_symvers=no
   else
     if test $with_gnu_ld = yes ; then