acinclude.m4 revision 110614
197403Sobriendnl
297403Sobriendnl Initialize configure bits.
397403Sobriendnl
4102782Skandnl GLIBCPP_TOPREL_CONFIGURE
5102782SkanAC_DEFUN(GLIBCPP_TOPREL_CONFIGURE, [
6102782Skan  dnl Default to --enable-multilib (this is also passed by default
7102782Skan  dnl from the ubercommon-top-level configure)
897403Sobrien  AC_ARG_ENABLE(multilib,
997403Sobrien  [  --enable-multilib       build hella library versions (default)],
1097403Sobrien  [case "${enableval}" in
1197403Sobrien    yes) multilib=yes ;;
1297403Sobrien    no)  multilib=no ;;
1397403Sobrien    *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
1497403Sobrien   esac], [multilib=yes])dnl
1597403Sobrien
1697403Sobrien  # When building with srcdir == objdir, links to the source files will
1797403Sobrien  # be created in directories within the target_subdir.  We have to
1897403Sobrien  # adjust toplevel_srcdir accordingly, so that configure finds
1997403Sobrien  # install-sh and other auxiliary files that live in the top-level
2097403Sobrien  # source directory.
2197403Sobrien  if test "${srcdir}" = "."; then
2297403Sobrien    if test -z "${with_target_subdir}"; then
2397403Sobrien      toprel=".."
2497403Sobrien    else
2597403Sobrien      if test "${with_target_subdir}" != "."; then
2697403Sobrien        toprel="${with_multisrctop}../.."
2797403Sobrien      else
2897403Sobrien        toprel="${with_multisrctop}.."
2997403Sobrien      fi
3097403Sobrien    fi
3197403Sobrien  else
3297403Sobrien    toprel=".."
3397403Sobrien  fi
3497403Sobrien  AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
3597403Sobrien  toplevel_srcdir=\${top_srcdir}/$toprel
3697403Sobrien  AC_SUBST(toplevel_srcdir)
37102782Skan])
3897403Sobrien
39102782Skandnl
40102782Skandnl Initialize configure bits.
41102782Skandnl
42102782Skandnl GLIBCPP_CONFIGURE
43102782SkanAC_DEFUN(GLIBCPP_CONFIGURE, [
44102782Skan
45102782Skan#possibly test for the presence of the compiler sources here?
46102782Skan
4797403Sobrien  # Export build and source directories.
4897403Sobrien  # These need to be absolute paths, yet at the same time need to
4997403Sobrien  # canonicalize only relative paths, because then amd will not unmount
5097403Sobrien  # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
51102782Skan  glibcpp_builddir=`${PWDCMD-pwd}`
5297403Sobrien  case $srcdir in
5397403Sobrien  [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
5497403Sobrien  *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
5597403Sobrien  esac
5697403Sobrien  AC_SUBST(glibcpp_builddir)
5797403Sobrien  AC_SUBST(glibcpp_srcdir)
5897403Sobrien
5997403Sobrien  dnl This is here just to satisfy automake.
6097403Sobrien  ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)])
6197403Sobrien
6297403Sobrien  AC_PROG_AWK
6397403Sobrien  # Will set LN_S to either 'ln -s' or 'ln'.  With autoconf 2.5x, can also
64102782Skan  # be 'cp -p' if linking isn't available.  Uncomment the next line to
65102782Skan  # force a particular method.
6697403Sobrien  #ac_cv_prog_LN_S='cp -p'
6797403Sobrien  AC_PROG_LN_S
6897403Sobrien
6997403Sobrien  # We use these options to decide which functions to include.
7097403Sobrien  AC_ARG_WITH(target-subdir,
7197403Sobrien  [  --with-target-subdir=SUBDIR
7297403Sobrien                          configuring in a subdirectory])
7397403Sobrien  AC_ARG_WITH(cross-host,
7497403Sobrien  [  --with-cross-host=HOST  configuring with a cross compiler])
7597403Sobrien
7697403Sobrien  glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
7797403Sobrien  AC_SUBST(glibcpp_basedir)
7897403Sobrien
7997403Sobrien  # Never versions of autoconf add an underscore to these functions.
8097403Sobrien  # Prevent future problems ...
8197403Sobrien  ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
8297403Sobrien  ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
8397403Sobrien  ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
8497403Sobrien  ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
8597403Sobrien
8697403Sobrien  # AC_PROG_CC
8797403Sobrien  # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
8897403Sobrien  # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
8997403Sobrien  # are probably using a cross compiler, which will not be able to fully
9097403Sobrien  # link an executable.  This is addressed in later versions of autoconf.
9197403Sobrien
9297403Sobrien  AC_DEFUN(LIB_AC_PROG_CC,
9397403Sobrien  [AC_BEFORE([$0], [AC_PROG_CPP])dnl
9497403Sobrien  dnl Fool anybody using AC_PROG_CC.
9597403Sobrien  AC_PROVIDE([AC_PROG_CC])
9697403Sobrien  AC_CHECK_PROG(CC, gcc, gcc)
9797403Sobrien  if test -z "$CC"; then
9897403Sobrien    AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
9997403Sobrien    test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
10097403Sobrien  fi
10197403Sobrien
10297403Sobrien  AC_PROG_CC_GNU
10397403Sobrien
10497403Sobrien  if test $ac_cv_prog_gcc = yes; then
10597403Sobrien    GCC=yes
10697403Sobrien  dnl Check whether -g works, even if CFLAGS is set, in case the package
10797403Sobrien  dnl plays around with CFLAGS (such as to build both debugging and
10897403Sobrien  dnl normal versions of a library), tasteless as that idea is.
10997403Sobrien    ac_test_CFLAGS="${CFLAGS+set}"
11097403Sobrien    ac_save_CFLAGS="$CFLAGS"
11197403Sobrien    CFLAGS=
11297403Sobrien    AC_PROG_CC_G
11397403Sobrien    if test "$ac_test_CFLAGS" = set; then
11497403Sobrien      CFLAGS="$ac_save_CFLAGS"
11597403Sobrien    elif test $ac_cv_prog_cc_g = yes; then
11697403Sobrien      CFLAGS="-g -O2"
11797403Sobrien    else
11897403Sobrien      CFLAGS="-O2"
11997403Sobrien    fi
12097403Sobrien  else
12197403Sobrien    GCC=
12297403Sobrien    test "${CFLAGS+set}" = set || CFLAGS="-g"
12397403Sobrien  fi
12497403Sobrien  ])
12597403Sobrien
12697403Sobrien  LIB_AC_PROG_CC
12797403Sobrien
12897403Sobrien  # Likewise for AC_PROG_CXX.  We can't just call it directly because g++
12997403Sobrien  # will try to link in libstdc++.
13097403Sobrien  AC_DEFUN(LIB_AC_PROG_CXX,
13197403Sobrien  [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
13297403Sobrien  dnl Fool anybody using AC_PROG_CXX.
13397403Sobrien  AC_PROVIDE([AC_PROG_CXX])
13497403Sobrien  # Use glibcpp_CXX so that we do not cause CXX to be cached with the
13597403Sobrien  # flags that come in CXX while configuring libstdc++.  They're different
13697403Sobrien  # from those used for all other target libraries.  If CXX is set in
13797403Sobrien  # the environment, respect that here.
13897403Sobrien  glibcpp_CXX=$CXX
13997403Sobrien  AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
14097403Sobrien  AC_SUBST(glibcpp_CXX)
14197403Sobrien  CXX=$glibcpp_CXX
14297403Sobrien  test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
14397403Sobrien
14497403Sobrien  AC_PROG_CXX_GNU
14597403Sobrien
14697403Sobrien  if test $ac_cv_prog_gxx = yes; then
14797403Sobrien    GXX=yes
14897403Sobrien    dnl Check whether -g works, even if CXXFLAGS is set, in case the package
14997403Sobrien    dnl plays around with CXXFLAGS (such as to build both debugging and
15097403Sobrien    dnl normal versions of a library), tasteless as that idea is.
15197403Sobrien    ac_test_CXXFLAGS="${CXXFLAGS+set}"
15297403Sobrien    ac_save_CXXFLAGS="$CXXFLAGS"
15397403Sobrien    CXXFLAGS=
15497403Sobrien    AC_PROG_CXX_G
15597403Sobrien    if test "$ac_test_CXXFLAGS" = set; then
15697403Sobrien      CXXFLAGS="$ac_save_CXXFLAGS"
15797403Sobrien    elif test $ac_cv_prog_cxx_g = yes; then
15897403Sobrien      CXXFLAGS="-g -O2"
15997403Sobrien    else
16097403Sobrien      CXXFLAGS="-O2"
16197403Sobrien    fi
16297403Sobrien  else
16397403Sobrien    GXX=
16497403Sobrien    test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
16597403Sobrien  fi
16697403Sobrien  ])
16797403Sobrien
16897403Sobrien  LIB_AC_PROG_CXX
16997403Sobrien
170102782Skan  # For directory versioning (e.g., headers) and other variables.
171102782Skan  AC_MSG_CHECKING([for GCC version number])
172102782Skan  gcc_version=`$glibcpp_CXX -dumpversion`
173102782Skan  AC_MSG_RESULT($gcc_version)
174102782Skan
17597403Sobrien  # For some reason, gettext needs this.
17697403Sobrien  AC_ISC_POSIX
17797403Sobrien
17897403Sobrien  AC_CHECK_TOOL(AS, as)
17997403Sobrien  AC_CHECK_TOOL(AR, ar)
18097403Sobrien  AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
18197403Sobrien  AC_PROG_INSTALL
18297403Sobrien
18397403Sobrien  AM_MAINTAINER_MODE
18497403Sobrien
18597403Sobrien  # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
18697403Sobrien  # at least currently, we never actually build a program, so we never
18797403Sobrien  # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
18897403Sobrien  # fails, because we are probably configuring with a cross compiler
18997403Sobrien  # which can't create executables.  So we include AC_EXEEXT to keep
19097403Sobrien  # automake happy, but we don't execute it, since we don't care about
19197403Sobrien  # the result.
19297403Sobrien  if false; then
19397403Sobrien    # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
19497403Sobrien    # to nothing, so nothing would remain between `then' and `fi' if it
19597403Sobrien    # were not for the `:' below.
19697403Sobrien    :
19797403Sobrien    AC_EXEEXT
19897403Sobrien  fi
19997403Sobrien
20097403Sobrien  case [$]{glibcpp_basedir} in
20197403Sobrien    /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
20297403Sobrien    *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
20397403Sobrien  esac
20497403Sobrien
205102782Skan  # Find platform-specific directories containing configuration info.  In
20697403Sobrien  # addition to possibly modifying the same flags, it also sets up symlinks.
20797403Sobrien  GLIBCPP_CHECK_TARGET
20897403Sobrien])
20997403Sobrien
21097403Sobrien
21197403Sobriendnl
21297403Sobriendnl Check to see if g++ can compile this library, and if so, if any version-
21397403Sobriendnl specific precautions need to be taken. 
21497403Sobriendnl 
21597403Sobriendnl GLIBCPP_CHECK_COMPILER_VERSION
21697403SobrienAC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
21797403Sobrienif test ! -f stamp-sanity-compiler; then
21897403Sobrien  AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
21997403Sobrien  AC_LANG_SAVE
22097403Sobrien  AC_LANG_CPLUSPLUS
22197403Sobrien  AC_TRY_COMPILE(, [
22297403Sobrien  #if __GNUC__ < 3
22397403Sobrien    not_ok
22497403Sobrien  #endif
22597403Sobrien  ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
22697403Sobrien  AC_LANG_RESTORE
22797403Sobrien  AC_MSG_RESULT($gpp_satisfactory)
22897403Sobrien  touch stamp-sanity-compiler
22997403Sobrienfi
23097403Sobrien])
23197403Sobrien
23297403Sobrien
23397403Sobriendnl
23497403Sobriendnl Tests for newer compiler features, or features that are present in newer
23597403Sobriendnl compiler versions but not older compiler versions still in use, should
23697403Sobriendnl be placed here.
23797403Sobriendnl
23897403Sobriendnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
23997403Sobriendnl new inlining code or the new system_header pragma will die on -Werror.
24097403Sobriendnl Leave it out by default and use maint-mode to use it.
24197403Sobriendnl
24297403Sobriendnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
24397403Sobriendnl compiler supports it and the user has not requested debug mode.
24497403Sobriendnl
24597403Sobriendnl GLIBCPP_CHECK_COMPILER_FEATURES
24697403SobrienAC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
24797403Sobrien  # All these tests are for C++; save the language and the compiler flags.
24897403Sobrien  # The CXXFLAGS thing is suspicious, but based on similar bits previously
24997403Sobrien  # found in GLIBCPP_CONFIGURE.
25097403Sobrien  AC_LANG_SAVE
25197403Sobrien  AC_LANG_CPLUSPLUS
25297403Sobrien  ac_test_CXXFLAGS="${CXXFLAGS+set}"
25397403Sobrien  ac_save_CXXFLAGS="$CXXFLAGS"
25497403Sobrien
25597403Sobrien  # Check for maintainer-mode bits.
25697403Sobrien  if test x"$USE_MAINTAINER_MODE" = xno; then
25797403Sobrien    WERROR=''
25897403Sobrien  else
25997403Sobrien    WERROR='-Werror'
26097403Sobrien  fi
26197403Sobrien
26297403Sobrien  # Check for -ffunction-sections -fdata-sections
26397403Sobrien  AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
26497403Sobrien  CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
26597403Sobrien  AC_TRY_COMPILE(, [int foo;
26697403Sobrien  ], [ac_fdsections=yes], [ac_fdsections=no])
26797403Sobrien  if test "$ac_test_CXXFLAGS" = set; then
26897403Sobrien    CXXFLAGS="$ac_save_CXXFLAGS"
26997403Sobrien  else
27097403Sobrien    # this is the suspicious part
27197403Sobrien    CXXFLAGS=''
27297403Sobrien  fi
27397403Sobrien  if test x"$ac_fdsections" = x"yes" &&
27497403Sobrien     test x"$enable_debug" = x"no"; then
27597403Sobrien    SECTION_FLAGS='-ffunction-sections -fdata-sections'
27697403Sobrien  fi
27797403Sobrien  AC_MSG_RESULT($ac_fdsections)
27897403Sobrien
27997403Sobrien  AC_LANG_RESTORE
28097403Sobrien  AC_SUBST(WERROR)
28197403Sobrien  AC_SUBST(SECTION_FLAGS)
28297403Sobrien])
28397403Sobrien
28497403Sobrien
28597403Sobriendnl
28697403Sobriendnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
28797403Sobriendnl the native linker is in use, all variables will be defined to something
28897403Sobriendnl safe (like an empty string).
28997403Sobriendnl
29097403Sobriendnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
29197403Sobriendnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
29297403Sobriendnl Define LD, with_gnu_ld, and (possibly) glibcpp_gnu_ld_version as
29397403Sobriendnl side-effects of testing.
29497403Sobriendnl
29597403Sobriendnl GLIBCPP_CHECK_LINKER_FEATURES
29697403SobrienAC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
29797403Sobrien  # If we're not using GNU ld, then there's no point in even trying these
29897403Sobrien  # tests.  Check for that first.  We should have already tested for gld
29997403Sobrien  # by now (in libtool), but require it now just to be safe...
30097403Sobrien  test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
30197403Sobrien  test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
30297403Sobrien  AC_REQUIRE([AC_PROG_LD])
30397403Sobrien
30497403Sobrien  # The name set by libtool depends on the version of libtool.  Shame on us
30597403Sobrien  # for depending on an impl detail, but c'est la vie.  Older versions used
30697403Sobrien  # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
30797403Sobrien  # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
30897403Sobrien  # makes sense).  We'll test with_gnu_ld everywhere else, so if that isn't
30997403Sobrien  # set (hence we're using an older libtool), then set it.
31097403Sobrien  if test x${with_gnu_ld+set} != xset; then
31197403Sobrien    if test x${ac_cv_prog_gnu_ld+set} != xset; then
31297403Sobrien      # We got through "ac_require(ac_prog_ld)" and still not set?  Huh?
31397403Sobrien      with_gnu_ld=no
31497403Sobrien    else
31597403Sobrien      with_gnu_ld=$ac_cv_prog_gnu_ld
31697403Sobrien    fi
31797403Sobrien  fi
31897403Sobrien
31997403Sobrien  # Start by getting the version number.  I think the libtool test already
32097403Sobrien  # does some of this, but throws away the result.
32197403Sobrien  changequote(,)
32297403Sobrien  ldver=`$LD --version 2>/dev/null | head -1 | \
32397403Sobrien         sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
32497403Sobrien  changequote([,])
32597403Sobrien  glibcpp_gnu_ld_version=`echo $ldver | \
32697403Sobrien         $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
32797403Sobrien
32897403Sobrien  # Set --gc-sections.
32997403Sobrien  if test "$with_gnu_ld" = "notbroken"; then
33097403Sobrien    # GNU ld it is!  Joy and bunny rabbits!
33197403Sobrien
33297403Sobrien    # All these tests are for C++; save the language and the compiler flags.
33397403Sobrien    # Need to do this so that g++ won't try to link in libstdc++
33497403Sobrien    ac_test_CFLAGS="${CFLAGS+set}"
33597403Sobrien    ac_save_CFLAGS="$CFLAGS"
33697403Sobrien    CFLAGS='-x c++  -Wl,--gc-sections'
33797403Sobrien
33897403Sobrien    # Check for -Wl,--gc-sections
33997403Sobrien    # XXX This test is broken at the moment, as symbols required for
34097403Sobrien    # linking are now in libsupc++ (not built yet.....). In addition, 
34197403Sobrien    # this test has cored on solaris in the past. In addition,
34297403Sobrien    # --gc-sections doesn't really work at the moment (keeps on discarding
34397403Sobrien    # used sections, first .eh_frame and now some of the glibc sections for
34497403Sobrien    # iconv). Bzzzzt. Thanks for playing, maybe next time.
34597403Sobrien    AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
34697403Sobrien    AC_TRY_RUN([
34797403Sobrien     int main(void) 
34897403Sobrien     {
34997403Sobrien       try { throw 1; }
35097403Sobrien       catch (...) { };
35197403Sobrien       return 0;
35297403Sobrien     }
35397403Sobrien    ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
35497403Sobrien    if test "$ac_test_CFLAGS" = set; then
35597403Sobrien      CFLAGS="$ac_save_CFLAGS"
35697403Sobrien    else
35797403Sobrien      # this is the suspicious part
35897403Sobrien      CFLAGS=''
35997403Sobrien    fi
36097403Sobrien    if test "$ac_sectionLDflags" = "yes"; then
36197403Sobrien      SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
36297403Sobrien    fi
36397403Sobrien    AC_MSG_RESULT($ac_sectionLDflags)
36497403Sobrien  fi
36597403Sobrien
36697403Sobrien  # Set linker optimization flags.
36797403Sobrien  if test x"$with_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
36897403Sobrien    OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
36997403Sobrien  fi
37097403Sobrien
37197403Sobrien  AC_SUBST(SECTION_LDFLAGS)
37297403Sobrien  AC_SUBST(OPT_LDFLAGS)
37397403Sobrien])
37497403Sobrien
37597403Sobrien
37697403Sobriendnl
37797403Sobriendnl Check to see if the (math function) argument passed is
37897403Sobriendnl declared when using the c++ compiler
37997403Sobriendnl ASSUMES argument is a math function with ONE parameter
38097403Sobriendnl
38197403Sobriendnl GLIBCPP_CHECK_MATH_DECL_1
38297403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
38397403Sobrien  AC_MSG_CHECKING([for $1 declaration])
38497403Sobrien  if test x${glibcpp_cv_func_$1_use+set} != xset; then
38597403Sobrien    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
38697403Sobrien      AC_LANG_SAVE
38797403Sobrien      AC_LANG_CPLUSPLUS
38897403Sobrien      AC_TRY_COMPILE([#include <math.h>
38997403Sobrien		      #ifdef HAVE_IEEEFP_H
39097403Sobrien		      #include <ieeefp.h>
39197403Sobrien		      #endif
39297403Sobrien		     ], 
39397403Sobrien                     [ $1(0);], 
39497403Sobrien                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
39597403Sobrien      AC_LANG_RESTORE
39697403Sobrien    ])
39797403Sobrien  fi
39897403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
39997403Sobrien])
40097403Sobrien
40197403Sobriendnl
40297403Sobriendnl Check to see if the (math function) argument passed is
40397403Sobriendnl 1) declared when using the c++ compiler
40497403Sobriendnl 2) has "C" linkage
40597403Sobriendnl 3) if not, see if 1) and 2) for argument prepended with '_'
40697403Sobriendnl
40797403Sobriendnl Define HAVE_CARGF etc if "cargf" is declared and links
40897403Sobriendnl
40997403Sobriendnl argument 1 is name of function to check
41097403Sobriendnl
41197403Sobriendnl ASSUMES argument is a math function with ONE parameter
41297403Sobriendnl
41397403Sobriendnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
41497403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
41597403Sobrien  GLIBCPP_CHECK_MATH_DECL_1($1)
41697403Sobrien  if test x$glibcpp_cv_func_$1_use = x"yes"; then
41797403Sobrien    AC_CHECK_FUNCS($1)    
41897403Sobrien  else
41997403Sobrien    GLIBCPP_CHECK_MATH_DECL_1(_$1)
42097403Sobrien    if test x$glibcpp_cv_func__$1_use = x"yes"; then
42197403Sobrien      AC_CHECK_FUNCS(_$1)    
42297403Sobrien    fi
42397403Sobrien  fi
42497403Sobrien])
42597403Sobrien
42697403Sobrien
42797403Sobriendnl
42897403Sobriendnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
42997403Sobriendnl of functions at once.  It's an all-or-nothing check -- either 
43097403Sobriendnl HAVE_XYZ is defined for each of the functions, or for none of them.
43197403Sobriendnl Doing it this way saves significant configure time.
43297403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
43397403Sobrien  AC_MSG_CHECKING([for $1 functions])
43497403Sobrien  AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
43597403Sobrien    AC_LANG_SAVE
43697403Sobrien    AC_LANG_CPLUSPLUS
43797403Sobrien    AC_TRY_COMPILE([#include <math.h>],
43897403Sobrien                   [ `for x in $3; do echo "$x (0);"; done` ],
43997403Sobrien                   [glibcpp_cv_func_$2_use=yes],
44097403Sobrien                   [glibcpp_cv_func_$2_use=no])
44197403Sobrien    AC_LANG_RESTORE])
44297403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$2_use)
44397403Sobrien  if test x$glibcpp_cv_func_$2_use = x"yes"; then
44497403Sobrien    AC_CHECK_FUNCS($3)
44597403Sobrien  fi
44697403Sobrien])
44797403Sobrien
44897403Sobriendnl
44997403Sobriendnl Check to see if the (math function) argument passed is
45097403Sobriendnl declared when using the c++ compiler
45197403Sobriendnl ASSUMES argument is a math function with TWO parameters
45297403Sobriendnl
45397403Sobriendnl GLIBCPP_CHECK_MATH_DECL_2
45497403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
45597403Sobrien  AC_MSG_CHECKING([for $1 declaration])
45697403Sobrien  if test x${glibcpp_cv_func_$1_use+set} != xset; then
45797403Sobrien    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
45897403Sobrien      AC_LANG_SAVE
45997403Sobrien      AC_LANG_CPLUSPLUS
46097403Sobrien      AC_TRY_COMPILE([#include <math.h>], 
46197403Sobrien                     [ $1(0, 0);], 
46297403Sobrien                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
46397403Sobrien      AC_LANG_RESTORE
46497403Sobrien    ])
46597403Sobrien  fi
46697403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
46797403Sobrien])
46897403Sobrien
46997403Sobriendnl
47097403Sobriendnl Check to see if the (math function) argument passed is
47197403Sobriendnl 1) declared when using the c++ compiler
47297403Sobriendnl 2) has "C" linkage
47397403Sobriendnl
47497403Sobriendnl Define HAVE_CARGF etc if "cargf" is declared and links
47597403Sobriendnl
47697403Sobriendnl argument 1 is name of function to check
47797403Sobriendnl
47897403Sobriendnl ASSUMES argument is a math function with TWO parameters
47997403Sobriendnl
48097403Sobriendnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
48197403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
48297403Sobrien  GLIBCPP_CHECK_MATH_DECL_2($1)
48397403Sobrien  if test x$glibcpp_cv_func_$1_use = x"yes"; then
48497403Sobrien    AC_CHECK_FUNCS($1)    
48597403Sobrien  else
48697403Sobrien    GLIBCPP_CHECK_MATH_DECL_2(_$1)
48797403Sobrien    if test x$glibcpp_cv_func__$1_use = x"yes"; then
48897403Sobrien      AC_CHECK_FUNCS(_$1)    
48997403Sobrien    fi
49097403Sobrien  fi
49197403Sobrien])
49297403Sobrien
49397403Sobrien
49497403Sobriendnl
49597403Sobriendnl Check to see if the (math function) argument passed is
49697403Sobriendnl declared when using the c++ compiler
49797403Sobriendnl ASSUMES argument is a math function with THREE parameters
49897403Sobriendnl
49997403Sobriendnl GLIBCPP_CHECK_MATH_DECL_3
50097403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
50197403Sobrien  AC_MSG_CHECKING([for $1 declaration])
50297403Sobrien  if test x${glibcpp_cv_func_$1_use+set} != xset; then
50397403Sobrien    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
50497403Sobrien      AC_LANG_SAVE
50597403Sobrien      AC_LANG_CPLUSPLUS
50697403Sobrien      AC_TRY_COMPILE([#include <math.h>], 
50797403Sobrien                     [ $1(0, 0, 0);], 
50897403Sobrien                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
50997403Sobrien      AC_LANG_RESTORE
51097403Sobrien    ])
51197403Sobrien  fi
51297403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
51397403Sobrien])
51497403Sobrien
51597403Sobriendnl
51697403Sobriendnl Check to see if the (math function) argument passed is
51797403Sobriendnl 1) declared when using the c++ compiler
51897403Sobriendnl 2) has "C" linkage
51997403Sobriendnl
52097403Sobriendnl Define HAVE_CARGF etc if "cargf" is declared and links
52197403Sobriendnl
52297403Sobriendnl argument 1 is name of function to check
52397403Sobriendnl
52497403Sobriendnl ASSUMES argument is a math function with THREE parameters
52597403Sobriendnl
52697403Sobriendnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
52797403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
52897403Sobrien  GLIBCPP_CHECK_MATH_DECL_3($1)
52997403Sobrien  if test x$glibcpp_cv_func_$1_use = x"yes"; then
53097403Sobrien    AC_CHECK_FUNCS($1)    
53197403Sobrien  else
53297403Sobrien    GLIBCPP_CHECK_MATH_DECL_3(_$1)
53397403Sobrien    if test x$glibcpp_cv_func__$1_use = x"yes"; then
53497403Sobrien      AC_CHECK_FUNCS(_$1)    
53597403Sobrien    fi
53697403Sobrien  fi
53797403Sobrien])
53897403Sobrien
53997403Sobrien
54097403Sobriendnl
54197403Sobriendnl Check to see if the (stdlib function) argument passed is
54297403Sobriendnl 1) declared when using the c++ compiler
54397403Sobriendnl 2) has "C" linkage
54497403Sobriendnl
54597403Sobriendnl argument 1 is name of function to check
54697403Sobriendnl
54797403Sobriendnl ASSUMES argument is a math function with TWO parameters
54897403Sobriendnl
54997403Sobriendnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
55097403SobrienAC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
55197403Sobrien  AC_MSG_CHECKING([for $1 declaration])
55297403Sobrien  if test x${glibcpp_cv_func_$1_use+set} != xset; then
55397403Sobrien    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
55497403Sobrien      AC_LANG_SAVE
55597403Sobrien      AC_LANG_CPLUSPLUS
55697403Sobrien      AC_TRY_COMPILE([#include <stdlib.h>], 
55797403Sobrien                     [ $1(0, 0);], 
55897403Sobrien                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
55997403Sobrien      AC_LANG_RESTORE
56097403Sobrien    ])
56197403Sobrien  fi
56297403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
56397403Sobrien  if test x$glibcpp_cv_func_$1_use = x"yes"; then
56497403Sobrien    AC_CHECK_FUNCS($1)    
56597403Sobrien  fi
56697403Sobrien])
56797403Sobrien
56897403Sobrien
56997403Sobriendnl
57097403Sobriendnl Check to see if the (stdlib function) argument passed is
57197403Sobriendnl 1) declared when using the c++ compiler
57297403Sobriendnl 2) has "C" linkage
57397403Sobriendnl
57497403Sobriendnl argument 1 is name of function to check
57597403Sobriendnl
57697403Sobriendnl ASSUMES argument is a function with THREE parameters
57797403Sobriendnl
57897403Sobriendnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3
57997403SobrienAC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
58097403Sobrien  AC_MSG_CHECKING([for $1 declaration])
58197403Sobrien  if test x${glibcpp_cv_func_$1_use+set} != xset; then
58297403Sobrien    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
58397403Sobrien      AC_LANG_SAVE
58497403Sobrien      AC_LANG_CPLUSPLUS
58597403Sobrien      AC_TRY_COMPILE([#include <stdlib.h>], 
58697403Sobrien                     [ $1(0, 0, 0);], 
58797403Sobrien                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
58897403Sobrien      AC_LANG_RESTORE
58997403Sobrien    ])
59097403Sobrien  fi
59197403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
59297403Sobrien  if test x$glibcpp_cv_func_$1_use = x"yes"; then
59397403Sobrien    AC_CHECK_FUNCS($1)    
59497403Sobrien  fi
59597403Sobrien])
59697403Sobrien
597110614Skandnl
598110614Skandnl Check to see if the (unistd function) argument passed is
599110614Skandnl 1) declared when using the c++ compiler
600110614Skandnl 2) has "C" linkage
601110614Skandnl
602110614Skandnl argument 1 is name of function to check
603110614Skandnl
604110614Skandnl ASSUMES argument is a function with ONE parameter
605110614Skandnl
606110614Skandnl GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1
607110614SkanAC_DEFUN(GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1, [
608110614Skan  AC_MSG_CHECKING([for $1 declaration])
609110614Skan  if test x${glibcpp_cv_func_$1_use+set} != xset; then
610110614Skan    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
611110614Skan      AC_LANG_SAVE
612110614Skan      AC_LANG_CPLUSPLUS
613110614Skan      AC_TRY_COMPILE([#include <unistd.h>], 
614110614Skan                     [ $1(0);], 
615110614Skan                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
616110614Skan      AC_LANG_RESTORE
617110614Skan    ])
618110614Skan  fi
619110614Skan  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
620110614Skan  if test x$glibcpp_cv_func_$1_use = x"yes"; then
621110614Skan    AC_CHECK_FUNCS($1)    
622110614Skan  fi
623110614Skan])
62497403Sobrien
62597403Sobriendnl
62697403Sobriendnl Because the builtins are picky picky picky about the arguments they take, 
62797403Sobriendnl do an explict linkage tests here.
62897403Sobriendnl Check to see if the (math function) argument passed is
62997403Sobriendnl 1) declared when using the c++ compiler
63097403Sobriendnl 2) has "C" linkage
63197403Sobriendnl
63297403Sobriendnl Define HAVE_CARGF etc if "cargf" is declared and links
63397403Sobriendnl
63497403Sobriendnl argument 1 is name of function to check
63597403Sobriendnl
63697403Sobriendnl ASSUMES argument is a math function with ONE parameter
63797403Sobriendnl
63897403Sobriendnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
63997403SobrienAC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
64097403Sobrien  AC_MSG_CHECKING([for $1 declaration])
64197403Sobrien  if test x${glibcpp_cv_func_$1_use+set} != xset; then
64297403Sobrien    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
64397403Sobrien      AC_LANG_SAVE
64497403Sobrien      AC_LANG_CPLUSPLUS
64597403Sobrien      AC_TRY_COMPILE([#include <math.h>], 
64697403Sobrien                     [ $1(0);], 
64797403Sobrien                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
64897403Sobrien      AC_LANG_RESTORE
64997403Sobrien    ])
65097403Sobrien  fi
65197403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
65297403Sobrien  if test x$glibcpp_cv_func_$1_use = x"yes"; then
65397403Sobrien    AC_MSG_CHECKING([for $1 linkage])
65497403Sobrien    if test x${glibcpp_cv_func_$1_link+set} != xset; then
65597403Sobrien      AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
65697403Sobrien        AC_TRY_LINK([#include <math.h>], 
65797403Sobrien                    [ $1(0);], 
65897403Sobrien                    [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
65997403Sobrien      ])
66097403Sobrien    fi
66197403Sobrien    AC_MSG_RESULT($glibcpp_cv_func_$1_link)
66297403Sobrien    if test x$glibcpp_cv_func_$1_link = x"yes"; then
66397403Sobrien      ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
66497403Sobrien      AC_DEFINE_UNQUOTED(${ac_tr_func})
66597403Sobrien    fi
66697403Sobrien  fi
66797403Sobrien])
66897403Sobrien
66997403Sobrien
67097403Sobriendnl
67197403Sobriendnl Check to see what builtin math functions are supported
67297403Sobriendnl
67397403Sobriendnl check for __builtin_abs
67497403Sobriendnl check for __builtin_fabsf
67597403Sobriendnl check for __builtin_fabs
67697403Sobriendnl check for __builtin_fabl
67797403Sobriendnl check for __builtin_labs
67897403Sobriendnl check for __builtin_sqrtf
67997403Sobriendnl check for __builtin_sqrtl
68097403Sobriendnl check for __builtin_sqrt
68197403Sobriendnl check for __builtin_sinf
68297403Sobriendnl check for __builtin_sin
68397403Sobriendnl check for __builtin_sinl
68497403Sobriendnl check for __builtin_cosf
68597403Sobriendnl check for __builtin_cos
68697403Sobriendnl check for __builtin_cosl
68797403Sobriendnl
68897403Sobriendnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
68997403SobrienAC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
69097403Sobrien  dnl Test for builtin math functions.
69197403Sobrien  dnl These are made in gcc/c-common.c 
69297403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
69397403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
69497403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
69597403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
69697403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
69797403Sobrien
69897403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
69997403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
70097403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
70197403Sobrien
70297403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
70397403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
70497403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
70597403Sobrien
70697403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
70797403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
70897403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
70997403Sobrien
71097403Sobrien  dnl There is, without a doubt, a more elegant way to have these
71197403Sobrien  dnl names exported so that they won't be stripped out of acconfig.h by
71297403Sobrien  dnl autoheader. I leave this as an exercise to somebody less frustrated
71397403Sobrien  dnl than I.... please email the libstdc++ list if you can figure out a
71497403Sobrien  dnl more elegant approach (see autoconf/acgen.m4 and specifically
71597403Sobrien  dnl AC_CHECK_FUNC for things to steal.)
71697403Sobrien  dummyvar=no
71797403Sobrien  if test x$dummyvar = x"yes"; then
71897403Sobrien    AC_DEFINE(HAVE___BUILTIN_ABS)
71997403Sobrien    AC_DEFINE(HAVE___BUILTIN_LABS)
72097403Sobrien    AC_DEFINE(HAVE___BUILTIN_COS)
72197403Sobrien    AC_DEFINE(HAVE___BUILTIN_COSF)
72297403Sobrien    AC_DEFINE(HAVE___BUILTIN_COSL)
72397403Sobrien    AC_DEFINE(HAVE___BUILTIN_FABS)
72497403Sobrien    AC_DEFINE(HAVE___BUILTIN_FABSF)
72597403Sobrien    AC_DEFINE(HAVE___BUILTIN_FABSL)
72697403Sobrien    AC_DEFINE(HAVE___BUILTIN_SIN)
72797403Sobrien    AC_DEFINE(HAVE___BUILTIN_SINF)
72897403Sobrien    AC_DEFINE(HAVE___BUILTIN_SINL)
72997403Sobrien    AC_DEFINE(HAVE___BUILTIN_SQRT)
73097403Sobrien    AC_DEFINE(HAVE___BUILTIN_SQRTF)
73197403Sobrien    AC_DEFINE(HAVE___BUILTIN_SQRTL)
73297403Sobrien  fi
73397403Sobrien])
73497403Sobrien
73597403Sobrien
73697403Sobriendnl
737110614Skandnl Check to see what the underlying c library is like
73897403Sobriendnl These checks need to do two things: 
73997403Sobriendnl 1) make sure the name is declared when using the c++ compiler
74097403Sobriendnl 2) make sure the name has "C" linkage
74197403Sobriendnl This might seem like overkill but experience has shown that it's not...
74297403Sobriendnl
74397403Sobriendnl Define HAVE_STRTOLD if "strtold" is declared and links
74497403Sobriendnl Define HAVE_STRTOF if "strtof" is declared and links
74597403Sobriendnl Define HAVE_DRAND48 if "drand48" is declared and links
74697403Sobriendnl
74797403Sobriendnl GLIBCPP_CHECK_STDLIB_SUPPORT
74897403SobrienAC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
74997403Sobrien  ac_test_CXXFLAGS="${CXXFLAGS+set}"
75097403Sobrien  ac_save_CXXFLAGS="$CXXFLAGS"
75197403Sobrien  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
75297403Sobrien
75397403Sobrien  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
75497403Sobrien  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
75597403Sobrien  AC_CHECK_FUNCS(drand48)
75697403Sobrien
75797403Sobrien  CXXFLAGS="$ac_save_CXXFLAGS"
75897403Sobrien])
75997403Sobrien
760110614Skandnl
761110614Skandnl Check to see what the underlying c library is like
762110614Skandnl These checks need to do two things: 
763110614Skandnl 1) make sure the name is declared when using the c++ compiler
764110614Skandnl 2) make sure the name has "C" linkage
765110614Skandnl This might seem like overkill but experience has shown that it's not...
766110614Skandnl
767110614Skandnl Define HAVE_ISATTY if "isatty" is declared and links
768110614Skandnl
769110614Skandnl GLIBCPP_CHECK_UNISTD_SUPPORT
770110614SkanAC_DEFUN(GLIBCPP_CHECK_UNISTD_SUPPORT, [
771110614Skan  ac_test_CXXFLAGS="${CXXFLAGS+set}"
772110614Skan  ac_save_CXXFLAGS="$CXXFLAGS"
773110614Skan  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
77497403Sobrien
775110614Skan  GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1(isatty)
776110614Skan  
777110614Skan  CXXFLAGS="$ac_save_CXXFLAGS"
778110614Skan])
779110614Skan
78097403Sobriendnl
78197403Sobriendnl Check to see what the underlying c library or math library is like.
78297403Sobriendnl These checks need to do two things: 
78397403Sobriendnl 1) make sure the name is declared when using the c++ compiler
78497403Sobriendnl 2) make sure the name has "C" linkage
78597403Sobriendnl This might seem like overkill but experience has shown that it's not...
78697403Sobriendnl
78797403Sobriendnl Define HAVE_CARGF etc if "cargf" is found.
78897403Sobriendnl
78997403Sobriendnl GLIBCPP_CHECK_MATH_SUPPORT
79097403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
79197403Sobrien  ac_test_CXXFLAGS="${CXXFLAGS+set}"
79297403Sobrien  ac_save_CXXFLAGS="$CXXFLAGS"
79397403Sobrien  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
79497403Sobrien
79597403Sobrien  dnl Check libm
79697403Sobrien  AC_CHECK_LIB(m, sin, libm="-lm")
79797403Sobrien  ac_save_LIBS="$LIBS"
79897403Sobrien  LIBS="$LIBS $libm"
79997403Sobrien
80097403Sobrien  dnl Check to see if certain C math functions exist.
80197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
80297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
80397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
80497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
80597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
80697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
80797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
80897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
80997403Sobrien
81097403Sobrien  dnl Check to see if basic C math functions have float versions.
81197403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
81297403Sobrien                                          float_trig,
81397403Sobrien                                          acosf asinf atanf \
81497403Sobrien                                          cosf sinf tanf \
81597403Sobrien                                          coshf sinhf tanhf)
81697403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
81797403Sobrien                                          float_round,
81897403Sobrien                                          ceilf floorf)
81997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
82097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
82197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
82297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
82397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
82497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
82597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
82697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
82797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
82897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
82997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
83097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
83197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
83297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
83397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
83497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
83597403Sobrien
83697403Sobrien  dnl Check to see if basic C math functions have long double versions.
83797403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
83897403Sobrien                                          long_double_trig,
83997403Sobrien                                          acosl asinl atanl \
84097403Sobrien                                          cosl sinl tanl \
84197403Sobrien                                          coshl sinhl tanhl)
84297403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
84397403Sobrien                                          long_double_round,
84497403Sobrien                                          ceill floorl)
84597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
84697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
84797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
84897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
84997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
85097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
85197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
85297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
85397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
85497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
85597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
85697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
85797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
85897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
85997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
86097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
86197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
86297403Sobrien
86397403Sobrien  dnl Some runtimes have these functions with a preceding underscore. Please
86497403Sobrien  dnl keep this sync'd with the one above. And if you add any new symbol,
86597403Sobrien  dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
86697403Sobrien  dnl Check to see if certain C math functions exist.
86797403Sobrien
86897403Sobrien  dnl Check to see if basic C math functions have float versions.
86997403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
87097403Sobrien                                          _float_trig,
87197403Sobrien                                          _acosf _asinf _atanf \
87297403Sobrien                                          _cosf _sinf _tanf \
87397403Sobrien                                          _coshf _sinhf _tanhf)
87497403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
87597403Sobrien                                          _float_round,
87697403Sobrien                                          _ceilf _floorf)
87797403Sobrien
87897403Sobrien  dnl Check to see if basic C math functions have long double versions.
87997403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
88097403Sobrien                                          _long_double_trig,
88197403Sobrien                                          _acosl _asinl _atanl \
88297403Sobrien                                          _cosl _sinl _tanl \
88397403Sobrien                                          _coshl _sinhl _tanhl)
88497403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
88597403Sobrien                                          _long_double_round,
88697403Sobrien                                          _ceill _floorl)
88797403Sobrien
88897403Sobrien  LIBS="$ac_save_LIBS"
88997403Sobrien  CXXFLAGS="$ac_save_CXXFLAGS"
89097403Sobrien])
89197403Sobrien
89297403Sobrien
89397403Sobriendnl
89497403Sobriendnl Check to see if there is native support for complex 
89597403Sobriendnl
89697403Sobriendnl Don't compile bits in math/* if native support exits.
89797403Sobriendnl
89897403Sobriendnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
89997403Sobriendnl
90097403Sobriendnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
90197403SobrienAC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
90297403Sobrien  dnl Check for complex versions of math functions of platform.
90397403Sobrien  AC_CHECK_LIB(m, main)
90497403Sobrien  AC_REPLACE_MATHFUNCS(nan copysignf)
90597403Sobrien
90697403Sobrien  dnl For __signbit to signbit conversions.
90797403Sobrien  AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
90897403Sobrien  AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
90997403Sobrien
91097403Sobrien  dnl Compile the long double complex functions only if the function 
91197403Sobrien  dnl provides the non-complex long double functions that are needed.
91297403Sobrien  dnl Currently this includes copysignl, which should be
91397403Sobrien  dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
91497403Sobrien  if test x$ac_cv_func_copysignl = x"yes"; then
91597403Sobrien    AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
91697403Sobrien  fi
91797403Sobrien
91897403Sobrien  AC_SUBST(LIBMATHOBJS)
91997403Sobrien])
92097403Sobrien
92197403Sobrien
92297403Sobriendnl Check to see what architecture and operating system we are compiling
92397403Sobriendnl for.  Also, if architecture- or OS-specific flags are required for
92497403Sobriendnl compilation, pick them up here.
92597403Sobriendnl 
92697403Sobriendnl GLIBCPP_CHECK_TARGET
92797403SobrienAC_DEFUN(GLIBCPP_CHECK_TARGET, [
92897403Sobrien    . [$]{glibcpp_basedir}/configure.target
92997403Sobrien    AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
93097403Sobrien    AC_MSG_RESULT(OS config directory is $os_include_dir)
93197403Sobrien])
93297403Sobrien
93397403Sobrien
93497403Sobriendnl
93597403Sobriendnl Check to see if this target can enable the wchar_t parts of libstdc++.
93697403Sobriendnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
93797403Sobriendnl must have been previously checked.)
93897403Sobriendnl
93997403Sobriendnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
94097403Sobriendnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
94197403Sobriendnl
94297403Sobriendnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
94397403SobrienAC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
94497403Sobrien
94597403Sobrien  dnl Test wchar.h for mbstate_t, which is needed for char_traits and
94697403Sobrien  dnl others even if wchar_t support is not on.
94797403Sobrien  AC_MSG_CHECKING([for mbstate_t])
94897403Sobrien  AC_TRY_COMPILE([#include <wchar.h>],
94997403Sobrien  [mbstate_t teststate;], 
95097403Sobrien  have_mbstate_t=yes, have_mbstate_t=no)
95197403Sobrien  AC_MSG_RESULT($have_mbstate_t)
95297403Sobrien  if test x"$have_mbstate_t" = xyes; then
95397403Sobrien    AC_DEFINE(HAVE_MBSTATE_T)
95497403Sobrien  fi
95597403Sobrien
95697403Sobrien  dnl Sanity check for existence of ISO C99 headers for extended encoding.
95797403Sobrien  AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
95897403Sobrien  AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
95997403Sobrien  
96097403Sobrien  dnl Only continue checking if the ISO C99 headers exist and support is on.
96197403Sobrien  if test x"$ac_has_wchar_h" = xyes &&
96297403Sobrien     test x"$ac_has_wctype_h" = xyes &&
96397403Sobrien     test x"$enable_c_mbchar" != xno; then
96497403Sobrien      
96597403Sobrien    dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
96697403Sobrien    dnl numeric_limits can instantiate type_traits<wchar_t>
96797403Sobrien    AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
96897403Sobrien    AC_TRY_COMPILE([#include <wchar.h>],
96997403Sobrien    [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
97097403Sobrien    has_wchar_minmax=yes, has_wchar_minmax=no)
97197403Sobrien    AC_MSG_RESULT($has_wchar_minmax)
97297403Sobrien    
97397403Sobrien    dnl Test wchar.h for WEOF, which is what we use to determine whether
97497403Sobrien    dnl to specialize for char_traits<wchar_t> or not.
97597403Sobrien    AC_MSG_CHECKING([for WEOF])
97697403Sobrien    AC_TRY_COMPILE([
97797403Sobrien      #include <wchar.h>
97897403Sobrien      #include <stddef.h>],
97997403Sobrien    [wint_t i = WEOF;],
98097403Sobrien    has_weof=yes, has_weof=no)
98197403Sobrien    AC_MSG_RESULT($has_weof)
98297403Sobrien  
98397403Sobrien    dnl Tests for wide character functions used in char_traits<wchar_t>.
98497403Sobrien    ac_wfuncs=yes
98597403Sobrien    AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
98697403Sobrien    ac_wfuncs=no)
98797403Sobrien  
98897403Sobrien    dnl Checks for names injected into std:: by the c_std headers.
98997403Sobrien    AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
99097403Sobrien    fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
99197403Sobrien    vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
99297403Sobrien    mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
99397403Sobrien    wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
99497403Sobrien    wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
99597403Sobrien    ac_wfuncs=no)
99697403Sobrien
99797403Sobrien    AC_MSG_CHECKING([for ISO C99 wchar_t support])
99897403Sobrien    if test x"$has_weof" = xyes &&
99997403Sobrien       test x"$has_wchar_minmax" = xyes &&
100097403Sobrien       test x"$ac_wfuncs" = xyes; then
100197403Sobrien      ac_isoC99_wchar_t=yes
100297403Sobrien    else
100397403Sobrien      ac_isoC99_wchar_t=no
100497403Sobrien    fi
100597403Sobrien    AC_MSG_RESULT($ac_isoC99_wchar_t)
100697403Sobrien  
100797403Sobrien    dnl Use iconv for wchar_t to char conversions. As such, check for 
100897403Sobrien    dnl X/Open Portability Guide, version 2 features (XPG2).
100997403Sobrien    AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
101097403Sobrien    AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
101197403Sobrien
101297403Sobrien    dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
101397403Sobrien    AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
101497403Sobrien    ac_save_LIBS="$LIBS"
101597403Sobrien    LIBS="$LIBS $libiconv"
101697403Sobrien
101797403Sobrien    AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
101897403Sobrien    ac_XPG2funcs=yes, ac_XPG2funcs=no)
101997403Sobrien  
102097403Sobrien    LIBS="$ac_save_LIBS"
102197403Sobrien
102297403Sobrien    AC_MSG_CHECKING([for XPG2 wchar_t support])
102397403Sobrien    if test x"$ac_has_iconv_h" = xyes &&
102497403Sobrien       test x"$ac_has_langinfo_h" = xyes &&
102597403Sobrien       test x"$ac_XPG2funcs" = xyes; then
102697403Sobrien      ac_XPG2_wchar_t=yes
102797403Sobrien    else
102897403Sobrien      ac_XPG2_wchar_t=no
102997403Sobrien    fi
103097403Sobrien    AC_MSG_RESULT($ac_XPG2_wchar_t)
103197403Sobrien  
103297403Sobrien    dnl At the moment, only enable wchar_t specializations if all the
103397403Sobrien    dnl above support is present.
103497403Sobrien    AC_MSG_CHECKING([for enabled wchar_t specializations])
103597403Sobrien    if test x"$ac_isoC99_wchar_t" = xyes &&
103697403Sobrien       test x"$ac_XPG2_wchar_t" = xyes; then
103797403Sobrien      AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
103897403Sobrien      AC_MSG_RESULT("yes")
103997403Sobrien    else
104097403Sobrien      AC_MSG_RESULT("no")
104197403Sobrien    fi
104297403Sobrien  else
104397403Sobrien    dnl Wide characters disabled by the user. 
104497403Sobrien    AC_MSG_WARN([wchar_t support disabled.])
104597403Sobrien  fi
104697403Sobrien])
104797403Sobrien
104897403Sobrien
104997403Sobriendnl
105097403Sobriendnl Check for special debugging mode; not for production use.
105197403Sobriendnl
105297403Sobriendnl GLIBCPP_ENABLE_DEBUG
105397403Sobriendnl --enable-debug sets '-ggdb3 -O0'.
105497403Sobriendnl --disable-debug sets '-g' and whatever optimization options the
105597403Sobriendnl     compiler can handle.
105697403Sobriendnl  +  --enable-maintainer-mode automatically defaults this to on.
105797403Sobriendnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
105897403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
105997403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
106097403Sobriendnl       defaults to `no'.
106197403SobrienAC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
106297403Sobriendefine([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
106397403SobrienAC_ARG_ENABLE(debug,
106497403Sobrienchangequote(<<, >>)dnl
106597403Sobrien<<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
106697403Sobrienchangequote([, ])dnl
106797403Sobrien[case "${enableval}" in
106897403Sobrien yes) enable_debug=yes ;;
106997403Sobrien no)  enable_debug=no ;;
107097403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
107197403Sobrien esac],
107297403Sobrienenable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
107397403Sobrien
107497403Sobriendnl Option parsed, now set things appropriately
107597403Sobriencase "${enable_debug}" in
107697403Sobrien    yes) 
107797403Sobrien        DEBUG_FLAGS='-O0 -ggdb3'                        
107897403Sobrien        ;; 
107997403Sobrien    no)   
108097403Sobrien        DEBUG_FLAGS='-g'
108197403Sobrien        ;;
108297403Sobrienesac
108397403SobrienAC_SUBST(DEBUG_FLAGS)
108497403Sobrien])
108597403Sobrien
108697403Sobrien
108797403Sobriendnl
108897403Sobriendnl Check for "unusual" flags to pass to the compiler while building.
108997403Sobriendnl
109097403Sobriendnl GLIBCPP_ENABLE_CXX_FLAGS
109197403Sobriendnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
109297403Sobriendnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
109397403Sobriendnl     Somehow this same set of flags must be passed when [re]building
109497403Sobriendnl     libgcc.
109597403Sobriendnl --disable-cxx-flags passes nothing.
109697403Sobriendnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
109797403Sobriendnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
109897403Sobriendnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
109997403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
110097403Sobriendnl       If "default flags" is an empty string (or "none"), the effect is
110197403Sobriendnl       the same as --disable or --enable=no.
110297403SobrienAC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
110397403Sobriendefine([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
110497403SobrienAC_ARG_ENABLE(cxx-flags,
110597403Sobrienchangequote(<<, >>)dnl
110697403Sobrien<<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
110797403Sobrien                                [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
110897403Sobrienchangequote([, ])dnl
110997403Sobrien[case "x$enableval" in
111097403Sobrien xyes)   
111197403Sobrien        AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
111297403Sobrien xno|x)  
111397403Sobrien        enable_cxx_flags='' ;;
111497403Sobrien *)      
111597403Sobrien        enable_cxx_flags="$enableval" ;;
111697403Sobrien esac],
111797403Sobrienenable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
111897403Sobrien
111997403Sobriendnl Thinko on my part during design.  This kludge is the workaround.
112097403Sobrienif test "$enable_cxx_flags" = "none"; then 
112197403Sobrien  enable_cxx_flags=''; 
112297403Sobrienfi
112397403Sobrien
112497403Sobriendnl Run through flags (either default or command-line) and set anything
112597403Sobriendnl extra (e.g., #defines) that must accompany particular g++ options.
112697403Sobrienif test -n "$enable_cxx_flags"; then
112797403Sobrien    for f in $enable_cxx_flags; do
112897403Sobrien        case "$f" in
112997403Sobrien            -fhonor-std)  ;;
113097403Sobrien            -*)  ;;
113197403Sobrien            *)   # and we're trying to pass /what/ exactly?
113297403Sobrien                 AC_MSG_ERROR([compiler flags start with a -]) ;;
113397403Sobrien        esac
113497403Sobrien    done
113597403Sobrienfi
113697403SobrienEXTRA_CXX_FLAGS="$enable_cxx_flags"
113797403SobrienAC_SUBST(EXTRA_CXX_FLAGS)
113897403Sobrien])
113997403Sobrien
114097403Sobrien
114197403Sobriendnl
114297403Sobriendnl Check for which locale library to use:  gnu or generic.
114397403Sobriendnl
114497403Sobriendnl GLIBCPP_ENABLE_CLOCALE
114597403Sobriendnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
114697403Sobriendnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
114797403Sobriendnl 
114897403Sobriendnl default is generic
114997403Sobriendnl
115097403SobrienAC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
115197403Sobrien  AC_MSG_CHECKING([for clocale to use])
115297403Sobrien  AC_ARG_ENABLE(clocale,
115397403Sobrien  [  --enable-clocale        enable model for target locale package. 
115497403Sobrien  --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
115597403Sobrien  ], 
115697403Sobrien  if test x$enable_clocale = xno; then
115797403Sobrien     enable_clocale=no
115897403Sobrien  fi,
115997403Sobrien     enable_clocale=no)
116097403Sobrien
116197403Sobrien  enable_clocale_flag=$enable_clocale
116297403Sobrien
116397403Sobrien  dnl Probe for locale support if no specific model is specified.
116497403Sobrien  dnl Default to "generic"
116597403Sobrien  if test x$enable_clocale_flag = xno; then
116697403Sobrien    case x${target_os} in
116797403Sobrien      xlinux* | xgnu*)
116897403Sobrien	AC_EGREP_CPP([_GLIBCPP_ok], [
116997403Sobrien        #include <features.h>
117097403Sobrien        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
117197403Sobrien          _GLIBCPP_ok
117297403Sobrien        #endif
117397403Sobrien        ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
117497403Sobrien
117597403Sobrien	# Test for bugs early in glibc-2.2.x series
117697403Sobrien  	if test x$enable_clocale_flag = xgnu; then
117797403Sobrien    	  AC_TRY_RUN([
117897403Sobrien	  #define _GNU_SOURCE 1
117997403Sobrien	  #include <locale.h>
1180103447Skan	  #include <string.h>
1181103447Skan	  #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
1182103447Skan	  extern __typeof(newlocale) __newlocale;
1183103447Skan	  extern __typeof(duplocale) __duplocale;
1184103447Skan	  extern __typeof(strcoll_l) __strcoll_l;
1185103447Skan	  #endif
118697403Sobrien	  int main()
118797403Sobrien	  {
118897403Sobrien  	    const char __one[] = "�uglein Augmen";
118997403Sobrien  	    const char __two[] = "�uglein";
119097403Sobrien  	    int i;
119197403Sobrien  	    int j;
119297403Sobrien  	    __locale_t	loc;
119397403Sobrien   	    __locale_t	loc_dup;
119497403Sobrien  	    loc = __newlocale(1 << LC_ALL, "de_DE", 0);
119597403Sobrien  	    loc_dup = __duplocale(loc);
119697403Sobrien  	    i = __strcoll_l(__one, __two, loc);
119797403Sobrien  	    j = __strcoll_l(__one, __two, loc_dup);
119897403Sobrien  	    return 0;
119997403Sobrien	  }
120097403Sobrien	  ], 
120197403Sobrien	  [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
120297403Sobrien	  [enable_clocale_flag=generic])
120397403Sobrien  	fi
120497403Sobrien
120597403Sobrien	# ... at some point put __strxfrm_l tests in as well.
120697403Sobrien        ;;
120797403Sobrien      *)
120897403Sobrien	enable_clocale_flag=generic
120997403Sobrien	;;
121097403Sobrien    esac
121197403Sobrien  fi
121297403Sobrien
121397403Sobrien  dnl Deal with gettext issues.
121497403Sobrien  AC_ARG_ENABLE(nls,
121597403Sobrien  [  --enable-nls            use Native Language Support (default)],
121697403Sobrien  , enable_nls=yes)
121797403Sobrien  USE_NLS=no
121897403Sobrien
121997403Sobrien  dnl Set configure bits for specified locale package
122097403Sobrien  case x${enable_clocale_flag} in
122197403Sobrien    xgeneric)
122297403Sobrien      AC_MSG_RESULT(generic)
122397403Sobrien
122497403Sobrien      CLOCALE_H=config/locale/generic/c_locale.h
122597403Sobrien      CLOCALE_CC=config/locale/generic/c_locale.cc
122697403Sobrien      CCODECVT_H=config/locale/generic/codecvt_specializations.h
1227103447Skan      CCODECVT_CC=config/locale/generic/codecvt_members.cc
122897403Sobrien      CCOLLATE_CC=config/locale/generic/collate_members.cc
122997403Sobrien      CCTYPE_CC=config/locale/generic/ctype_members.cc
123097403Sobrien      CMESSAGES_H=config/locale/generic/messages_members.h
123197403Sobrien      CMESSAGES_CC=config/locale/generic/messages_members.cc
123297403Sobrien      CMONEY_CC=config/locale/generic/monetary_members.cc
123397403Sobrien      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1234110614Skan      CTIME_H=config/locale/generic/time_members.h
123597403Sobrien      CTIME_CC=config/locale/generic/time_members.cc
1236103447Skan      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
123797403Sobrien      ;;
123897403Sobrien    xgnu)
123997403Sobrien      AC_MSG_RESULT(gnu)
124097403Sobrien
124197403Sobrien      # Declare intention to use gettext, and add support for specific
124297403Sobrien      # languages.
1243102782Skan      # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
124497403Sobrien      ALL_LINGUAS="de fr"
124597403Sobrien
1246102782Skan      # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
124797403Sobrien      AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
124897403Sobrien      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
124997403Sobrien	USE_NLS=yes
125097403Sobrien      fi
125197403Sobrien      # Export the build objects.
125297403Sobrien      for ling in $ALL_LINGUAS; do \
125397403Sobrien        glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
125497403Sobrien        glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
125597403Sobrien      done
125697403Sobrien      AC_SUBST(glibcpp_MOFILES)
125797403Sobrien      AC_SUBST(glibcpp_POFILES)
125897403Sobrien
125997403Sobrien      CLOCALE_H=config/locale/gnu/c_locale.h
126097403Sobrien      CLOCALE_CC=config/locale/gnu/c_locale.cc
126197403Sobrien      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1262103447Skan      CCODECVT_CC=config/locale/gnu/codecvt_members.cc
126397403Sobrien      CCOLLATE_CC=config/locale/gnu/collate_members.cc
126497403Sobrien      CCTYPE_CC=config/locale/gnu/ctype_members.cc
126597403Sobrien      CMESSAGES_H=config/locale/gnu/messages_members.h
126697403Sobrien      CMESSAGES_CC=config/locale/gnu/messages_members.cc
126797403Sobrien      CMONEY_CC=config/locale/gnu/monetary_members.cc
126897403Sobrien      CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1269110614Skan      CTIME_H=config/locale/gnu/time_members.h
127097403Sobrien      CTIME_CC=config/locale/gnu/time_members.cc
1271103447Skan      CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
127297403Sobrien      ;;
127397403Sobrien    xieee_1003.1-2001)
127497403Sobrien      AC_MSG_RESULT(generic)
127597403Sobrien
127697403Sobrien      CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
127797403Sobrien      CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
127897403Sobrien      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1279103447Skan      CCODECVT_CC=config/locale/generic/codecvt_members.cc
128097403Sobrien      CCOLLATE_CC=config/locale/generic/collate_members.cc
128197403Sobrien      CCTYPE_CC=config/locale/generic/ctype_members.cc
128297403Sobrien      CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
128397403Sobrien      CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
128497403Sobrien      CMONEY_CC=config/locale/generic/monetary_members.cc
128597403Sobrien      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1286110614Skan      CTIME_H=config/locale/generic/time_members.h
128797403Sobrien      CTIME_CC=config/locale/generic/time_members.cc
1288103447Skan      CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
128997403Sobrien      ;;
129097403Sobrien    *)
129197403Sobrien      echo "$enable_clocale is an unknown locale package" 1>&2
129297403Sobrien      exit 1
129397403Sobrien      ;;
129497403Sobrien  esac
129597403Sobrien
129697403Sobrien  # This is where the testsuite looks for locale catalogs, using the
129797403Sobrien  # -DLOCALEDIR define during testsuite compilation.
129897403Sobrien  glibcpp_localedir=${glibcpp_builddir}/po/share/locale
129997403Sobrien  AC_SUBST(glibcpp_localedir)
130097403Sobrien
1301103447Skan  # For the time being, transform ctype_noninline.h to ctype_members_char.cc
1302103447Skan#  CCTYPE_CHAR_CC=config/${os_include_dir}/ctype_noninline.h
1303103447Skan
130497403Sobrien  AC_SUBST(USE_NLS)
130597403Sobrien  AC_SUBST(CLOCALE_H)
130697403Sobrien  AC_SUBST(CCODECVT_H)
130797403Sobrien  AC_SUBST(CMESSAGES_H)
1308110614Skan  AC_SUBST(CTIME_H)
130997403Sobrien  AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1310103447Skan  AC_LINK_FILES($CCODECVT_CC, src/codecvt_members.cc)
1311103447Skan  AC_LINK_FILES($CCOLLATE_CC, src/collate_members.cc)
1312103447Skan#  AC_LINK_FILES($CCTYPE_CHAR_CC, src/ctype_members_char.cc)
1313103447Skan  AC_LINK_FILES($CCTYPE_CC, src/ctype_members.cc)
1314103447Skan  AC_LINK_FILES($CMESSAGES_CC, src/messages_members.cc)
1315103447Skan  AC_LINK_FILES($CMONEY_CC, src/monetary_members.cc)
1316103447Skan  AC_LINK_FILES($CNUMERIC_CC, src/numeric_members.cc)
1317103447Skan  AC_LINK_FILES($CTIME_CC, src/time_members.cc)
1318103447Skan  AC_LINK_FILES($CLOCALE_INTERNAL_H, src/c++locale_internal.h)
131997403Sobrien])
132097403Sobrien
132197403Sobrien
132297403Sobriendnl
132397403Sobriendnl Check for which I/O library to use:  libio, or something specific.
132497403Sobriendnl
132597403Sobriendnl GLIBCPP_ENABLE_CSTDIO
132697403Sobriendnl --enable-cstdio=libio sets config/io/c_io_libio.h and friends
132797403Sobriendnl 
132897403Sobriendnl default is stdio
132997403Sobriendnl
133097403SobrienAC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
133197403Sobrien  AC_MSG_CHECKING([for cstdio to use])
133297403Sobrien  AC_ARG_ENABLE(cstdio,
133397403Sobrien  [  --enable-cstdio         enable stdio for target io package. 
133497403Sobrien  --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
133597403Sobrien  ], 
133697403Sobrien  if test x$enable_cstdio = xno; then
133797403Sobrien     enable_cstdio=stdio
133897403Sobrien  fi,
133997403Sobrien     enable_cstdio=stdio)
134097403Sobrien
134197403Sobrien  enable_cstdio_flag=$enable_cstdio
134297403Sobrien
134397403Sobrien  dnl Check if a valid I/O package
134497403Sobrien  case x${enable_cstdio_flag} in
134597403Sobrien    xlibio)
134697403Sobrien      CSTDIO_H=config/io/c_io_libio.h
134797403Sobrien      BASIC_FILE_H=config/io/basic_file_libio.h
134897403Sobrien      BASIC_FILE_CC=config/io/basic_file_libio.cc
134997403Sobrien      AC_MSG_RESULT(libio)
135097403Sobrien
135197403Sobrien      # see if we are on a system with libio native (ie, linux)
135297403Sobrien      AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
135397403Sobrien
135497403Sobrien      # Need to check and see what version of glibc is being used. If
135597403Sobrien      # it's not glibc-2.2 or higher, then we'll need to go ahead and 
135697403Sobrien      # compile most of libio for linux systems.
135797403Sobrien      if test x$has_libio = x"yes"; then
135897403Sobrien        case "$target" in
135997403Sobrien          *-*-linux*)
136097403Sobrien              AC_MSG_CHECKING([for glibc version >= 2.2])
136197403Sobrien              AC_EGREP_CPP([ok], [
136297403Sobrien            #include <features.h>
136397403Sobrien              #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
136497403Sobrien                    ok
136597403Sobrien              #endif
136697403Sobrien              ], glibc_satisfactory=yes, glibc_satisfactory=no)
136797403Sobrien              AC_MSG_RESULT($glibc_satisfactory)
136897403Sobrien            ;;
136997403Sobrien        esac
137097403Sobrien
137197403Sobrien        # XXX at the moment, admit defeat and force the recompilation
137297403Sobrien        # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
137397403Sobrien        glibc_satisfactory=no        
137497403Sobrien
137597403Sobrien        if test x$glibc_satisfactory = x"yes"; then
137697403Sobrien           need_libio=no
137797403Sobrien           need_wlibio=no        
137897403Sobrien        else
137997403Sobrien           need_libio=yes
138097403Sobrien           # bkoz XXX need to add checks to enable this
138197403Sobrien           # pme XXX here's a first pass at such a check
138297403Sobrien           if test x$enable_c_mbchar != xno; then
138397403Sobrien              need_wlibio=yes
138497403Sobrien           else
138597403Sobrien              need_wlibio=no
138697403Sobrien           fi
138797403Sobrien        fi
138897403Sobrien
138997403Sobrien      else
139097403Sobrien         # Using libio, but <libio.h> doesn't exist on the target system. . .
139197403Sobrien         need_libio=yes
139297403Sobrien         # bkoz XXX need to add checks to enable this
139397403Sobrien         # pme XXX here's a first pass at such a check
139497403Sobrien         if test x$enable_c_mbchar != xno; then
139597403Sobrien             need_wlibio=yes
139697403Sobrien         else
139797403Sobrien             need_wlibio=no
139897403Sobrien         fi
139997403Sobrien      fi
140097403Sobrien      ;;
140197403Sobrien    xstdio | x | xno | xnone | xyes)
140297403Sobrien      # default
140397403Sobrien      CSTDIO_H=config/io/c_io_stdio.h
140497403Sobrien      BASIC_FILE_H=config/io/basic_file_stdio.h
140597403Sobrien      BASIC_FILE_CC=config/io/basic_file_stdio.cc
140697403Sobrien      AC_MSG_RESULT(stdio)
140797403Sobrien
140897403Sobrien      # We're not using stdio.
140997403Sobrien      need_libio=no
141097403Sobrien      need_wlibio=no
141197403Sobrien      ;;
141297403Sobrien    *)
141397403Sobrien      echo "$enable_cstdio is an unknown io package" 1>&2
141497403Sobrien      exit 1
141597403Sobrien      ;;
141697403Sobrien  esac
141797403Sobrien  AC_SUBST(CSTDIO_H)
141897403Sobrien  AC_SUBST(BASIC_FILE_H)
141997403Sobrien  AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
142097403Sobrien
142197403Sobrien  # 2000-08-04 bkoz hack
142297403Sobrien  CCODECVT_C=config/io/c_io_libio_codecvt.c
142397403Sobrien  AC_SUBST(CCODECVT_C)
142497403Sobrien  # 2000-08-04 bkoz hack
142597403Sobrien
142697403Sobrien  AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
142797403Sobrien                 test "$need_libio" = yes || test "$need_wlibio" = yes)
142897403Sobrien  AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
142997403Sobrien  AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
143097403Sobrien  if test "$need_libio" = yes || test "$need_wlibio" = yes; then
143197403Sobrien    libio_la=../libio/libio.la
143297403Sobrien  else
143397403Sobrien    libio_la=
143497403Sobrien  fi
143597403Sobrien  AC_SUBST(libio_la)
143697403Sobrien])
143797403Sobrien
143897403Sobrien
143997403Sobriendnl
144097403Sobriendnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
144197403Sobriendnl We must stage the required headers so that they will be installed
144297403Sobriendnl with the library (unlike libgcc, the STL implementation is provided
144397403Sobriendnl solely within headers).  Since we must not inject random user-space
144497403Sobriendnl macro names into user-provided C++ code, we first stage into <file>-in
144597403Sobriendnl and process to <file> with an output command.  The reason for a two-
144697403Sobriendnl stage process here is to correctly handle $srcdir!=$objdir without
144797403Sobriendnl having to write complex code (the sed commands to clean the macro
144897403Sobriendnl namespace are complex and fragile enough as it is).  We must also
144997403Sobriendnl add a relative path so that -I- is supported properly.
145097403Sobriendnl
145197403SobrienAC_DEFUN(GLIBCPP_ENABLE_THREADS, [
145297403Sobrien  AC_MSG_CHECKING([for thread model used by GCC])
145397403Sobrien  target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
145497403Sobrien  AC_MSG_RESULT([$target_thread_file])
145597403Sobrien
145697403Sobrien  if test $target_thread_file != single; then
145797403Sobrien    AC_DEFINE(HAVE_GTHR_DEFAULT)
145897403Sobrien    AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
145997403Sobrien  fi
146097403Sobrien
146197403Sobrien  glibcpp_thread_h=gthr-$target_thread_file.h
146297403Sobrien  AC_SUBST(glibcpp_thread_h)
146397403Sobrien])
146497403Sobrien
146597403Sobrien
146697403Sobriendnl
146797403Sobriendnl Check for exception handling support.  If an explicit enable/disable
146897403Sobriendnl sjlj exceptions is given, we don't have to detect.  Otherwise the
146997403Sobriendnl target may or may not support call frame exceptions.
147097403Sobriendnl
147197403Sobriendnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
147297403Sobriendnl --enable-sjlj-exceptions forces the use of builtin setjmp.
147397403Sobriendnl --disable-sjlj-exceptions forces the use of call frame unwinding.
147497403Sobriendnl
147597403Sobriendnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
147697403Sobriendnl
147797403SobrienAC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
147897403Sobrien  AC_MSG_CHECKING([for exception model to use])
147997403Sobrien  AC_LANG_SAVE
148097403Sobrien  AC_LANG_CPLUSPLUS
148197403Sobrien  AC_ARG_ENABLE(sjlj-exceptions,
148297403Sobrien  [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
148397403Sobrien  [:],
148497403Sobrien  [dnl Botheration.  Now we've got to detect the exception model.
148597403Sobrien   dnl Link tests against libgcc.a are problematic since -- at least
148697403Sobrien   dnl as of this writing -- we've not been given proper -L bits for
148797403Sobrien   dnl single-tree newlib and libgloss.
148897403Sobrien   dnl
148997403Sobrien   dnl This is what AC_TRY_COMPILE would do if it didn't delete the
149097403Sobrien   dnl conftest files before we got a change to grep them first.
149197403Sobrien   cat > conftest.$ac_ext << EOF
149297403Sobrien[#]line __oline__ "configure"
149397403Sobrienstruct S { ~S(); };
149497403Sobrienvoid bar();
149597403Sobrienvoid foo()
149697403Sobrien{
149797403Sobrien  S s;
149897403Sobrien  bar();
149997403Sobrien}
150097403SobrienEOF
150197403Sobrien   old_CXXFLAGS="$CXXFLAGS"  
150297403Sobrien   CXXFLAGS="-S -fexceptions"
150397403Sobrien   if AC_TRY_EVAL(ac_compile); then
150497403Sobrien     if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
150597403Sobrien       enable_sjlj_exceptions=yes
150697403Sobrien     elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
150797403Sobrien       enable_sjlj_exceptions=no
150897403Sobrien     fi
150997403Sobrien   fi
151097403Sobrien   CXXFLAGS="$old_CXXFLAGS"
151197403Sobrien   rm -f conftest*])
151297403Sobrien   if test x$enable_sjlj_exceptions = xyes; then
151397403Sobrien     AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
151497403Sobrien        [Define if the compiler is configured for setjmp/longjmp exceptions.])
151597403Sobrien     ac_exception_model_name=sjlj
151697403Sobrien   elif test x$enable_sjlj_exceptions = xno; then
151797403Sobrien     ac_exception_model_name="call frame"
151897403Sobrien   else
151997403Sobrien     AC_MSG_ERROR([unable to detect exception model])
152097403Sobrien   fi
152197403Sobrien   AC_LANG_RESTORE
152297403Sobrien   AC_MSG_RESULT($ac_exception_model_name)
152397403Sobrien])
152497403Sobrien
152597403Sobrien
152697403Sobriendnl
152797403Sobriendnl Check for libunwind exception handling support. If enabled then
152897403Sobriendnl we assume that the _Unwind_* functions that make up the Unwind ABI
152997403Sobriendnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
153097403Sobriendnl libunwind instead of libgcc and that libstdc++ has a dependency
153197403Sobriendnl on libunwind as well as libgcc.
153297403Sobriendnl
153397403Sobriendnl GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
153497403Sobriendnl --enable-libunwind-exceptions forces the use of libunwind.
153597403Sobriendnl --disable-libunwind-exceptions assumes there is no libunwind.
153697403Sobriendnl
153797403Sobriendnl Define _GLIBCPP_LIBUNWIND_EXCEPTIONS if requested.
153897403Sobriendnl
153997403SobrienAC_DEFUN(GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS, [
154097403Sobrien  AC_MSG_CHECKING([for use of libunwind])
154197403Sobrien  AC_ARG_ENABLE(libunwind-exceptions,
154297403Sobrien  [  --enable-libunwind-exceptions  force use of libunwind for exceptions],
154397403Sobrien  use_libunwind_exceptions=$enableval,
154497403Sobrien  use_libunwind_exceptions=no)
154597403Sobrien  AC_MSG_RESULT($use_libunwind_exceptions)
154697403Sobrien  dnl Option parsed, now set things appropriately
154797403Sobrien  if test x"$use_libunwind_exceptions" = xyes; then
154897403Sobrien    LIBUNWIND_FLAG="-lunwind"
154997403Sobrien  else
155097403Sobrien    LIBUNWIND_FLAG=""
155197403Sobrien  fi
155297403Sobrien  AC_SUBST(LIBUNWIND_FLAG)
155397403Sobrien])
155497403Sobrien
155597403Sobriendnl
155697403Sobriendnl Check for ISO/IEC 9899:1999 "C99" support.
155797403Sobriendnl
155897403Sobriendnl GLIBCPP_ENABLE_C99
155997403Sobriendnl --enable-c99 defines _GLIBCPP_USE_C99
156097403Sobriendnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
156197403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
156297403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
156397403Sobriendnl       defaults to `no'.
156497403Sobriendnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
156597403Sobriendnl
156697403Sobriendnl GLIBCPP_ENABLE_C99
156797403SobrienAC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
156897403Sobrien  define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
156997403Sobrien
157097403Sobrien  AC_ARG_ENABLE(c99,
157197403Sobrien  changequote(<<, >>)dnl
157297403Sobrien  <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
157397403Sobrien  changequote([, ])dnl
157497403Sobrien  [case "$enableval" in
157597403Sobrien   yes) enable_c99=yes ;;
157697403Sobrien   no)  enable_c99=no ;;
157797403Sobrien   *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
157897403Sobrien   esac],
157997403Sobrien  enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
158097403Sobrien 
158197403Sobrien  AC_LANG_SAVE
158297403Sobrien  AC_LANG_CPLUSPLUS
158397403Sobrien
158497403Sobrien  # Check for the existence of <math.h> functions used if C99 is enabled.
158597403Sobrien  ac_c99_math=yes;
158697403Sobrien  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
158797403Sobrien  AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
158897403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
158997403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
159097403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
159197403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
159297403Sobrien  AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
159397403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
159497403Sobrien  AC_TRY_COMPILE([#include <math.h>],
159597403Sobrien                 [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
159697403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
159797403Sobrien  AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
159897403Sobrien  AC_TRY_COMPILE([#include <math.h>],
159997403Sobrien	         [islessgreater(0.0,0.0);],, [ac_c99_math=no])
160097403Sobrien  AC_TRY_COMPILE([#include <math.h>],
160197403Sobrien	         [isunordered(0.0,0.0);],, [ac_c99_math=no])
160297403Sobrien  AC_MSG_RESULT($ac_c99_math)
160397403Sobrien
160497403Sobrien  # Check for the existence in <stdio.h> of vscanf, et. al.
160597403Sobrien  ac_c99_stdio=yes;
160697403Sobrien  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
160797403Sobrien  AC_TRY_COMPILE([#include <stdio.h>],
160897403Sobrien		 [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
160997403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
161097403Sobrien		  #include <stdarg.h>
161197403Sobrien		  void foo(char* fmt, ...)
161297403Sobrien		  {va_list args; va_start(args, fmt);
161397403Sobrien	          vfscanf(stderr, "%i", args);}],
161497403Sobrien	          [],, [ac_c99_stdio=no])
161597403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
161697403Sobrien		  #include <stdarg.h>
161797403Sobrien		  void foo(char* fmt, ...)
161897403Sobrien		  {va_list args; va_start(args, fmt);
161997403Sobrien	          vscanf("%i", args);}],
162097403Sobrien	          [],, [ac_c99_stdio=no])
162197403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
162297403Sobrien		  #include <stdarg.h>
162397403Sobrien		  void foo(char* fmt, ...)
162497403Sobrien		  {va_list args; va_start(args, fmt);
162597403Sobrien	          vsnprintf(fmt, 0, "%i", args);}],
162697403Sobrien	          [],, [ac_c99_stdio=no])
162797403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
162897403Sobrien		  #include <stdarg.h>
162997403Sobrien		  void foo(char* fmt, ...)
163097403Sobrien		  {va_list args; va_start(args, fmt);
163197403Sobrien	          vsscanf(fmt, "%i", args);}],
163297403Sobrien	          [],, [ac_c99_stdio=no])
163397403Sobrien  AC_MSG_RESULT($ac_c99_stdio)
163497403Sobrien
163597403Sobrien  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
163697403Sobrien  ac_c99_stdlib=yes;
163797403Sobrien  AC_MSG_CHECKING([for lldiv_t declaration])
163897403Sobrien  AC_CACHE_VAL(ac_c99_lldiv_t, [
163997403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], 
164097403Sobrien                   [ lldiv_t mydivt;], 
164197403Sobrien                   [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
164297403Sobrien  ])
164397403Sobrien  AC_MSG_RESULT($ac_c99_lldiv_t)
164497403Sobrien
164597403Sobrien  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
164697403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
164797403Sobrien	         [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
164897403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
164997403Sobrien	         [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
165097403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
165197403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
165297403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
165397403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
165497403Sobrien  if test x"$ac_c99_lldiv_t" = x"no"; then
165597403Sobrien    ac_c99_stdlib=no; 
165697403Sobrien  fi; 
165797403Sobrien  AC_MSG_RESULT($ac_c99_stdlib)
165897403Sobrien
165997403Sobrien  # Check for the existence of <wchar.h> functions used if C99 is enabled.
166097403Sobrien  # XXX the wchar.h checks should be rolled into the general C99 bits.
166197403Sobrien  ac_c99_wchar=yes;
166297403Sobrien  AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
166397403Sobrien  AC_TRY_COMPILE([#include <wchar.h>], 
166497403Sobrien	         [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
166597403Sobrien  AC_TRY_COMPILE([#include <wchar.h>], 
166697403Sobrien	         [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
166797403Sobrien  AC_TRY_COMPILE([#include <wchar.h>], 
166897403Sobrien	         [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
166997403Sobrien  AC_MSG_RESULT($ac_c99_wchar)
167097403Sobrien
167197403Sobrien  AC_MSG_CHECKING([for enabled ISO C99 support])
167297403Sobrien  if test x"$ac_c99_math" = x"no" ||
167397403Sobrien     test x"$ac_c99_stdio" = x"no" ||
167497403Sobrien     test x"$ac_c99_stdlib" = x"no" ||
167597403Sobrien     test x"$ac_c99_wchar" = x"no"; then
167697403Sobrien    enable_c99=no; 
167797403Sobrien  fi; 
167897403Sobrien  AC_MSG_RESULT($enable_c99)
167997403Sobrien
168097403Sobrien  # Option parsed, now set things appropriately
168197403Sobrien  if test x"$enable_c99" = x"yes"; then
168297403Sobrien    AC_DEFINE(_GLIBCPP_USE_C99)
168397403Sobrien  fi
168497403Sobrien
168597403Sobrien  AC_LANG_RESTORE
168697403Sobrien])
168797403Sobrien
168897403Sobrien
168997403Sobriendnl
169097403Sobriendnl Check for template specializations for the 'long long' type extension.
169197403Sobriendnl The result determines only whether 'long long' I/O is enabled; things
169297403Sobriendnl like numeric_limits<> specializations are always available.
169397403Sobriendnl
169497403Sobriendnl GLIBCPP_ENABLE_LONG_LONG
169597403Sobriendnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
169697403Sobriendnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
169797403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
169897403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
169997403Sobriendnl       defaults to `no'.
170097403Sobriendnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
170197403Sobriendnl
170297403Sobriendnl GLIBCPP_ENABLE_LONG_LONG
170397403SobrienAC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
170497403Sobrien  define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
170597403Sobrien
170697403Sobrien  AC_ARG_ENABLE(long-long,
170797403Sobrien  changequote(<<, >>)dnl
170897403Sobrien  <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
170997403Sobrien  changequote([, ])dnl
171097403Sobrien  [case "$enableval" in
171197403Sobrien   yes) enable_long_long=yes ;;
171297403Sobrien   no)  enable_long_long=no ;;
171397403Sobrien   *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
171497403Sobrien   esac],
171597403Sobrien  enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
171697403Sobrien
171797403Sobrien  AC_LANG_SAVE
171897403Sobrien  AC_LANG_CPLUSPLUS
171997403Sobrien
172097403Sobrien  AC_MSG_CHECKING([for enabled long long I/O support])
172197403Sobrien  # iostreams require strtoll, strtoull to compile
172297403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
172397403Sobrien                 [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
172497403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
172597403Sobrien                 [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
172697403Sobrien
172797403Sobrien  # Option parsed, now set things appropriately
172897403Sobrien  if test x"$enable_long_long" = xyes; then
172997403Sobrien    AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
173097403Sobrien  fi
173197403Sobrien  AC_MSG_RESULT($enable_long_long)
173297403Sobrien
173397403Sobrien  AC_LANG_RESTORE
173497403Sobrien])
173597403Sobrien
173697403Sobrien
173797403Sobriendnl
173897403Sobriendnl Check for what kind of C headers to use.
173997403Sobriendnl
174097403Sobriendnl GLIBCPP_ENABLE_CHEADERS
174197403Sobriendnl --enable-cheaders= [does stuff].
174297403Sobriendnl --disable-cheaders [does not do anything, really].
174397403Sobriendnl  +  This will eventually need to be 'c_shadow' by default.
174497403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
174597403Sobriendnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
174697403Sobriendnl       If ommitted, it defaults to `c_std'.
174797403SobrienAC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
174897403Sobriendefine([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
174997403SobrienAC_MSG_CHECKING([for c header strategy to use])
175097403SobrienAC_ARG_ENABLE(cheaders,
175197403Sobrienchangequote(<<, >>)dnl
175297403Sobrien<<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
175397403Sobrienchangequote([, ])
175497403Sobrien  [case "$enableval" in
175597403Sobrien   c) 
175697403Sobrien        enable_cheaders=c 
175797403Sobrien        ;;
175897403Sobrien   c_std)  
175997403Sobrien        enable_cheaders=c_std 
176097403Sobrien        ;;
176197403Sobrien   c_shadow)  
176297403Sobrien        enable_cheaders=c_shadow 
176397403Sobrien        ;;
176497403Sobrien   *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
176597403Sobrien        ;;
176697403Sobrien  esac],
176797403Sobrien  enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
176897403Sobrien  AC_MSG_RESULT($enable_cheaders)
176997403Sobrien
177097403Sobrien  dnl Option parsed, now set things appropriately
177197403Sobrien  case "$enable_cheaders" in
177297403Sobrien    c_shadow) 
177397403Sobrien        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
177497403Sobrien        ;;
177597403Sobrien    c_std)   
177697403Sobrien        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
177797403Sobrien        ;;
177897403Sobrien    c)   
177997403Sobrien        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
178097403Sobrien        ;;
178197403Sobrien  esac
178297403Sobrien
178397403Sobrien  AC_SUBST(C_INCLUDE_DIR)
178497403Sobrien  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C, test "$enable_cheaders" = c)
178597403Sobrien  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C_STD, test "$enable_cheaders" = c_std)
1786102782Skan  AM_CONDITIONAL(GLIBCPP_C_HEADERS_COMPATIBILITY, test "$c_compatibility" = yes)
178797403Sobrien])
178897403Sobrien
178997403Sobrien
179097403Sobriendnl
179197403Sobriendnl Check for wide character support.  Has the same effect as the option
179297403Sobriendnl in gcc's configure, but in a form that autoconf can mess with.
179397403Sobriendnl
179497403Sobriendnl GLIBCPP_ENABLE_C_MBCHAR
179597403Sobriendnl --enable-c-mbchar requests all the wchar_t stuff.
179697403Sobriendnl --disable-c-mbchar doesn't.
179797403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
179897403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
179997403Sobriendnl       defaults to `no'.
180097403SobrienAC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
180197403Sobriendefine([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
180297403SobrienAC_ARG_ENABLE(c-mbchar,
180397403Sobrienchangequote(<<, >>)dnl
180497403Sobrien<<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
180597403Sobrienchangequote([, ])dnl
180697403Sobrien[case "$enableval" in
180797403Sobrien yes) enable_c_mbchar=yes ;;
180897403Sobrien no)  enable_c_mbchar=no ;;
180997403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
181097403Sobrien esac],
181197403Sobrienenable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
181297403Sobriendnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
181397403Sobrien])
181497403Sobrien
181597403Sobrien
181697403Sobriendnl
181797403Sobriendnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
181897403Sobriendnl
181997403Sobriendnl TOPLEVEL_INCLUDES
182097403Sobriendnl LIBMATH_INCLUDES
182197403Sobriendnl LIBSUPCXX_INCLUDES
182297403Sobriendnl LIBIO_INCLUDES
182397403Sobriendnl CSHADOW_INCLUDES
182497403Sobriendnl
182597403Sobriendnl GLIBCPP_EXPORT_INCLUDES
182697403SobrienAC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
182797403Sobrien  # Root level of the build directory include sources.
182897403Sobrien  GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
182997403Sobrien
183097403Sobrien  # Passed down for canadian crosses.
183197403Sobrien  if test x"$CANADIAN" = xyes; then
183297403Sobrien    TOPLEVEL_INCLUDES='-I$(includedir)'
183397403Sobrien  fi
183497403Sobrien
183597403Sobrien  LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
183697403Sobrien
183797403Sobrien  LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
183897403Sobrien
183997403Sobrien  if test x"$need_libio" = xyes; then
184097403Sobrien    LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
184197403Sobrien    AC_SUBST(LIBIO_INCLUDES)
184297403Sobrien  fi
184397403Sobrien
184497403Sobrien  # Now, export this to all the little Makefiles....
184597403Sobrien  AC_SUBST(GLIBCPP_INCLUDES)
184697403Sobrien  AC_SUBST(TOPLEVEL_INCLUDES)
184797403Sobrien  AC_SUBST(LIBMATH_INCLUDES)
184897403Sobrien  AC_SUBST(LIBSUPCXX_INCLUDES)
184997403Sobrien])
185097403Sobrien
185197403Sobrien
185297403Sobriendnl
185397403Sobriendnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
185497403Sobriendnl
185597403SobrienAC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
185697403Sobrien  # Optimization flags that are probably a good idea for thrill-seekers. Just
185797403Sobrien  # uncomment the lines below and make, everything else is ready to go... 
185897403Sobrien  # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
185997403Sobrien  OPTIMIZE_CXXFLAGS=
186097403Sobrien  AC_SUBST(OPTIMIZE_CXXFLAGS)
186197403Sobrien
186297403Sobrien  WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
186397403Sobrien  AC_SUBST(WARN_FLAGS)
186497403Sobrien])
186597403Sobrien
186697403Sobriendnl
186797403Sobriendnl  GLIBCPP_EXPORT_INSTALL_INFO
186897403Sobriendnl  calculates gxx_install_dir
186997403Sobriendnl  exports glibcpp_toolexecdir
187097403Sobriendnl  exports glibcpp_toolexeclibdir
187197403Sobriendnl  exports glibcpp_prefixdir
187297403Sobriendnl
187397403Sobriendnl Assumes cross_compiling bits already done, and with_cross_host in
187497403Sobriendnl particular
187597403Sobriendnl
187697403Sobriendnl GLIBCPP_EXPORT_INSTALL_INFO
187797403SobrienAC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
187897403Sobrien# Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
187997403Sobrien# exported correctly in GLIBCPP_CONFIGURE.
188097403Sobrienglibcpp_toolexecdir=no
188197403Sobrienglibcpp_toolexeclibdir=no
188297403Sobrienglibcpp_prefixdir=${prefix}
188397403Sobrien
188497403Sobrien# Process the option --with-gxx-include-dir=<path to include-files directory>
188597403SobrienAC_MSG_CHECKING([for --with-gxx-include-dir])
188697403SobrienAC_ARG_WITH(gxx-include-dir,
188797403Sobrien[  --with-gxx-include-dir  the installation directory for include files],
188897403Sobrien[case "${withval}" in
188997403Sobrien  yes)
189097403Sobrien    AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
189197403Sobrien    gxx_include_dir=no
189297403Sobrien    ;;
189397403Sobrien  no)
189497403Sobrien    gxx_include_dir=no
189597403Sobrien    ;;
189697403Sobrien  *)
189797403Sobrien    gxx_include_dir=${withval}
189897403Sobrien    ;;
189997403Sobrienesac], [gxx_include_dir=no])
190097403SobrienAC_MSG_RESULT($gxx_include_dir)
190197403Sobrien
190297403Sobrien# Process the option "--enable-version-specific-runtime-libs"
190397403SobrienAC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
190497403SobrienAC_ARG_ENABLE(version-specific-runtime-libs,
190597403Sobrien[  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
190697403Sobrien[case "$enableval" in
190797403Sobrien yes) version_specific_libs=yes ;;
190897403Sobrien no)  version_specific_libs=no ;;
190997403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
191097403Sobrien esac],
191197403Sobrienversion_specific_libs=no)dnl
191297403Sobrien# Option set, now we can test it.
191397403SobrienAC_MSG_RESULT($version_specific_libs)
191497403Sobrien
1915102782Skan# Default case for install directory for include files.
1916102782Skanif test $version_specific_libs = no && test $gxx_include_dir = no; then
1917102782Skan  gxx_include_dir='$(prefix)'/include/c++/${gcc_version}
1918102782Skanfi
1919102782Skan
1920102782Skan# Version-specific runtime libs processing.
192197403Sobrienif test $version_specific_libs = yes; then
192297403Sobrien  # Need the gcc compiler version to know where to install libraries
192397403Sobrien  # and header files if --enable-version-specific-runtime-libs option
192497403Sobrien  # is selected.
192597403Sobrien  if test x"$gxx_include_dir" = x"no"; then
1926102782Skan    gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/c++
192797403Sobrien  fi
192897403Sobrien  glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
192997403Sobrien  glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
193097403Sobrienfi
193197403Sobrien
193297403Sobrien# Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
193397403Sobrien# Install a library built with a cross compiler in tooldir, not libdir.
193497403Sobrienif test x"$glibcpp_toolexecdir" = x"no"; then 
193597403Sobrien  if test -n "$with_cross_host" &&
193697403Sobrien     test x"$with_cross_host" != x"no"; then
193797403Sobrien    glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1938110614Skan    glibcpp_toolexeclibdir='$(toolexecdir)/lib'
193997403Sobrien  else
194097403Sobrien    glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1941110614Skan    glibcpp_toolexeclibdir='$(libdir)'
194297403Sobrien  fi
1943110614Skan  glibcpp_toolexeclibdir=$glibcpp_toolexeclibdir/`$CC -print-multi-os-directory`
194497403Sobrienfi
194597403Sobrien
194697403SobrienAC_MSG_CHECKING([for install location])
194797403SobrienAC_MSG_RESULT($gxx_include_dir)
194897403Sobrien
194997403SobrienAC_SUBST(glibcpp_prefixdir)
195097403SobrienAC_SUBST(gxx_include_dir)
195197403SobrienAC_SUBST(glibcpp_toolexecdir)
195297403SobrienAC_SUBST(glibcpp_toolexeclibdir)
195397403Sobrien])
195497403Sobrien
195597403Sobrien
195697403Sobrien# Check for functions in math library.
195797403Sobrien# Ulrich Drepper <drepper@cygnus.com>, 1998.
195897403Sobrien#
195997403Sobrien# This file can be copied and used freely without restrictions.  It can
196097403Sobrien# be used in projects which are not available under the GNU Public License
196197403Sobrien# but which still want to provide support for the GNU gettext functionality.
196297403Sobrien# Please note that the actual code is *not* freely available.
196397403Sobrien
196497403Sobrien# serial 1
196597403Sobrien
196697403Sobriendnl AC_REPLACE_MATHFUNCS(FUNCTION...)
196797403SobrienAC_DEFUN(AC_REPLACE_MATHFUNCS,
196897403Sobrien[AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])])
196997403Sobrien
197097403Sobrien
197197403Sobriendnl This macro searches for a GNU version of make.  If a match is found, the
197297403Sobriendnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
197397403Sobriendnl set to "#". This is useful for  including a special features in a Makefile,
197497403Sobriendnl which cannot be handled by other versions of make.  The variable
197597403Sobriendnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
197697403Sobriendnl the empty string otherwise.
197797403Sobriendnl
197897403Sobriendnl Here is an example of its use:
197997403Sobriendnl
198097403Sobriendnl Makefile.in might contain:
198197403Sobriendnl
198297403Sobriendnl     # A failsafe way of putting a dependency rule into a makefile
198397403Sobriendnl     $(DEPEND):
198497403Sobriendnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
198597403Sobriendnl
198697403Sobriendnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
198797403Sobriendnl     @ifGNUmake@ include $(DEPEND)
198897403Sobriendnl     @ifGNUmake@ endif
198997403Sobriendnl
199097403Sobriendnl Then configure.in would normally contain:
199197403Sobriendnl
199297403Sobriendnl     CHECK_GNU_MAKE()
199397403Sobriendnl     AC_OUTPUT(Makefile)
199497403Sobriendnl
199597403Sobriendnl Then perhaps to cause gnu make to override any other make, we could do
199697403Sobriendnl something like this (note that GNU make always looks for GNUmakefile first):
199797403Sobriendnl
199897403Sobriendnl     if  ! test x$_cv_gnu_make_command = x ; then
199997403Sobriendnl             mv Makefile GNUmakefile
200097403Sobriendnl             echo .DEFAULT: > Makefile ;
200197403Sobriendnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
200297403Sobriendnl     fi
200397403Sobriendnl
200497403Sobriendnl Then, if any (well almost any) other make is called, and GNU make also
200597403Sobriendnl exists, then the other make wraps the GNU make.
200697403Sobriendnl
200797403Sobriendnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
200897403Sobriendnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
200997403Sobriendnl
201097403Sobriendnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
201197403Sobriendnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
201297403Sobriendnl #### conditional's subshell (" --version" is not a command), using a
201397403Sobriendnl #### different option to grep(1).
201497403Sobriendnl #### -pme
201597403Sobriendnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
201697403Sobriendnl #### ${MAKE:-make}).
201797403Sobriendnl #### -msokolov
201897403SobrienAC_DEFUN(
201997403Sobrien  GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
202097403Sobrien          _cv_gnu_make_command='' ;
202197403Sobriendnl Search all the common names for GNU make
202297403Sobrien          for a in "${MAKE-make}" make gmake gnumake ; do
202397403Sobrien                  if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
202497403Sobrien                  then
202597403Sobrien                          _cv_gnu_make_command=$a ;
202697403Sobrien                          break;
202797403Sobrien                  fi
202897403Sobrien          done ;
202997403Sobrien  ) ;
203097403Sobriendnl If there was a GNU version, then set @ifGNUmake@ to the empty
203197403Sobriendnl string, '#' otherwise
203297403Sobrien  if test  "x$_cv_gnu_make_command" != "x"  ; then
203397403Sobrien          ifGNUmake='' ;
203497403Sobrien  else
203597403Sobrien          ifGNUmake='#' ;
203697403Sobrien  fi
203797403Sobrien  AC_SUBST(ifGNUmake)
203897403Sobrien])
203997403Sobrien
204097403Sobrien
204197403Sobriendnl Check for headers for, and arguments to, the setrlimit() function.
204297403Sobriendnl Used only in testsuite_hooks.h.
204397403SobrienAC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
204497403Sobrien  AC_TRY_COMPILE([#include <sys/resource.h>
204597403Sobrien                  #include <unistd.h>
204697403Sobrien                 ], [ int f = RLIMIT_$1 ; ],
204797403Sobrien                 [glibcpp_mresult=1], [glibcpp_mresult=0])
204897403Sobrien  AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
204997403Sobrien                     [Only used in build directory testsuite_hooks.h.])
205097403Sobrien])
205197403SobrienAC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
205297403Sobrien  setrlimit_have_headers=yes
205397403Sobrien  AC_CHECK_HEADERS(sys/resource.h unistd.h,
205497403Sobrien                   [],
205597403Sobrien                   setrlimit_have_headers=no)
205697403Sobrien  # If don't have the headers, then we can't run the tests now, and we
205797403Sobrien  # won't be seeing any of these during testsuite compilation.
205897403Sobrien  if test $setrlimit_have_headers = yes; then
205997403Sobrien    # Can't do these in a loop, else the resulting syntax is wrong.
206097403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
206197403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
206297403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
206397403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
206497403Sobrien
206597403Sobrien    # Check for rlimit, setrlimit.
206697403Sobrien    AC_CACHE_VAL(ac_setrlimit, [
206797403Sobrien      AC_TRY_COMPILE([#include <sys/resource.h>
206897403Sobrien		      #include <unistd.h>
206997403Sobrien		     ], 
207097403Sobrien                     [ struct rlimit r; setrlimit(0, &r);], 
207197403Sobrien                     [ac_setrlimit=yes], [ac_setrlimit=no])
207297403Sobrien    ])
207397403Sobrien  fi
207497403Sobrien
207597403Sobrien  AC_MSG_CHECKING([for testsuite memory limit support])
207697403Sobrien  if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
207797403Sobrien    ac_mem_limits=yes
207897403Sobrien    AC_DEFINE(_GLIBCPP_MEM_LIMITS)
207997403Sobrien  else
208097403Sobrien    ac_mem_limits=no
208197403Sobrien  fi
208297403Sobrien  AC_MSG_RESULT($ac_mem_limits)
208397403Sobrien])
208497403Sobrien
208597403Sobrien
208697403Sobriendnl
208797403Sobriendnl Does any necessary configuration of the testsuite directory.  Generates
208897403Sobriendnl the testsuite_hooks.h header.
208997403Sobriendnl
209097403Sobriendnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
209197403SobrienAC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
209297403Sobrien  GLIBCPP_CHECK_SETRLIMIT
209397403Sobrien
209497403Sobrien  # Look for setenv, so that extended locale tests can be performed.
209597403Sobrien  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
2096102782Skan
2097102782Skan  # Export file names for ABI checking.
2098102782Skan  baseline_file="${glibcpp_srcdir}/config/abi/${abi_baseline_triplet}/baseline_symbols.txt"
2099102782Skan  AC_SUBST(baseline_file)
2100102782Skan
2101102782Skan  # Don't do ABI checking unless native.
2102102782Skan  AM_CONDITIONAL(GLIBCPP_BUILD_ABI_CHECK,
2103102782Skan                 test x"$build" = x"$host" && test -z "$with_cross_host")
210497403Sobrien])
210597403Sobrien
210697403Sobrien
210797403Sobriensinclude(../libtool.m4)
210897403Sobriendnl The lines below arrange for aclocal not to bring an installed
210997403Sobriendnl libtool.m4 into aclocal.m4, while still arranging for automake to
211097403Sobriendnl add a definition of LIBTOOL to Makefile.in.
211197403Sobrienifelse(,,,[AC_SUBST(LIBTOOL)
211297403SobrienAC_DEFUN([AM_PROG_LIBTOOL])
211397403SobrienAC_DEFUN([AC_LIBTOOL_DLOPEN])
211497403SobrienAC_DEFUN([AC_PROG_LD])
211597403Sobrien])
211697403Sobrien
211797403Sobrien
211897403Sobrien# Check whether LC_MESSAGES is available in <locale.h>.
211997403Sobrien# Ulrich Drepper <drepper@cygnus.com>, 1995.
212097403Sobrien#
212197403Sobrien# This file file be copied and used freely without restrictions.  It can
212297403Sobrien# be used in projects which are not available under the GNU Public License
212397403Sobrien# but which still want to provide support for the GNU gettext functionality.
212497403Sobrien# Please note that the actual code is *not* freely available.
212597403Sobrien
212697403Sobrien# serial 1
212797403Sobrien
212897403SobrienAC_DEFUN(AC_LC_MESSAGES, [
212997403Sobrien  AC_CHECK_HEADER(locale.h, [
213097403Sobrien    AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
213197403Sobrien      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
213297403Sobrien       ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
213397403Sobrien    if test $ac_cv_val_LC_MESSAGES = yes; then
213497403Sobrien      AC_DEFINE(HAVE_LC_MESSAGES)
213597403Sobrien    fi
213697403Sobrien  ])
213797403Sobrien])
213897403Sobrien
213997403Sobrien
214097403Sobriendnl
214197403Sobriendnl Check for whether the Boost-derived checks should be turned on.
214297403Sobriendnl
214397403Sobriendnl GLIBCPP_ENABLE_CONCEPT_CHECKS
214497403Sobriendnl --enable-concept-checks turns them on.
214597403Sobriendnl --disable-concept-checks leaves them off.
214697403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
214797403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
214897403Sobriendnl       defaults to `no'.
214997403SobrienAC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
215097403Sobriendefine([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
215197403SobrienAC_ARG_ENABLE(concept-checks,
215297403Sobrienchangequote(<<, >>)dnl
215397403Sobrien<<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
215497403Sobrienchangequote([, ])dnl
215597403Sobrien[case "$enableval" in
215697403Sobrien yes) enable_concept_checks=yes ;;
215797403Sobrien no)  enable_concept_checks=no ;;
215897403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
215997403Sobrien esac],
216097403Sobrienenable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
216197403Sobriendnl Option parsed, now set things appropriately
216297403Sobrienif test x"$enable_concept_checks" = xyes; then
216397403Sobrien  AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
216497403Sobrienfi
216597403Sobrien])
216697403Sobrien
216797403Sobrien
216897403Sobriendnl
216997403Sobriendnl Add version tags to symbols in shared library (or not), additionally
217097403Sobriendnl marking other symbols as private/local (or not).
217197403Sobriendnl
217297403Sobriendnl GLIBCPP_ENABLE_SYMVERS
217397403Sobriendnl --enable-symvers=style adds a version script to the linker call when
217497403Sobriendnl       creating the shared library.  The choice of version script is
217597403Sobriendnl       controlled by 'style'.
217697403Sobriendnl --disable-symvers does not.
217797403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
217897403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
217997403Sobriendnl       defaults to `no'.  Passing `yes' tries to choose a default style
218097403Sobriendnl       based on linker characteristics.  Passing 'no' disables versioning.
218197403SobrienAC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
218297403Sobriendefine([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
218397403SobrienAC_ARG_ENABLE(symvers,
218497403Sobrienchangequote(<<, >>)dnl
218597403Sobrien<<  --enable-symvers=style  enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
218697403Sobrienchangequote([, ])dnl
218797403Sobrien[case "$enableval" in
218897403Sobrien yes) enable_symvers=yes ;;
218997403Sobrien no)  enable_symvers=no ;;
219097403Sobrien # other names here, just as sanity checks
219197403Sobrien #gnu|sun|etcetera) enable_symvers=$enableval ;;
219297403Sobrien gnu) enable_symvers=$enableval ;;
219397403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
219497403Sobrien esac],
219597403Sobrienenable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
219697403Sobrien
219797403Sobrien# If we never went through the GLIBCPP_CHECK_LINKER_FEATURES macro, then we
219897403Sobrien# don't know enough about $LD to do tricks... 
219997403Sobrienif test x$enable_shared = xno || 
2200102782Skan	test "x$LD" = x || 
220197403Sobrien	test x$glibcpp_gnu_ld_version = x; then
220297403Sobrien  enable_symvers=no
220397403Sobrienfi
220497403Sobrien
220597403Sobrien# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
220697403SobrienAC_MSG_CHECKING([for shared libgcc])
220797403Sobrienac_save_CFLAGS="$CFLAGS"
220897403SobrienCFLAGS=' -lgcc_s'
220997403SobrienAC_TRY_LINK( , [return 0], glibcpp_shared_libgcc=yes, glibcpp_shared_libgcc=no)
221097403SobrienCFLAGS="$ac_save_CFLAGS"
221197403SobrienAC_MSG_RESULT($glibcpp_shared_libgcc)
221297403Sobrien
221397403Sobrien# For GNU ld, we need at least this version.  It's 2.12 in the same format
221497403Sobrien# as the tested-for version.  See GLIBCPP_CHECK_LINKER_FEATURES for more.
221597403Sobrienglibcpp_min_gnu_ld_version=21200
221697403Sobrien
221797403Sobrien# Check to see if unspecified "yes" value can win, given results
221897403Sobrien# above.  
221997403Sobrienif test $enable_symvers = yes ; then
222097403Sobrien  if test $with_gnu_ld = yes &&
222197403Sobrien    test $glibcpp_shared_libgcc = yes ;
222297403Sobrien  then
222397403Sobrien    if test $glibcpp_gnu_ld_version -ge $glibcpp_min_gnu_ld_version ; then
222497403Sobrien        enable_symvers=gnu
222597403Sobrien    else
222697403Sobrien      ac_test_CFLAGS="${CFLAGS+set}"
222797403Sobrien      ac_save_CFLAGS="$CFLAGS"
222897403Sobrien      CFLAGS='-shared -Wl,--version-script,conftest.map'
222997403Sobrien      enable_symvers=no
223097403Sobrien      changequote(,)
223197403Sobrien      echo 'FOO { global: f[a-z]o; local: *; };' > conftest.map
223297403Sobrien      changequote([,])
223397403Sobrien      AC_TRY_LINK([int foo;],, enable_symvers=gnu)
223497403Sobrien      if test "$ac_test_CFLAGS" = set; then
223597403Sobrien	CFLAGS="$ac_save_CFLAGS"
223697403Sobrien      else
223797403Sobrien	# this is the suspicious part
223897403Sobrien	CFLAGS=''
223997403Sobrien      fi
224097403Sobrien      rm -f conftest.map
224197403Sobrien    fi
224297403Sobrien  else
224397403Sobrien    # just fail for now
224497403Sobrien    enable_symvers=no
224597403Sobrien  fi
224697403Sobrienfi
224797403Sobrien
224897403Sobriendnl Everything parsed; figure out what file to use.
224997403Sobriencase $enable_symvers in
225097403Sobrien  no)
225197403Sobrien      LINKER_MAP=config/linker-map.dummy
225297403Sobrien      ;;
225397403Sobrien  gnu)
225497403Sobrien      LINKER_MAP=config/linker-map.gnu
2255107606Sobrien      AC_DEFINE(_GLIBCPP_SYMVER)	
225697403Sobrien      ;;
225797403Sobrienesac
225897403Sobrien
225997403SobrienAC_LINK_FILES($LINKER_MAP, src/linker.map)
226097403SobrienAM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
226197403SobrienAC_MSG_CHECKING([versioning on shared library symbols])
226297403SobrienAC_MSG_RESULT($enable_symvers)
226397403Sobrien])
226497403Sobrien
2265