acinclude.m4 revision 102782
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
59797403Sobrien
59897403Sobriendnl
59997403Sobriendnl Because the builtins are picky picky picky about the arguments they take, 
60097403Sobriendnl do an explict linkage tests here.
60197403Sobriendnl Check to see if the (math function) argument passed is
60297403Sobriendnl 1) declared when using the c++ compiler
60397403Sobriendnl 2) has "C" linkage
60497403Sobriendnl
60597403Sobriendnl Define HAVE_CARGF etc if "cargf" is declared and links
60697403Sobriendnl
60797403Sobriendnl argument 1 is name of function to check
60897403Sobriendnl
60997403Sobriendnl ASSUMES argument is a math function with ONE parameter
61097403Sobriendnl
61197403Sobriendnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
61297403SobrienAC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
61397403Sobrien  AC_MSG_CHECKING([for $1 declaration])
61497403Sobrien  if test x${glibcpp_cv_func_$1_use+set} != xset; then
61597403Sobrien    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
61697403Sobrien      AC_LANG_SAVE
61797403Sobrien      AC_LANG_CPLUSPLUS
61897403Sobrien      AC_TRY_COMPILE([#include <math.h>], 
61997403Sobrien                     [ $1(0);], 
62097403Sobrien                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
62197403Sobrien      AC_LANG_RESTORE
62297403Sobrien    ])
62397403Sobrien  fi
62497403Sobrien  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
62597403Sobrien  if test x$glibcpp_cv_func_$1_use = x"yes"; then
62697403Sobrien    AC_MSG_CHECKING([for $1 linkage])
62797403Sobrien    if test x${glibcpp_cv_func_$1_link+set} != xset; then
62897403Sobrien      AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
62997403Sobrien        AC_TRY_LINK([#include <math.h>], 
63097403Sobrien                    [ $1(0);], 
63197403Sobrien                    [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
63297403Sobrien      ])
63397403Sobrien    fi
63497403Sobrien    AC_MSG_RESULT($glibcpp_cv_func_$1_link)
63597403Sobrien    if test x$glibcpp_cv_func_$1_link = x"yes"; then
63697403Sobrien      ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
63797403Sobrien      AC_DEFINE_UNQUOTED(${ac_tr_func})
63897403Sobrien    fi
63997403Sobrien  fi
64097403Sobrien])
64197403Sobrien
64297403Sobrien
64397403Sobriendnl
64497403Sobriendnl Check to see what builtin math functions are supported
64597403Sobriendnl
64697403Sobriendnl check for __builtin_abs
64797403Sobriendnl check for __builtin_fabsf
64897403Sobriendnl check for __builtin_fabs
64997403Sobriendnl check for __builtin_fabl
65097403Sobriendnl check for __builtin_labs
65197403Sobriendnl check for __builtin_sqrtf
65297403Sobriendnl check for __builtin_sqrtl
65397403Sobriendnl check for __builtin_sqrt
65497403Sobriendnl check for __builtin_sinf
65597403Sobriendnl check for __builtin_sin
65697403Sobriendnl check for __builtin_sinl
65797403Sobriendnl check for __builtin_cosf
65897403Sobriendnl check for __builtin_cos
65997403Sobriendnl check for __builtin_cosl
66097403Sobriendnl
66197403Sobriendnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
66297403SobrienAC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
66397403Sobrien  dnl Test for builtin math functions.
66497403Sobrien  dnl These are made in gcc/c-common.c 
66597403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
66697403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
66797403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
66897403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
66997403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
67097403Sobrien
67197403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
67297403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
67397403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
67497403Sobrien
67597403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
67697403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
67797403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
67897403Sobrien
67997403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
68097403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
68197403Sobrien  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
68297403Sobrien
68397403Sobrien  dnl There is, without a doubt, a more elegant way to have these
68497403Sobrien  dnl names exported so that they won't be stripped out of acconfig.h by
68597403Sobrien  dnl autoheader. I leave this as an exercise to somebody less frustrated
68697403Sobrien  dnl than I.... please email the libstdc++ list if you can figure out a
68797403Sobrien  dnl more elegant approach (see autoconf/acgen.m4 and specifically
68897403Sobrien  dnl AC_CHECK_FUNC for things to steal.)
68997403Sobrien  dummyvar=no
69097403Sobrien  if test x$dummyvar = x"yes"; then
69197403Sobrien    AC_DEFINE(HAVE___BUILTIN_ABS)
69297403Sobrien    AC_DEFINE(HAVE___BUILTIN_LABS)
69397403Sobrien    AC_DEFINE(HAVE___BUILTIN_COS)
69497403Sobrien    AC_DEFINE(HAVE___BUILTIN_COSF)
69597403Sobrien    AC_DEFINE(HAVE___BUILTIN_COSL)
69697403Sobrien    AC_DEFINE(HAVE___BUILTIN_FABS)
69797403Sobrien    AC_DEFINE(HAVE___BUILTIN_FABSF)
69897403Sobrien    AC_DEFINE(HAVE___BUILTIN_FABSL)
69997403Sobrien    AC_DEFINE(HAVE___BUILTIN_SIN)
70097403Sobrien    AC_DEFINE(HAVE___BUILTIN_SINF)
70197403Sobrien    AC_DEFINE(HAVE___BUILTIN_SINL)
70297403Sobrien    AC_DEFINE(HAVE___BUILTIN_SQRT)
70397403Sobrien    AC_DEFINE(HAVE___BUILTIN_SQRTF)
70497403Sobrien    AC_DEFINE(HAVE___BUILTIN_SQRTL)
70597403Sobrien  fi
70697403Sobrien])
70797403Sobrien
70897403Sobrien
70997403Sobriendnl
71097403Sobriendnl Check to see what the underlying c library 
71197403Sobriendnl These checks need to do two things: 
71297403Sobriendnl 1) make sure the name is declared when using the c++ compiler
71397403Sobriendnl 2) make sure the name has "C" linkage
71497403Sobriendnl This might seem like overkill but experience has shown that it's not...
71597403Sobriendnl
71697403Sobriendnl Define HAVE_STRTOLD if "strtold" is declared and links
71797403Sobriendnl Define HAVE_STRTOF if "strtof" is declared and links
71897403Sobriendnl Define HAVE_DRAND48 if "drand48" is declared and links
71997403Sobriendnl
72097403Sobriendnl GLIBCPP_CHECK_STDLIB_SUPPORT
72197403SobrienAC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
72297403Sobrien  ac_test_CXXFLAGS="${CXXFLAGS+set}"
72397403Sobrien  ac_save_CXXFLAGS="$CXXFLAGS"
72497403Sobrien  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
72597403Sobrien
72697403Sobrien  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
72797403Sobrien  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
72897403Sobrien  AC_CHECK_FUNCS(drand48)
72997403Sobrien
73097403Sobrien  CXXFLAGS="$ac_save_CXXFLAGS"
73197403Sobrien])
73297403Sobrien
73397403Sobrien
73497403Sobriendnl
73597403Sobriendnl Check to see what the underlying c library or math library is like.
73697403Sobriendnl These checks need to do two things: 
73797403Sobriendnl 1) make sure the name is declared when using the c++ compiler
73897403Sobriendnl 2) make sure the name has "C" linkage
73997403Sobriendnl This might seem like overkill but experience has shown that it's not...
74097403Sobriendnl
74197403Sobriendnl Define HAVE_CARGF etc if "cargf" is found.
74297403Sobriendnl
74397403Sobriendnl GLIBCPP_CHECK_MATH_SUPPORT
74497403SobrienAC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
74597403Sobrien  ac_test_CXXFLAGS="${CXXFLAGS+set}"
74697403Sobrien  ac_save_CXXFLAGS="$CXXFLAGS"
74797403Sobrien  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
74897403Sobrien
74997403Sobrien  dnl Check libm
75097403Sobrien  AC_CHECK_LIB(m, sin, libm="-lm")
75197403Sobrien  ac_save_LIBS="$LIBS"
75297403Sobrien  LIBS="$LIBS $libm"
75397403Sobrien
75497403Sobrien  dnl Check to see if certain C math functions exist.
75597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
75697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
75797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
75897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
75997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
76097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
76197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
76297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
76397403Sobrien
76497403Sobrien  dnl Check to see if basic C math functions have float versions.
76597403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
76697403Sobrien                                          float_trig,
76797403Sobrien                                          acosf asinf atanf \
76897403Sobrien                                          cosf sinf tanf \
76997403Sobrien                                          coshf sinhf tanhf)
77097403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
77197403Sobrien                                          float_round,
77297403Sobrien                                          ceilf floorf)
77397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
77497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
77597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
77697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
77797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
77897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
77997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
78097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
78197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
78297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
78397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
78497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
78597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
78697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
78797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
78897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
78997403Sobrien
79097403Sobrien  dnl Check to see if basic C math functions have long double versions.
79197403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
79297403Sobrien                                          long_double_trig,
79397403Sobrien                                          acosl asinl atanl \
79497403Sobrien                                          cosl sinl tanl \
79597403Sobrien                                          coshl sinhl tanhl)
79697403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
79797403Sobrien                                          long_double_round,
79897403Sobrien                                          ceill floorl)
79997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
80097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
80197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
80297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
80397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
80497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
80597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
80697403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
80797403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
80897403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
80997403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
81097403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
81197403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
81297403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
81397403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
81497403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
81597403Sobrien  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
81697403Sobrien
81797403Sobrien  dnl Some runtimes have these functions with a preceding underscore. Please
81897403Sobrien  dnl keep this sync'd with the one above. And if you add any new symbol,
81997403Sobrien  dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
82097403Sobrien  dnl Check to see if certain C math functions exist.
82197403Sobrien
82297403Sobrien  dnl Check to see if basic C math functions have float versions.
82397403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
82497403Sobrien                                          _float_trig,
82597403Sobrien                                          _acosf _asinf _atanf \
82697403Sobrien                                          _cosf _sinf _tanf \
82797403Sobrien                                          _coshf _sinhf _tanhf)
82897403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
82997403Sobrien                                          _float_round,
83097403Sobrien                                          _ceilf _floorf)
83197403Sobrien
83297403Sobrien  dnl Check to see if basic C math functions have long double versions.
83397403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
83497403Sobrien                                          _long_double_trig,
83597403Sobrien                                          _acosl _asinl _atanl \
83697403Sobrien                                          _cosl _sinl _tanl \
83797403Sobrien                                          _coshl _sinhl _tanhl)
83897403Sobrien  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
83997403Sobrien                                          _long_double_round,
84097403Sobrien                                          _ceill _floorl)
84197403Sobrien
84297403Sobrien  LIBS="$ac_save_LIBS"
84397403Sobrien  CXXFLAGS="$ac_save_CXXFLAGS"
84497403Sobrien])
84597403Sobrien
84697403Sobrien
84797403Sobriendnl
84897403Sobriendnl Check to see if there is native support for complex 
84997403Sobriendnl
85097403Sobriendnl Don't compile bits in math/* if native support exits.
85197403Sobriendnl
85297403Sobriendnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
85397403Sobriendnl
85497403Sobriendnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
85597403SobrienAC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
85697403Sobrien  dnl Check for complex versions of math functions of platform.
85797403Sobrien  AC_CHECK_LIB(m, main)
85897403Sobrien  AC_REPLACE_MATHFUNCS(nan copysignf)
85997403Sobrien
86097403Sobrien  dnl For __signbit to signbit conversions.
86197403Sobrien  AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
86297403Sobrien  AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
86397403Sobrien
86497403Sobrien  dnl Compile the long double complex functions only if the function 
86597403Sobrien  dnl provides the non-complex long double functions that are needed.
86697403Sobrien  dnl Currently this includes copysignl, which should be
86797403Sobrien  dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
86897403Sobrien  if test x$ac_cv_func_copysignl = x"yes"; then
86997403Sobrien    AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
87097403Sobrien  fi
87197403Sobrien
87297403Sobrien  AC_SUBST(LIBMATHOBJS)
87397403Sobrien])
87497403Sobrien
87597403Sobrien
87697403Sobriendnl Check to see what architecture and operating system we are compiling
87797403Sobriendnl for.  Also, if architecture- or OS-specific flags are required for
87897403Sobriendnl compilation, pick them up here.
87997403Sobriendnl 
88097403Sobriendnl GLIBCPP_CHECK_TARGET
88197403SobrienAC_DEFUN(GLIBCPP_CHECK_TARGET, [
88297403Sobrien    . [$]{glibcpp_basedir}/configure.target
88397403Sobrien    AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
88497403Sobrien    AC_MSG_RESULT(OS config directory is $os_include_dir)
88597403Sobrien])
88697403Sobrien
88797403Sobrien
88897403Sobriendnl
88997403Sobriendnl Check to see if this target can enable the wchar_t parts of libstdc++.
89097403Sobriendnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
89197403Sobriendnl must have been previously checked.)
89297403Sobriendnl
89397403Sobriendnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
89497403Sobriendnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
89597403Sobriendnl
89697403Sobriendnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
89797403SobrienAC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
89897403Sobrien
89997403Sobrien  dnl Test wchar.h for mbstate_t, which is needed for char_traits and
90097403Sobrien  dnl others even if wchar_t support is not on.
90197403Sobrien  AC_MSG_CHECKING([for mbstate_t])
90297403Sobrien  AC_TRY_COMPILE([#include <wchar.h>],
90397403Sobrien  [mbstate_t teststate;], 
90497403Sobrien  have_mbstate_t=yes, have_mbstate_t=no)
90597403Sobrien  AC_MSG_RESULT($have_mbstate_t)
90697403Sobrien  if test x"$have_mbstate_t" = xyes; then
90797403Sobrien    AC_DEFINE(HAVE_MBSTATE_T)
90897403Sobrien  fi
90997403Sobrien
91097403Sobrien  dnl Sanity check for existence of ISO C99 headers for extended encoding.
91197403Sobrien  AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
91297403Sobrien  AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
91397403Sobrien  
91497403Sobrien  dnl Only continue checking if the ISO C99 headers exist and support is on.
91597403Sobrien  if test x"$ac_has_wchar_h" = xyes &&
91697403Sobrien     test x"$ac_has_wctype_h" = xyes &&
91797403Sobrien     test x"$enable_c_mbchar" != xno; then
91897403Sobrien      
91997403Sobrien    dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
92097403Sobrien    dnl numeric_limits can instantiate type_traits<wchar_t>
92197403Sobrien    AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
92297403Sobrien    AC_TRY_COMPILE([#include <wchar.h>],
92397403Sobrien    [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
92497403Sobrien    has_wchar_minmax=yes, has_wchar_minmax=no)
92597403Sobrien    AC_MSG_RESULT($has_wchar_minmax)
92697403Sobrien    
92797403Sobrien    dnl Test wchar.h for WEOF, which is what we use to determine whether
92897403Sobrien    dnl to specialize for char_traits<wchar_t> or not.
92997403Sobrien    AC_MSG_CHECKING([for WEOF])
93097403Sobrien    AC_TRY_COMPILE([
93197403Sobrien      #include <wchar.h>
93297403Sobrien      #include <stddef.h>],
93397403Sobrien    [wint_t i = WEOF;],
93497403Sobrien    has_weof=yes, has_weof=no)
93597403Sobrien    AC_MSG_RESULT($has_weof)
93697403Sobrien  
93797403Sobrien    dnl Tests for wide character functions used in char_traits<wchar_t>.
93897403Sobrien    ac_wfuncs=yes
93997403Sobrien    AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
94097403Sobrien    ac_wfuncs=no)
94197403Sobrien  
94297403Sobrien    dnl Checks for names injected into std:: by the c_std headers.
94397403Sobrien    AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
94497403Sobrien    fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
94597403Sobrien    vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
94697403Sobrien    mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
94797403Sobrien    wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
94897403Sobrien    wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
94997403Sobrien    ac_wfuncs=no)
95097403Sobrien
95197403Sobrien    AC_MSG_CHECKING([for ISO C99 wchar_t support])
95297403Sobrien    if test x"$has_weof" = xyes &&
95397403Sobrien       test x"$has_wchar_minmax" = xyes &&
95497403Sobrien       test x"$ac_wfuncs" = xyes; then
95597403Sobrien      ac_isoC99_wchar_t=yes
95697403Sobrien    else
95797403Sobrien      ac_isoC99_wchar_t=no
95897403Sobrien    fi
95997403Sobrien    AC_MSG_RESULT($ac_isoC99_wchar_t)
96097403Sobrien  
96197403Sobrien    dnl Use iconv for wchar_t to char conversions. As such, check for 
96297403Sobrien    dnl X/Open Portability Guide, version 2 features (XPG2).
96397403Sobrien    AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
96497403Sobrien    AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
96597403Sobrien
96697403Sobrien    dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
96797403Sobrien    AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
96897403Sobrien    ac_save_LIBS="$LIBS"
96997403Sobrien    LIBS="$LIBS $libiconv"
97097403Sobrien
97197403Sobrien    AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
97297403Sobrien    ac_XPG2funcs=yes, ac_XPG2funcs=no)
97397403Sobrien  
97497403Sobrien    LIBS="$ac_save_LIBS"
97597403Sobrien
97697403Sobrien    AC_MSG_CHECKING([for XPG2 wchar_t support])
97797403Sobrien    if test x"$ac_has_iconv_h" = xyes &&
97897403Sobrien       test x"$ac_has_langinfo_h" = xyes &&
97997403Sobrien       test x"$ac_XPG2funcs" = xyes; then
98097403Sobrien      ac_XPG2_wchar_t=yes
98197403Sobrien    else
98297403Sobrien      ac_XPG2_wchar_t=no
98397403Sobrien    fi
98497403Sobrien    AC_MSG_RESULT($ac_XPG2_wchar_t)
98597403Sobrien  
98697403Sobrien    dnl At the moment, only enable wchar_t specializations if all the
98797403Sobrien    dnl above support is present.
98897403Sobrien    AC_MSG_CHECKING([for enabled wchar_t specializations])
98997403Sobrien    if test x"$ac_isoC99_wchar_t" = xyes &&
99097403Sobrien       test x"$ac_XPG2_wchar_t" = xyes; then
99197403Sobrien      AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
99297403Sobrien      AC_MSG_RESULT("yes")
99397403Sobrien    else
99497403Sobrien      AC_MSG_RESULT("no")
99597403Sobrien    fi
99697403Sobrien  else
99797403Sobrien    dnl Wide characters disabled by the user. 
99897403Sobrien    AC_MSG_WARN([wchar_t support disabled.])
99997403Sobrien  fi
100097403Sobrien])
100197403Sobrien
100297403Sobrien
100397403Sobriendnl
100497403Sobriendnl Check for special debugging mode; not for production use.
100597403Sobriendnl
100697403Sobriendnl GLIBCPP_ENABLE_DEBUG
100797403Sobriendnl --enable-debug sets '-ggdb3 -O0'.
100897403Sobriendnl --disable-debug sets '-g' and whatever optimization options the
100997403Sobriendnl     compiler can handle.
101097403Sobriendnl  +  --enable-maintainer-mode automatically defaults this to on.
101197403Sobriendnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
101297403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
101397403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
101497403Sobriendnl       defaults to `no'.
101597403SobrienAC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
101697403Sobriendefine([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
101797403SobrienAC_ARG_ENABLE(debug,
101897403Sobrienchangequote(<<, >>)dnl
101997403Sobrien<<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
102097403Sobrienchangequote([, ])dnl
102197403Sobrien[case "${enableval}" in
102297403Sobrien yes) enable_debug=yes ;;
102397403Sobrien no)  enable_debug=no ;;
102497403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
102597403Sobrien esac],
102697403Sobrienenable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
102797403Sobrien
102897403Sobriendnl Option parsed, now set things appropriately
102997403Sobriencase "${enable_debug}" in
103097403Sobrien    yes) 
103197403Sobrien        DEBUG_FLAGS='-O0 -ggdb3'                        
103297403Sobrien        ;; 
103397403Sobrien    no)   
103497403Sobrien        DEBUG_FLAGS='-g'
103597403Sobrien        ;;
103697403Sobrienesac
103797403SobrienAC_SUBST(DEBUG_FLAGS)
103897403Sobrien])
103997403Sobrien
104097403Sobrien
104197403Sobriendnl
104297403Sobriendnl Check for "unusual" flags to pass to the compiler while building.
104397403Sobriendnl
104497403Sobriendnl GLIBCPP_ENABLE_CXX_FLAGS
104597403Sobriendnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
104697403Sobriendnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
104797403Sobriendnl     Somehow this same set of flags must be passed when [re]building
104897403Sobriendnl     libgcc.
104997403Sobriendnl --disable-cxx-flags passes nothing.
105097403Sobriendnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
105197403Sobriendnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
105297403Sobriendnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
105397403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
105497403Sobriendnl       If "default flags" is an empty string (or "none"), the effect is
105597403Sobriendnl       the same as --disable or --enable=no.
105697403SobrienAC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
105797403Sobriendefine([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
105897403SobrienAC_ARG_ENABLE(cxx-flags,
105997403Sobrienchangequote(<<, >>)dnl
106097403Sobrien<<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
106197403Sobrien                                [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
106297403Sobrienchangequote([, ])dnl
106397403Sobrien[case "x$enableval" in
106497403Sobrien xyes)   
106597403Sobrien        AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
106697403Sobrien xno|x)  
106797403Sobrien        enable_cxx_flags='' ;;
106897403Sobrien *)      
106997403Sobrien        enable_cxx_flags="$enableval" ;;
107097403Sobrien esac],
107197403Sobrienenable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
107297403Sobrien
107397403Sobriendnl Thinko on my part during design.  This kludge is the workaround.
107497403Sobrienif test "$enable_cxx_flags" = "none"; then 
107597403Sobrien  enable_cxx_flags=''; 
107697403Sobrienfi
107797403Sobrien
107897403Sobriendnl Run through flags (either default or command-line) and set anything
107997403Sobriendnl extra (e.g., #defines) that must accompany particular g++ options.
108097403Sobrienif test -n "$enable_cxx_flags"; then
108197403Sobrien    for f in $enable_cxx_flags; do
108297403Sobrien        case "$f" in
108397403Sobrien            -fhonor-std)  ;;
108497403Sobrien            -*)  ;;
108597403Sobrien            *)   # and we're trying to pass /what/ exactly?
108697403Sobrien                 AC_MSG_ERROR([compiler flags start with a -]) ;;
108797403Sobrien        esac
108897403Sobrien    done
108997403Sobrienfi
109097403SobrienEXTRA_CXX_FLAGS="$enable_cxx_flags"
109197403SobrienAC_SUBST(EXTRA_CXX_FLAGS)
109297403Sobrien])
109397403Sobrien
109497403Sobrien
109597403Sobriendnl
109697403Sobriendnl Check for which locale library to use:  gnu or generic.
109797403Sobriendnl
109897403Sobriendnl GLIBCPP_ENABLE_CLOCALE
109997403Sobriendnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
110097403Sobriendnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
110197403Sobriendnl 
110297403Sobriendnl default is generic
110397403Sobriendnl
110497403SobrienAC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
110597403Sobrien  AC_MSG_CHECKING([for clocale to use])
110697403Sobrien  AC_ARG_ENABLE(clocale,
110797403Sobrien  [  --enable-clocale        enable model for target locale package. 
110897403Sobrien  --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
110997403Sobrien  ], 
111097403Sobrien  if test x$enable_clocale = xno; then
111197403Sobrien     enable_clocale=no
111297403Sobrien  fi,
111397403Sobrien     enable_clocale=no)
111497403Sobrien
111597403Sobrien  enable_clocale_flag=$enable_clocale
111697403Sobrien
111797403Sobrien  dnl Probe for locale support if no specific model is specified.
111897403Sobrien  dnl Default to "generic"
111997403Sobrien  if test x$enable_clocale_flag = xno; then
112097403Sobrien    case x${target_os} in
112197403Sobrien      xlinux* | xgnu*)
112297403Sobrien	AC_EGREP_CPP([_GLIBCPP_ok], [
112397403Sobrien        #include <features.h>
112497403Sobrien        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
112597403Sobrien          _GLIBCPP_ok
112697403Sobrien        #endif
112797403Sobrien        ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
112897403Sobrien
112997403Sobrien	# Test for bugs early in glibc-2.2.x series
113097403Sobrien  	if test x$enable_clocale_flag = xgnu; then
113197403Sobrien    	  AC_TRY_RUN([
113297403Sobrien	  #define _GNU_SOURCE 1
113397403Sobrien	  #include <locale.h>
113497403Sobrien	  int main()
113597403Sobrien	  {
113697403Sobrien  	    const char __one[] = "�uglein Augmen";
113797403Sobrien  	    const char __two[] = "�uglein";
113897403Sobrien  	    int i;
113997403Sobrien  	    int j;
114097403Sobrien  	    __locale_t	loc;
114197403Sobrien   	    __locale_t	loc_dup;
114297403Sobrien  	    loc = __newlocale(1 << LC_ALL, "de_DE", 0);
114397403Sobrien  	    loc_dup = __duplocale(loc);
114497403Sobrien  	    i = __strcoll_l(__one, __two, loc);
114597403Sobrien  	    j = __strcoll_l(__one, __two, loc_dup);
114697403Sobrien  	    return 0;
114797403Sobrien	  }
114897403Sobrien	  ], 
114997403Sobrien	  [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
115097403Sobrien	  [enable_clocale_flag=generic])
115197403Sobrien  	fi
115297403Sobrien
115397403Sobrien	# ... at some point put __strxfrm_l tests in as well.
115497403Sobrien        ;;
115597403Sobrien      *)
115697403Sobrien	enable_clocale_flag=generic
115797403Sobrien	;;
115897403Sobrien    esac
115997403Sobrien  fi
116097403Sobrien
116197403Sobrien  dnl Deal with gettext issues.
116297403Sobrien  AC_ARG_ENABLE(nls,
116397403Sobrien  [  --enable-nls            use Native Language Support (default)],
116497403Sobrien  , enable_nls=yes)
116597403Sobrien  USE_NLS=no
116697403Sobrien
116797403Sobrien  dnl Set configure bits for specified locale package
116897403Sobrien  case x${enable_clocale_flag} in
116997403Sobrien    xgeneric)
117097403Sobrien      AC_MSG_RESULT(generic)
117197403Sobrien
117297403Sobrien      CLOCALE_H=config/locale/generic/c_locale.h
117397403Sobrien      CLOCALE_CC=config/locale/generic/c_locale.cc
117497403Sobrien      CCODECVT_H=config/locale/generic/codecvt_specializations.h
117597403Sobrien      CCOLLATE_CC=config/locale/generic/collate_members.cc
117697403Sobrien      CCTYPE_CC=config/locale/generic/ctype_members.cc
117797403Sobrien      CMESSAGES_H=config/locale/generic/messages_members.h
117897403Sobrien      CMESSAGES_CC=config/locale/generic/messages_members.cc
117997403Sobrien      CMONEY_CC=config/locale/generic/monetary_members.cc
118097403Sobrien      CNUMERIC_CC=config/locale/generic/numeric_members.cc
118197403Sobrien      CTIME_CC=config/locale/generic/time_members.cc
118297403Sobrien      ;;
118397403Sobrien    xgnu)
118497403Sobrien      AC_MSG_RESULT(gnu)
118597403Sobrien
118697403Sobrien      # Declare intention to use gettext, and add support for specific
118797403Sobrien      # languages.
1188102782Skan      # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
118997403Sobrien      ALL_LINGUAS="de fr"
119097403Sobrien
1191102782Skan      # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
119297403Sobrien      AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
119397403Sobrien      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
119497403Sobrien	USE_NLS=yes
119597403Sobrien      fi
119697403Sobrien      # Export the build objects.
119797403Sobrien      for ling in $ALL_LINGUAS; do \
119897403Sobrien        glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
119997403Sobrien        glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
120097403Sobrien      done
120197403Sobrien      AC_SUBST(glibcpp_MOFILES)
120297403Sobrien      AC_SUBST(glibcpp_POFILES)
120397403Sobrien
120497403Sobrien      CLOCALE_H=config/locale/gnu/c_locale.h
120597403Sobrien      CLOCALE_CC=config/locale/gnu/c_locale.cc
120697403Sobrien      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
120797403Sobrien      CCOLLATE_CC=config/locale/gnu/collate_members.cc
120897403Sobrien      CCTYPE_CC=config/locale/gnu/ctype_members.cc
120997403Sobrien      CMESSAGES_H=config/locale/gnu/messages_members.h
121097403Sobrien      CMESSAGES_CC=config/locale/gnu/messages_members.cc
121197403Sobrien      CMONEY_CC=config/locale/gnu/monetary_members.cc
121297403Sobrien      CNUMERIC_CC=config/locale/gnu/numeric_members.cc
121397403Sobrien      CTIME_CC=config/locale/gnu/time_members.cc
121497403Sobrien      ;;
121597403Sobrien    xieee_1003.1-2001)
121697403Sobrien      AC_MSG_RESULT(generic)
121797403Sobrien
121897403Sobrien      CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
121997403Sobrien      CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
122097403Sobrien      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
122197403Sobrien      CCOLLATE_CC=config/locale/generic/collate_members.cc
122297403Sobrien      CCTYPE_CC=config/locale/generic/ctype_members.cc
122397403Sobrien      CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
122497403Sobrien      CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
122597403Sobrien      CMONEY_CC=config/locale/generic/monetary_members.cc
122697403Sobrien      CNUMERIC_CC=config/locale/generic/numeric_members.cc
122797403Sobrien      CTIME_CC=config/locale/generic/time_members.cc
122897403Sobrien      ;;
122997403Sobrien    *)
123097403Sobrien      echo "$enable_clocale is an unknown locale package" 1>&2
123197403Sobrien      exit 1
123297403Sobrien      ;;
123397403Sobrien  esac
123497403Sobrien
123597403Sobrien  # This is where the testsuite looks for locale catalogs, using the
123697403Sobrien  # -DLOCALEDIR define during testsuite compilation.
123797403Sobrien  glibcpp_localedir=${glibcpp_builddir}/po/share/locale
123897403Sobrien  AC_SUBST(glibcpp_localedir)
123997403Sobrien
124097403Sobrien  AC_SUBST(USE_NLS)
124197403Sobrien  AC_SUBST(CLOCALE_H)
124297403Sobrien  AC_SUBST(CCODECVT_H)
124397403Sobrien  AC_SUBST(CMESSAGES_H)
124497403Sobrien  AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
124597403Sobrien  AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
124697403Sobrien  AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
124797403Sobrien  AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
124897403Sobrien  AC_LINK_FILES($CMONEY_CC, src/monetary.cc)
124997403Sobrien  AC_LINK_FILES($CNUMERIC_CC, src/numeric.cc)
125097403Sobrien  AC_LINK_FILES($CTIME_CC, src/time.cc)
125197403Sobrien])
125297403Sobrien
125397403Sobrien
125497403Sobriendnl
125597403Sobriendnl Check for which I/O library to use:  libio, or something specific.
125697403Sobriendnl
125797403Sobriendnl GLIBCPP_ENABLE_CSTDIO
125897403Sobriendnl --enable-cstdio=libio sets config/io/c_io_libio.h and friends
125997403Sobriendnl 
126097403Sobriendnl default is stdio
126197403Sobriendnl
126297403SobrienAC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
126397403Sobrien  AC_MSG_CHECKING([for cstdio to use])
126497403Sobrien  AC_ARG_ENABLE(cstdio,
126597403Sobrien  [  --enable-cstdio         enable stdio for target io package. 
126697403Sobrien  --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
126797403Sobrien  ], 
126897403Sobrien  if test x$enable_cstdio = xno; then
126997403Sobrien     enable_cstdio=stdio
127097403Sobrien  fi,
127197403Sobrien     enable_cstdio=stdio)
127297403Sobrien
127397403Sobrien  enable_cstdio_flag=$enable_cstdio
127497403Sobrien
127597403Sobrien  dnl Check if a valid I/O package
127697403Sobrien  case x${enable_cstdio_flag} in
127797403Sobrien    xlibio)
127897403Sobrien      CSTDIO_H=config/io/c_io_libio.h
127997403Sobrien      BASIC_FILE_H=config/io/basic_file_libio.h
128097403Sobrien      BASIC_FILE_CC=config/io/basic_file_libio.cc
128197403Sobrien      AC_MSG_RESULT(libio)
128297403Sobrien
128397403Sobrien      # see if we are on a system with libio native (ie, linux)
128497403Sobrien      AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
128597403Sobrien
128697403Sobrien      # Need to check and see what version of glibc is being used. If
128797403Sobrien      # it's not glibc-2.2 or higher, then we'll need to go ahead and 
128897403Sobrien      # compile most of libio for linux systems.
128997403Sobrien      if test x$has_libio = x"yes"; then
129097403Sobrien        case "$target" in
129197403Sobrien          *-*-linux*)
129297403Sobrien              AC_MSG_CHECKING([for glibc version >= 2.2])
129397403Sobrien              AC_EGREP_CPP([ok], [
129497403Sobrien            #include <features.h>
129597403Sobrien              #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
129697403Sobrien                    ok
129797403Sobrien              #endif
129897403Sobrien              ], glibc_satisfactory=yes, glibc_satisfactory=no)
129997403Sobrien              AC_MSG_RESULT($glibc_satisfactory)
130097403Sobrien            ;;
130197403Sobrien        esac
130297403Sobrien
130397403Sobrien        # XXX at the moment, admit defeat and force the recompilation
130497403Sobrien        # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
130597403Sobrien        glibc_satisfactory=no        
130697403Sobrien
130797403Sobrien        if test x$glibc_satisfactory = x"yes"; then
130897403Sobrien           need_libio=no
130997403Sobrien           need_wlibio=no        
131097403Sobrien        else
131197403Sobrien           need_libio=yes
131297403Sobrien           # bkoz XXX need to add checks to enable this
131397403Sobrien           # pme XXX here's a first pass at such a check
131497403Sobrien           if test x$enable_c_mbchar != xno; then
131597403Sobrien              need_wlibio=yes
131697403Sobrien           else
131797403Sobrien              need_wlibio=no
131897403Sobrien           fi
131997403Sobrien        fi
132097403Sobrien
132197403Sobrien      else
132297403Sobrien         # Using libio, but <libio.h> doesn't exist on the target system. . .
132397403Sobrien         need_libio=yes
132497403Sobrien         # bkoz XXX need to add checks to enable this
132597403Sobrien         # pme XXX here's a first pass at such a check
132697403Sobrien         if test x$enable_c_mbchar != xno; then
132797403Sobrien             need_wlibio=yes
132897403Sobrien         else
132997403Sobrien             need_wlibio=no
133097403Sobrien         fi
133197403Sobrien      fi
133297403Sobrien      ;;
133397403Sobrien    xstdio | x | xno | xnone | xyes)
133497403Sobrien      # default
133597403Sobrien      CSTDIO_H=config/io/c_io_stdio.h
133697403Sobrien      BASIC_FILE_H=config/io/basic_file_stdio.h
133797403Sobrien      BASIC_FILE_CC=config/io/basic_file_stdio.cc
133897403Sobrien      AC_MSG_RESULT(stdio)
133997403Sobrien
134097403Sobrien      # We're not using stdio.
134197403Sobrien      need_libio=no
134297403Sobrien      need_wlibio=no
134397403Sobrien      ;;
134497403Sobrien    *)
134597403Sobrien      echo "$enable_cstdio is an unknown io package" 1>&2
134697403Sobrien      exit 1
134797403Sobrien      ;;
134897403Sobrien  esac
134997403Sobrien  AC_SUBST(CSTDIO_H)
135097403Sobrien  AC_SUBST(BASIC_FILE_H)
135197403Sobrien  AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
135297403Sobrien
135397403Sobrien  # 2000-08-04 bkoz hack
135497403Sobrien  CCODECVT_C=config/io/c_io_libio_codecvt.c
135597403Sobrien  AC_SUBST(CCODECVT_C)
135697403Sobrien  # 2000-08-04 bkoz hack
135797403Sobrien
135897403Sobrien  AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
135997403Sobrien                 test "$need_libio" = yes || test "$need_wlibio" = yes)
136097403Sobrien  AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
136197403Sobrien  AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
136297403Sobrien  if test "$need_libio" = yes || test "$need_wlibio" = yes; then
136397403Sobrien    libio_la=../libio/libio.la
136497403Sobrien  else
136597403Sobrien    libio_la=
136697403Sobrien  fi
136797403Sobrien  AC_SUBST(libio_la)
136897403Sobrien])
136997403Sobrien
137097403Sobrien
137197403Sobriendnl
137297403Sobriendnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
137397403Sobriendnl We must stage the required headers so that they will be installed
137497403Sobriendnl with the library (unlike libgcc, the STL implementation is provided
137597403Sobriendnl solely within headers).  Since we must not inject random user-space
137697403Sobriendnl macro names into user-provided C++ code, we first stage into <file>-in
137797403Sobriendnl and process to <file> with an output command.  The reason for a two-
137897403Sobriendnl stage process here is to correctly handle $srcdir!=$objdir without
137997403Sobriendnl having to write complex code (the sed commands to clean the macro
138097403Sobriendnl namespace are complex and fragile enough as it is).  We must also
138197403Sobriendnl add a relative path so that -I- is supported properly.
138297403Sobriendnl
138397403SobrienAC_DEFUN(GLIBCPP_ENABLE_THREADS, [
138497403Sobrien  AC_MSG_CHECKING([for thread model used by GCC])
138597403Sobrien  target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
138697403Sobrien  AC_MSG_RESULT([$target_thread_file])
138797403Sobrien
138897403Sobrien  if test $target_thread_file != single; then
138997403Sobrien    AC_DEFINE(HAVE_GTHR_DEFAULT)
139097403Sobrien    AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
139197403Sobrien  fi
139297403Sobrien
139397403Sobrien  glibcpp_thread_h=gthr-$target_thread_file.h
139497403Sobrien  AC_SUBST(glibcpp_thread_h)
139597403Sobrien])
139697403Sobrien
139797403Sobrien
139897403Sobriendnl
139997403Sobriendnl Check for exception handling support.  If an explicit enable/disable
140097403Sobriendnl sjlj exceptions is given, we don't have to detect.  Otherwise the
140197403Sobriendnl target may or may not support call frame exceptions.
140297403Sobriendnl
140397403Sobriendnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
140497403Sobriendnl --enable-sjlj-exceptions forces the use of builtin setjmp.
140597403Sobriendnl --disable-sjlj-exceptions forces the use of call frame unwinding.
140697403Sobriendnl
140797403Sobriendnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
140897403Sobriendnl
140997403SobrienAC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
141097403Sobrien  AC_MSG_CHECKING([for exception model to use])
141197403Sobrien  AC_LANG_SAVE
141297403Sobrien  AC_LANG_CPLUSPLUS
141397403Sobrien  AC_ARG_ENABLE(sjlj-exceptions,
141497403Sobrien  [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
141597403Sobrien  [:],
141697403Sobrien  [dnl Botheration.  Now we've got to detect the exception model.
141797403Sobrien   dnl Link tests against libgcc.a are problematic since -- at least
141897403Sobrien   dnl as of this writing -- we've not been given proper -L bits for
141997403Sobrien   dnl single-tree newlib and libgloss.
142097403Sobrien   dnl
142197403Sobrien   dnl This is what AC_TRY_COMPILE would do if it didn't delete the
142297403Sobrien   dnl conftest files before we got a change to grep them first.
142397403Sobrien   cat > conftest.$ac_ext << EOF
142497403Sobrien[#]line __oline__ "configure"
142597403Sobrienstruct S { ~S(); };
142697403Sobrienvoid bar();
142797403Sobrienvoid foo()
142897403Sobrien{
142997403Sobrien  S s;
143097403Sobrien  bar();
143197403Sobrien}
143297403SobrienEOF
143397403Sobrien   old_CXXFLAGS="$CXXFLAGS"  
143497403Sobrien   CXXFLAGS="-S -fexceptions"
143597403Sobrien   if AC_TRY_EVAL(ac_compile); then
143697403Sobrien     if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
143797403Sobrien       enable_sjlj_exceptions=yes
143897403Sobrien     elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
143997403Sobrien       enable_sjlj_exceptions=no
144097403Sobrien     fi
144197403Sobrien   fi
144297403Sobrien   CXXFLAGS="$old_CXXFLAGS"
144397403Sobrien   rm -f conftest*])
144497403Sobrien   if test x$enable_sjlj_exceptions = xyes; then
144597403Sobrien     AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
144697403Sobrien        [Define if the compiler is configured for setjmp/longjmp exceptions.])
144797403Sobrien     ac_exception_model_name=sjlj
144897403Sobrien   elif test x$enable_sjlj_exceptions = xno; then
144997403Sobrien     ac_exception_model_name="call frame"
145097403Sobrien   else
145197403Sobrien     AC_MSG_ERROR([unable to detect exception model])
145297403Sobrien   fi
145397403Sobrien   AC_LANG_RESTORE
145497403Sobrien   AC_MSG_RESULT($ac_exception_model_name)
145597403Sobrien])
145697403Sobrien
145797403Sobrien
145897403Sobriendnl
145997403Sobriendnl Check for libunwind exception handling support. If enabled then
146097403Sobriendnl we assume that the _Unwind_* functions that make up the Unwind ABI
146197403Sobriendnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
146297403Sobriendnl libunwind instead of libgcc and that libstdc++ has a dependency
146397403Sobriendnl on libunwind as well as libgcc.
146497403Sobriendnl
146597403Sobriendnl GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
146697403Sobriendnl --enable-libunwind-exceptions forces the use of libunwind.
146797403Sobriendnl --disable-libunwind-exceptions assumes there is no libunwind.
146897403Sobriendnl
146997403Sobriendnl Define _GLIBCPP_LIBUNWIND_EXCEPTIONS if requested.
147097403Sobriendnl
147197403SobrienAC_DEFUN(GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS, [
147297403Sobrien  AC_MSG_CHECKING([for use of libunwind])
147397403Sobrien  AC_ARG_ENABLE(libunwind-exceptions,
147497403Sobrien  [  --enable-libunwind-exceptions  force use of libunwind for exceptions],
147597403Sobrien  use_libunwind_exceptions=$enableval,
147697403Sobrien  use_libunwind_exceptions=no)
147797403Sobrien  AC_MSG_RESULT($use_libunwind_exceptions)
147897403Sobrien  dnl Option parsed, now set things appropriately
147997403Sobrien  if test x"$use_libunwind_exceptions" = xyes; then
148097403Sobrien    LIBUNWIND_FLAG="-lunwind"
148197403Sobrien  else
148297403Sobrien    LIBUNWIND_FLAG=""
148397403Sobrien  fi
148497403Sobrien  AC_SUBST(LIBUNWIND_FLAG)
148597403Sobrien])
148697403Sobrien
148797403Sobriendnl
148897403Sobriendnl Check for ISO/IEC 9899:1999 "C99" support.
148997403Sobriendnl
149097403Sobriendnl GLIBCPP_ENABLE_C99
149197403Sobriendnl --enable-c99 defines _GLIBCPP_USE_C99
149297403Sobriendnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
149397403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
149497403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
149597403Sobriendnl       defaults to `no'.
149697403Sobriendnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
149797403Sobriendnl
149897403Sobriendnl GLIBCPP_ENABLE_C99
149997403SobrienAC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
150097403Sobrien  define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
150197403Sobrien
150297403Sobrien  AC_ARG_ENABLE(c99,
150397403Sobrien  changequote(<<, >>)dnl
150497403Sobrien  <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
150597403Sobrien  changequote([, ])dnl
150697403Sobrien  [case "$enableval" in
150797403Sobrien   yes) enable_c99=yes ;;
150897403Sobrien   no)  enable_c99=no ;;
150997403Sobrien   *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
151097403Sobrien   esac],
151197403Sobrien  enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
151297403Sobrien 
151397403Sobrien  AC_LANG_SAVE
151497403Sobrien  AC_LANG_CPLUSPLUS
151597403Sobrien
151697403Sobrien  # Check for the existence of <math.h> functions used if C99 is enabled.
151797403Sobrien  ac_c99_math=yes;
151897403Sobrien  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
151997403Sobrien  AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
152097403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
152197403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
152297403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
152397403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
152497403Sobrien  AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
152597403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
152697403Sobrien  AC_TRY_COMPILE([#include <math.h>],
152797403Sobrien                 [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
152897403Sobrien  AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
152997403Sobrien  AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
153097403Sobrien  AC_TRY_COMPILE([#include <math.h>],
153197403Sobrien	         [islessgreater(0.0,0.0);],, [ac_c99_math=no])
153297403Sobrien  AC_TRY_COMPILE([#include <math.h>],
153397403Sobrien	         [isunordered(0.0,0.0);],, [ac_c99_math=no])
153497403Sobrien  AC_MSG_RESULT($ac_c99_math)
153597403Sobrien
153697403Sobrien  # Check for the existence in <stdio.h> of vscanf, et. al.
153797403Sobrien  ac_c99_stdio=yes;
153897403Sobrien  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
153997403Sobrien  AC_TRY_COMPILE([#include <stdio.h>],
154097403Sobrien		 [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
154197403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
154297403Sobrien		  #include <stdarg.h>
154397403Sobrien		  void foo(char* fmt, ...)
154497403Sobrien		  {va_list args; va_start(args, fmt);
154597403Sobrien	          vfscanf(stderr, "%i", args);}],
154697403Sobrien	          [],, [ac_c99_stdio=no])
154797403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
154897403Sobrien		  #include <stdarg.h>
154997403Sobrien		  void foo(char* fmt, ...)
155097403Sobrien		  {va_list args; va_start(args, fmt);
155197403Sobrien	          vscanf("%i", args);}],
155297403Sobrien	          [],, [ac_c99_stdio=no])
155397403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
155497403Sobrien		  #include <stdarg.h>
155597403Sobrien		  void foo(char* fmt, ...)
155697403Sobrien		  {va_list args; va_start(args, fmt);
155797403Sobrien	          vsnprintf(fmt, 0, "%i", args);}],
155897403Sobrien	          [],, [ac_c99_stdio=no])
155997403Sobrien  AC_TRY_COMPILE([#include <stdio.h>
156097403Sobrien		  #include <stdarg.h>
156197403Sobrien		  void foo(char* fmt, ...)
156297403Sobrien		  {va_list args; va_start(args, fmt);
156397403Sobrien	          vsscanf(fmt, "%i", args);}],
156497403Sobrien	          [],, [ac_c99_stdio=no])
156597403Sobrien  AC_MSG_RESULT($ac_c99_stdio)
156697403Sobrien
156797403Sobrien  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
156897403Sobrien  ac_c99_stdlib=yes;
156997403Sobrien  AC_MSG_CHECKING([for lldiv_t declaration])
157097403Sobrien  AC_CACHE_VAL(ac_c99_lldiv_t, [
157197403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], 
157297403Sobrien                   [ lldiv_t mydivt;], 
157397403Sobrien                   [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
157497403Sobrien  ])
157597403Sobrien  AC_MSG_RESULT($ac_c99_lldiv_t)
157697403Sobrien
157797403Sobrien  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
157897403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
157997403Sobrien	         [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
158097403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
158197403Sobrien	         [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
158297403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
158397403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
158497403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
158597403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
158697403Sobrien  if test x"$ac_c99_lldiv_t" = x"no"; then
158797403Sobrien    ac_c99_stdlib=no; 
158897403Sobrien  fi; 
158997403Sobrien  AC_MSG_RESULT($ac_c99_stdlib)
159097403Sobrien
159197403Sobrien  # Check for the existence of <wchar.h> functions used if C99 is enabled.
159297403Sobrien  # XXX the wchar.h checks should be rolled into the general C99 bits.
159397403Sobrien  ac_c99_wchar=yes;
159497403Sobrien  AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
159597403Sobrien  AC_TRY_COMPILE([#include <wchar.h>], 
159697403Sobrien	         [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
159797403Sobrien  AC_TRY_COMPILE([#include <wchar.h>], 
159897403Sobrien	         [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
159997403Sobrien  AC_TRY_COMPILE([#include <wchar.h>], 
160097403Sobrien	         [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
160197403Sobrien  AC_MSG_RESULT($ac_c99_wchar)
160297403Sobrien
160397403Sobrien  AC_MSG_CHECKING([for enabled ISO C99 support])
160497403Sobrien  if test x"$ac_c99_math" = x"no" ||
160597403Sobrien     test x"$ac_c99_stdio" = x"no" ||
160697403Sobrien     test x"$ac_c99_stdlib" = x"no" ||
160797403Sobrien     test x"$ac_c99_wchar" = x"no"; then
160897403Sobrien    enable_c99=no; 
160997403Sobrien  fi; 
161097403Sobrien  AC_MSG_RESULT($enable_c99)
161197403Sobrien
161297403Sobrien  # Option parsed, now set things appropriately
161397403Sobrien  if test x"$enable_c99" = x"yes"; then
161497403Sobrien    AC_DEFINE(_GLIBCPP_USE_C99)
161597403Sobrien  fi
161697403Sobrien
161797403Sobrien  AC_LANG_RESTORE
161897403Sobrien])
161997403Sobrien
162097403Sobrien
162197403Sobriendnl
162297403Sobriendnl Check for template specializations for the 'long long' type extension.
162397403Sobriendnl The result determines only whether 'long long' I/O is enabled; things
162497403Sobriendnl like numeric_limits<> specializations are always available.
162597403Sobriendnl
162697403Sobriendnl GLIBCPP_ENABLE_LONG_LONG
162797403Sobriendnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
162897403Sobriendnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
162997403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
163097403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
163197403Sobriendnl       defaults to `no'.
163297403Sobriendnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
163397403Sobriendnl
163497403Sobriendnl GLIBCPP_ENABLE_LONG_LONG
163597403SobrienAC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
163697403Sobrien  define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
163797403Sobrien
163897403Sobrien  AC_ARG_ENABLE(long-long,
163997403Sobrien  changequote(<<, >>)dnl
164097403Sobrien  <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
164197403Sobrien  changequote([, ])dnl
164297403Sobrien  [case "$enableval" in
164397403Sobrien   yes) enable_long_long=yes ;;
164497403Sobrien   no)  enable_long_long=no ;;
164597403Sobrien   *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
164697403Sobrien   esac],
164797403Sobrien  enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
164897403Sobrien
164997403Sobrien  AC_LANG_SAVE
165097403Sobrien  AC_LANG_CPLUSPLUS
165197403Sobrien
165297403Sobrien  AC_MSG_CHECKING([for enabled long long I/O support])
165397403Sobrien  # iostreams require strtoll, strtoull to compile
165497403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
165597403Sobrien                 [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
165697403Sobrien  AC_TRY_COMPILE([#include <stdlib.h>],
165797403Sobrien                 [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
165897403Sobrien
165997403Sobrien  # Option parsed, now set things appropriately
166097403Sobrien  if test x"$enable_long_long" = xyes; then
166197403Sobrien    AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
166297403Sobrien  fi
166397403Sobrien  AC_MSG_RESULT($enable_long_long)
166497403Sobrien
166597403Sobrien  AC_LANG_RESTORE
166697403Sobrien])
166797403Sobrien
166897403Sobrien
166997403Sobriendnl
167097403Sobriendnl Check for what kind of C headers to use.
167197403Sobriendnl
167297403Sobriendnl GLIBCPP_ENABLE_CHEADERS
167397403Sobriendnl --enable-cheaders= [does stuff].
167497403Sobriendnl --disable-cheaders [does not do anything, really].
167597403Sobriendnl  +  This will eventually need to be 'c_shadow' by default.
167697403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
167797403Sobriendnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
167897403Sobriendnl       If ommitted, it defaults to `c_std'.
167997403SobrienAC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
168097403Sobriendefine([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
168197403SobrienAC_MSG_CHECKING([for c header strategy to use])
168297403SobrienAC_ARG_ENABLE(cheaders,
168397403Sobrienchangequote(<<, >>)dnl
168497403Sobrien<<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
168597403Sobrienchangequote([, ])
168697403Sobrien  [case "$enableval" in
168797403Sobrien   c) 
168897403Sobrien        enable_cheaders=c 
168997403Sobrien        ;;
169097403Sobrien   c_std)  
169197403Sobrien        enable_cheaders=c_std 
169297403Sobrien        ;;
169397403Sobrien   c_shadow)  
169497403Sobrien        enable_cheaders=c_shadow 
169597403Sobrien        ;;
169697403Sobrien   *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
169797403Sobrien        ;;
169897403Sobrien  esac],
169997403Sobrien  enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
170097403Sobrien  AC_MSG_RESULT($enable_cheaders)
170197403Sobrien
170297403Sobrien  dnl Option parsed, now set things appropriately
170397403Sobrien  case "$enable_cheaders" in
170497403Sobrien    c_shadow) 
170597403Sobrien        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
170697403Sobrien        ;;
170797403Sobrien    c_std)   
170897403Sobrien        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
170997403Sobrien        ;;
171097403Sobrien    c)   
171197403Sobrien        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
171297403Sobrien        ;;
171397403Sobrien  esac
171497403Sobrien
171597403Sobrien  AC_SUBST(C_INCLUDE_DIR)
171697403Sobrien  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C, test "$enable_cheaders" = c)
171797403Sobrien  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C_STD, test "$enable_cheaders" = c_std)
1718102782Skan  AM_CONDITIONAL(GLIBCPP_C_HEADERS_COMPATIBILITY, test "$c_compatibility" = yes)
171997403Sobrien])
172097403Sobrien
172197403Sobrien
172297403Sobriendnl
172397403Sobriendnl Check for wide character support.  Has the same effect as the option
172497403Sobriendnl in gcc's configure, but in a form that autoconf can mess with.
172597403Sobriendnl
172697403Sobriendnl GLIBCPP_ENABLE_C_MBCHAR
172797403Sobriendnl --enable-c-mbchar requests all the wchar_t stuff.
172897403Sobriendnl --disable-c-mbchar doesn't.
172997403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
173097403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
173197403Sobriendnl       defaults to `no'.
173297403SobrienAC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
173397403Sobriendefine([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
173497403SobrienAC_ARG_ENABLE(c-mbchar,
173597403Sobrienchangequote(<<, >>)dnl
173697403Sobrien<<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
173797403Sobrienchangequote([, ])dnl
173897403Sobrien[case "$enableval" in
173997403Sobrien yes) enable_c_mbchar=yes ;;
174097403Sobrien no)  enable_c_mbchar=no ;;
174197403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
174297403Sobrien esac],
174397403Sobrienenable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
174497403Sobriendnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
174597403Sobrien])
174697403Sobrien
174797403Sobrien
174897403Sobriendnl
174997403Sobriendnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
175097403Sobriendnl
175197403Sobriendnl TOPLEVEL_INCLUDES
175297403Sobriendnl LIBMATH_INCLUDES
175397403Sobriendnl LIBSUPCXX_INCLUDES
175497403Sobriendnl LIBIO_INCLUDES
175597403Sobriendnl CSHADOW_INCLUDES
175697403Sobriendnl
175797403Sobriendnl GLIBCPP_EXPORT_INCLUDES
175897403SobrienAC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
175997403Sobrien  # Root level of the build directory include sources.
176097403Sobrien  GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
176197403Sobrien
176297403Sobrien  # Passed down for canadian crosses.
176397403Sobrien  if test x"$CANADIAN" = xyes; then
176497403Sobrien    TOPLEVEL_INCLUDES='-I$(includedir)'
176597403Sobrien  fi
176697403Sobrien
176797403Sobrien  LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
176897403Sobrien
176997403Sobrien  LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
177097403Sobrien
177197403Sobrien  if test x"$need_libio" = xyes; then
177297403Sobrien    LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
177397403Sobrien    AC_SUBST(LIBIO_INCLUDES)
177497403Sobrien  fi
177597403Sobrien
177697403Sobrien  # Now, export this to all the little Makefiles....
177797403Sobrien  AC_SUBST(GLIBCPP_INCLUDES)
177897403Sobrien  AC_SUBST(TOPLEVEL_INCLUDES)
177997403Sobrien  AC_SUBST(LIBMATH_INCLUDES)
178097403Sobrien  AC_SUBST(LIBSUPCXX_INCLUDES)
178197403Sobrien])
178297403Sobrien
178397403Sobrien
178497403Sobriendnl
178597403Sobriendnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
178697403Sobriendnl
178797403SobrienAC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
178897403Sobrien  # Optimization flags that are probably a good idea for thrill-seekers. Just
178997403Sobrien  # uncomment the lines below and make, everything else is ready to go... 
179097403Sobrien  # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
179197403Sobrien  OPTIMIZE_CXXFLAGS=
179297403Sobrien  AC_SUBST(OPTIMIZE_CXXFLAGS)
179397403Sobrien
179497403Sobrien  WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
179597403Sobrien  AC_SUBST(WARN_FLAGS)
179697403Sobrien])
179797403Sobrien
179897403Sobriendnl
179997403Sobriendnl  GLIBCPP_EXPORT_INSTALL_INFO
180097403Sobriendnl  calculates gxx_install_dir
180197403Sobriendnl  exports glibcpp_toolexecdir
180297403Sobriendnl  exports glibcpp_toolexeclibdir
180397403Sobriendnl  exports glibcpp_prefixdir
180497403Sobriendnl
180597403Sobriendnl Assumes cross_compiling bits already done, and with_cross_host in
180697403Sobriendnl particular
180797403Sobriendnl
180897403Sobriendnl GLIBCPP_EXPORT_INSTALL_INFO
180997403SobrienAC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
181097403Sobrien# Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
181197403Sobrien# exported correctly in GLIBCPP_CONFIGURE.
181297403Sobrienglibcpp_toolexecdir=no
181397403Sobrienglibcpp_toolexeclibdir=no
181497403Sobrienglibcpp_prefixdir=${prefix}
181597403Sobrien
181697403Sobrien# Process the option --with-gxx-include-dir=<path to include-files directory>
181797403SobrienAC_MSG_CHECKING([for --with-gxx-include-dir])
181897403SobrienAC_ARG_WITH(gxx-include-dir,
181997403Sobrien[  --with-gxx-include-dir  the installation directory for include files],
182097403Sobrien[case "${withval}" in
182197403Sobrien  yes)
182297403Sobrien    AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
182397403Sobrien    gxx_include_dir=no
182497403Sobrien    ;;
182597403Sobrien  no)
182697403Sobrien    gxx_include_dir=no
182797403Sobrien    ;;
182897403Sobrien  *)
182997403Sobrien    gxx_include_dir=${withval}
183097403Sobrien    ;;
183197403Sobrienesac], [gxx_include_dir=no])
183297403SobrienAC_MSG_RESULT($gxx_include_dir)
183397403Sobrien
183497403Sobrien# Process the option "--enable-version-specific-runtime-libs"
183597403SobrienAC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
183697403SobrienAC_ARG_ENABLE(version-specific-runtime-libs,
183797403Sobrien[  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
183897403Sobrien[case "$enableval" in
183997403Sobrien yes) version_specific_libs=yes ;;
184097403Sobrien no)  version_specific_libs=no ;;
184197403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
184297403Sobrien esac],
184397403Sobrienversion_specific_libs=no)dnl
184497403Sobrien# Option set, now we can test it.
184597403SobrienAC_MSG_RESULT($version_specific_libs)
184697403Sobrien
1847102782Skan# Default case for install directory for include files.
1848102782Skanif test $version_specific_libs = no && test $gxx_include_dir = no; then
1849102782Skan  gxx_include_dir='$(prefix)'/include/c++/${gcc_version}
1850102782Skanfi
1851102782Skan
1852102782Skan# Version-specific runtime libs processing.
185397403Sobrienif test $version_specific_libs = yes; then
185497403Sobrien  # Need the gcc compiler version to know where to install libraries
185597403Sobrien  # and header files if --enable-version-specific-runtime-libs option
185697403Sobrien  # is selected.
185797403Sobrien  if test x"$gxx_include_dir" = x"no"; then
1858102782Skan    gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/c++
185997403Sobrien  fi
186097403Sobrien  glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
186197403Sobrien  glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
186297403Sobrienfi
186397403Sobrien
186497403Sobrien# Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
186597403Sobrien# Install a library built with a cross compiler in tooldir, not libdir.
186697403Sobrienif test x"$glibcpp_toolexecdir" = x"no"; then 
186797403Sobrien  if test -n "$with_cross_host" &&
186897403Sobrien     test x"$with_cross_host" != x"no"; then
186997403Sobrien    glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
187097403Sobrien    glibcpp_toolexeclibdir='$(toolexecdir)/lib$(MULTISUBDIR)'
187197403Sobrien  else
187297403Sobrien    glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
187397403Sobrien    glibcpp_toolexeclibdir='$(libdir)$(MULTISUBDIR)'
187497403Sobrien  fi
187597403Sobrienfi
187697403Sobrien
187797403SobrienAC_MSG_CHECKING([for install location])
187897403SobrienAC_MSG_RESULT($gxx_include_dir)
187997403Sobrien
188097403SobrienAC_SUBST(glibcpp_prefixdir)
188197403SobrienAC_SUBST(gxx_include_dir)
188297403SobrienAC_SUBST(glibcpp_toolexecdir)
188397403SobrienAC_SUBST(glibcpp_toolexeclibdir)
188497403Sobrien])
188597403Sobrien
188697403Sobrien
188797403Sobrien# Check for functions in math library.
188897403Sobrien# Ulrich Drepper <drepper@cygnus.com>, 1998.
188997403Sobrien#
189097403Sobrien# This file can be copied and used freely without restrictions.  It can
189197403Sobrien# be used in projects which are not available under the GNU Public License
189297403Sobrien# but which still want to provide support for the GNU gettext functionality.
189397403Sobrien# Please note that the actual code is *not* freely available.
189497403Sobrien
189597403Sobrien# serial 1
189697403Sobrien
189797403Sobriendnl AC_REPLACE_MATHFUNCS(FUNCTION...)
189897403SobrienAC_DEFUN(AC_REPLACE_MATHFUNCS,
189997403Sobrien[AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])])
190097403Sobrien
190197403Sobrien
190297403Sobriendnl This macro searches for a GNU version of make.  If a match is found, the
190397403Sobriendnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
190497403Sobriendnl set to "#". This is useful for  including a special features in a Makefile,
190597403Sobriendnl which cannot be handled by other versions of make.  The variable
190697403Sobriendnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
190797403Sobriendnl the empty string otherwise.
190897403Sobriendnl
190997403Sobriendnl Here is an example of its use:
191097403Sobriendnl
191197403Sobriendnl Makefile.in might contain:
191297403Sobriendnl
191397403Sobriendnl     # A failsafe way of putting a dependency rule into a makefile
191497403Sobriendnl     $(DEPEND):
191597403Sobriendnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
191697403Sobriendnl
191797403Sobriendnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
191897403Sobriendnl     @ifGNUmake@ include $(DEPEND)
191997403Sobriendnl     @ifGNUmake@ endif
192097403Sobriendnl
192197403Sobriendnl Then configure.in would normally contain:
192297403Sobriendnl
192397403Sobriendnl     CHECK_GNU_MAKE()
192497403Sobriendnl     AC_OUTPUT(Makefile)
192597403Sobriendnl
192697403Sobriendnl Then perhaps to cause gnu make to override any other make, we could do
192797403Sobriendnl something like this (note that GNU make always looks for GNUmakefile first):
192897403Sobriendnl
192997403Sobriendnl     if  ! test x$_cv_gnu_make_command = x ; then
193097403Sobriendnl             mv Makefile GNUmakefile
193197403Sobriendnl             echo .DEFAULT: > Makefile ;
193297403Sobriendnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
193397403Sobriendnl     fi
193497403Sobriendnl
193597403Sobriendnl Then, if any (well almost any) other make is called, and GNU make also
193697403Sobriendnl exists, then the other make wraps the GNU make.
193797403Sobriendnl
193897403Sobriendnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
193997403Sobriendnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
194097403Sobriendnl
194197403Sobriendnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
194297403Sobriendnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
194397403Sobriendnl #### conditional's subshell (" --version" is not a command), using a
194497403Sobriendnl #### different option to grep(1).
194597403Sobriendnl #### -pme
194697403Sobriendnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
194797403Sobriendnl #### ${MAKE:-make}).
194897403Sobriendnl #### -msokolov
194997403SobrienAC_DEFUN(
195097403Sobrien  GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
195197403Sobrien          _cv_gnu_make_command='' ;
195297403Sobriendnl Search all the common names for GNU make
195397403Sobrien          for a in "${MAKE-make}" make gmake gnumake ; do
195497403Sobrien                  if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
195597403Sobrien                  then
195697403Sobrien                          _cv_gnu_make_command=$a ;
195797403Sobrien                          break;
195897403Sobrien                  fi
195997403Sobrien          done ;
196097403Sobrien  ) ;
196197403Sobriendnl If there was a GNU version, then set @ifGNUmake@ to the empty
196297403Sobriendnl string, '#' otherwise
196397403Sobrien  if test  "x$_cv_gnu_make_command" != "x"  ; then
196497403Sobrien          ifGNUmake='' ;
196597403Sobrien  else
196697403Sobrien          ifGNUmake='#' ;
196797403Sobrien  fi
196897403Sobrien  AC_SUBST(ifGNUmake)
196997403Sobrien])
197097403Sobrien
197197403Sobrien
197297403Sobriendnl Check for headers for, and arguments to, the setrlimit() function.
197397403Sobriendnl Used only in testsuite_hooks.h.
197497403SobrienAC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
197597403Sobrien  AC_TRY_COMPILE([#include <sys/resource.h>
197697403Sobrien                  #include <unistd.h>
197797403Sobrien                 ], [ int f = RLIMIT_$1 ; ],
197897403Sobrien                 [glibcpp_mresult=1], [glibcpp_mresult=0])
197997403Sobrien  AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
198097403Sobrien                     [Only used in build directory testsuite_hooks.h.])
198197403Sobrien])
198297403SobrienAC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
198397403Sobrien  setrlimit_have_headers=yes
198497403Sobrien  AC_CHECK_HEADERS(sys/resource.h unistd.h,
198597403Sobrien                   [],
198697403Sobrien                   setrlimit_have_headers=no)
198797403Sobrien  # If don't have the headers, then we can't run the tests now, and we
198897403Sobrien  # won't be seeing any of these during testsuite compilation.
198997403Sobrien  if test $setrlimit_have_headers = yes; then
199097403Sobrien    # Can't do these in a loop, else the resulting syntax is wrong.
199197403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
199297403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
199397403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
199497403Sobrien    GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
199597403Sobrien
199697403Sobrien    # Check for rlimit, setrlimit.
199797403Sobrien    AC_CACHE_VAL(ac_setrlimit, [
199897403Sobrien      AC_TRY_COMPILE([#include <sys/resource.h>
199997403Sobrien		      #include <unistd.h>
200097403Sobrien		     ], 
200197403Sobrien                     [ struct rlimit r; setrlimit(0, &r);], 
200297403Sobrien                     [ac_setrlimit=yes], [ac_setrlimit=no])
200397403Sobrien    ])
200497403Sobrien  fi
200597403Sobrien
200697403Sobrien  AC_MSG_CHECKING([for testsuite memory limit support])
200797403Sobrien  if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
200897403Sobrien    ac_mem_limits=yes
200997403Sobrien    AC_DEFINE(_GLIBCPP_MEM_LIMITS)
201097403Sobrien  else
201197403Sobrien    ac_mem_limits=no
201297403Sobrien  fi
201397403Sobrien  AC_MSG_RESULT($ac_mem_limits)
201497403Sobrien])
201597403Sobrien
201697403Sobrien
201797403Sobriendnl
201897403Sobriendnl Does any necessary configuration of the testsuite directory.  Generates
201997403Sobriendnl the testsuite_hooks.h header.
202097403Sobriendnl
202197403Sobriendnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
202297403SobrienAC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
202397403Sobrien  GLIBCPP_CHECK_SETRLIMIT
202497403Sobrien
202597403Sobrien  # Look for setenv, so that extended locale tests can be performed.
202697403Sobrien  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
2027102782Skan
2028102782Skan  # Export file names for ABI checking.
2029102782Skan  baseline_file="${glibcpp_srcdir}/config/abi/${abi_baseline_triplet}/baseline_symbols.txt"
2030102782Skan  AC_SUBST(baseline_file)
2031102782Skan
2032102782Skan  # Don't do ABI checking unless native.
2033102782Skan  AM_CONDITIONAL(GLIBCPP_BUILD_ABI_CHECK,
2034102782Skan                 test x"$build" = x"$host" && test -z "$with_cross_host")
203597403Sobrien])
203697403Sobrien
203797403Sobrien
203897403Sobriensinclude(../libtool.m4)
203997403Sobriendnl The lines below arrange for aclocal not to bring an installed
204097403Sobriendnl libtool.m4 into aclocal.m4, while still arranging for automake to
204197403Sobriendnl add a definition of LIBTOOL to Makefile.in.
204297403Sobrienifelse(,,,[AC_SUBST(LIBTOOL)
204397403SobrienAC_DEFUN([AM_PROG_LIBTOOL])
204497403SobrienAC_DEFUN([AC_LIBTOOL_DLOPEN])
204597403SobrienAC_DEFUN([AC_PROG_LD])
204697403Sobrien])
204797403Sobrien
204897403Sobrien
204997403Sobrien# Check whether LC_MESSAGES is available in <locale.h>.
205097403Sobrien# Ulrich Drepper <drepper@cygnus.com>, 1995.
205197403Sobrien#
205297403Sobrien# This file file be copied and used freely without restrictions.  It can
205397403Sobrien# be used in projects which are not available under the GNU Public License
205497403Sobrien# but which still want to provide support for the GNU gettext functionality.
205597403Sobrien# Please note that the actual code is *not* freely available.
205697403Sobrien
205797403Sobrien# serial 1
205897403Sobrien
205997403SobrienAC_DEFUN(AC_LC_MESSAGES, [
206097403Sobrien  AC_CHECK_HEADER(locale.h, [
206197403Sobrien    AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
206297403Sobrien      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
206397403Sobrien       ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
206497403Sobrien    if test $ac_cv_val_LC_MESSAGES = yes; then
206597403Sobrien      AC_DEFINE(HAVE_LC_MESSAGES)
206697403Sobrien    fi
206797403Sobrien  ])
206897403Sobrien])
206997403Sobrien
207097403Sobrien
207197403Sobriendnl
207297403Sobriendnl Check for whether the Boost-derived checks should be turned on.
207397403Sobriendnl
207497403Sobriendnl GLIBCPP_ENABLE_CONCEPT_CHECKS
207597403Sobriendnl --enable-concept-checks turns them on.
207697403Sobriendnl --disable-concept-checks leaves them off.
207797403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
207897403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
207997403Sobriendnl       defaults to `no'.
208097403SobrienAC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
208197403Sobriendefine([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
208297403SobrienAC_ARG_ENABLE(concept-checks,
208397403Sobrienchangequote(<<, >>)dnl
208497403Sobrien<<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
208597403Sobrienchangequote([, ])dnl
208697403Sobrien[case "$enableval" in
208797403Sobrien yes) enable_concept_checks=yes ;;
208897403Sobrien no)  enable_concept_checks=no ;;
208997403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
209097403Sobrien esac],
209197403Sobrienenable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
209297403Sobriendnl Option parsed, now set things appropriately
209397403Sobrienif test x"$enable_concept_checks" = xyes; then
209497403Sobrien  AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
209597403Sobrienfi
209697403Sobrien])
209797403Sobrien
209897403Sobrien
209997403Sobriendnl
210097403Sobriendnl Add version tags to symbols in shared library (or not), additionally
210197403Sobriendnl marking other symbols as private/local (or not).
210297403Sobriendnl
210397403Sobriendnl GLIBCPP_ENABLE_SYMVERS
210497403Sobriendnl --enable-symvers=style adds a version script to the linker call when
210597403Sobriendnl       creating the shared library.  The choice of version script is
210697403Sobriendnl       controlled by 'style'.
210797403Sobriendnl --disable-symvers does not.
210897403Sobriendnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
210997403Sobriendnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
211097403Sobriendnl       defaults to `no'.  Passing `yes' tries to choose a default style
211197403Sobriendnl       based on linker characteristics.  Passing 'no' disables versioning.
211297403SobrienAC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
211397403Sobriendefine([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
211497403SobrienAC_ARG_ENABLE(symvers,
211597403Sobrienchangequote(<<, >>)dnl
211697403Sobrien<<  --enable-symvers=style  enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
211797403Sobrienchangequote([, ])dnl
211897403Sobrien[case "$enableval" in
211997403Sobrien yes) enable_symvers=yes ;;
212097403Sobrien no)  enable_symvers=no ;;
212197403Sobrien # other names here, just as sanity checks
212297403Sobrien #gnu|sun|etcetera) enable_symvers=$enableval ;;
212397403Sobrien gnu) enable_symvers=$enableval ;;
212497403Sobrien *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
212597403Sobrien esac],
212697403Sobrienenable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
212797403Sobrien
212897403Sobrien# If we never went through the GLIBCPP_CHECK_LINKER_FEATURES macro, then we
212997403Sobrien# don't know enough about $LD to do tricks... 
213097403Sobrienif test x$enable_shared = xno || 
2131102782Skan	test "x$LD" = x || 
213297403Sobrien	test x$glibcpp_gnu_ld_version = x; then
213397403Sobrien  enable_symvers=no
213497403Sobrienfi
213597403Sobrien
213697403Sobrien# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
213797403SobrienAC_MSG_CHECKING([for shared libgcc])
213897403Sobrienac_save_CFLAGS="$CFLAGS"
213997403SobrienCFLAGS=' -lgcc_s'
214097403SobrienAC_TRY_LINK( , [return 0], glibcpp_shared_libgcc=yes, glibcpp_shared_libgcc=no)
214197403SobrienCFLAGS="$ac_save_CFLAGS"
214297403SobrienAC_MSG_RESULT($glibcpp_shared_libgcc)
214397403Sobrien
214497403Sobrien# For GNU ld, we need at least this version.  It's 2.12 in the same format
214597403Sobrien# as the tested-for version.  See GLIBCPP_CHECK_LINKER_FEATURES for more.
214697403Sobrienglibcpp_min_gnu_ld_version=21200
214797403Sobrien
214897403Sobrien# Check to see if unspecified "yes" value can win, given results
214997403Sobrien# above.  
215097403Sobrienif test $enable_symvers = yes ; then
215197403Sobrien  if test $with_gnu_ld = yes &&
215297403Sobrien    test $glibcpp_shared_libgcc = yes ;
215397403Sobrien  then
215497403Sobrien    if test $glibcpp_gnu_ld_version -ge $glibcpp_min_gnu_ld_version ; then
215597403Sobrien        enable_symvers=gnu
215697403Sobrien    else
215797403Sobrien      ac_test_CFLAGS="${CFLAGS+set}"
215897403Sobrien      ac_save_CFLAGS="$CFLAGS"
215997403Sobrien      CFLAGS='-shared -Wl,--version-script,conftest.map'
216097403Sobrien      enable_symvers=no
216197403Sobrien      changequote(,)
216297403Sobrien      echo 'FOO { global: f[a-z]o; local: *; };' > conftest.map
216397403Sobrien      changequote([,])
216497403Sobrien      AC_TRY_LINK([int foo;],, enable_symvers=gnu)
216597403Sobrien      if test "$ac_test_CFLAGS" = set; then
216697403Sobrien	CFLAGS="$ac_save_CFLAGS"
216797403Sobrien      else
216897403Sobrien	# this is the suspicious part
216997403Sobrien	CFLAGS=''
217097403Sobrien      fi
217197403Sobrien      rm -f conftest.map
217297403Sobrien    fi
217397403Sobrien  else
217497403Sobrien    # just fail for now
217597403Sobrien    enable_symvers=no
217697403Sobrien  fi
217797403Sobrienfi
217897403Sobrien
217997403Sobriendnl Everything parsed; figure out what file to use.
218097403Sobriencase $enable_symvers in
218197403Sobrien  no)
218297403Sobrien      LINKER_MAP=config/linker-map.dummy
218397403Sobrien      ;;
218497403Sobrien  gnu)
218597403Sobrien      LINKER_MAP=config/linker-map.gnu
218697403Sobrien      ;;
218797403Sobrienesac
218897403Sobrien
218997403SobrienAC_LINK_FILES($LINKER_MAP, src/linker.map)
219097403SobrienAM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
219197403SobrienAC_MSG_CHECKING([versioning on shared library symbols])
219297403SobrienAC_MSG_RESULT($enable_symvers)
219397403Sobrien])
219497403Sobrien
2195