acinclude.m4 revision 97403
18870Srgrimesdnl
250476Speterdnl Initialize configure bits.
38870Srgrimesdnl
42116Sjkhdnl GLIBCPP_CONFIGURE
52116SjkhAC_DEFUN(GLIBCPP_CONFIGURE, [
68870Srgrimes  dnl Default to --enable-multilib
72116Sjkh  AC_ARG_ENABLE(multilib,
82116Sjkh  [  --enable-multilib       build hella library versions (default)],
98870Srgrimes  [case "${enableval}" in
102116Sjkh    yes) multilib=yes ;;
112116Sjkh    no)  multilib=no ;;
128870Srgrimes    *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
138870Srgrimes   esac], [multilib=yes])dnl
142116Sjkh
15212518Simp  # When building with srcdir == objdir, links to the source files will
16131001Smarcel  # be created in directories within the target_subdir.  We have to
17141281Sdas  # adjust toplevel_srcdir accordingly, so that configure finds
18212518Simp  # install-sh and other auxiliary files that live in the top-level
1933662Sjb  # source directory.
202116Sjkh  if test "${srcdir}" = "."; then
21141281Sdas    if test -z "${with_target_subdir}"; then
22130149Sdas      toprel=".."
23180581Sdas    else
242116Sjkh      if test "${with_target_subdir}" != "."; then
25174684Sdas        toprel="${with_multisrctop}../.."
26174684Sdas      else
27174684Sdas        toprel="${with_multisrctop}.."
28181074Sdas      fi
29174684Sdas    fi
30174684Sdas  else
31181074Sdas    toprel=".."
32174684Sdas  fi
33174684Sdas  AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
34180581Sdas  toplevel_srcdir=\${top_srcdir}/$toprel
35180581Sdas  AC_SUBST(toplevel_srcdir)
36180581Sdas
37180581Sdas  # Export build and source directories.
382116Sjkh  # These need to be absolute paths, yet at the same time need to
39119017Sgordon  # canonicalize only relative paths, because then amd will not unmount
40169807Sdeischen  # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
41181064Sdas  glibcpp_builddir=`pwd`
4293211Sbde  case $srcdir in
4393211Sbde  [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
442116Sjkh  *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
452116Sjkh  esac
462116Sjkh  AC_SUBST(glibcpp_builddir)
472116Sjkh  AC_SUBST(glibcpp_srcdir)
48216211Sdas
49216211Sdas  dnl This is here just to satisfy automake.
502116Sjkh  ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)])
51130149Sdas
52152133Sbde  AC_PROG_AWK
53141280Sdas  # Will set LN_S to either 'ln -s' or 'ln'.  With autoconf 2.5x, can also
54181074Sdas  # be 'cp -p' if linking isn't available.
55176243Sbde  #ac_cv_prog_LN_S='cp -p'
56174617Sdas  AC_PROG_LN_S
57174617Sdas
58144650Sdas  # We use these options to decide which functions to include.
59144650Sdas  AC_ARG_WITH(target-subdir,
60176243Sbde  [  --with-target-subdir=SUBDIR
61140609Sdas                          configuring in a subdirectory])
62131320Sdas  AC_ARG_WITH(cross-host,
63143222Sdas  [  --with-cross-host=HOST  configuring with a cross compiler])
64144772Sdas
65140088Sdas  glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
66144772Sdas  AC_SUBST(glibcpp_basedir)
67174684Sdas
68144091Sdas  # Never versions of autoconf add an underscore to these functions.
69144772Sdas  # Prevent future problems ...
70132382Sdas  ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
71176243Sbde  ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
72176388Sdas  ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
73141280Sdas  ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
742116Sjkh
75121497Sdes  # AC_PROG_CC
76121497Sdes  # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
77211934Snwhitehorn  # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
78211934Snwhitehorn  # are probably using a cross compiler, which will not be able to fully
79211934Snwhitehorn  # link an executable.  This is addressed in later versions of autoconf.
80211934Snwhitehorn
81211934Snwhitehorn  AC_DEFUN(LIB_AC_PROG_CC,
82176361Sdas  [AC_BEFORE([$0], [AC_PROG_CPP])dnl
83211934Snwhitehorn  dnl Fool anybody using AC_PROG_CC.
84157196Sdeischen  AC_PROVIDE([AC_PROG_CC])
85121497Sdes  AC_CHECK_PROG(CC, gcc, gcc)
86157196Sdeischen  if test -z "$CC"; then
87157196Sdeischen    AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
88157196Sdeischen    test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
89121497Sdes  fi
90175309Sdas
91143222Sdas  AC_PROG_CC_GNU
92143222Sdas
93181074Sdas  if test $ac_cv_prog_gcc = yes; then
94181074Sdas    GCC=yes
95181074Sdas  dnl Check whether -g works, even if CFLAGS is set, in case the package
96219576Skargl  dnl plays around with CFLAGS (such as to build both debugging and
97219571Skargl  dnl normal versions of a library), tasteless as that idea is.
98176361Sdas    ac_test_CFLAGS="${CFLAGS+set}"
99177766Sdas    ac_save_CFLAGS="$CFLAGS"
100177766Sdas    CFLAGS=
101143222Sdas    AC_PROG_CC_G
102121497Sdes    if test "$ac_test_CFLAGS" = set; then
103129864Sstefanf      CFLAGS="$ac_save_CFLAGS"
104226458Sdas    elif test $ac_cv_prog_cc_g = yes; then
105226458Sdas      CFLAGS="-g -O2"
106219359Sdas    else
107226458Sdas      CFLAGS="-O2"
108226458Sdas    fi
109129864Sstefanf  else
1102116Sjkh    GCC=
1112116Sjkh    test "${CFLAGS+set}" = set || CFLAGS="-g"
1122116Sjkh  fi
113117912Speter  ])
114117912Speter
1156953Sbde  LIB_AC_PROG_CC
116117912Speter
1176953Sbde  # Likewise for AC_PROG_CXX.  We can't just call it directly because g++
118117912Speter  # will try to link in libstdc++.
1196953Sbde  AC_DEFUN(LIB_AC_PROG_CXX,
120216137Sdas  [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
121216137Sdas  dnl Fool anybody using AC_PROG_CXX.
122216137Sdas  AC_PROVIDE([AC_PROG_CXX])
123216137Sdas  # Use glibcpp_CXX so that we do not cause CXX to be cached with the
124216137Sdas  # flags that come in CXX while configuring libstdc++.  They're different
125216137Sdas  # from those used for all other target libraries.  If CXX is set in
126117912Speter  # the environment, respect that here.
127117912Speter  glibcpp_CXX=$CXX
128130149Sdas  AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
12996462Sru  AC_SUBST(glibcpp_CXX)
130226458Sdas  CXX=$glibcpp_CXX
131226458Sdas  test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
132174617Sdas
133143709Sdas  AC_PROG_CXX_GNU
134143709Sdas
135140890Sdas  if test $ac_cv_prog_gxx = yes; then
136175462Sdas    GXX=yes
137175462Sdas    dnl Check whether -g works, even if CXXFLAGS is set, in case the package
138218877Smurray    dnl plays around with CXXFLAGS (such as to build both debugging and
139218877Smurray    dnl normal versions of a library), tasteless as that idea is.
14011682Sbde    ac_test_CXXFLAGS="${CXXFLAGS+set}"
141181074Sdas    ac_save_CXXFLAGS="$CXXFLAGS"
14213987Smpp    CXXFLAGS=
143181074Sdas    AC_PROG_CXX_G
14413987Smpp    if test "$ac_test_CXXFLAGS" = set; then
145181074Sdas      CXXFLAGS="$ac_save_CXXFLAGS"
14613987Smpp    elif test $ac_cv_prog_cxx_g = yes; then
147181074Sdas      CXXFLAGS="-g -O2"
148181074Sdas    else
149226458Sdas      CXXFLAGS="-O2"
150226458Sdas    fi
151226458Sdas  else
152140172Sstefanf    GXX=
153219359Sdas    test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
154133289Sstefanf  fi
155133289Sstefanf  ])
156181377Sdas
157133289Sstefanf  LIB_AC_PROG_CXX
158140890Sdas
159176361Sdas  # For some reason, gettext needs this.
16013987Smpp  AC_ISC_POSIX
161177761Sdas
16213987Smpp  AC_CHECK_TOOL(AS, as)
163175462Sdas  AC_CHECK_TOOL(AR, ar)
164175462Sdas  AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
165129038Sstefanf  AC_PROG_INSTALL
166131320Sdas
167130149Sdas  AM_MAINTAINER_MODE
168130149Sdas
169143709Sdas  # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
170130149Sdas  # at least currently, we never actually build a program, so we never
171130149Sdas  # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
172130149Sdas  # fails, because we are probably configuring with a cross compiler
173140143Sstefanf  # which can't create executables.  So we include AC_EXEEXT to keep
174143222Sdas  # automake happy, but we don't execute it, since we don't care about
175131320Sdas  # the result.
176131320Sdas  if false; then
177179882Sdas    # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
178177760Sdas    # to nothing, so nothing would remain between `then' and `fi' if it
179177760Sdas    # were not for the `:' below.
18013987Smpp    :
18113987Smpp    AC_EXEEXT
182152117Sbde  fi
183174698Sdas
18413987Smpp  . [$]{glibcpp_basedir}/configure.host
18513987Smpp
186176388Sdas  case [$]{glibcpp_basedir} in
187176388Sdas    /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
188216211Sdas    *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
189175309Sdas  esac
190175309Sdas
191144772Sdas  # This does for the target what configure.host does for the host.  In
192144772Sdas  # addition to possibly modifying the same flags, it also sets up symlinks.
193174684Sdas  GLIBCPP_CHECK_TARGET
194143222Sdas
195143222Sdas])
196143222Sdas
197177766Sdas
198177766Sdasdnl
199175309Sdasdnl Check to see if g++ can compile this library, and if so, if any version-
200175309Sdasdnl specific precautions need to be taken. 
201144772Sdasdnl 
202143222Sdasdnl GLIBCPP_CHECK_COMPILER_VERSION
203143222SdasAC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
204176361Sdasif test ! -f stamp-sanity-compiler; then
20513988Smpp  AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
206219571Skargl  AC_LANG_SAVE
207219571Skargl  AC_LANG_CPLUSPLUS
208176361Sdas  AC_TRY_COMPILE(, [
20913987Smpp  #if __GNUC__ < 3
210145208Sache    not_ok
2112116Sjkh  #endif
2122116Sjkh  ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
213  AC_LANG_RESTORE
214  AC_MSG_RESULT($gpp_satisfactory)
215  touch stamp-sanity-compiler
216fi
217])
218
219
220dnl
221dnl Tests for newer compiler features, or features that are present in newer
222dnl compiler versions but not older compiler versions still in use, should
223dnl be placed here.
224dnl
225dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
226dnl new inlining code or the new system_header pragma will die on -Werror.
227dnl Leave it out by default and use maint-mode to use it.
228dnl
229dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
230dnl compiler supports it and the user has not requested debug mode.
231dnl
232dnl GLIBCPP_CHECK_COMPILER_FEATURES
233AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
234  # All these tests are for C++; save the language and the compiler flags.
235  # The CXXFLAGS thing is suspicious, but based on similar bits previously
236  # found in GLIBCPP_CONFIGURE.
237  AC_LANG_SAVE
238  AC_LANG_CPLUSPLUS
239  ac_test_CXXFLAGS="${CXXFLAGS+set}"
240  ac_save_CXXFLAGS="$CXXFLAGS"
241
242  # Check for maintainer-mode bits.
243  if test x"$USE_MAINTAINER_MODE" = xno; then
244    WERROR=''
245  else
246    WERROR='-Werror'
247  fi
248
249  # Check for -ffunction-sections -fdata-sections
250  AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
251  CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
252  AC_TRY_COMPILE(, [int foo;
253  ], [ac_fdsections=yes], [ac_fdsections=no])
254  if test "$ac_test_CXXFLAGS" = set; then
255    CXXFLAGS="$ac_save_CXXFLAGS"
256  else
257    # this is the suspicious part
258    CXXFLAGS=''
259  fi
260  if test x"$ac_fdsections" = x"yes" &&
261     test x"$enable_debug" = x"no"; then
262    SECTION_FLAGS='-ffunction-sections -fdata-sections'
263  fi
264  AC_MSG_RESULT($ac_fdsections)
265
266  AC_LANG_RESTORE
267  AC_SUBST(WERROR)
268  AC_SUBST(SECTION_FLAGS)
269])
270
271
272dnl
273dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
274dnl the native linker is in use, all variables will be defined to something
275dnl safe (like an empty string).
276dnl
277dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
278dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
279dnl Define LD, with_gnu_ld, and (possibly) glibcpp_gnu_ld_version as
280dnl side-effects of testing.
281dnl
282dnl GLIBCPP_CHECK_LINKER_FEATURES
283AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
284  # If we're not using GNU ld, then there's no point in even trying these
285  # tests.  Check for that first.  We should have already tested for gld
286  # by now (in libtool), but require it now just to be safe...
287  test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
288  test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
289  AC_REQUIRE([AC_PROG_LD])
290
291  # The name set by libtool depends on the version of libtool.  Shame on us
292  # for depending on an impl detail, but c'est la vie.  Older versions used
293  # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
294  # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
295  # makes sense).  We'll test with_gnu_ld everywhere else, so if that isn't
296  # set (hence we're using an older libtool), then set it.
297  if test x${with_gnu_ld+set} != xset; then
298    if test x${ac_cv_prog_gnu_ld+set} != xset; then
299      # We got through "ac_require(ac_prog_ld)" and still not set?  Huh?
300      with_gnu_ld=no
301    else
302      with_gnu_ld=$ac_cv_prog_gnu_ld
303    fi
304  fi
305
306  # Start by getting the version number.  I think the libtool test already
307  # does some of this, but throws away the result.
308  changequote(,)
309  ldver=`$LD --version 2>/dev/null | head -1 | \
310         sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
311  changequote([,])
312  glibcpp_gnu_ld_version=`echo $ldver | \
313         $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
314
315  # Set --gc-sections.
316  if test "$with_gnu_ld" = "notbroken"; then
317    # GNU ld it is!  Joy and bunny rabbits!
318
319    # All these tests are for C++; save the language and the compiler flags.
320    # Need to do this so that g++ won't try to link in libstdc++
321    ac_test_CFLAGS="${CFLAGS+set}"
322    ac_save_CFLAGS="$CFLAGS"
323    CFLAGS='-x c++  -Wl,--gc-sections'
324
325    # Check for -Wl,--gc-sections
326    # XXX This test is broken at the moment, as symbols required for
327    # linking are now in libsupc++ (not built yet.....). In addition, 
328    # this test has cored on solaris in the past. In addition,
329    # --gc-sections doesn't really work at the moment (keeps on discarding
330    # used sections, first .eh_frame and now some of the glibc sections for
331    # iconv). Bzzzzt. Thanks for playing, maybe next time.
332    AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
333    AC_TRY_RUN([
334     int main(void) 
335     {
336       try { throw 1; }
337       catch (...) { };
338       return 0;
339     }
340    ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
341    if test "$ac_test_CFLAGS" = set; then
342      CFLAGS="$ac_save_CFLAGS"
343    else
344      # this is the suspicious part
345      CFLAGS=''
346    fi
347    if test "$ac_sectionLDflags" = "yes"; then
348      SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
349    fi
350    AC_MSG_RESULT($ac_sectionLDflags)
351  fi
352
353  # Set linker optimization flags.
354  if test x"$with_gnu_ld" = x"yes" && test x"$enable_debug" = x"no"; then
355    OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
356  fi
357
358  AC_SUBST(SECTION_LDFLAGS)
359  AC_SUBST(OPT_LDFLAGS)
360])
361
362
363dnl
364dnl Check to see if the (math function) argument passed is
365dnl declared when using the c++ compiler
366dnl ASSUMES argument is a math function with ONE parameter
367dnl
368dnl GLIBCPP_CHECK_MATH_DECL_1
369AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
370  AC_MSG_CHECKING([for $1 declaration])
371  if test x${glibcpp_cv_func_$1_use+set} != xset; then
372    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
373      AC_LANG_SAVE
374      AC_LANG_CPLUSPLUS
375      AC_TRY_COMPILE([#include <math.h>
376		      #ifdef HAVE_IEEEFP_H
377		      #include <ieeefp.h>
378		      #endif
379		     ], 
380                     [ $1(0);], 
381                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
382      AC_LANG_RESTORE
383    ])
384  fi
385  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
386])
387
388dnl
389dnl Check to see if the (math function) argument passed is
390dnl 1) declared when using the c++ compiler
391dnl 2) has "C" linkage
392dnl 3) if not, see if 1) and 2) for argument prepended with '_'
393dnl
394dnl Define HAVE_CARGF etc if "cargf" is declared and links
395dnl
396dnl argument 1 is name of function to check
397dnl
398dnl ASSUMES argument is a math function with ONE parameter
399dnl
400dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
401AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
402  GLIBCPP_CHECK_MATH_DECL_1($1)
403  if test x$glibcpp_cv_func_$1_use = x"yes"; then
404    AC_CHECK_FUNCS($1)    
405  else
406    GLIBCPP_CHECK_MATH_DECL_1(_$1)
407    if test x$glibcpp_cv_func__$1_use = x"yes"; then
408      AC_CHECK_FUNCS(_$1)    
409    fi
410  fi
411])
412
413
414dnl
415dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
416dnl of functions at once.  It's an all-or-nothing check -- either 
417dnl HAVE_XYZ is defined for each of the functions, or for none of them.
418dnl Doing it this way saves significant configure time.
419AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
420  AC_MSG_CHECKING([for $1 functions])
421  AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
422    AC_LANG_SAVE
423    AC_LANG_CPLUSPLUS
424    AC_TRY_COMPILE([#include <math.h>],
425                   [ `for x in $3; do echo "$x (0);"; done` ],
426                   [glibcpp_cv_func_$2_use=yes],
427                   [glibcpp_cv_func_$2_use=no])
428    AC_LANG_RESTORE])
429  AC_MSG_RESULT($glibcpp_cv_func_$2_use)
430  if test x$glibcpp_cv_func_$2_use = x"yes"; then
431    AC_CHECK_FUNCS($3)
432  fi
433])
434
435dnl
436dnl Check to see if the (math function) argument passed is
437dnl declared when using the c++ compiler
438dnl ASSUMES argument is a math function with TWO parameters
439dnl
440dnl GLIBCPP_CHECK_MATH_DECL_2
441AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
442  AC_MSG_CHECKING([for $1 declaration])
443  if test x${glibcpp_cv_func_$1_use+set} != xset; then
444    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
445      AC_LANG_SAVE
446      AC_LANG_CPLUSPLUS
447      AC_TRY_COMPILE([#include <math.h>], 
448                     [ $1(0, 0);], 
449                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
450      AC_LANG_RESTORE
451    ])
452  fi
453  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
454])
455
456dnl
457dnl Check to see if the (math function) argument passed is
458dnl 1) declared when using the c++ compiler
459dnl 2) has "C" linkage
460dnl
461dnl Define HAVE_CARGF etc if "cargf" is declared and links
462dnl
463dnl argument 1 is name of function to check
464dnl
465dnl ASSUMES argument is a math function with TWO parameters
466dnl
467dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
468AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
469  GLIBCPP_CHECK_MATH_DECL_2($1)
470  if test x$glibcpp_cv_func_$1_use = x"yes"; then
471    AC_CHECK_FUNCS($1)    
472  else
473    GLIBCPP_CHECK_MATH_DECL_2(_$1)
474    if test x$glibcpp_cv_func__$1_use = x"yes"; then
475      AC_CHECK_FUNCS(_$1)    
476    fi
477  fi
478])
479
480
481dnl
482dnl Check to see if the (math function) argument passed is
483dnl declared when using the c++ compiler
484dnl ASSUMES argument is a math function with THREE parameters
485dnl
486dnl GLIBCPP_CHECK_MATH_DECL_3
487AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
488  AC_MSG_CHECKING([for $1 declaration])
489  if test x${glibcpp_cv_func_$1_use+set} != xset; then
490    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
491      AC_LANG_SAVE
492      AC_LANG_CPLUSPLUS
493      AC_TRY_COMPILE([#include <math.h>], 
494                     [ $1(0, 0, 0);], 
495                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
496      AC_LANG_RESTORE
497    ])
498  fi
499  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
500])
501
502dnl
503dnl Check to see if the (math function) argument passed is
504dnl 1) declared when using the c++ compiler
505dnl 2) has "C" linkage
506dnl
507dnl Define HAVE_CARGF etc if "cargf" is declared and links
508dnl
509dnl argument 1 is name of function to check
510dnl
511dnl ASSUMES argument is a math function with THREE parameters
512dnl
513dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
514AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
515  GLIBCPP_CHECK_MATH_DECL_3($1)
516  if test x$glibcpp_cv_func_$1_use = x"yes"; then
517    AC_CHECK_FUNCS($1)    
518  else
519    GLIBCPP_CHECK_MATH_DECL_3(_$1)
520    if test x$glibcpp_cv_func__$1_use = x"yes"; then
521      AC_CHECK_FUNCS(_$1)    
522    fi
523  fi
524])
525
526
527dnl
528dnl Check to see if the (stdlib function) argument passed is
529dnl 1) declared when using the c++ compiler
530dnl 2) has "C" linkage
531dnl
532dnl argument 1 is name of function to check
533dnl
534dnl ASSUMES argument is a math function with TWO parameters
535dnl
536dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
537AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
538  AC_MSG_CHECKING([for $1 declaration])
539  if test x${glibcpp_cv_func_$1_use+set} != xset; then
540    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
541      AC_LANG_SAVE
542      AC_LANG_CPLUSPLUS
543      AC_TRY_COMPILE([#include <stdlib.h>], 
544                     [ $1(0, 0);], 
545                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
546      AC_LANG_RESTORE
547    ])
548  fi
549  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
550  if test x$glibcpp_cv_func_$1_use = x"yes"; then
551    AC_CHECK_FUNCS($1)    
552  fi
553])
554
555
556dnl
557dnl Check to see if the (stdlib function) argument passed is
558dnl 1) declared when using the c++ compiler
559dnl 2) has "C" linkage
560dnl
561dnl argument 1 is name of function to check
562dnl
563dnl ASSUMES argument is a function with THREE parameters
564dnl
565dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3
566AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3, [
567  AC_MSG_CHECKING([for $1 declaration])
568  if test x${glibcpp_cv_func_$1_use+set} != xset; then
569    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
570      AC_LANG_SAVE
571      AC_LANG_CPLUSPLUS
572      AC_TRY_COMPILE([#include <stdlib.h>], 
573                     [ $1(0, 0, 0);], 
574                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
575      AC_LANG_RESTORE
576    ])
577  fi
578  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
579  if test x$glibcpp_cv_func_$1_use = x"yes"; then
580    AC_CHECK_FUNCS($1)    
581  fi
582])
583
584
585dnl
586dnl Because the builtins are picky picky picky about the arguments they take, 
587dnl do an explict linkage tests here.
588dnl Check to see if the (math function) argument passed is
589dnl 1) declared when using the c++ compiler
590dnl 2) has "C" linkage
591dnl
592dnl Define HAVE_CARGF etc if "cargf" is declared and links
593dnl
594dnl argument 1 is name of function to check
595dnl
596dnl ASSUMES argument is a math function with ONE parameter
597dnl
598dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
599AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
600  AC_MSG_CHECKING([for $1 declaration])
601  if test x${glibcpp_cv_func_$1_use+set} != xset; then
602    AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
603      AC_LANG_SAVE
604      AC_LANG_CPLUSPLUS
605      AC_TRY_COMPILE([#include <math.h>], 
606                     [ $1(0);], 
607                     [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
608      AC_LANG_RESTORE
609    ])
610  fi
611  AC_MSG_RESULT($glibcpp_cv_func_$1_use)
612  if test x$glibcpp_cv_func_$1_use = x"yes"; then
613    AC_MSG_CHECKING([for $1 linkage])
614    if test x${glibcpp_cv_func_$1_link+set} != xset; then
615      AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
616        AC_TRY_LINK([#include <math.h>], 
617                    [ $1(0);], 
618                    [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
619      ])
620    fi
621    AC_MSG_RESULT($glibcpp_cv_func_$1_link)
622    if test x$glibcpp_cv_func_$1_link = x"yes"; then
623      ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
624      AC_DEFINE_UNQUOTED(${ac_tr_func})
625    fi
626  fi
627])
628
629
630dnl
631dnl Check to see what builtin math functions are supported
632dnl
633dnl check for __builtin_abs
634dnl check for __builtin_fabsf
635dnl check for __builtin_fabs
636dnl check for __builtin_fabl
637dnl check for __builtin_labs
638dnl check for __builtin_sqrtf
639dnl check for __builtin_sqrtl
640dnl check for __builtin_sqrt
641dnl check for __builtin_sinf
642dnl check for __builtin_sin
643dnl check for __builtin_sinl
644dnl check for __builtin_cosf
645dnl check for __builtin_cos
646dnl check for __builtin_cosl
647dnl
648dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
649AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
650  dnl Test for builtin math functions.
651  dnl These are made in gcc/c-common.c 
652  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
653  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
654  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
655  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
656  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
657
658  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
659  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
660  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
661
662  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
663  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
664  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
665
666  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
667  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
668  GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
669
670  dnl There is, without a doubt, a more elegant way to have these
671  dnl names exported so that they won't be stripped out of acconfig.h by
672  dnl autoheader. I leave this as an exercise to somebody less frustrated
673  dnl than I.... please email the libstdc++ list if you can figure out a
674  dnl more elegant approach (see autoconf/acgen.m4 and specifically
675  dnl AC_CHECK_FUNC for things to steal.)
676  dummyvar=no
677  if test x$dummyvar = x"yes"; then
678    AC_DEFINE(HAVE___BUILTIN_ABS)
679    AC_DEFINE(HAVE___BUILTIN_LABS)
680    AC_DEFINE(HAVE___BUILTIN_COS)
681    AC_DEFINE(HAVE___BUILTIN_COSF)
682    AC_DEFINE(HAVE___BUILTIN_COSL)
683    AC_DEFINE(HAVE___BUILTIN_FABS)
684    AC_DEFINE(HAVE___BUILTIN_FABSF)
685    AC_DEFINE(HAVE___BUILTIN_FABSL)
686    AC_DEFINE(HAVE___BUILTIN_SIN)
687    AC_DEFINE(HAVE___BUILTIN_SINF)
688    AC_DEFINE(HAVE___BUILTIN_SINL)
689    AC_DEFINE(HAVE___BUILTIN_SQRT)
690    AC_DEFINE(HAVE___BUILTIN_SQRTF)
691    AC_DEFINE(HAVE___BUILTIN_SQRTL)
692  fi
693])
694
695
696dnl
697dnl Check to see what the underlying c library 
698dnl These checks need to do two things: 
699dnl 1) make sure the name is declared when using the c++ compiler
700dnl 2) make sure the name has "C" linkage
701dnl This might seem like overkill but experience has shown that it's not...
702dnl
703dnl Define HAVE_STRTOLD if "strtold" is declared and links
704dnl Define HAVE_STRTOF if "strtof" is declared and links
705dnl Define HAVE_DRAND48 if "drand48" is declared and links
706dnl
707dnl GLIBCPP_CHECK_STDLIB_SUPPORT
708AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
709  ac_test_CXXFLAGS="${CXXFLAGS+set}"
710  ac_save_CXXFLAGS="$CXXFLAGS"
711  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
712
713  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
714  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
715  AC_CHECK_FUNCS(drand48)
716
717  CXXFLAGS="$ac_save_CXXFLAGS"
718])
719
720
721dnl
722dnl Check to see what the underlying c library or math library is like.
723dnl These checks need to do two things: 
724dnl 1) make sure the name is declared when using the c++ compiler
725dnl 2) make sure the name has "C" linkage
726dnl This might seem like overkill but experience has shown that it's not...
727dnl
728dnl Define HAVE_CARGF etc if "cargf" is found.
729dnl
730dnl GLIBCPP_CHECK_MATH_SUPPORT
731AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
732  ac_test_CXXFLAGS="${CXXFLAGS+set}"
733  ac_save_CXXFLAGS="$CXXFLAGS"
734  CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
735
736  dnl Check libm
737  AC_CHECK_LIB(m, sin, libm="-lm")
738  ac_save_LIBS="$LIBS"
739  LIBS="$LIBS $libm"
740
741  dnl Check to see if certain C math functions exist.
742  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
743  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
744  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
745  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
746  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
747  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
748  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
749  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
750
751  dnl Check to see if basic C math functions have float versions.
752  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
753                                          float_trig,
754                                          acosf asinf atanf \
755                                          cosf sinf tanf \
756                                          coshf sinhf tanhf)
757  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
758                                          float_round,
759                                          ceilf floorf)
760  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
761  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
762  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
763  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
764  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
765  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
766  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
767  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
768  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
769  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
770  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
771  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
772  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
773  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
774  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
775  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
776
777  dnl Check to see if basic C math functions have long double versions.
778  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
779                                          long_double_trig,
780                                          acosl asinl atanl \
781                                          cosl sinl tanl \
782                                          coshl sinhl tanhl)
783  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
784                                          long_double_round,
785                                          ceill floorl)
786  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
787  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
788  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
789  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
790  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
791  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
792  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
793  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
794  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
795  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
796  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
797  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
798  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
799  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
800  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
801  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
802  GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
803
804  dnl Some runtimes have these functions with a preceding underscore. Please
805  dnl keep this sync'd with the one above. And if you add any new symbol,
806  dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
807  dnl Check to see if certain C math functions exist.
808
809  dnl Check to see if basic C math functions have float versions.
810  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
811                                          _float_trig,
812                                          _acosf _asinf _atanf \
813                                          _cosf _sinf _tanf \
814                                          _coshf _sinhf _tanhf)
815  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
816                                          _float_round,
817                                          _ceilf _floorf)
818
819  dnl Check to see if basic C math functions have long double versions.
820  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
821                                          _long_double_trig,
822                                          _acosl _asinl _atanl \
823                                          _cosl _sinl _tanl \
824                                          _coshl _sinhl _tanhl)
825  GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
826                                          _long_double_round,
827                                          _ceill _floorl)
828
829  LIBS="$ac_save_LIBS"
830  CXXFLAGS="$ac_save_CXXFLAGS"
831])
832
833
834dnl
835dnl Check to see if there is native support for complex 
836dnl
837dnl Don't compile bits in math/* if native support exits.
838dnl
839dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
840dnl
841dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
842AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
843  dnl Check for complex versions of math functions of platform.
844  AC_CHECK_LIB(m, main)
845  AC_REPLACE_MATHFUNCS(nan copysignf)
846
847  dnl For __signbit to signbit conversions.
848  AC_CHECK_FUNCS([__signbit], , [LIBMATHOBJS="$LIBMATHOBJS signbit.lo"])
849  AC_CHECK_FUNCS([__signbitf], , [LIBMATHOBJS="$LIBMATHOBJS signbitf.lo"])
850
851  dnl Compile the long double complex functions only if the function 
852  dnl provides the non-complex long double functions that are needed.
853  dnl Currently this includes copysignl, which should be
854  dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
855  if test x$ac_cv_func_copysignl = x"yes"; then
856    AC_CHECK_FUNCS([__signbitl], , [LIBMATHOBJS="$LIBMATHOBJS signbitl.lo"])
857  fi
858
859  AC_SUBST(LIBMATHOBJS)
860])
861
862
863dnl Check to see what architecture and operating system we are compiling
864dnl for.  Also, if architecture- or OS-specific flags are required for
865dnl compilation, pick them up here.
866dnl 
867dnl GLIBCPP_CHECK_TARGET
868AC_DEFUN(GLIBCPP_CHECK_TARGET, [
869    . [$]{glibcpp_basedir}/configure.target
870    AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
871    AC_MSG_RESULT(OS config directory is $os_include_dir)
872])
873
874
875dnl
876dnl Check to see if this target can enable the wchar_t parts of libstdc++.
877dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
878dnl must have been previously checked.)
879dnl
880dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
881dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
882dnl
883dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
884AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
885
886  dnl Test wchar.h for mbstate_t, which is needed for char_traits and
887  dnl others even if wchar_t support is not on.
888  AC_MSG_CHECKING([for mbstate_t])
889  AC_TRY_COMPILE([#include <wchar.h>],
890  [mbstate_t teststate;], 
891  have_mbstate_t=yes, have_mbstate_t=no)
892  AC_MSG_RESULT($have_mbstate_t)
893  if test x"$have_mbstate_t" = xyes; then
894    AC_DEFINE(HAVE_MBSTATE_T)
895  fi
896
897  dnl Sanity check for existence of ISO C99 headers for extended encoding.
898  AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
899  AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
900  
901  dnl Only continue checking if the ISO C99 headers exist and support is on.
902  if test x"$ac_has_wchar_h" = xyes &&
903     test x"$ac_has_wctype_h" = xyes &&
904     test x"$enable_c_mbchar" != xno; then
905      
906    dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
907    dnl numeric_limits can instantiate type_traits<wchar_t>
908    AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
909    AC_TRY_COMPILE([#include <wchar.h>],
910    [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
911    has_wchar_minmax=yes, has_wchar_minmax=no)
912    AC_MSG_RESULT($has_wchar_minmax)
913    
914    dnl Test wchar.h for WEOF, which is what we use to determine whether
915    dnl to specialize for char_traits<wchar_t> or not.
916    AC_MSG_CHECKING([for WEOF])
917    AC_TRY_COMPILE([
918      #include <wchar.h>
919      #include <stddef.h>],
920    [wint_t i = WEOF;],
921    has_weof=yes, has_weof=no)
922    AC_MSG_RESULT($has_weof)
923  
924    dnl Tests for wide character functions used in char_traits<wchar_t>.
925    ac_wfuncs=yes
926    AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
927    ac_wfuncs=no)
928  
929    dnl Checks for names injected into std:: by the c_std headers.
930    AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
931    fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
932    vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
933    mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
934    wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
935    wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
936    ac_wfuncs=no)
937
938    AC_MSG_CHECKING([for ISO C99 wchar_t support])
939    if test x"$has_weof" = xyes &&
940       test x"$has_wchar_minmax" = xyes &&
941       test x"$ac_wfuncs" = xyes; then
942      ac_isoC99_wchar_t=yes
943    else
944      ac_isoC99_wchar_t=no
945    fi
946    AC_MSG_RESULT($ac_isoC99_wchar_t)
947  
948    dnl Use iconv for wchar_t to char conversions. As such, check for 
949    dnl X/Open Portability Guide, version 2 features (XPG2).
950    AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
951    AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
952
953    dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
954    AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
955    ac_save_LIBS="$LIBS"
956    LIBS="$LIBS $libiconv"
957
958    AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
959    ac_XPG2funcs=yes, ac_XPG2funcs=no)
960  
961    LIBS="$ac_save_LIBS"
962
963    AC_MSG_CHECKING([for XPG2 wchar_t support])
964    if test x"$ac_has_iconv_h" = xyes &&
965       test x"$ac_has_langinfo_h" = xyes &&
966       test x"$ac_XPG2funcs" = xyes; then
967      ac_XPG2_wchar_t=yes
968    else
969      ac_XPG2_wchar_t=no
970    fi
971    AC_MSG_RESULT($ac_XPG2_wchar_t)
972  
973    dnl At the moment, only enable wchar_t specializations if all the
974    dnl above support is present.
975    AC_MSG_CHECKING([for enabled wchar_t specializations])
976    if test x"$ac_isoC99_wchar_t" = xyes &&
977       test x"$ac_XPG2_wchar_t" = xyes; then
978      AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
979      AC_MSG_RESULT("yes")
980    else
981      AC_MSG_RESULT("no")
982    fi
983  else
984    dnl Wide characters disabled by the user. 
985    AC_MSG_WARN([wchar_t support disabled.])
986  fi
987])
988
989
990dnl
991dnl Check for special debugging mode; not for production use.
992dnl
993dnl GLIBCPP_ENABLE_DEBUG
994dnl --enable-debug sets '-ggdb3 -O0'.
995dnl --disable-debug sets '-g' and whatever optimization options the
996dnl     compiler can handle.
997dnl  +  --enable-maintainer-mode automatically defaults this to on.
998dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
999dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
1000dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1001dnl       defaults to `no'.
1002AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
1003define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
1004AC_ARG_ENABLE(debug,
1005changequote(<<, >>)dnl
1006<<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
1007changequote([, ])dnl
1008[case "${enableval}" in
1009 yes) enable_debug=yes ;;
1010 no)  enable_debug=no ;;
1011 *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1012 esac],
1013enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1014
1015dnl Option parsed, now set things appropriately
1016case "${enable_debug}" in
1017    yes) 
1018        DEBUG_FLAGS='-O0 -ggdb3'                        
1019        ;; 
1020    no)   
1021        DEBUG_FLAGS='-g'
1022        ;;
1023esac
1024AC_SUBST(DEBUG_FLAGS)
1025])
1026
1027
1028dnl
1029dnl Check for "unusual" flags to pass to the compiler while building.
1030dnl
1031dnl GLIBCPP_ENABLE_CXX_FLAGS
1032dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1033dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1034dnl     Somehow this same set of flags must be passed when [re]building
1035dnl     libgcc.
1036dnl --disable-cxx-flags passes nothing.
1037dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
1038dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
1039dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
1040dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1041dnl       If "default flags" is an empty string (or "none"), the effect is
1042dnl       the same as --disable or --enable=no.
1043AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1044define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1045AC_ARG_ENABLE(cxx-flags,
1046changequote(<<, >>)dnl
1047<<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
1048                                [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1049changequote([, ])dnl
1050[case "x$enableval" in
1051 xyes)   
1052        AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1053 xno|x)  
1054        enable_cxx_flags='' ;;
1055 *)      
1056        enable_cxx_flags="$enableval" ;;
1057 esac],
1058enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1059
1060dnl Thinko on my part during design.  This kludge is the workaround.
1061if test "$enable_cxx_flags" = "none"; then 
1062  enable_cxx_flags=''; 
1063fi
1064
1065dnl Run through flags (either default or command-line) and set anything
1066dnl extra (e.g., #defines) that must accompany particular g++ options.
1067if test -n "$enable_cxx_flags"; then
1068    for f in $enable_cxx_flags; do
1069        case "$f" in
1070            -fhonor-std)  ;;
1071            -*)  ;;
1072            *)   # and we're trying to pass /what/ exactly?
1073                 AC_MSG_ERROR([compiler flags start with a -]) ;;
1074        esac
1075    done
1076fi
1077EXTRA_CXX_FLAGS="$enable_cxx_flags"
1078AC_SUBST(EXTRA_CXX_FLAGS)
1079])
1080
1081
1082dnl
1083dnl Check for which locale library to use:  gnu or generic.
1084dnl
1085dnl GLIBCPP_ENABLE_CLOCALE
1086dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1087dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
1088dnl 
1089dnl default is generic
1090dnl
1091AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1092  AC_MSG_CHECKING([for clocale to use])
1093  AC_ARG_ENABLE(clocale,
1094  [  --enable-clocale        enable model for target locale package. 
1095  --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
1096  ], 
1097  if test x$enable_clocale = xno; then
1098     enable_clocale=no
1099  fi,
1100     enable_clocale=no)
1101
1102  enable_clocale_flag=$enable_clocale
1103
1104  dnl Probe for locale support if no specific model is specified.
1105  dnl Default to "generic"
1106  if test x$enable_clocale_flag = xno; then
1107    case x${target_os} in
1108      xlinux* | xgnu*)
1109	AC_EGREP_CPP([_GLIBCPP_ok], [
1110        #include <features.h>
1111        #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1112          _GLIBCPP_ok
1113        #endif
1114        ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1115
1116	# Test for bugs early in glibc-2.2.x series
1117  	if test x$enable_clocale_flag = xgnu; then
1118    	  AC_TRY_RUN([
1119	  #define _GNU_SOURCE 1
1120	  #include <locale.h>
1121	  int main()
1122	  {
1123  	    const char __one[] = "�uglein Augmen";
1124  	    const char __two[] = "�uglein";
1125  	    int i;
1126  	    int j;
1127  	    __locale_t	loc;
1128   	    __locale_t	loc_dup;
1129  	    loc = __newlocale(1 << LC_ALL, "de_DE", 0);
1130  	    loc_dup = __duplocale(loc);
1131  	    i = __strcoll_l(__one, __two, loc);
1132  	    j = __strcoll_l(__one, __two, loc_dup);
1133  	    return 0;
1134	  }
1135	  ], 
1136	  [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
1137	  [enable_clocale_flag=generic])
1138  	fi
1139
1140	# ... at some point put __strxfrm_l tests in as well.
1141        ;;
1142      *)
1143	enable_clocale_flag=generic
1144	;;
1145    esac
1146  fi
1147
1148  dnl Deal with gettext issues.
1149  AC_ARG_ENABLE(nls,
1150  [  --enable-nls            use Native Language Support (default)],
1151  , enable_nls=yes)
1152  USE_NLS=no
1153
1154  dnl Set configure bits for specified locale package
1155  case x${enable_clocale_flag} in
1156    xgeneric)
1157      AC_MSG_RESULT(generic)
1158
1159      CLOCALE_H=config/locale/generic/c_locale.h
1160      CLOCALE_CC=config/locale/generic/c_locale.cc
1161      CCODECVT_H=config/locale/generic/codecvt_specializations.h
1162      CCOLLATE_CC=config/locale/generic/collate_members.cc
1163      CCTYPE_CC=config/locale/generic/ctype_members.cc
1164      CMESSAGES_H=config/locale/generic/messages_members.h
1165      CMESSAGES_CC=config/locale/generic/messages_members.cc
1166      CMONEY_CC=config/locale/generic/monetary_members.cc
1167      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1168      CTIME_CC=config/locale/generic/time_members.cc
1169      ;;
1170    xgnu)
1171      AC_MSG_RESULT(gnu)
1172
1173      # Declare intention to use gettext, and add support for specific
1174      # languages.
1175      # For some reason, ALL_LINGUAS has to be before AM_GNU_GETTEXT
1176      ALL_LINGUAS="de fr"
1177
1178      # Don't call AM_GNU_GETTEXT here. Instead, assume glibc.
1179      AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1180      if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
1181	USE_NLS=yes
1182      fi
1183
1184      # Export the build objects.
1185      for ling in $ALL_LINGUAS; do \
1186        glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
1187        glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
1188      done
1189      AC_SUBST(glibcpp_MOFILES)
1190      AC_SUBST(glibcpp_POFILES)
1191
1192      CLOCALE_H=config/locale/gnu/c_locale.h
1193      CLOCALE_CC=config/locale/gnu/c_locale.cc
1194      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1195      CCOLLATE_CC=config/locale/gnu/collate_members.cc
1196      CCTYPE_CC=config/locale/gnu/ctype_members.cc
1197      CMESSAGES_H=config/locale/gnu/messages_members.h
1198      CMESSAGES_CC=config/locale/gnu/messages_members.cc
1199      CMONEY_CC=config/locale/gnu/monetary_members.cc
1200      CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1201      CTIME_CC=config/locale/gnu/time_members.cc
1202      ;;
1203    xieee_1003.1-2001)
1204      AC_MSG_RESULT(generic)
1205
1206      CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1207      CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
1208      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
1209      CCOLLATE_CC=config/locale/generic/collate_members.cc
1210      CCTYPE_CC=config/locale/generic/ctype_members.cc
1211      CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1212      CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1213      CMONEY_CC=config/locale/generic/monetary_members.cc
1214      CNUMERIC_CC=config/locale/generic/numeric_members.cc
1215      CTIME_CC=config/locale/generic/time_members.cc
1216      ;;
1217    *)
1218      echo "$enable_clocale is an unknown locale package" 1>&2
1219      exit 1
1220      ;;
1221  esac
1222
1223  # This is where the testsuite looks for locale catalogs, using the
1224  # -DLOCALEDIR define during testsuite compilation.
1225  glibcpp_localedir=${glibcpp_builddir}/po/share/locale
1226  AC_SUBST(glibcpp_localedir)
1227
1228  AC_SUBST(USE_NLS)
1229  AC_SUBST(CLOCALE_H)
1230  AC_SUBST(CCODECVT_H)
1231  AC_SUBST(CMESSAGES_H)
1232  AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1233  AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
1234  AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
1235  AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
1236  AC_LINK_FILES($CMONEY_CC, src/monetary.cc)
1237  AC_LINK_FILES($CNUMERIC_CC, src/numeric.cc)
1238  AC_LINK_FILES($CTIME_CC, src/time.cc)
1239])
1240
1241
1242dnl
1243dnl Check for which I/O library to use:  libio, or something specific.
1244dnl
1245dnl GLIBCPP_ENABLE_CSTDIO
1246dnl --enable-cstdio=libio sets config/io/c_io_libio.h and friends
1247dnl 
1248dnl default is stdio
1249dnl
1250AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1251  AC_MSG_CHECKING([for cstdio to use])
1252  AC_ARG_ENABLE(cstdio,
1253  [  --enable-cstdio         enable stdio for target io package. 
1254  --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
1255  ], 
1256  if test x$enable_cstdio = xno; then
1257     enable_cstdio=stdio
1258  fi,
1259     enable_cstdio=stdio)
1260
1261  enable_cstdio_flag=$enable_cstdio
1262
1263  dnl Check if a valid I/O package
1264  case x${enable_cstdio_flag} in
1265    xlibio)
1266      CSTDIO_H=config/io/c_io_libio.h
1267      BASIC_FILE_H=config/io/basic_file_libio.h
1268      BASIC_FILE_CC=config/io/basic_file_libio.cc
1269      AC_MSG_RESULT(libio)
1270
1271      # see if we are on a system with libio native (ie, linux)
1272      AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1273
1274      # Need to check and see what version of glibc is being used. If
1275      # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1276      # compile most of libio for linux systems.
1277      if test x$has_libio = x"yes"; then
1278        case "$target" in
1279          *-*-linux*)
1280              AC_MSG_CHECKING([for glibc version >= 2.2])
1281              AC_EGREP_CPP([ok], [
1282            #include <features.h>
1283              #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1284                    ok
1285              #endif
1286              ], glibc_satisfactory=yes, glibc_satisfactory=no)
1287              AC_MSG_RESULT($glibc_satisfactory)
1288            ;;
1289        esac
1290
1291        # XXX at the moment, admit defeat and force the recompilation
1292        # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1293        glibc_satisfactory=no        
1294
1295        if test x$glibc_satisfactory = x"yes"; then
1296           need_libio=no
1297           need_wlibio=no        
1298        else
1299           need_libio=yes
1300           # bkoz XXX need to add checks to enable this
1301           # pme XXX here's a first pass at such a check
1302           if test x$enable_c_mbchar != xno; then
1303              need_wlibio=yes
1304           else
1305              need_wlibio=no
1306           fi
1307        fi
1308
1309      else
1310         # Using libio, but <libio.h> doesn't exist on the target system. . .
1311         need_libio=yes
1312         # bkoz XXX need to add checks to enable this
1313         # pme XXX here's a first pass at such a check
1314         if test x$enable_c_mbchar != xno; then
1315             need_wlibio=yes
1316         else
1317             need_wlibio=no
1318         fi
1319      fi
1320      ;;
1321    xstdio | x | xno | xnone | xyes)
1322      # default
1323      CSTDIO_H=config/io/c_io_stdio.h
1324      BASIC_FILE_H=config/io/basic_file_stdio.h
1325      BASIC_FILE_CC=config/io/basic_file_stdio.cc
1326      AC_MSG_RESULT(stdio)
1327
1328      # We're not using stdio.
1329      need_libio=no
1330      need_wlibio=no
1331      ;;
1332    *)
1333      echo "$enable_cstdio is an unknown io package" 1>&2
1334      exit 1
1335      ;;
1336  esac
1337  AC_SUBST(CSTDIO_H)
1338  AC_SUBST(BASIC_FILE_H)
1339  AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
1340
1341  # 2000-08-04 bkoz hack
1342  CCODECVT_C=config/io/c_io_libio_codecvt.c
1343  AC_SUBST(CCODECVT_C)
1344  # 2000-08-04 bkoz hack
1345
1346  AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1347                 test "$need_libio" = yes || test "$need_wlibio" = yes)
1348  AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1349  AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1350  if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1351    libio_la=../libio/libio.la
1352  else
1353    libio_la=
1354  fi
1355  AC_SUBST(libio_la)
1356])
1357
1358
1359dnl
1360dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1361dnl We must stage the required headers so that they will be installed
1362dnl with the library (unlike libgcc, the STL implementation is provided
1363dnl solely within headers).  Since we must not inject random user-space
1364dnl macro names into user-provided C++ code, we first stage into <file>-in
1365dnl and process to <file> with an output command.  The reason for a two-
1366dnl stage process here is to correctly handle $srcdir!=$objdir without
1367dnl having to write complex code (the sed commands to clean the macro
1368dnl namespace are complex and fragile enough as it is).  We must also
1369dnl add a relative path so that -I- is supported properly.
1370dnl
1371AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1372  AC_MSG_CHECKING([for thread model used by GCC])
1373  target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1374  AC_MSG_RESULT([$target_thread_file])
1375
1376  if test $target_thread_file != single; then
1377    AC_DEFINE(HAVE_GTHR_DEFAULT)
1378    AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1379  fi
1380
1381  glibcpp_thread_h=gthr-$target_thread_file.h
1382  AC_SUBST(glibcpp_thread_h)
1383])
1384
1385
1386dnl
1387dnl Check for exception handling support.  If an explicit enable/disable
1388dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1389dnl target may or may not support call frame exceptions.
1390dnl
1391dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1392dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1393dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1394dnl
1395dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1396dnl
1397AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1398  AC_MSG_CHECKING([for exception model to use])
1399  AC_LANG_SAVE
1400  AC_LANG_CPLUSPLUS
1401  AC_ARG_ENABLE(sjlj-exceptions,
1402  [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1403  [:],
1404  [dnl Botheration.  Now we've got to detect the exception model.
1405   dnl Link tests against libgcc.a are problematic since -- at least
1406   dnl as of this writing -- we've not been given proper -L bits for
1407   dnl single-tree newlib and libgloss.
1408   dnl
1409   dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1410   dnl conftest files before we got a change to grep them first.
1411   cat > conftest.$ac_ext << EOF
1412[#]line __oline__ "configure"
1413struct S { ~S(); };
1414void bar();
1415void foo()
1416{
1417  S s;
1418  bar();
1419}
1420EOF
1421   old_CXXFLAGS="$CXXFLAGS"  
1422   CXXFLAGS="-S -fexceptions"
1423   if AC_TRY_EVAL(ac_compile); then
1424     if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1425       enable_sjlj_exceptions=yes
1426     elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1427       enable_sjlj_exceptions=no
1428     fi
1429   fi
1430   CXXFLAGS="$old_CXXFLAGS"
1431   rm -f conftest*])
1432   if test x$enable_sjlj_exceptions = xyes; then
1433     AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1434        [Define if the compiler is configured for setjmp/longjmp exceptions.])
1435     ac_exception_model_name=sjlj
1436   elif test x$enable_sjlj_exceptions = xno; then
1437     ac_exception_model_name="call frame"
1438   else
1439     AC_MSG_ERROR([unable to detect exception model])
1440   fi
1441   AC_LANG_RESTORE
1442   AC_MSG_RESULT($ac_exception_model_name)
1443])
1444
1445
1446dnl
1447dnl Check for libunwind exception handling support. If enabled then
1448dnl we assume that the _Unwind_* functions that make up the Unwind ABI
1449dnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
1450dnl libunwind instead of libgcc and that libstdc++ has a dependency
1451dnl on libunwind as well as libgcc.
1452dnl
1453dnl GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
1454dnl --enable-libunwind-exceptions forces the use of libunwind.
1455dnl --disable-libunwind-exceptions assumes there is no libunwind.
1456dnl
1457dnl Define _GLIBCPP_LIBUNWIND_EXCEPTIONS if requested.
1458dnl
1459AC_DEFUN(GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS, [
1460  AC_MSG_CHECKING([for use of libunwind])
1461  AC_ARG_ENABLE(libunwind-exceptions,
1462  [  --enable-libunwind-exceptions  force use of libunwind for exceptions],
1463  use_libunwind_exceptions=$enableval,
1464  use_libunwind_exceptions=no)
1465  AC_MSG_RESULT($use_libunwind_exceptions)
1466  dnl Option parsed, now set things appropriately
1467  if test x"$use_libunwind_exceptions" = xyes; then
1468    LIBUNWIND_FLAG="-lunwind"
1469  else
1470    LIBUNWIND_FLAG=""
1471  fi
1472  AC_SUBST(LIBUNWIND_FLAG)
1473])
1474
1475dnl
1476dnl Check for ISO/IEC 9899:1999 "C99" support.
1477dnl
1478dnl GLIBCPP_ENABLE_C99
1479dnl --enable-c99 defines _GLIBCPP_USE_C99
1480dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1481dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1482dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1483dnl       defaults to `no'.
1484dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1485dnl
1486dnl GLIBCPP_ENABLE_C99
1487AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1488  define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1489
1490  AC_ARG_ENABLE(c99,
1491  changequote(<<, >>)dnl
1492  <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1493  changequote([, ])dnl
1494  [case "$enableval" in
1495   yes) enable_c99=yes ;;
1496   no)  enable_c99=no ;;
1497   *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1498   esac],
1499  enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1500 
1501  AC_LANG_SAVE
1502  AC_LANG_CPLUSPLUS
1503
1504  # Check for the existence of <math.h> functions used if C99 is enabled.
1505  ac_c99_math=yes;
1506  AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1507  AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1508  AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1509  AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1510  AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1511  AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1512  AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1513  AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1514  AC_TRY_COMPILE([#include <math.h>],
1515                 [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1516  AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1517  AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1518  AC_TRY_COMPILE([#include <math.h>],
1519	         [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1520  AC_TRY_COMPILE([#include <math.h>],
1521	         [isunordered(0.0,0.0);],, [ac_c99_math=no])
1522  AC_MSG_RESULT($ac_c99_math)
1523
1524  # Check for the existence in <stdio.h> of vscanf, et. al.
1525  ac_c99_stdio=yes;
1526  AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1527  AC_TRY_COMPILE([#include <stdio.h>],
1528		 [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
1529  AC_TRY_COMPILE([#include <stdio.h>
1530		  #include <stdarg.h>
1531		  void foo(char* fmt, ...)
1532		  {va_list args; va_start(args, fmt);
1533	          vfscanf(stderr, "%i", args);}],
1534	          [],, [ac_c99_stdio=no])
1535  AC_TRY_COMPILE([#include <stdio.h>
1536		  #include <stdarg.h>
1537		  void foo(char* fmt, ...)
1538		  {va_list args; va_start(args, fmt);
1539	          vscanf("%i", args);}],
1540	          [],, [ac_c99_stdio=no])
1541  AC_TRY_COMPILE([#include <stdio.h>
1542		  #include <stdarg.h>
1543		  void foo(char* fmt, ...)
1544		  {va_list args; va_start(args, fmt);
1545	          vsnprintf(fmt, 0, "%i", args);}],
1546	          [],, [ac_c99_stdio=no])
1547  AC_TRY_COMPILE([#include <stdio.h>
1548		  #include <stdarg.h>
1549		  void foo(char* fmt, ...)
1550		  {va_list args; va_start(args, fmt);
1551	          vsscanf(fmt, "%i", args);}],
1552	          [],, [ac_c99_stdio=no])
1553  AC_MSG_RESULT($ac_c99_stdio)
1554
1555  # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1556  ac_c99_stdlib=yes;
1557  AC_MSG_CHECKING([for lldiv_t declaration])
1558  AC_CACHE_VAL(ac_c99_lldiv_t, [
1559  AC_TRY_COMPILE([#include <stdlib.h>], 
1560                   [ lldiv_t mydivt;], 
1561                   [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1562  ])
1563  AC_MSG_RESULT($ac_c99_lldiv_t)
1564
1565  AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1566  AC_TRY_COMPILE([#include <stdlib.h>],
1567	         [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1568  AC_TRY_COMPILE([#include <stdlib.h>],
1569	         [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1570  AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1571  AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1572  AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1573  AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1574  if test x"$ac_c99_lldiv_t" = x"no"; then
1575    ac_c99_stdlib=no; 
1576  fi; 
1577  AC_MSG_RESULT($ac_c99_stdlib)
1578
1579  # Check for the existence of <wchar.h> functions used if C99 is enabled.
1580  # XXX the wchar.h checks should be rolled into the general C99 bits.
1581  ac_c99_wchar=yes;
1582  AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1583  AC_TRY_COMPILE([#include <wchar.h>], 
1584	         [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1585  AC_TRY_COMPILE([#include <wchar.h>], 
1586	         [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1587  AC_TRY_COMPILE([#include <wchar.h>], 
1588	         [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1589  AC_MSG_RESULT($ac_c99_wchar)
1590
1591  AC_MSG_CHECKING([for enabled ISO C99 support])
1592  if test x"$ac_c99_math" = x"no" ||
1593     test x"$ac_c99_stdio" = x"no" ||
1594     test x"$ac_c99_stdlib" = x"no" ||
1595     test x"$ac_c99_wchar" = x"no"; then
1596    enable_c99=no; 
1597  fi; 
1598  AC_MSG_RESULT($enable_c99)
1599
1600  # Option parsed, now set things appropriately
1601  if test x"$enable_c99" = x"yes"; then
1602    AC_DEFINE(_GLIBCPP_USE_C99)
1603  fi
1604
1605  AC_LANG_RESTORE
1606])
1607
1608
1609dnl
1610dnl Check for template specializations for the 'long long' type extension.
1611dnl The result determines only whether 'long long' I/O is enabled; things
1612dnl like numeric_limits<> specializations are always available.
1613dnl
1614dnl GLIBCPP_ENABLE_LONG_LONG
1615dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1616dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1617dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1618dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1619dnl       defaults to `no'.
1620dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1621dnl
1622dnl GLIBCPP_ENABLE_LONG_LONG
1623AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1624  define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1625
1626  AC_ARG_ENABLE(long-long,
1627  changequote(<<, >>)dnl
1628  <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1629  changequote([, ])dnl
1630  [case "$enableval" in
1631   yes) enable_long_long=yes ;;
1632   no)  enable_long_long=no ;;
1633   *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1634   esac],
1635  enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1636
1637  AC_LANG_SAVE
1638  AC_LANG_CPLUSPLUS
1639
1640  AC_MSG_CHECKING([for enabled long long I/O support])
1641  # iostreams require strtoll, strtoull to compile
1642  AC_TRY_COMPILE([#include <stdlib.h>],
1643                 [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
1644  AC_TRY_COMPILE([#include <stdlib.h>],
1645                 [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
1646
1647  # Option parsed, now set things appropriately
1648  if test x"$enable_long_long" = xyes; then
1649    AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1650  fi
1651  AC_MSG_RESULT($enable_long_long)
1652
1653  AC_LANG_RESTORE
1654])
1655
1656
1657dnl
1658dnl Check for what kind of C headers to use.
1659dnl
1660dnl GLIBCPP_ENABLE_CHEADERS
1661dnl --enable-cheaders= [does stuff].
1662dnl --disable-cheaders [does not do anything, really].
1663dnl  +  This will eventually need to be 'c_shadow' by default.
1664dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1665dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1666dnl       If ommitted, it defaults to `c_std'.
1667AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1668define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1669AC_MSG_CHECKING([for c header strategy to use])
1670AC_ARG_ENABLE(cheaders,
1671changequote(<<, >>)dnl
1672<<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1673changequote([, ])
1674  [case "$enableval" in
1675   c) 
1676        enable_cheaders=c 
1677        ;;
1678   c_std)  
1679        enable_cheaders=c_std 
1680        ;;
1681   c_shadow)  
1682        enable_cheaders=c_shadow 
1683        ;;
1684   *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1685        ;;
1686  esac],
1687  enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1688  AC_MSG_RESULT($enable_cheaders)
1689
1690  dnl Option parsed, now set things appropriately
1691  case "$enable_cheaders" in
1692    c_shadow) 
1693        CSHADOW_FLAGS="-fno-builtin"
1694        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
1695        ;;
1696    c_std)   
1697        CSHADOW_FLAGS=""
1698        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1699        ;;
1700    c)   
1701        CSHADOW_FLAGS=""
1702        C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1703        ;;
1704  esac
1705
1706  AC_SUBST(CSHADOW_FLAGS)
1707  AC_SUBST(C_INCLUDE_DIR)
1708  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C, test "$enable_cheaders" = c)
1709  AM_CONDITIONAL(GLIBCPP_C_HEADERS_C_STD, test "$enable_cheaders" = c_std)
1710])
1711
1712
1713dnl
1714dnl Check for wide character support.  Has the same effect as the option
1715dnl in gcc's configure, but in a form that autoconf can mess with.
1716dnl
1717dnl GLIBCPP_ENABLE_C_MBCHAR
1718dnl --enable-c-mbchar requests all the wchar_t stuff.
1719dnl --disable-c-mbchar doesn't.
1720dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1721dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1722dnl       defaults to `no'.
1723AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1724define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1725AC_ARG_ENABLE(c-mbchar,
1726changequote(<<, >>)dnl
1727<<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1728changequote([, ])dnl
1729[case "$enableval" in
1730 yes) enable_c_mbchar=yes ;;
1731 no)  enable_c_mbchar=no ;;
1732 *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1733 esac],
1734enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1735dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1736])
1737
1738
1739dnl
1740dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1741dnl
1742dnl TOPLEVEL_INCLUDES
1743dnl LIBMATH_INCLUDES
1744dnl LIBSUPCXX_INCLUDES
1745dnl LIBIO_INCLUDES
1746dnl CSHADOW_INCLUDES
1747dnl
1748dnl GLIBCPP_EXPORT_INCLUDES
1749AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1750  # Root level of the build directory include sources.
1751  GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1752
1753  # Passed down for canadian crosses.
1754  if test x"$CANADIAN" = xyes; then
1755    TOPLEVEL_INCLUDES='-I$(includedir)'
1756  fi
1757
1758  LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1759
1760  LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1761
1762  if test x"$need_libio" = xyes; then
1763    LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1764    AC_SUBST(LIBIO_INCLUDES)
1765  fi
1766
1767  # Now, export this to all the little Makefiles....
1768  AC_SUBST(GLIBCPP_INCLUDES)
1769  AC_SUBST(TOPLEVEL_INCLUDES)
1770  AC_SUBST(LIBMATH_INCLUDES)
1771  AC_SUBST(LIBSUPCXX_INCLUDES)
1772])
1773
1774
1775dnl
1776dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1777dnl
1778AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1779  # Optimization flags that are probably a good idea for thrill-seekers. Just
1780  # uncomment the lines below and make, everything else is ready to go... 
1781  # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1782  OPTIMIZE_CXXFLAGS=
1783  AC_SUBST(OPTIMIZE_CXXFLAGS)
1784
1785  WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1786  AC_SUBST(WARN_FLAGS)
1787])
1788
1789dnl
1790dnl  GLIBCPP_EXPORT_INSTALL_INFO
1791dnl  calculates gxx_install_dir
1792dnl  exports glibcpp_toolexecdir
1793dnl  exports glibcpp_toolexeclibdir
1794dnl  exports glibcpp_prefixdir
1795dnl
1796dnl Assumes cross_compiling bits already done, and with_cross_host in
1797dnl particular
1798dnl
1799dnl GLIBCPP_EXPORT_INSTALL_INFO
1800AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1801# Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
1802# exported correctly in GLIBCPP_CONFIGURE.
1803glibcpp_toolexecdir=no
1804glibcpp_toolexeclibdir=no
1805glibcpp_prefixdir=${prefix}
1806
1807AC_MSG_CHECKING([for interface version number])
1808libstdcxx_interface=$INTERFACE
1809AC_MSG_RESULT($libstdcxx_interface)
1810
1811# Process the option --with-gxx-include-dir=<path to include-files directory>
1812AC_MSG_CHECKING([for --with-gxx-include-dir])
1813AC_ARG_WITH(gxx-include-dir,
1814[  --with-gxx-include-dir  the installation directory for include files],
1815[case "${withval}" in
1816  yes)
1817    AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1818    gxx_include_dir=no
1819    ;;
1820  no)
1821    gxx_include_dir=no
1822    ;;
1823  *)
1824    gxx_include_dir=${withval}
1825    ;;
1826esac], [gxx_include_dir=no])
1827AC_MSG_RESULT($gxx_include_dir)
1828
1829# Process the option "--enable-version-specific-runtime-libs"
1830AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1831AC_ARG_ENABLE(version-specific-runtime-libs,
1832[  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1833[case "$enableval" in
1834 yes) version_specific_libs=yes ;;
1835 no)  version_specific_libs=no ;;
1836 *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1837 esac],
1838version_specific_libs=no)dnl
1839# Option set, now we can test it.
1840AC_MSG_RESULT($version_specific_libs)
1841
1842if test $version_specific_libs = yes; then
1843  # Need the gcc compiler version to know where to install libraries
1844  # and header files if --enable-version-specific-runtime-libs option
1845  # is selected.
1846  changequote(,)dnl
1847  gcc_version_trigger=${srcdir}/../gcc/version.c
1848  gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
1849  gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
1850  if test x"$gxx_include_dir" = x"no"; then
1851    gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/g++
1852  fi
1853  glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1854  glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1855  changequote([,])dnl
1856fi
1857
1858# Default case for install directory for include files.
1859if test $version_specific_libs = no &&
1860   test $gxx_include_dir = no; then
1861  gxx_include_dir='$(prefix)'/include/g++-${libstdcxx_interface}
1862fi
1863
1864# Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
1865# Install a library built with a cross compiler in tooldir, not libdir.
1866if test x"$glibcpp_toolexecdir" = x"no"; then 
1867  if test -n "$with_cross_host" &&
1868     test x"$with_cross_host" != x"no"; then
1869    glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1870    glibcpp_toolexeclibdir='$(toolexecdir)/lib$(MULTISUBDIR)'
1871  else
1872    glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1873    glibcpp_toolexeclibdir='$(libdir)$(MULTISUBDIR)'
1874  fi
1875fi
1876
1877AC_MSG_CHECKING([for install location])
1878AC_MSG_RESULT($gxx_include_dir)
1879
1880AC_SUBST(glibcpp_prefixdir)
1881AC_SUBST(gxx_include_dir)
1882AC_SUBST(glibcpp_toolexecdir)
1883AC_SUBST(glibcpp_toolexeclibdir)
1884])
1885
1886
1887# Check for functions in math library.
1888# Ulrich Drepper <drepper@cygnus.com>, 1998.
1889#
1890# This file can be copied and used freely without restrictions.  It can
1891# be used in projects which are not available under the GNU Public License
1892# but which still want to provide support for the GNU gettext functionality.
1893# Please note that the actual code is *not* freely available.
1894
1895# serial 1
1896
1897dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1898AC_DEFUN(AC_REPLACE_MATHFUNCS,
1899[AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])])
1900
1901
1902dnl This macro searches for a GNU version of make.  If a match is found, the
1903dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1904dnl set to "#". This is useful for  including a special features in a Makefile,
1905dnl which cannot be handled by other versions of make.  The variable
1906dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1907dnl the empty string otherwise.
1908dnl
1909dnl Here is an example of its use:
1910dnl
1911dnl Makefile.in might contain:
1912dnl
1913dnl     # A failsafe way of putting a dependency rule into a makefile
1914dnl     $(DEPEND):
1915dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1916dnl
1917dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1918dnl     @ifGNUmake@ include $(DEPEND)
1919dnl     @ifGNUmake@ endif
1920dnl
1921dnl Then configure.in would normally contain:
1922dnl
1923dnl     CHECK_GNU_MAKE()
1924dnl     AC_OUTPUT(Makefile)
1925dnl
1926dnl Then perhaps to cause gnu make to override any other make, we could do
1927dnl something like this (note that GNU make always looks for GNUmakefile first):
1928dnl
1929dnl     if  ! test x$_cv_gnu_make_command = x ; then
1930dnl             mv Makefile GNUmakefile
1931dnl             echo .DEFAULT: > Makefile ;
1932dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1933dnl     fi
1934dnl
1935dnl Then, if any (well almost any) other make is called, and GNU make also
1936dnl exists, then the other make wraps the GNU make.
1937dnl
1938dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1939dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1940dnl
1941dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1942dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1943dnl #### conditional's subshell (" --version" is not a command), using a
1944dnl #### different option to grep(1).
1945dnl #### -pme
1946dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
1947dnl #### ${MAKE:-make}).
1948dnl #### -msokolov
1949AC_DEFUN(
1950  GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1951          _cv_gnu_make_command='' ;
1952dnl Search all the common names for GNU make
1953          for a in "${MAKE-make}" make gmake gnumake ; do
1954                  if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
1955                  then
1956                          _cv_gnu_make_command=$a ;
1957                          break;
1958                  fi
1959          done ;
1960  ) ;
1961dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1962dnl string, '#' otherwise
1963  if test  "x$_cv_gnu_make_command" != "x"  ; then
1964          ifGNUmake='' ;
1965  else
1966          ifGNUmake='#' ;
1967  fi
1968  AC_SUBST(ifGNUmake)
1969])
1970
1971
1972dnl Check for headers for, and arguments to, the setrlimit() function.
1973dnl Used only in testsuite_hooks.h.
1974AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
1975  AC_TRY_COMPILE([#include <sys/resource.h>
1976                  #include <unistd.h>
1977                 ], [ int f = RLIMIT_$1 ; ],
1978                 [glibcpp_mresult=1], [glibcpp_mresult=0])
1979  AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
1980                     [Only used in build directory testsuite_hooks.h.])
1981])
1982AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
1983  setrlimit_have_headers=yes
1984  AC_CHECK_HEADERS(sys/resource.h unistd.h,
1985                   [],
1986                   setrlimit_have_headers=no)
1987  # If don't have the headers, then we can't run the tests now, and we
1988  # won't be seeing any of these during testsuite compilation.
1989  if test $setrlimit_have_headers = yes; then
1990    # Can't do these in a loop, else the resulting syntax is wrong.
1991    GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
1992    GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
1993    GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
1994    GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
1995
1996    # Check for rlimit, setrlimit.
1997    AC_CACHE_VAL(ac_setrlimit, [
1998      AC_TRY_COMPILE([#include <sys/resource.h>
1999		      #include <unistd.h>
2000		     ], 
2001                     [ struct rlimit r; setrlimit(0, &r);], 
2002                     [ac_setrlimit=yes], [ac_setrlimit=no])
2003    ])
2004  fi
2005
2006  AC_MSG_CHECKING([for testsuite memory limit support])
2007  if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
2008    ac_mem_limits=yes
2009    AC_DEFINE(_GLIBCPP_MEM_LIMITS)
2010  else
2011    ac_mem_limits=no
2012  fi
2013  AC_MSG_RESULT($ac_mem_limits)
2014])
2015
2016
2017dnl
2018dnl Does any necessary configuration of the testsuite directory.  Generates
2019dnl the testsuite_hooks.h header.
2020dnl
2021dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
2022AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
2023  GLIBCPP_CHECK_SETRLIMIT
2024
2025  # Look for setenv, so that extended locale tests can be performed.
2026  GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
2027])
2028
2029
2030sinclude(../libtool.m4)
2031dnl The lines below arrange for aclocal not to bring an installed
2032dnl libtool.m4 into aclocal.m4, while still arranging for automake to
2033dnl add a definition of LIBTOOL to Makefile.in.
2034ifelse(,,,[AC_SUBST(LIBTOOL)
2035AC_DEFUN([AM_PROG_LIBTOOL])
2036AC_DEFUN([AC_LIBTOOL_DLOPEN])
2037AC_DEFUN([AC_PROG_LD])
2038])
2039
2040
2041# Check whether LC_MESSAGES is available in <locale.h>.
2042# Ulrich Drepper <drepper@cygnus.com>, 1995.
2043#
2044# This file file be copied and used freely without restrictions.  It can
2045# be used in projects which are not available under the GNU Public License
2046# but which still want to provide support for the GNU gettext functionality.
2047# Please note that the actual code is *not* freely available.
2048
2049# serial 1
2050
2051AC_DEFUN(AC_LC_MESSAGES, [
2052  AC_CHECK_HEADER(locale.h, [
2053    AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
2054      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2055       ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
2056    if test $ac_cv_val_LC_MESSAGES = yes; then
2057      AC_DEFINE(HAVE_LC_MESSAGES)
2058    fi
2059  ])
2060])
2061
2062
2063dnl
2064dnl Check for whether the Boost-derived checks should be turned on.
2065dnl
2066dnl GLIBCPP_ENABLE_CONCEPT_CHECKS
2067dnl --enable-concept-checks turns them on.
2068dnl --disable-concept-checks leaves them off.
2069dnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
2070dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2071dnl       defaults to `no'.
2072AC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
2073define([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
2074AC_ARG_ENABLE(concept-checks,
2075changequote(<<, >>)dnl
2076<<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
2077changequote([, ])dnl
2078[case "$enableval" in
2079 yes) enable_concept_checks=yes ;;
2080 no)  enable_concept_checks=no ;;
2081 *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
2082 esac],
2083enable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
2084dnl Option parsed, now set things appropriately
2085if test x"$enable_concept_checks" = xyes; then
2086  AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
2087fi
2088])
2089
2090
2091dnl
2092dnl Add version tags to symbols in shared library (or not), additionally
2093dnl marking other symbols as private/local (or not).
2094dnl
2095dnl GLIBCPP_ENABLE_SYMVERS
2096dnl --enable-symvers=style adds a version script to the linker call when
2097dnl       creating the shared library.  The choice of version script is
2098dnl       controlled by 'style'.
2099dnl --disable-symvers does not.
2100dnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
2101dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2102dnl       defaults to `no'.  Passing `yes' tries to choose a default style
2103dnl       based on linker characteristics.  Passing 'no' disables versioning.
2104AC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
2105define([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
2106AC_ARG_ENABLE(symvers,
2107changequote(<<, >>)dnl
2108<<  --enable-symvers=style  enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
2109changequote([, ])dnl
2110[case "$enableval" in
2111 yes) enable_symvers=yes ;;
2112 no)  enable_symvers=no ;;
2113 # other names here, just as sanity checks
2114 #gnu|sun|etcetera) enable_symvers=$enableval ;;
2115 gnu) enable_symvers=$enableval ;;
2116 *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
2117 esac],
2118enable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
2119
2120# If we never went through the GLIBCPP_CHECK_LINKER_FEATURES macro, then we
2121# don't know enough about $LD to do tricks... 
2122if test x$enable_shared = xno || 
2123	test x$LD = x || 
2124	test x$glibcpp_gnu_ld_version = x; then
2125  enable_symvers=no
2126fi
2127
2128# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2129AC_MSG_CHECKING([for shared libgcc])
2130ac_save_CFLAGS="$CFLAGS"
2131CFLAGS=' -lgcc_s'
2132AC_TRY_LINK( , [return 0], glibcpp_shared_libgcc=yes, glibcpp_shared_libgcc=no)
2133CFLAGS="$ac_save_CFLAGS"
2134AC_MSG_RESULT($glibcpp_shared_libgcc)
2135
2136# For GNU ld, we need at least this version.  It's 2.12 in the same format
2137# as the tested-for version.  See GLIBCPP_CHECK_LINKER_FEATURES for more.
2138glibcpp_min_gnu_ld_version=21200
2139
2140# Check to see if unspecified "yes" value can win, given results
2141# above.  
2142if test $enable_symvers = yes ; then
2143  if test $with_gnu_ld = yes &&
2144    test $glibcpp_shared_libgcc = yes ;
2145  then
2146    if test $glibcpp_gnu_ld_version -ge $glibcpp_min_gnu_ld_version ; then
2147        enable_symvers=gnu
2148    else
2149      ac_test_CFLAGS="${CFLAGS+set}"
2150      ac_save_CFLAGS="$CFLAGS"
2151      CFLAGS='-shared -Wl,--version-script,conftest.map'
2152      enable_symvers=no
2153      changequote(,)
2154      echo 'FOO { global: f[a-z]o; local: *; };' > conftest.map
2155      changequote([,])
2156      AC_TRY_LINK([int foo;],, enable_symvers=gnu)
2157      if test "$ac_test_CFLAGS" = set; then
2158	CFLAGS="$ac_save_CFLAGS"
2159      else
2160	# this is the suspicious part
2161	CFLAGS=''
2162      fi
2163      rm -f conftest.map
2164    fi
2165  else
2166    # just fail for now
2167    enable_symvers=no
2168  fi
2169fi
2170
2171dnl Everything parsed; figure out what file to use.
2172case $enable_symvers in
2173  no)
2174      LINKER_MAP=config/linker-map.dummy
2175      ;;
2176  gnu)
2177      LINKER_MAP=config/linker-map.gnu
2178      ;;
2179esac
2180
2181AC_LINK_FILES($LINKER_MAP, src/linker.map)
2182AM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
2183AC_MSG_CHECKING([versioning on shared library symbols])
2184AC_MSG_RESULT($enable_symvers)
2185])
2186
2187