OSDN Git Service

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