OSDN Git Service

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