OSDN Git Service

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