OSDN Git Service

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