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