OSDN Git Service

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