OSDN Git Service

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