OSDN Git Service

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