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