OSDN Git Service

* c-common.c (decl_attributes): Differentiate between
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
1 dnl
2 dnl Initialize configure bits.
3 dnl
4 dnl Define OPTLEVEL='-O2' if new inlining code present.
5 dnl
6 dnl GLIBCPP_CONFIGURE
7 AC_DEFUN(GLIBCPP_CONFIGURE, [
8   dnl Default to --enable-multilib
9   AC_ARG_ENABLE(multilib,
10   [  --enable-multilib       build hella library versions (default)],
11   [case "${enableval}" in
12     yes) multilib=yes ;;
13     no)  multilib=no ;;
14     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
15    esac], [multilib=yes])dnl
16
17   dnl We may get other options which we dont document:
18   dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
19   if test "[$]{srcdir}" = "."; then
20     if test "[$]{with_target_subdir}" != "."; then
21       glibcpp_basedir="[$]{srcdir}/[$]{with_multisrctop}../$1"
22     else
23       glibcpp_basedir="[$]{srcdir}/[$]{with_multisrctop}$1"
24     fi
25   else
26     glibcpp_basedir="[$]{srcdir}/$1"
27   fi
28   AC_SUBST(glibcpp_basedir)
29
30   AC_CANONICAL_HOST
31
32   AM_INIT_AUTOMAKE(libstdc++, 2.90.8)
33
34 # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
35 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
36 # are probably using a cross compiler, which will not be able to fully
37 # link an executable.  This should really be fixed in autoconf
38 # itself.
39
40 AC_DEFUN(LIB_AC_PROG_CC,
41 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
42 dnl Fool anybody using AC_PROG_CC.
43 AC_PROVIDE([AC_PROG_CC])
44 AC_CHECK_PROG(CC, gcc, gcc)
45 if test -z "$CC"; then
46   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
47   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
48 fi
49
50 AC_PROG_CC_GNU
51
52 if test $ac_cv_prog_gcc = yes; then
53   GCC=yes
54 dnl Check whether -g works, even if CFLAGS is set, in case the package
55 dnl plays around with CFLAGS (such as to build both debugging and
56 dnl normal versions of a library), tasteless as that idea is.
57   ac_test_CFLAGS="${CFLAGS+set}"
58   ac_save_CFLAGS="$CFLAGS"
59   CFLAGS=
60   AC_PROG_CC_G
61   if test "$ac_test_CFLAGS" = set; then
62     CFLAGS="$ac_save_CFLAGS"
63   elif test $ac_cv_prog_cc_g = yes; then
64     CFLAGS="-g -O2"
65   else
66     CFLAGS="-O2"
67   fi
68 else
69   GCC=
70   test "${CFLAGS+set}" = set || CFLAGS="-g"
71 fi
72 ])
73
74 LIB_AC_PROG_CC
75
76 # Likewise for AC_PROG_CXX.
77 AC_DEFUN(LIB_AC_PROG_CXX,
78 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
79 dnl Fool anybody using AC_PROG_CXX.
80 AC_PROVIDE([AC_PROG_CXX])
81 AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
82 test -z "$CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
83
84 AC_PROG_CXX_GNU
85
86 if test $ac_cv_prog_gxx = yes; then
87   GXX=yes
88 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
89 dnl plays around with CXXFLAGS (such as to build both debugging and
90 dnl normal versions of a library), tasteless as that idea is.
91   ac_test_CXXFLAGS="${CXXFLAGS+set}"
92   ac_save_CXXFLAGS="$CXXFLAGS"
93   CXXFLAGS=
94   AC_PROG_CXX_G
95   if test "$ac_test_CXXFLAGS" = set; then
96     CXXFLAGS="$ac_save_CXXFLAGS"
97   elif test $ac_cv_prog_cxx_g = yes; then
98     CXXFLAGS="-g -O2"
99   else
100     CXXFLAGS="-O2"
101   fi
102 else
103   GXX=
104   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
105 fi
106 ])
107
108 LIB_AC_PROG_CXX
109
110 # AC_CHECK_TOOL does AC_REQUIRE (AC_CANONICAL_BUILD).  If we dont
111 # run it explicitly here, it will be run implicitly before
112 # LIBGCJ_CONFIGURE, which doesn't work because that means that it will
113 # be run before AC_CANONICAL_HOST.
114 AC_CANONICAL_BUILD
115
116 AC_CHECK_TOOL(AS, as)
117 AC_CHECK_TOOL(AR, ar)
118 AC_CHECK_TOOL(RANLIB, ranlib, :)
119
120 AC_PROG_INSTALL
121
122 AM_MAINTAINER_MODE
123
124 # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
125 # at least currently, we never actually build a program, so we never
126 # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
127 # fails, because we are probably configuring with a cross compiler
128 # which cant create executables.  So we include AC_EXEEXT to keep
129 # automake happy, but we dont execute it, since we dont care about
130 # the result.
131 if false; then
132   AC_EXEEXT
133 fi
134
135 # configure.host sets the following important variables
136 #       glibcpp_cflags    - host specific C compiler flags
137 #       glibcpp_cxxflags  - host specific C++ compiler flags
138
139 glibcpp_cflags=
140 glibcpp_cxxflags=
141
142 . [$]{glibcpp_basedir}/configure.host
143
144 case [$]{glibcpp_basedir} in
145 /* | [A-Za-z]:[/\\]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
146 *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
147 esac
148
149 GLIBCPP_CFLAGS="[$]{glibcpp_cflags}"
150 GLIBCPP_CXXFLAGS="[$]{glibcpp_cxxflags}"
151 AC_SUBST(GLIBCPP_CFLAGS)
152 AC_SUBST(GLIBCPP_CXXFLAGS)
153 ])
154
155
156 dnl
157 dnl Check to see if g++ can compile this library, and if so, if any version-
158 dnl specific precautions need to be taken. 
159 dnl 
160 dnl GLIBCPP_CHECK_COMPILER_VERSION
161 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
162   # Sanity check that g++ is capable of dealing with v-3.
163   AC_MSG_CHECKING([for g++ that will successfully compile this code])
164   AC_EGREP_CPP([ok], [
165   #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 
166     ok
167   #endif
168   ], gpp_satisfactory=yes, AC_MSG_ERROR("please upgrade to gcc-2.95 or above"))
169   AC_MSG_RESULT($gpp_satisfactory)
170 ])
171
172
173 dnl
174 dnl Test for newer compiler features, or features that are present in newer
175 dnl compiler version but not older compiler versions should be placed
176 dnl here.
177 dnl
178 dnl Define WFMT_FLAGS='-fdiagnostics-show-location=once' if possible
179 dnl 
180 dnl Define WERROR='-Werror' if possible; g++'s that lack the new inlining
181 dnl code or the new system_header pragma will die.  
182 dnl
183 dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
184 dnl compiler supports it.  
185 dnl GLIBCPP_CHECK_COMPILER_FEATURES
186 AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
187   # All these tests are for C++; save the language and the compiler flags.
188   # The CXXFLAGS thing is suspicious, but based on similar bits 
189   # found in GLIBCPP_CONFIGURE.
190   AC_LANG_SAVE
191   AC_LANG_CPLUSPLUS
192   ac_test_CXXFLAGS="${CXXFLAGS+set}"
193   ac_save_CXXFLAGS="$CXXFLAGS"
194   WERROR='-Werror'
195
196   # Check for pragma system_header.
197   AC_MSG_CHECKING([for g++ that supports pragma system_header])
198   CXXFLAGS='-Wunknown-pragmas -Werror'
199   AC_TRY_COMPILE([#pragma system_header], [int foo;
200   ], [ac_newpragma=yes], [ac_newpragma=no])
201   if test "$ac_test_CXXFLAGS" = set; then
202     CXXFLAGS="$ac_save_CXXFLAGS"
203   else
204     # this is the suspicious part
205     CXXFLAGS=''
206   fi
207   if test "$ac_newpragma" = "no"; then
208     WERROR="$WERROR -Wno-unknown-pragmas"
209   fi
210   AC_MSG_RESULT($ac_newpragma)
211
212   # Check for more sophisticated diagnostic control.
213   AC_MSG_CHECKING([for g++ that supports -fdiagnostics-show-location=once])
214   CXXFLAGS='-fdiagnostics-show-location=once'
215   AC_TRY_COMPILE(, [int foo;
216   ], [ac_gabydiags=yes], [ac_gabydiags=no])
217   if test "$ac_test_CXXFLAGS" = set; then
218     CXXFLAGS="$ac_save_CXXFLAGS"
219   else
220     # this is the suspicious part
221     CXXFLAGS=''
222   fi
223   if test "$ac_gabydiags" = "yes"; then
224     WFMT_FLAGS='-fdiagnostics-show-location=once'
225   fi
226   AC_MSG_RESULT($ac_gabydiags)
227
228   # Check for -ffunction-sections -fdata-sections
229   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
230   CXXFLAGS='-ffunction-sections -fdata-sections'
231   AC_TRY_COMPILE(, [int foo;
232   ], [ac_fdsections=yes], [ac_fdsections=no])
233   if test "$ac_test_CXXFLAGS" = set; then
234     CXXFLAGS="$ac_save_CXXFLAGS"
235   else
236     # this is the suspicious part
237     CXXFLAGS=''
238   fi
239   if test "$ac_fdsections" = "yes"; then
240     SECTION_FLAGS='-ffunction-sections -fdata-sections'
241   fi
242   AC_MSG_RESULT($ac_fdsections)
243
244   AC_LANG_RESTORE
245   AC_SUBST(WERROR)
246   AC_SUBST(WFMT_FLAGS)
247   AC_SUBST(SECTION_FLAGS)
248 ])
249
250
251 dnl
252 dnl Check to see if tricky linker opts can be used.
253 dnl
254 dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible
255 dnl GLIBCPP_CHECK_LINKER_FEATURES
256 AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
257   # All these tests are for C++; save the language and the compiler flags.
258   # Need to do this so that g++ won't try to link in libstdc++
259   ac_test_CFLAGS="${CFLAGS+set}"
260   ac_save_CFLAGS="$CFLAGS"
261   CFLAGS='-x c++  -Wl,--gc-sections'
262
263   # Check for -Wl,--gc-sections
264   AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
265   AC_TRY_RUN([
266    int main(void) 
267    {
268      try { throw 1; }
269      catch (...) { };
270      return 0;
271    }
272   ], [ac_sectionLDflags=yes], [ac_sectionLFflags=no], [ac_sectionLDflags=yes])
273   if test "$ac_test_CFLAGS" = set; then
274     CFLAGS="$ac_save_CFLAGS"
275   else
276     # this is the suspicious part
277     CFLAGS=''
278   fi
279   if test "$ac_sectionLDflags" = "yes"; then
280     SECTION_LDFLAGS='-Wl,--gc-sections'
281   fi
282   AC_MSG_RESULT($ac_sectionLDflags)
283
284   AC_SUBST(SECTION_LDFLAGS)
285 ])
286
287
288 dnl
289 dnl Check to see if the (math function) argument passed is
290 dnl 1) declared when using the c++ compiler
291 dnl 2) has "C" linkage
292 dnl
293 dnl Define HAVE_CARGF etc if "cargf" is declared and links
294 dnl
295 dnl argument 1 is name of function to check
296 dnl
297 dnl ASSUMES argument is a math function with ONE parameter
298 dnl
299 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
300 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
301   AC_LANG_SAVE
302   AC_LANG_CPLUSPLUS
303   AC_MSG_CHECKING([for $1 declaration])
304   AC_TRY_COMPILE([#include <math.h>], 
305   [ $1(0);], 
306   [use_$1=yes], [use_$1=no])
307   AC_MSG_RESULT($use_$1)
308   AC_LANG_RESTORE
309   if test x$use_$1 = x"yes"; then
310     AC_CHECK_FUNCS($1)    
311   fi
312 ])
313
314
315 dnl
316 dnl Check to see if the (math function) argument passed is
317 dnl 1) declared when using the c++ compiler
318 dnl 2) has "C" linkage
319 dnl
320 dnl Define HAVE_CARGF etc if "cargf" is declared and links
321 dnl
322 dnl argument 1 is name of function to check
323 dnl
324 dnl ASSUMES argument is a math function with TWO parameters
325 dnl
326 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
327 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
328   AC_LANG_SAVE
329   AC_LANG_CPLUSPLUS
330   AC_MSG_CHECKING([for $1 declaration])
331   AC_TRY_COMPILE([#include <math.h>], 
332   [ $1(0, 0);], 
333   [use_$1=yes], [use_$1=no])
334   AC_MSG_RESULT($use_$1)
335   AC_LANG_RESTORE
336   if test x$use_$1 = x"yes"; then
337     AC_CHECK_FUNCS($1)    
338   fi
339 ])
340
341
342 dnl
343 dnl Check to see if the (math function) argument passed is
344 dnl 1) declared when using the c++ compiler
345 dnl 2) has "C" linkage
346 dnl
347 dnl Define HAVE_CARGF etc if "cargf" is declared and links
348 dnl
349 dnl argument 1 is name of function to check
350 dnl
351 dnl ASSUMES argument is a math function with THREE parameters
352 dnl
353 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
354 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
355   AC_LANG_SAVE
356   AC_LANG_CPLUSPLUS
357   AC_MSG_CHECKING([for $1 declaration])
358   AC_TRY_COMPILE([#include <math.h>], 
359   [ $1(0, 0, 0);], 
360   [use_$1=yes], [use_$1=no])
361   AC_MSG_RESULT($use_$1)
362   AC_LANG_RESTORE
363   if test x$use_$1 = x"yes"; then
364     AC_CHECK_FUNCS($1)    
365   fi
366 ])
367
368
369 dnl
370 dnl Because the builtins are picky picky picky about the arguments they take, 
371 dnl do an explict linkage tests here.
372 dnl Check to see if the (math function) argument passed is
373 dnl 1) declared when using the c++ compiler
374 dnl 2) has "C" linkage
375 dnl
376 dnl Define HAVE_CARGF etc if "cargf" is declared and links
377 dnl
378 dnl argument 1 is name of function to check
379 dnl
380 dnl ASSUMES argument is a math function with ONE parameter
381 dnl
382 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
383 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
384   AC_LANG_SAVE
385   AC_LANG_CPLUSPLUS
386   AC_MSG_CHECKING([for $1 declaration])
387   AC_TRY_COMPILE([#include <math.h>], 
388   [ $1(0);], 
389   [use_$1=yes], [use_$1=no])
390   AC_MSG_RESULT($use_$1)
391   AC_LANG_RESTORE
392   if test x$use_$1 = x"yes"; then
393     AC_MSG_CHECKING([for $1 linkage])
394       AC_TRY_LINK([#include <math.h>], 
395       [ $1(0);],
396       [link_$1=yes], [link_$1=no])
397     AC_MSG_RESULT($link_$1)
398     if test x$link_$1 = x"yes"; then
399       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
400       AC_DEFINE_UNQUOTED(${ac_tr_func})
401     fi
402   fi
403 ])
404
405
406 dnl
407 dnl Check to see what builtin math functions are supported
408 dnl
409 dnl check for __builtin_abs
410 dnl check for __builtin_fabsf
411 dnl check for __builtin_fabs
412 dnl check for __builtin_fabl
413 dnl check for __builtin_labs
414 dnl check for __builtin_sqrtf
415 dnl check for __builtin_sqrtl
416 dnl check for __builtin_fsqrt
417 dnl check for __builtin_sinf
418 dnl check for __builtin_sin
419 dnl check for __builtin_sinl
420 dnl check for __builtin_cosf
421 dnl check for __builtin_cos
422 dnl check for __builtin_cosl
423 dnl
424 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
425 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
426   dnl Test for builtin math functions.
427   dnl These are made in gcc/c-common.c 
428   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
429   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
430   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
431   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
432   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
433
434   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
435   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fsqrt)
436   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
437
438   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
439   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
440   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
441
442   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
443   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
444   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
445
446   dnl There is, without a doubt, a more elegant way to have these
447   dnl names exported so that they won't be stripped out of acconfig.h by
448   dnl autoheader. I leave this as an exercise to somebody less frustrated
449   dnl than I.... please email the libstdc++ list if you can figure out a
450   dnl more elegant approach (see autoconf/acgen.m4 and specifically
451   dnl AC_CHECK_FUNC for things to steal.)
452   dummyvar=no
453   if test x$dummyvar = x"yes"; then
454     AC_DEFINE(HAVE___BUILTIN_ABS)
455     AC_DEFINE(HAVE___BUILTIN_LABS)
456     AC_DEFINE(HAVE___BUILTIN_COS)
457     AC_DEFINE(HAVE___BUILTIN_COSF)
458     AC_DEFINE(HAVE___BUILTIN_COSL)
459     AC_DEFINE(HAVE___BUILTIN_FABS)
460     AC_DEFINE(HAVE___BUILTIN_FABSF)
461     AC_DEFINE(HAVE___BUILTIN_FABSL)
462     AC_DEFINE(HAVE___BUILTIN_SIN)
463     AC_DEFINE(HAVE___BUILTIN_SINF)
464     AC_DEFINE(HAVE___BUILTIN_SINL)
465     AC_DEFINE(HAVE___BUILTIN_FSQRT)
466     AC_DEFINE(HAVE___BUILTIN_SQRTF)
467     AC_DEFINE(HAVE___BUILTIN_SQRTL)
468   fi
469 ])
470
471
472 dnl
473 dnl Check to see what the underlying c library or math library is like.
474 dnl These checks need to do two things: 
475 dnl 1) make sure the name is declared when using the c++ compiler
476 dnl 2) make sure the name has "C" linkage
477 dnl This might seem like overkill but experience has shown that it's not...
478 dnl
479 dnl Define HAVE_CARGF etc if "cargf" is found.
480 dnl
481 dnl GLIBCPP_CHECK_MATH_SUPPORT
482 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
483   ac_test_CXXFLAGS="${CXXFLAGS+set}"
484   ac_save_CXXFLAGS="$CXXFLAGS"
485   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
486
487   dnl Check libm
488   AC_CHECK_LIB(m, sin, libm="-lm")
489   ac_save_LIBS="$LIBS"
490   LIBS="$LIBS $libm"
491
492   dnl Although not math functions, needed and for some reason checked here.
493   AC_CHECK_FUNCS(strtof strtold)
494
495   dnl Check to see if certain C math functions exist.
496   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
497   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
498   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
499   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
500   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
501   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
502   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
503
504   dnl Check to see if basic C math functions have float versions.
505   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
506   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
507   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(acosf)
508   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(asinf)
509   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(atanf)
510   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
511   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(ceilf)
512   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(cosf)
513   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(coshf)
514   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expf)
515   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
516   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(floorf)
517   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
518   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
519   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
520   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
521   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
522   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
523   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
524   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinf)
525   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinhf)
526   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
527   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanf)
528   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanhf)
529   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
530   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
531
532   dnl Check to see if basic C math functions have long double versions.
533   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
534   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
535   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
536   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(acosl)
537   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(asinl)
538   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(atanl)
539   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
540   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(ceill)
541   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(cosl)
542   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(coshl)
543   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
544   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
545   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(floorl)
546   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
547   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
548   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
549   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
550   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
551   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
552   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
553   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinl)
554   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sinhl)
555   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
556   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanl)
557   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(tanhl)
558   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
559   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
560
561   dnl Some runtimes have these functions with a preceding underscore. Please
562   dnl keep this sync'd with the one above. And if you add any new symbol,
563   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
564   dnl Check to see if certain C math functions exist.
565   dnl Check to see if certain C math functions exist.
566   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isinf)
567   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isnan)
568   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_finite)
569   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_copysign)
570   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(_sincos)
571   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_fpclass)
572   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_qfpclass)
573
574   dnl Check to see if basic C math functions have float versions.
575   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isnanf)
576   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isinff)
577   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_acosf)
578   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_asinf)
579   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_atanf)
580   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_atan2f)
581   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_ceilf)
582   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_cosf)
583   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_coshf)
584   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_expf)
585   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_fabsf)
586   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_floorf)
587   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_fmodf)
588   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_frexpf)
589   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_ldexpf)
590   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_logf)
591   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_log10f)
592   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_modff)
593   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_powf)
594   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinf)
595   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinhf)
596   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sqrtf)
597   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanf)
598   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanhf)
599   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(_sincosf)
600   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_finitef)
601
602   dnl Check to see if basic C math functions have long double versions.
603   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isnanl)
604   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_isinfl)
605   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_copysignl)
606   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_acosl)
607   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_asinl)
608   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_atanl)
609   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_atan2l)
610   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_ceill)
611   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_cosl)
612   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_coshl)
613   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_expl)
614   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_fabsl)
615   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_floorl)
616   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_fmodl)
617   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_frexpl)
618   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_ldexpl)
619   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_logl)
620   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_log10l)
621   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_modfl)
622   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(_powl)
623   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinl)
624   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sinhl)
625   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_sqrtl)
626   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanl)
627   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_tanhl)
628   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(_sincosl)
629   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(_finitel)
630
631   LIBS="$ac_save_LIBS"
632   CXXFLAGS="$ac_save_CXXFLAGS"
633 ])
634
635
636 dnl
637 dnl Check to see if there is native support for complex 
638 dnl
639 dnl Don't compile bits in math/* if native support exits.
640 dnl
641 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "cargf" is found.
642 dnl
643 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
644 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
645   dnl Check for complex versions of math functions of platform.
646   AC_CHECK_HEADERS([complex.h])
647   AC_REPLACE_MATHFUNCS(ccos ccosf ccosh ccoshf cexp cexpf c_log c_logf \
648   clog10 clog10f cpow cpowf csin csinf csinh csinhf csqrt csqrtf \
649   ctan ctanf ctanh ctanhf carg cargf nan hypot hypotf atan2f expf copysignf)
650
651   dnl Compile the long double complex functions only if the function 
652   dnl provides the non-complex long double functions that are needed.
653   dnl Currently this includes copysignl and atan2l, which should be
654   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
655   USE_COMPLEX_LONG_DOUBLE=no
656   if test x$ac_cv_func_atan2l = x"yes" \
657      && test x$ac_cv_func_copysignl = x"yes"; then
658     USE_COMPLEX_LONG_DOUBLE=yes
659     AC_REPLACE_MATHFUNCS(ccoshl ccosl cexpl cpowl csinhl csinl \
660     csqrtl ctanhl ctanl cargl hypotl signbitl c_logl clog10l)
661   fi
662
663   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
664 ])
665
666
667 dnl Check to see what architecture we are compiling for. If it's
668 dnl supported, use special hand-crafted routines to provide thread
669 dnl primitives. Also, if architecture-specific flags are required for 
670 dnl compilation, add them here.
671 dnl 
672 dnl Depending on what is found, select configure/cpu/*/bits/atomicity.h 
673 dnl If not found, select configure/cpu/generic/bits/atomicity.h
674 dnl
675 dnl GLIBCPP_CHECK_CPU
676 AC_DEFUN(GLIBCPP_CHECK_CPU, [
677     AC_MSG_CHECKING([for cpu primitives directory])
678     CPU_FLAGS=                  
679     case "$target_cpu" in
680       alpha*)
681         cpu_include_dir="config/cpu/alpha"
682         ;;
683       arm*)
684         cpu_include_dir="config/cpu/arm"
685         ;;
686       i386)
687         cpu_include_dir="config/cpu/i386"
688         ;;
689       i486 | i586 | i686 | i786)
690         cpu_include_dir="config/cpu/i486"
691         ;;
692       powerpc | rs6000)
693         cpu_include_dir="config/cpu/powerpc"
694         CPU_FLAGS='-mcpu=powerpc'
695         ;;
696       sparc64 | ultrasparc)
697         cpu_include_dir="config/cpu/sparc/sparc64"
698         ;;
699       sparc*)
700         cpu_include_dir="config/cpu/sparc/sparc32"
701         ;;
702       *)
703         cpu_include_dir="config/cpu/generic"
704         ;;
705     esac
706     AC_MSG_RESULT($cpu_include_dir)
707     AC_SUBST(cpu_include_dir)
708     AC_SUBST(CPU_FLAGS)
709 ])
710
711  
712 dnl
713 dnl Check to see what the underlying c library's interface to ctype looks
714 dnl like. Bits of locale rely on things like isspace, toupper, etc. This
715 dnl stuff makes sure the right bits from the clibrary get called.
716 dnl 
717 dnl Depending on what is found, select various configure/*/bits/ctype_base.h 
718 dnl Depending on what is found, select various configure/*/ctype.cc
719 dnl
720 dnl GLIBCPP_CHECK_CTYPE
721 AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
722   AC_CHECK_HEADER(ctype.h, [
723     
724     dnl If doesn't match any specified, go with defaults.
725     ctype_default=yes
726
727     dnl Test for <ctype> functionality -- gnu-linux
728     AC_MSG_CHECKING([<ctype> for gnu-linux ])
729     AC_TRY_COMPILE([#include <ctype.h>],
730     [int
731     foo (int a)
732     { return _ISspace + _ISprint + _IScntrl + _ISupper + _ISlower + _ISalpha \
733         + _ISdigit + _ISpunct + _ISxdigit + _ISalnum + _ISgraph \
734         + __ctype_tolower[a] + __ctype_toupper[a] + __ctype_b[a];}], \
735     ctype_linux=yes, ctype_linux=no)
736     AC_MSG_RESULT($ctype_linux)
737     if test $ctype_linux = "yes"; then
738       ctype_include_dir="config/gnu-linux"
739       ctype_default=no
740     fi
741
742     dnl Test for <ctype> functionality -- FreeBSD 4.0
743     if test $ctype_default = "yes"; then
744     AC_MSG_CHECKING([<ctype> for freebsd 4.0 ])
745     AC_TRY_COMPILE([#include <ctype.h>],
746     [int
747     foo (int a)
748     { return _CTYPE_S + _CTYPE_R + _CTYPE_C + _CTYPE_U + _CTYPE_L + _CTYPE_A \
749         + _CTYPE_D + _CTYPE_P + _CTYPE_X + _CTYPE_G ;}], \
750     ctype_bsd=yes, ctype_bsd=no)
751     AC_MSG_RESULT($ctype_bsd)
752     if test $ctype_bsd = "yes"; then
753       ctype_include_dir="config/bsd"
754       ctype_default=no
755     fi
756     fi
757
758     dnl Test for <ctype> functionality -- FreeBSD 3.4
759     if test $ctype_default = "yes"; then
760     AC_MSG_CHECKING([<ctype> for freebsd 3.4 ])
761     AC_TRY_COMPILE([#include <ctype.h>],
762     [int
763     foo (int a)
764     { return _S + _R + _C + _U + _L + _A \
765       + _D + _P + _X + _G + __istype (a, 0);}], \
766     ctype_freebsd34=yes, ctype_freebsd34=no)
767     AC_MSG_RESULT($ctype_freebsd34)
768     if test $ctype_freebsd34 = "yes"; then
769       ctype_include_dir="config/bsd"
770       ctype_default=no
771     fi
772     fi
773
774     dnl Test for <ctype> functionality -- solaris 2.6 and 2.7
775     if test $ctype_default = "yes"; then
776     AC_MSG_CHECKING([<ctype> for solaris 2.[6,7,8] ])
777     AC_TRY_COMPILE([#include <ctype.h>],
778     [int
779     foo (int a)
780     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
781         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
782         + __trans_lower[a] + __trans_upper[a] + __ctype_mask[a];}], \
783     ctype_solaris=yes, ctype_solaris=no)
784     AC_MSG_RESULT($ctype_solaris)
785
786     if test $ctype_solaris = "yes"; then
787       AC_MSG_CHECKING([  for version])
788       AC_LANG_CPLUSPLUS 
789       AC_TRY_COMPILE([#include <ctype.h>],
790       [typedef long* __to_type; __to_type const& _M_toupper = __trans_upper;],\
791       ctype_solaris26=yes, ctype_solaris26=no)
792       AC_LANG_C
793       if test $ctype_solaris26 = "yes"; then
794         ctype_include_dir="config/solaris/solaris2.6"
795         AC_MSG_RESULT("solaris2.6")
796         ctype_default=no
797       else
798         ctype_include_dir="config/solaris/solaris2.7"
799         AC_MSG_RESULT("solaris2.[7,8]")
800         ctype_default=no
801       fi
802     fi
803     fi  
804
805     dnl Test for <ctype> functionality -- solaris 2.5.1
806     if test $ctype_default = "yes"; then
807     AC_MSG_CHECKING([<ctype> for solaris 2.5.1 ])
808     AC_TRY_COMPILE([#include <ctype.h>],
809     [int
810     foo (int a)
811     { return _U + _L + _N + _S + _P + _C + _X + _B \
812         + __ctype[a];}], \
813     ctype_solaris25=yes, ctype_solaris25=no)
814     AC_MSG_RESULT($ctype_solaris25)
815     if test $ctype_solaris25 = "yes"; then
816       ctype_include_dir="config/solaris/solaris2.5"
817       ctype_default=no
818     fi
819     fi
820
821     dnl Test for <ctype> functionality -- aix
822     if test $ctype_default = "yes"; then
823     AC_MSG_CHECKING([<ctype> for aix ])
824     AC_TRY_COMPILE([#include <ctype.h>],
825     [int
826     foo (int a)
827     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
828         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
829         + _VALC('a') + _IS('c', 0);}], \
830     ctype_aix=yes, ctype_aix=no)
831     AC_MSG_RESULT($ctype_aix)
832     if test $ctype_aix = "yes"; then
833       ctype_include_dir="config/aix"
834       ctype_default=no
835     fi
836     fi
837
838     dnl Test for <ctype> functionality -- newlib
839     if test $ctype_default = "yes"; then
840     AC_MSG_CHECKING([<ctype> for newlib ])
841     AC_TRY_COMPILE([#include <ctype.h>],
842     [int
843     foo (int a)
844     { return _U + _L + _N + _S + _P + _C + _X + _B \
845         + _ctype_[a];}], \
846     ctype_newlib=yes, ctype_newlib=no)
847     AC_MSG_RESULT($ctype_newlib)
848     if test $ctype_newlib = "yes"; then
849       ctype_include_dir="config/newlib"
850       ctype_default=no
851     fi
852     fi
853
854     if test $ctype_default = "yes"; then
855       ctype_include_dir="config/generic"
856       AC_MSG_WARN("Using default ctype headers.")
857     fi
858     AC_SUBST(ctype_include_dir)
859   ])
860 ])
861
862
863 dnl
864 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
865 dnl
866 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
867 dnl Define _GLIBCPP_NEED_MBSTATE_T if mbstate_t is not in wchar.h
868 dnl
869 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
870 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
871
872   dnl Sanity check for existence of ISO C9X headers for extended encoding.
873   AC_CHECK_HEADER(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
874   AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
875         
876   dnl Only continue checking if the ISO C9X headers exist.
877   if test x"$ac_has_wchar_h" = xyes && test x"$ac_has_wctype_h" = xyes; then
878
879     dnl Test wchar.h for mbstate_t, which is needed for char_traits and others.
880     AC_MSG_CHECKING([for mbstate_t])
881     AC_TRY_COMPILE([#include <wchar.h>],
882     [mbstate_t teststate;], 
883     use_native_mbstatet=yes, use_native_mbstatet=no)
884     AC_MSG_RESULT($use_native_mbstatet)
885     if test x"$use_native_mbstatet" = xno; then
886       AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
887     fi
888   
889     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
890     dnl numeric_limits can instantiate type_traits<wchar_t>
891     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
892     AC_TRY_COMPILE([#include <wchar.h>],
893     [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
894     has_wchar_minmax=yes, has_wchar_minmax=no)
895     AC_MSG_RESULT($has_wchar_minmax)
896   
897     dnl Test wchar.h for WEOF, which is what we use to determine whether
898     dnl to specialize for char_traits<wchar_t> or not.
899     AC_MSG_CHECKING([for WEOF])
900     AC_TRY_COMPILE([
901       #include <wchar.h>
902       #include <stddef.h>],
903     [wint_t i = WEOF;],
904     has_weof=yes, has_weof=no)
905     AC_MSG_RESULT($has_weof)
906
907     dnl Tests for wide character functions used in char_traits<wchar_t>.
908     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset, ac_wfuncs=yes, ac_wfuncs=no)
909
910     AC_MSG_CHECKING([for ISO C9X wchar_t support])
911     if test x"$has_weof" = xyes && test x"$has_wchar_minmax" = xyes && test x"$ac_wfuncs" = xyes; then
912       ac_isoC9X_wchar_t=yes
913     else
914       ac_isoC9X_wchar_t=no
915     fi
916     AC_MSG_RESULT($ac_isoC9X_wchar_t)
917
918     dnl Use iconv for wchar_t to char conversions. As such, check for 
919     dnl X/Open Portability Guide, version 2 features (XPG2).
920     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
921     AC_CHECK_FUNCS(iconv_open iconv_close iconv, ac_XPG2funcs=yes, ac_XPG2funcs=no)
922
923     AC_MSG_CHECKING([for XPG2 wchar_t support])
924     if test x"$ac_has_iconv_h" = xyes && test x"$ac_XPG2funcs" = xyes; then
925       ac_XPG2_wchar_t=yes
926     else
927       ac_XPG2_wchar_t=no
928     fi
929     AC_MSG_RESULT($ac_XPG2_wchar_t)
930
931     dnl At the moment, only enable wchar_t specializations if all the
932     dnl above support is present.
933     AC_MSG_CHECKING([for enabled wchar_t specializations])
934     if test x"$ac_isoC9X_wchar_t" = xyes && test x"$ac_XPG2_wchar_t" = xyes; then
935       libinst_wstring_la="libinst-wstring.la"
936       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
937       AC_MSG_RESULT("yes")
938     else
939       libinst_wstring_la=""
940       AC_MSG_RESULT("no")
941     fi
942     AC_SUBST(libinst_wstring_la)
943
944   else
945     AC_MSG_WARN([<wchar.h> not found])
946     AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
947   fi
948 ])
949
950
951 dnl
952 dnl Check to see if this version of GNU C++ is afflicted by bugs in
953 dnl __complex__ float support.
954 dnl
955 dnl Define _GLIBCPP_BUGGY_FLOAT_COMPLEX if buggy.
956 dnl
957 dnl Check to see if this version of GNU C++ is afflicted by bugs in 
958 dnl __complex__ support.Check for buggy __complex__ that will cause ICE in
959 dnl gcc-2.95.x when using the library, unless we define the default copy
960 dnl ctor in the specializations of complex<>. 
961 dnl 
962 dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
963 dnl GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT
964 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_COMPILER_SUPPORT, [
965   AC_REQUIRE([AC_PROG_CXX])
966
967   AC_MSG_CHECKING([for GNU C++ __complex__ support])
968   AC_CACHE_VAL(glibcpp_cv_complex, [
969     AC_LANG_SAVE
970     AC_LANG_CPLUSPLUS
971     AC_TRY_COMPILE([struct dcomplex { __complex__ double x; }; \
972                     dcomplex f(const dcomplex& x) { return dcomplex(x); }], \
973                     [ dcomplex x; f(x); ],
974       glibcpp_cv_complex=ok,
975       glibcpp_cv_complex=buggy
976     )
977     AC_LANG_RESTORE
978   ])
979   AC_MSG_RESULT($glibcpp_cv_complex)
980   if test $glibcpp_cv_complex = buggy; then
981     AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
982   fi
983
984   AC_MSG_CHECKING([for GNU C++ __complex__ float support])
985   AC_CACHE_VAL(glibcpp_cv_float_complex, [
986     AC_LANG_SAVE
987     AC_LANG_CPLUSPLUS
988     rm -f conftest.h
989     cat > conftest.h <<EOB
990       //
991       // Check for buggy __complex__ that causes ICE in most versions of egcs
992       // and gcc-2.95.x on certain platforms (eg., x86-win32).
993       //
994       // See http://egcs.cygnus.com/ml/gcc-bugs/1999-07/msg00845.html for
995       // more info on the bug itself.
996       //
997       struct
998       float_complex
999       {
1000        __complex__ float m_value;
1001        float_complex (float = 0.0f, float = 0.0f);
1002        float_complex (__complex__ float val) : m_value (val) {}
1003        float_complex foo (const float_complex &val)
1004          { return float_complex (~val.m_value); }
1005       };
1006 EOB
1007     AC_TRY_COMPILE([#include "conftest.h"], ,
1008       glibcpp_cv_float_complex=ok,
1009       glibcpp_cv_float_complex=buggy
1010     )
1011     AC_LANG_RESTORE
1012   ])
1013   AC_MSG_RESULT($glibcpp_cv_float_complex)
1014   if test $glibcpp_cv_float_complex = buggy; then
1015     AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
1016   fi
1017 ])
1018
1019
1020 dnl
1021 dnl Check for special debugging mode; not for production use.
1022 dnl
1023 dnl GLIBCPP_ENABLE_DEBUG
1024 dnl --enable-debug sets '-ggdb -O0'.
1025 dnl --disable-debug sets '-g' and whatever optimization options the
1026 dnl     compiler can handle.
1027 dnl  +  Perhaps --enable-maintainer-mode should automatically turn this on?
1028 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
1029 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
1030 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1031 dnl       defaults to `no'.
1032 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
1033 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
1034 AC_ARG_ENABLE(debug,
1035 changequote(<<, >>)dnl
1036 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
1037 changequote([, ])dnl
1038 [case "$enableval" in
1039  yes) enable_debug=yes ;;
1040  no)  enable_debug=no ;;
1041  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
1042  esac],
1043 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
1044 dnl Option parsed, now set things appropriately
1045 case "$enable_debug" in
1046     yes) 
1047         DEBUG_FLAGS='-O0 -ggdb'                 
1048         ;;
1049     no)   
1050         DEBUG_FLAGS='-g'
1051         ;;
1052 esac
1053 AC_SUBST(DEBUG_FLAGS)
1054 ])
1055
1056
1057 dnl
1058 dnl Check for "unusual" flags to pass to the compiler while building.
1059 dnl
1060 dnl GLIBCPP_ENABLE_CXX_FLAGS
1061 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
1062 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
1063 dnl     Somehow this same set of flags must be passed when [re]building
1064 dnl     libgcc.
1065 dnl --disable-cxx-flags passes nothing.
1066 dnl  +  See http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00131.html
1067 dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00284.html
1068 dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q1/msg00035.html
1069 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
1070 dnl       If "default flags" is an empty string (or "none"), the effect is
1071 dnl       the same as --disable or --enable=no.
1072 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
1073 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
1074 AC_ARG_ENABLE(cxx-flags,
1075 changequote(<<, >>)dnl
1076 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
1077                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
1078 changequote([, ])dnl
1079 [case "x$enableval" in
1080  xyes)   AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1081  xno|x)  enable_cxx_flags='' ;;
1082  *)      enable_cxx_flags="$enableval" ;;
1083  esac],
1084 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')dnl
1085 dnl Thinko on my part during design.  This kludge is the workaround.
1086 if test "$enable_cxx_flags" = "none"; then enable_cxx_flags=''; fi
1087 dnl Run through flags (either default or command-line) and set anything
1088 dnl extra (e.g., #defines) that must accompany particular g++ options.
1089 if test -n "$enable_cxx_flags"; then
1090     for f in $enable_cxx_flags; do
1091         case "$f" in
1092             -fhonor-std)  ;;
1093             -*)  ;;
1094             *)   # and we're trying to pass /what/ exactly?
1095                  AC_MSG_ERROR([compiler flags start with a -]) ;;
1096         esac
1097     done
1098 fi
1099 EXTRA_CXX_FLAGS="$enable_cxx_flags"
1100 AC_SUBST(EXTRA_CXX_FLAGS)
1101 ])
1102
1103
1104 dnl
1105 dnl Check for instructions to automatically rebuild libgcc.a.  Requires,
1106 dnl of course, the location of the gcc objdir.  Note that if --disable-
1107 dnl namespaces is in effect, rebuilding libgcc.a is an expensive no-op.
1108 dnl
1109 dnl GLIBCPP_ENABLE_RELIBGCC
1110 dnl --enable-libgcc-rebuild=/absolute/path/to/gcc/objdir sets GCC_OBJDIR
1111 dnl     (presumably in the top-level Makefile) to /absol.../objdir
1112 dnl --disable-libgcc-rebuild will not touch libgcc.a at all (maybe print
1113 dnl     a warning if this is given along with --enable-namespaces), by
1114 dnl     setting GCC_OBJDIR to `no'.
1115 dnl  +  Doing this by default is going to be interesting.  What default
1116 dnl     "on" value can there be?
1117 dnl  +  Usage:  GLIBCPP_ENABLE_RELIBGCC[(DEFAULT)]
1118 dnl       The default path should be ../.. if bundled with GCC source.
1119 dnl       If ommitted, it defaults to `no'.
1120 dnl
1121 AC_DEFUN(GLIBCPP_ENABLE_RELIBGCC, [dnl
1122 define([GLIBCPP_ENABLE_RELIBGCC_DEFAULT], ifelse($1,, no, $1))dnl
1123 AC_ARG_ENABLE(libgcc-rebuild,
1124 changequote(<<, >>)dnl
1125 <<  --enable-libgcc-rebuild=DIR     also rebuild libgcc.a; DIR is
1126                                   the GCC objdir; see install.html>>,
1127 changequote([, ])dnl
1128 [case "$enableval" in
1129  yes) AC_MSG_ERROR([--enable-libgcc-rebuild needs a pathname]) ;;
1130  no)  enable_libgcc_rebuild=no ;;
1131  *)   if test -d "$enableval" && test -d "${enableval}/gcc" && \
1132          test -d "${enableval}/libiberty"
1133       then
1134          enable_libgcc_rebuild="$enableval"
1135       else
1136          AC_MSG_ERROR(["$enableval" does not appear to be the GCC objdir])
1137       fi
1138       ;;
1139  esac],
1140 enable_libgcc_rebuild=GLIBCPP_ENABLE_RELIBGCC_DEFAULT)dnl
1141 GCC_OBJDIR="$enable_libgcc_rebuild"
1142 AC_SUBST(GCC_OBJDIR)
1143 ])
1144
1145
1146 dnl
1147 dnl Check for which I/O library to use:  libio, or something specific.
1148 dnl
1149 dnl GLIBCPP_ENABLE_CSTDIO
1150 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
1151 dnl 
1152 dnl default is libio
1153 dnl
1154 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1155   AC_MSG_CHECKING([for cstdio to use])
1156   AC_ARG_ENABLE(cstdio,
1157   [  --enable-cstdio         enable GNU libio for target io package. (default)
1158   --enable-cstdio=LIB     use LIB target-speific io package.], 
1159   if test x$enable_cstdio = xno; then
1160     enable_cstdio=libio
1161   fi,
1162      enable_cstdio=libio)
1163
1164   enable_cstdio_flag=$enable_cstdio
1165
1166   dnl Check if a valid thread package
1167   case x${enable_cstdio_flag} in
1168         xlibio | x | xno | xnone | xyes)
1169                 # default
1170                 CSTDIO_H=c_io_libio.h
1171                 CSTDIO_CC=c_io_libio.cc
1172                 AC_MSG_RESULT(libio)
1173
1174                 # see if we are on a system with libio native (ie, linux)
1175                 AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1176                 if test $has_libio = "yes"; then
1177                   BUILD_LIBIO_INCLUDE=
1178                   need_libio=no
1179                 else
1180                   BUILD_LIBIO_INCLUDE='-I../libio'
1181                   need_libio=yes
1182                 fi
1183                 AC_SUBST(BUILD_LIBIO_INCLUDE)
1184
1185                 # see if the _G_config.h header needs to be built. 
1186                 # NB: This replaces the _G_CONFIG_H machinery in libio-v2
1187                 AC_CHECK_HEADER(_G_config.h,  has_gconf_h=yes, has_gconf_h=no)
1188                 AM_CONDITIONAL(GLIBCPP_NEED_LIBIO_CONFIG_H, test "$has_gconf_h" = no)
1189                 ;;
1190         xwince)
1191                 CSTDIO_H=c_io_wince.h
1192                 CSTDIO_CC=c_io_wince.cc
1193                 AC_MSG_RESULT(wince)
1194
1195                 need_libio=no
1196                 BUILD_LIBIO_INCLUDE=
1197                 AC_SUBST(BUILD_LIBIO_INCLUDE)
1198                 ;;
1199         *)
1200                 echo "$enable_cstdio is an unknown io package" 1>&2
1201                 exit 1
1202                 ;;
1203   esac
1204   AC_SUBST(CSTDIO_H)
1205   AC_SUBST(CSTDIO_CC)
1206   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1207 ])
1208
1209
1210 dnl
1211 dnl Check for which threading library to use.
1212 dnl
1213 dnl GLIBCPP_ENABLE_THREADS
1214 dnl --enable-threads=posix sets config/threads-posix.h et. al.
1215 dnl 
1216 dnl default is no threads
1217 dnl
1218 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1219   dnl Note this comes from the gcc/config.in and libjava/config.in
1220   dnl Efforts should be made to keep this in sync.
1221   AC_MSG_CHECKING([for threads package to use])
1222   AC_ARG_ENABLE(threads,
1223   [  --enable-threads        enable thread usage for target GCC.
1224   --enable-threads=LIB    use LIB thread package for target GCC.],
1225   if test x$enable_threads = xno; then
1226     enable_threads=''
1227   fi,
1228     enable_threads='')
1229
1230   enable_threads_flag=$enable_threads
1231
1232   dnl Check if a valid thread package
1233   case x${enable_threads_flag} in
1234         x | xno | xnone)
1235                 # No threads
1236                 target_thread_file='single'
1237                 ;;
1238         xyes)
1239                 # default
1240                 target_thread_file=''
1241                 ;;
1242         xdecosf1 | xirix | xmach | xos2 | xposix | xpthreads | xsingle | \
1243         xsolaris | xwin32 | xdce | xvxworks)
1244                 target_thread_file=$enable_threads_flag
1245                 ;;
1246         *)
1247                 echo "$enable_threads is an unknown thread package" 1>&2
1248                 exit 1
1249                 ;;
1250   esac
1251
1252   dnl Check for thread package actually supported in libstdc++ 
1253   case "$target_thread_file" in
1254     no | none | single)
1255       THREADS=none
1256       ;;
1257     posix | pthreads)
1258       THREADS=posix
1259       case "$host" in
1260         *-*-linux*)
1261         ;;
1262       esac
1263       ;;
1264     decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
1265       AC_MSG_ERROR(thread package $THREADS not yet supported)
1266       ;;
1267     *)
1268       AC_MSG_ERROR($THREADS is an unknown thread package)
1269       ;;
1270   esac
1271   AC_MSG_RESULT($THREADS)
1272
1273   THREADLIBS=
1274   THREADINCS=
1275   THREADDEPS=
1276   THREADOBJS=
1277   THREADH=
1278   THREADSPEC=
1279   case "$THREADS" in
1280     posix)
1281       AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
1282       THREADLIBS=-lpthread
1283       THREADSPEC=-lpthread
1284       dnl Not presently used
1285       dnl THREADOBJS=threads-posix.lo
1286       THREADH=threads-posix.h
1287       ;;
1288     none)
1289       dnl Not presently used
1290       dnl THREADOBJS=threads-no.lo
1291       THREADH=threads-no.h
1292       ;;
1293   esac
1294   AC_SUBST(THREADLIBS)
1295   AC_SUBST(THREADINCS)
1296   AC_SUBST(THREADDEPS)
1297   AC_SUBST(THREADOBJS)
1298   AC_SUBST(THREADSPEC)
1299 ])
1300
1301
1302 dnl
1303 dnl Check for template specializations for the 'long long' type extension.
1304 dnl
1305 dnl GLIBCPP_ENABLE_LONG_LONG
1306 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1307 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1308 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1309 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1310 dnl       defaults to `no'.
1311 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1312 dnl
1313 dnl GLIBCPP_ENABLE_LONG_LONG
1314 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1315   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1316
1317   AC_ARG_ENABLE(long-long,
1318   changequote(<<, >>)dnl
1319   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1320   changequote([, ])dnl
1321   [case "$enableval" in
1322    yes) enable_long_long=yes ;;
1323    no)  enable_long_long=no ;;
1324    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1325    esac],
1326   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1327
1328   # Check for the existance of functions used if long long is enabled.
1329   AC_CHECK_FUNC(strtoll,,ac_strtoll=no)
1330   AC_CHECK_FUNC(strtoull,,ac_strtoull=no)
1331
1332   AC_MSG_CHECKING([for enabled long long])
1333   if test x"$ac_strtoll" = xno || test x"$ac_strtoull" = xno; then 
1334     enable_long_long=no; 
1335   fi; 
1336   AC_MSG_RESULT($enable_long_long)
1337
1338   dnl Option parsed, now set things appropriately
1339   case "$enable_long_long" in
1340     yes)  AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1341           ;;
1342   esac
1343 ])
1344
1345
1346 dnl
1347 dnl Check for whether or not to do shadowed C headers.
1348 dnl
1349 dnl GLIBCPP_ENABLE_SHADOW
1350 dnl --enable-cshadow-headers [does stuff].
1351 dnl --disable-cshadow-headers [does not do stuff].
1352 dnl  +  This will eventually need to be on by default.
1353 dnl  +  Usage:  GLIBCPP_ENABLE_SHADOW[(DEFAULT)]
1354 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1355 dnl       defaults to `no'.
1356 AC_DEFUN(GLIBCPP_ENABLE_SHADOW, [dnl
1357 define([GLIBCPP_ENABLE_SHADOW_DEFAULT], ifelse($1, yes, yes, no))dnl
1358 AC_MSG_CHECKING([for enabled cshadow headers])
1359 AC_ARG_ENABLE(cshadow-headers,
1360 changequote(<<, >>)dnl
1361 <<  --enable-cshadow-headers construct "shadowed" C header files for
1362                            g++ [default=>>GLIBCPP_ENABLE_SHADOW_DEFAULT],
1363 changequote([, ])dnl
1364 [case "$enableval" in
1365  yes) enable_cshadow_headers=yes 
1366         ;;
1367  no)  enable_cshadow_headers=no 
1368         ;;
1369  *)   AC_MSG_ERROR([Unknown argument to enable/disable shadowed C headers]) 
1370         ;;
1371  esac],
1372 enable_cshadow_headers=GLIBCPP_ENABLE_SHADOW_DEFAULT)dnl
1373 AC_MSG_RESULT($enable_cshadow_headers)
1374 dnl Option parsed, now set things appropriately
1375 case "$enable_cshadow_headers" in
1376     yes) 
1377         CSHADOWFLAGS="-D_GNU_SOURCE"
1378         CSHADOW_INCLUDES=" -I$srcdir/shadow -I$blddir/cshadow"
1379         ;;
1380     no)   
1381         CSHADOWFLAGS=""
1382         CSHADOW_INCLUDES=""
1383         ;;
1384 esac
1385
1386 AC_SUBST(CSHADOWFLAGS)
1387 AC_SUBST(CSHADOW_INCLUDES)
1388 AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cshadow_headers" = yes)
1389 ])
1390
1391
1392 # Check whether LC_MESSAGES is available in <locale.h>.
1393 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1394 #
1395 # This file file be copied and used freely without restrictions.  It can
1396 # be used in projects which are not available under the GNU Public License
1397 # but which still want to provide support for the GNU gettext functionality.
1398 # Please note that the actual code is *not* freely available.
1399
1400 # serial 1
1401
1402 AC_DEFUN(AC_LC_MESSAGES,
1403   [if test $ac_cv_header_locale_h = yes; then
1404     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
1405       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1406        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
1407     if test $ac_cv_val_LC_MESSAGES = yes; then
1408       AC_DEFINE(HAVE_LC_MESSAGES)
1409     fi
1410   fi])
1411
1412
1413 # Check for functions in math library.
1414 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1415 #
1416 # This file can be copied and used freely without restrictions.  It can
1417 # be used in projects which are not available under the GNU Public License
1418 # but which still want to provide support for the GNU gettext functionality.
1419 # Please note that the actual code is *not* freely available.
1420
1421 # serial 1
1422
1423 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1424 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1425 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1426 AC_SUBST(LIBMATHOBJS)dnl
1427 ])
1428
1429
1430 # Check for string functions.
1431 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1432 #
1433 # This file can be copied and used freely without restrictions.  It can
1434 # be used in projects which are not available under the GNU Public License
1435 # but which still want to provide support for the GNU gettext functionality.
1436 # Please note that the actual code is *not* freely available.
1437
1438 # serial 1
1439
1440 dnl AC_REPLACE_STRINGFUNCS(FUNCTION...)
1441 AC_DEFUN(AC_REPLACE_STRINGFUNCS,
1442 [AC_CHECK_FUNCS([$1], , [LIBSTRINGOBJS="$LIBSTRINGOBJS ${ac_func}.lo"])
1443 AC_SUBST(LIBSTRINGOBJS)dnl
1444 ])