OSDN Git Service

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