OSDN Git Service

2003-12-15 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
index c5f0377..f124358 100644 (file)
@@ -1,5 +1,22 @@
 
 dnl
+dnl GLIBCXX_CONDITIONAL (NAME, SHELL-TEST)
+dnl
+dnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the
+dnl end of configure.  This lets tested variables be reassigned, and the
+dnl conditional will depend on the final state of the variable.  For a simple
+dnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED.
+dnl
+m4_define([_m4_divert(glibcxx_diversion)], 8000)dnl
+AC_DEFUN(GLIBCXX_CONDITIONAL, [dnl
+  m4_divert_text([glibcxx_diversion],dnl
+   AM_CONDITIONAL([$1],[$2])
+  )dnl
+])dnl
+AC_DEFUN(GLIBCXX_EVALUATE_CONDITIONALS, [m4_undivert([glibcxx_diversion])])dnl
+
+
+dnl
 dnl Check to see what architecture and operating system we are compiling
 dnl for.  Also, if architecture- or OS-specific flags are required for
 dnl compilation, pick them up here.
@@ -48,6 +65,7 @@ dnl variables like $host.
 dnl
 dnl Sets:
 dnl  gcc_version          (x.y.z format)
+dnl  SUBDIRS
 dnl Substs:
 dnl  glibcxx_builddir     (absolute path)
 dnl  glibcxx_srcdir       (absolute path)
@@ -61,6 +79,12 @@ dnl  - default settings for all AM_CONFITIONAL test variables
 dnl  - lots of tools, like CC and CXX
 dnl
 AC_DEFUN(GLIBCXX_CONFIGURE, [
+  # Keep these sync'd with the list in Makefile.am.  The first provides an
+  # expandable list at autoconf time; the second provides an expandable list
+  # (i.e., shell variable) at configure time.
+  m4_define([glibcxx_SUBDIRS],[include libmath libsupc++ src po testsuite])
+  SUBDIRS='glibcxx_SUBDIRS'
+
   # These need to be absolute paths, yet at the same time need to
   # canonicalize only relative paths, because then amd will not unmount
   # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
@@ -122,9 +146,6 @@ AC_DEFUN(GLIBCXX_CONFIGURE, [
   gcc_version=`$CXX -dumpversion`
   AC_MSG_RESULT($gcc_version)
 
-  # For some reason, gettext needs this.
-  AC_ISC_POSIX
-
   # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
   # available).  Uncomment the next line to force a particular method.
   AC_PROG_LN_S
@@ -136,7 +157,10 @@ AC_DEFUN(GLIBCXX_CONFIGURE, [
 
   AM_MAINTAINER_MODE
 
-  # Set up safe default values for all subsequent AM_CONDITIONAL tests.
+  # Set up safe default values for all subsequent AM_CONDITIONAL tests
+  # which are themselves conditionally expanded.
+  ## (Right now, this only matters for enable_wchar_t, but nothing prevents
+  ## other macros from doing the same.  This should be automated.)  -pme
   need_libmath=no
   enable_wchar_t=no
   #enable_libstdcxx_debug=no
@@ -145,6 +169,7 @@ AC_DEFUN(GLIBCXX_CONFIGURE, [
   #c_compatibility=no
   #enable_abi_check=no
   #enable_symvers=no
+  #enable_hosted_libstdcxx=yes
 
   # Find platform-specific directories containing configuration info.
   # Also possibly modify flags used elsewhere, as needed by the platform.
@@ -153,6 +178,7 @@ AC_DEFUN(GLIBCXX_CONFIGURE, [
 
 
 m4_include([linkage.m4])
+m4_include([../config/no-executables.m4])
 
 
 dnl
@@ -357,13 +383,18 @@ AC_DEFUN(GLIBCXX_CHECK_WCHAR_T_SUPPORT, [
 
     # Checks for names injected into std:: by the c_std headers.
     AC_CHECK_FUNCS([btowc wctob fgetwc fgetws fputwc fputws fwide \
-    fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
-    vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
-    mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
+    fwprintf fwscanf swprintf swscanf vfwprintf vswprintf \
+    vwprintf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
+    mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstol \
     wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
     wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr],
     [],[ac_wfuncs=no])
 
+    # Checks for wide character functions that are not required
+    # for basic wchar_t support.  Don't disable support if they are missing.
+    # Injection of these is wrapped with guard macros.
+    AC_CHECK_FUNCS([vfwscanf vswscanf vwscanf wcstof iswblank],[],[])
+
     AC_MSG_CHECKING([for ISO C99 wchar_t support])
     if test x"$has_weof" = xyes &&
        test x"$has_wchar_minmax" = xyes &&
@@ -509,7 +540,7 @@ dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
 dnl
 AC_DEFUN(GLIBCXX_CHECK_POLL, [
   AC_CACHE_VAL(glibcxx_cv_POLL, [
-    AC_TRY_COMPILE(
+    AC_TRY_LINK(
       [#include <poll.h>],
       [struct pollfd pfd[1];
        pfd[0].events = POLLIN;
@@ -528,7 +559,7 @@ dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
 dnl
 AC_DEFUN(GLIBCXX_CHECK_WRITEV, [
   AC_CACHE_VAL(glibcxx_cv_WRITEV, [
-    AC_TRY_COMPILE(
+    AC_TRY_LINK(
       [#include <sys/uio.h>],
       [struct iovec iov[2];
        writev(0, iov, 0);],
@@ -542,6 +573,49 @@ AC_DEFUN(GLIBCXX_CHECK_WRITEV, [
 
 
 dnl
+dnl Check whether int64_t is available in <stdint.h>, and define HAVE_INT64_T.
+dnl
+AC_DEFUN(GLIBCXX_CHECK_INT64_T, [
+  AC_CACHE_VAL(glibcxx_cv_INT64_T, [
+    AC_TRY_COMPILE(
+      [#include <stdint.h>],
+      [int64_t var;],
+      [glibcxx_cv_INT64_T=yes],
+      [glibcxx_cv_INT64_T=no])
+  ])
+  if test $glibcxx_cv_INT64_T = yes; then
+    AC_DEFINE(HAVE_INT64_T)
+  fi
+])
+
+
+dnl
+dnl Check whether LFS support is available.
+dnl
+AC_DEFUN(GLIBCXX_CHECK_LFS, [
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS    
+  AC_CACHE_VAL(glibcxx_cv_LFS, [
+    AC_TRY_LINK(
+      [#include <unistd.h>
+       #include <stdio.h>
+      ],
+      [FILE* fp;
+       fopen64("t", "w");
+       fseeko64(fp, 0, SEEK_CUR);
+       ftello64(fp);
+       lseek64(1, 0, SEEK_CUR);],      
+      [glibcxx_cv_LFS=yes],
+      [glibcxx_cv_LFS=no])
+  ])
+  if test $glibcxx_cv_LFS = yes; then
+    AC_DEFINE(_GLIBCXX_USE_LFS)
+  fi
+  AC_LANG_RESTORE      
+])
+
+
+dnl
 dnl Does any necessary configuration of the testsuite directory.  Generates
 dnl the testsuite_hooks.h header.
 dnl
@@ -553,32 +627,35 @@ dnl Substs:
 dnl  baseline_dir
 dnl
 AC_DEFUN(GLIBCXX_CONFIGURE_TESTSUITE, [
-  if $GLIBCXX_IS_NATIVE; then
+  if $GLIBCXX_IS_NATIVE && test $is_hosted = yes; then
     # Do checks for memory limit functions.
     GLIBCXX_CHECK_SETRLIMIT
 
     # Look for setenv, so that extended locale tests can be performed.
     GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
+
+    if test $enable_symvers = no; then
+      enable_abi_check=no
+    else
+      case "$host" in
+        *-*-cygwin*)
+          enable_abi_check=no ;;
+        *)
+          enable_abi_check=yes ;;
+      esac
+    fi
+  else
+    # Only build this as native, since automake does not understand
+    # CXX_FOR_BUILD.
+    enable_abi_check=no
   fi
 
   # Export file names for ABI checking.
   baseline_dir="$glibcxx_srcdir/config/abi/${abi_baseline_pair}\$(MULTISUBDIR)"
   AC_SUBST(baseline_dir)
 
-  # Determine if checking the ABI is desirable.
-  if test $enable_symvers = no; then
-    enable_abi_check=no
-  else
-    case "$host" in
-      *-*-cygwin*)
-        enable_abi_check=no ;;
-      *)
-        enable_abi_check=yes ;;
-    esac
-  fi
-
-  AM_CONDITIONAL(GLIBCXX_TEST_WCHAR_T, test $enable_wchar_t = yes)
-  AM_CONDITIONAL(GLIBCXX_TEST_ABI, test $enable_abi_check = yes)
+  GLIBCXX_CONDITIONAL(GLIBCXX_TEST_WCHAR_T, test $enable_wchar_t = yes)
+  GLIBCXX_CONDITIONAL(GLIBCXX_TEST_ABI, test $enable_abi_check = yes)
 ])
 
 
@@ -588,27 +665,27 @@ dnl
 dnl Substs:
 dnl  GLIBCXX_INCLUDES
 dnl  TOPLEVEL_INCLUDES
-dnl  LIBMATH_INCLUDES
-dnl  LIBSUPCXX_INCLUDES
 dnl
 AC_DEFUN(GLIBCXX_EXPORT_INCLUDES, [
-  # Root level of the build directory include sources.
-  GLIBCXX_INCLUDES="-I$glibcxx_builddir/include/$host_alias -I$glibcxx_builddir/include"
+  # Used for every C++ compile we perform.
+  GLIBCXX_INCLUDES="\
+-I$glibcxx_builddir/include/$host_alias \
+-I$glibcxx_builddir/include \
+-I$glibcxx_srcdir/libsupc++"
 
-  # Passed down for canadian crosses.
+  # For Canadian crosses, pick this up too.
   if test $CANADIAN = yes; then
-    TOPLEVEL_INCLUDES='-I${includedir}'
+    GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
   fi
 
-  LIBMATH_INCLUDES='-I${glibcxx_srcdir}/libmath'
-
-  LIBSUPCXX_INCLUDES='-I${glibcxx_srcdir}/libsupc++'
+  # Stuff in the actual top level.  Currently only used by libsupc++ to
+  # get unwind* headers from the gcc dir.
+  #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include'
+  TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc'
 
   # Now, export this to all the little Makefiles....
   AC_SUBST(GLIBCXX_INCLUDES)
   AC_SUBST(TOPLEVEL_INCLUDES)
-  AC_SUBST(LIBMATH_INCLUDES)
-  AC_SUBST(LIBSUPCXX_INCLUDES)
 ])
 
 
@@ -627,7 +704,7 @@ AC_DEFUN(GLIBCXX_EXPORT_FLAGS, [
   OPTIMIZE_CXXFLAGS=
   AC_SUBST(OPTIMIZE_CXXFLAGS)
 
-  WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings'
+  WARN_FLAGS='-Wall -W -Wwrite-strings -Wcast-qual'
   AC_SUBST(WARN_FLAGS)
 ])
 
@@ -890,9 +967,9 @@ AC_DEFUN(GLIBCXX_ENABLE_CHEADERS, [
   C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
 
   AC_SUBST(C_INCLUDE_DIR)
-  AM_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
-  AM_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
-  AM_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
+  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_COMPATIBILITY, test $c_compatibility = yes)
 ])
 
 
@@ -922,7 +999,7 @@ AC_DEFUN(GLIBCXX_ENABLE_CLOCALE, [
   # Default to "generic".
   if test $enable_clocale_flag = auto; then
     case x${target_os} in
-      xlinux* | xgnu*)
+      xlinux* | xgnu* | xkfreebsd*-gnu | xknetbsd*-gnu)
         AC_EGREP_CPP([_GLIBCXX_ok], [
         #include <features.h>
         #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
@@ -1119,11 +1196,7 @@ AC_DEFUN(GLIBCXX_ENABLE_CSTDIO, [
       ;;
   esac
 
-  dnl Set directory for fpos.h
-  FPOS_H=$fpos_include_dir
-
   AC_SUBST(CSTDIO_H)
-  AC_SUBST(FPOS_H)
   AC_SUBST(BASIC_FILE_H)
   AC_SUBST(BASIC_FILE_CC)
 ])
@@ -1206,7 +1279,7 @@ AC_DEFUN(GLIBCXX_ENABLE_DEBUG, [
   AC_MSG_CHECKING([for additional debug build])
   GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library])
   AC_MSG_RESULT($enable_libstdcxx_debug)
-  AM_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
+  GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
 ])
 
 
@@ -1240,29 +1313,37 @@ AC_DEFUN(GLIBCXX_ENABLE_DEBUG_FLAGS, [
 
 
 dnl
-dnl Check for libunwind exception handling support.  If enabled, then
-dnl we assume that the _Unwind_* functions that make up the Unwind ABI
-dnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
-dnl libunwind instead of libgcc, and that libstdc++ has a dependency
-dnl on libunwind as well as libgcc.
+dnl Check if the user only wants a freestanding library implementation.
 dnl
-dnl --enable-libunwind-exceptions forces the use of libunwind.
-dnl --disable-libunwind-exceptions assumes there is no libunwind.
+dnl --disable-hosted-libstdcxx will turn off most of the library build,
+dnl installing only the headers required by [17.4.1.3] and the language
+dnl support library.  More than that will be built (to keep the Makefiles
+dnl conveniently clean), but not installed.
 dnl
-dnl Substs:
-dnl  LIBUNWIND_FLAG
-dnl
-AC_DEFUN(GLIBCXX_ENABLE_LIBUNWIND_EXCEPTIONS, [
-  AC_MSG_CHECKING([for use of libunwind])
-  GLIBCXX_ENABLE(libunwind-exceptions,no,,
-    [force use of libunwind for exceptions])
-  AC_MSG_RESULT($use_libunwind_exceptions)
-  if test $enable_libunwind_exceptions = yes; then
-    LIBUNWIND_FLAG="-lunwind"
+dnl Sets:
+dnl  is_hosted  (yes/no)
+dnl
+dnl Defines:
+dnl  _GLIBCXX_HOSTED   (always defined, either to 1 or 0)
+dnl
+AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [
+  AC_ARG_ENABLE([hosted-libstdcxx],
+    AC_HELP_STRING([--disable-hosted-libstdcxx],
+                   [only build freestanding C++ runtime support]),,
+    [enable_hosted_libstdcxx=yes])
+  if test "$enable_hosted_libstdcxx" = no; then
+    AC_MSG_NOTICE([Only freestanding libraries will be built])
+    is_hosted=no
+    hosted_define=0
+    enable_abi_check=no
+    enable_libstdcxx_pch=no
   else
-    LIBUNWIND_FLAG=""
+    is_hosted=yes
+    hosted_define=1
   fi
-  AC_SUBST(LIBUNWIND_FLAG)
+  GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
+  AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
+    [Define to 1 if a full hosted library is built, or 0 if freestanding.])
 ])
 
 
@@ -1344,7 +1425,7 @@ AC_DEFUN(GLIBCXX_ENABLE_PCH, [
     enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch
   fi
 
-  AM_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
+  GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
   if test $enable_libstdcxx_pch = yes; then
     glibcxx_PCHFLAGS="-include bits/stdc++.h"
   else
@@ -1516,7 +1597,7 @@ esac
 
 AC_SUBST(SYMVER_MAP)
 AC_SUBST(port_specific_symbol_files)
-AM_CONDITIONAL(GLIBCXX_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
+GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
 AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
 ])