[multiple changes]
[platform/upstream/gcc.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. In particular, test for
159 dnl newer compiler features, or features that are present in newer
160 dnl compiler version but not older compiler versions should be placed
161 dnl here.
162 dnl
163 dnl Define FMTFLAGS='-fdiagnostics-show-location=once' if possible
164 dnl Define WERROR='-Werror' if possible; g++'s that lack the new inlining
165 dnl    code or the new system_header pragma will die.  Other options dealing
166 dnl    with warnings, errors, and compiler complaints may be folded into
167 dnl    the WERROR variable.
168 dnl
169 dnl GLIBCPP_CHECK_COMPILER_VERSION
170 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
171   # All these tests are for C++; save the language and the compiler flags.
172   # The CXXFLAGS thing is suspicious, but based on similar bits 
173   # found in GLIBCPP_CONFIGURE.
174   AC_LANG_SAVE
175   AC_LANG_CPLUSPLUS
176   ac_test_CXXFLAGS="${CXXFLAGS+set}"
177   ac_save_CXXFLAGS="$CXXFLAGS"
178   WERROR='-Werror'
179
180   # Sanity check that g++ is capable of dealing with v-3.
181   AC_MSG_CHECKING([for g++ that will successfullly compile this code])
182   AC_EGREP_CPP([ok], [
183   #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) 
184     ok
185   #endif
186   ], gpp_satisfactory=yes, AC_MSG_ERROR("please upgrade to gcc-2.95 or above"))
187   AC_MSG_RESULT($gpp_satisfactory)
188
189   # Check for pragma system_header.
190   AC_MSG_CHECKING([for g++ that supports pragma system_header])
191   CXXFLAGS='-Wunknown-pragmas -Werror'
192   AC_TRY_COMPILE([#pragma system_header], [int foo;
193   ], [ac_newpragma=yes], [ac_newpragma=no])
194   if test "$ac_test_CXXFLAGS" = set; then
195     CXXFLAGS="$ac_save_CXXFLAGS"
196   else
197     # this is the suspicious part
198     CXXFLAGS=''
199   fi
200   if test "$ac_newpragma" = "no"; then
201     WERROR="$WERROR -Wno-unknown-pragmas"
202   fi
203   AC_MSG_RESULT($ac_newpragma)
204
205   # Check for more sophisticated diagnostic control.
206   AC_MSG_CHECKING([for g++ that supports -fdiagnostics-show-location=once])
207   CXXFLAGS='-fdiagnostics-show-location=once'
208   AC_TRY_COMPILE(, [int foo;
209   ], [ac_gabydiags=yes], [ac_gabydiags=no])
210   if test "$ac_test_CXXFLAGS" = set; then
211     CXXFLAGS="$ac_save_CXXFLAGS"
212   else
213     # this is the suspicious part
214     CXXFLAGS=''
215   fi
216   if test "$ac_gabydiags" = "yes"; then
217     FMTFLAGS='-fdiagnostics-show-location=once'
218   fi
219   AC_MSG_RESULT($ac_gabydiags)
220
221   AC_LANG_RESTORE
222   AC_SUBST(WERROR)
223   AC_SUBST(FMTFLAGS)
224 ])
225
226
227 dnl
228 dnl Check to see what builtin math functions are supported
229 dnl
230 dnl Define _GLIBCPP_HAS_BUILTIN_SINF if __builtin_sinf
231 dnl Define _GLIBCPP_HAS_BUILTIN_COSF if __builtin_cosf
232 dnl Define _GLIBCPP_HAS_BUILTIN_FABSF if __builtin_fabsf
233 dnl Define _GLIBCPP_HAS_BUILTIN_SQRTF if __builtin_sqrtf
234 dnl
235 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
236 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
237   dnl Test for builtin math functions.
238   AC_MSG_CHECKING([for __builtin_sinf])
239   AC_TRY_COMPILE([#include <math.h>], 
240   [float foo(void) { __builtin_sinf(0.0); }], 
241   use_builtin_sinf=yes, use_builtin_sinf=no)
242   AC_MSG_RESULT($use_builtin_sinf)
243   if test $use_builtin_sinf = "yes"; then
244     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_SINF)
245   fi
246
247   AC_MSG_CHECKING([for __builtin_cosf])
248   AC_TRY_COMPILE([#include <math.h>], 
249   [float foo(void) { __builtin_cosf(0.0); }], 
250   use_builtin_cosf=yes, use_builtin_cosf=no)
251   AC_MSG_RESULT($use_builtin_cosf)
252   if test $use_builtin_cosf = "yes"; then
253     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_COSF)
254   fi
255
256   AC_MSG_CHECKING([for __builtin_fabsf])
257   AC_TRY_COMPILE([#include <math.h>], 
258   [float foo(void) { __builtin_fabsf(0.0); }], 
259   use_builtin_fabsf=yes, use_builtin_fabsf=no)
260   AC_MSG_RESULT($use_builtin_fabsf)
261   if test $use_builtin_fabsf = "yes"; then
262     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_FABSF)
263   fi
264
265   AC_MSG_CHECKING([for __builtin_sqrtf])
266   AC_TRY_COMPILE([#include <math.h>], 
267   [float foo(void) { __builtin_sqrtf(0.0); }], 
268   use_builtin_sqrtf=yes, use_builtin_sqrtf=no)
269   AC_MSG_RESULT($use_builtin_sqrtf)
270   if test $use_builtin_sqrtf = "yes"; then
271     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_SQRTF)
272   fi
273 ])
274
275
276 dnl Check to see what architecture we are compiling for. If it's
277 dnl supported, use special hand-crafted routines to provide thread
278 dnl primitives. Also, if architecture-specific flags are required for 
279 dnl compilation, add them here.
280 dnl 
281 dnl Depending on what is found, select configure/cpu/*/bits/atomicity.h 
282 dnl If not found, select configure/cpu/generic/bits/atomicity.h
283 dnl
284 dnl GLIBCPP_CHECK_CPU
285 AC_DEFUN(GLIBCPP_CHECK_CPU, [
286     AC_MSG_CHECKING([for cpu primitives directory])
287     CPUFLAGS=                   
288     case "$target_cpu" in
289       alpha*)
290         cpu_include_dir="config/cpu/alpha"
291         ;;
292       arm*)
293         cpu_include_dir="config/cpu/arm"
294         ;;
295       i386)
296         cpu_include_dir="config/cpu/i386"
297         ;;
298       i486 | i586 | i686 | i786)
299         cpu_include_dir="config/cpu/i486"
300         ;;
301       powerpc | rs6000)
302         cpu_include_dir="config/cpu/powerpc"
303         CPUFLAGS='-mcpu=powerpc'
304         ;;
305       sparc64 | ultrasparc)
306         cpu_include_dir="config/cpu/sparc/sparc64"
307         ;;
308       sparc*)
309         cpu_include_dir="config/cpu/sparc/sparc32"
310         ;;
311       *)
312         cpu_include_dir="config/cpu/generic"
313         ;;
314     esac
315     AC_MSG_RESULT($cpu_include_dir)
316     AC_SUBST(cpu_include_dir)
317     AC_SUBST(CPUFLAGS)
318 ])
319
320  
321 dnl
322 dnl Check to see what the underlying c library's interface to ctype looks
323 dnl like. Bits of locale rely on things like isspace, toupper, etc. This
324 dnl stuff makes sure the right bits from the clibrary get called.
325 dnl 
326 dnl Depending on what is found, select various configure/*/bits/ctype_base.h 
327 dnl Depending on what is found, select various configure/*/ctype.cc
328 dnl
329 dnl GLIBCPP_CHECK_CTYPE
330 AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
331   AC_CHECK_HEADER(ctype.h, [
332     
333     dnl If doesn't match any specified, go with defaults.
334     ctype_default=yes
335
336     dnl Test for <ctype> functionality -- gnu-linux
337     AC_MSG_CHECKING([<ctype> for gnu-linux ])
338     AC_TRY_COMPILE([#include <ctype.h>],
339     [int
340     foo (int a)
341     { return _ISspace + _ISprint + _IScntrl + _ISupper + _ISlower + _ISalpha \
342         + _ISdigit + _ISpunct + _ISxdigit + _ISalnum + _ISgraph \
343         + __ctype_tolower[a] + __ctype_toupper[a] + __ctype_b[a];}], \
344     ctype_linux=yes, ctype_linux=no)
345     AC_MSG_RESULT($ctype_linux)
346     if test $ctype_linux = "yes"; then
347       ctype_include_dir="config/gnu-linux"
348       ctype_default=no
349     fi
350
351     dnl Test for <ctype> functionality -- FreeBSD 4.0
352     if test $ctype_default = "yes"; then
353     AC_MSG_CHECKING([<ctype> for freebsd 4.0 ])
354     AC_TRY_COMPILE([#include <ctype.h>],
355     [int
356     foo (int a)
357     { return _CTYPE_S + _CTYPE_R + _CTYPE_C + _CTYPE_U + _CTYPE_L + _CTYPE_A \
358         + _CTYPE_D + _CTYPE_P + _CTYPE_X + _CTYPE_G ;}], \
359     ctype_bsd=yes, ctype_bsd=no)
360     AC_MSG_RESULT($ctype_bsd)
361     if test $ctype_bsd = "yes"; then
362       ctype_include_dir="config/bsd"
363       ctype_default=no
364     fi
365     fi
366
367     dnl Test for <ctype> functionality -- FreeBSD 3.4
368     if test $ctype_default = "yes"; then
369     AC_MSG_CHECKING([<ctype> for freebsd 3.4 ])
370     AC_TRY_COMPILE([#include <ctype.h>],
371     [int
372     foo (int a)
373     { return _S + _R + _C + _U + _L + _A \
374       + _D + _P + _X + _G + __istype (a, 0);}], \
375     ctype_freebsd34=yes, ctype_freebsd34=no)
376     AC_MSG_RESULT($ctype_freebsd34)
377     if test $ctype_freebsd34 = "yes"; then
378       ctype_include_dir="config/bsd"
379       ctype_default=no
380     fi
381     fi
382
383     dnl Test for <ctype> functionality -- solaris 2.6 and 2.7
384     if test $ctype_default = "yes"; then
385     AC_MSG_CHECKING([<ctype> for solaris 2.[6,7,8] ])
386     AC_TRY_COMPILE([#include <ctype.h>],
387     [int
388     foo (int a)
389     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
390         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
391         + __trans_lower[a] + __trans_upper[a] + __ctype_mask[a];}], \
392     ctype_solaris=yes, ctype_solaris=no)
393     AC_MSG_RESULT($ctype_solaris)
394
395     if test $ctype_solaris = "yes"; then
396       AC_MSG_CHECKING([  for version])
397       AC_LANG_CPLUSPLUS 
398       AC_TRY_COMPILE([#include <ctype.h>],
399       [typedef long* __to_type; __to_type const& _M_toupper = __trans_upper;],\
400       ctype_solaris26=yes, ctype_solaris26=no)
401       AC_LANG_C
402       if test $ctype_solaris26 = "yes"; then
403         ctype_include_dir="config/solaris/solaris2.6"
404         AC_MSG_RESULT("solaris2.6")
405         ctype_default=no
406       else
407         ctype_include_dir="config/solaris/solaris2.7"
408         AC_MSG_RESULT("solaris2.[7,8]")
409         ctype_default=no
410       fi
411     fi
412     fi  
413
414     dnl Test for <ctype> functionality -- solaris 2.5.1
415     if test $ctype_default = "yes"; then
416     AC_MSG_CHECKING([<ctype> for solaris 2.5.1 ])
417     AC_TRY_COMPILE([#include <ctype.h>],
418     [int
419     foo (int a)
420     { return _U + _L + _N + _S + _P + _C + _X + _B \
421         + __ctype[a];}], \
422     ctype_solaris25=yes, ctype_solaris25=no)
423     AC_MSG_RESULT($ctype_solaris25)
424     if test $ctype_solaris25 = "yes"; then
425       ctype_include_dir="config/solaris/solaris2.5"
426       ctype_default=no
427     fi
428     fi
429
430     dnl Test for <ctype> functionality -- aix
431     if test $ctype_default = "yes"; then
432     AC_MSG_CHECKING([<ctype> for aix ])
433     AC_TRY_COMPILE([#include <ctype.h>],
434     [int
435     foo (int a)
436     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
437         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
438         + _VALC('a') + _IS('c', 0);}], \
439     ctype_aix=yes, ctype_aix=no)
440     AC_MSG_RESULT($ctype_aix)
441     if test $ctype_aix = "yes"; then
442       ctype_include_dir="config/aix"
443       ctype_default=no
444     fi
445     fi
446
447     dnl Test for <ctype> functionality -- newlib
448     if test $ctype_default = "yes"; then
449     AC_MSG_CHECKING([<ctype> for newlib ])
450     AC_TRY_COMPILE([#include <ctype.h>],
451     [int
452     foo (int a)
453     { return _U + _L + _N + _S + _P + _C + _X + _B \
454         + _ctype_[a];}], \
455     ctype_newlib=yes, ctype_newlib=no)
456     AC_MSG_RESULT($ctype_newlib)
457     if test $ctype_newlib = "yes"; then
458       ctype_include_dir="config/newlib"
459       ctype_default=no
460     fi
461     fi
462
463     if test $ctype_default = "yes"; then
464       ctype_include_dir="config/generic"
465       AC_MSG_WARN("Using default ctype headers.")
466     fi
467     AC_SUBST(ctype_include_dir)
468   ])
469 ])
470
471
472 dnl
473 dnl Check to see what the underlying c library or math library is like.
474 dnl
475 dnl Define HAVE_CARGF etc if "cargf" is found.
476 dnl
477 dnl GLIBCPP_CHECK_MATH_SUPPORT
478 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
479   AC_CHECK_LIB(m, sin, libm="-lm")
480   save_LIBS="$LIBS"
481   LIBS="$LIBS $libm"
482
483   dnl Check for complex versions of math functions of platform.
484   AC_CHECK_HEADERS([complex.h])
485   AC_REPLACE_MATHFUNCS(ccos ccosf ccosh ccoshf cexp cexpf c_log c_logf \
486   clog10 clog10f cpow cpowf csin csinf csinh csinhf csqrt csqrtf \
487   ctan ctanf ctanh ctanhf \
488   carg cargf nan hypot hypotf atan2f expf copysignf)
489
490   dnl We compile the long double complex functions only if the function 
491   dnl provides the non-complex long double functions.
492   USE_LONG_DOUBLE=no
493   AC_CHECK_FUNC(copysignl,
494   USE_LONG_DOUBLE=yes
495   AC_REPLACE_MATHFUNCS(ccoshl ccosl cexpl cpowl csinhl csinl \
496   csqrtl ctanhl ctanl cargl hypotl signbitl c_logl clog10l))
497   AC_SUBST(USE_LONG_DOUBLE)
498
499   dnl Check to see if basic C math functions have faster float versions.
500   AC_CHECK_FUNCS(modf isnan isnanf isnanl isinf isinff isinfl copysign \
501   copysignl cosf coshf logf log10f powf sinf sinhf sqrtf tanf tanhf \
502   strtof strtold fabsf sincos sincosf sincosl finite finite fqfinite \
503   fpclass qfpclass)
504
505 #Some runtimes have these functions with a preceding underscore. Please
506 # keep this sync'd with the one above. And if you add any new symbol,
507 # please add the corresponding block in the @BOTTOM@ section of
508 # acconfig.h.
509 AC_CHECK_FUNCS(_modf _isnan _isnanf _isnanl _isinf _isinff _isinfl _copysign \
510 _copysignl _cosf _coshf _logf _log10f _powf _sinf _sinhf _sqrtf _tanf _tanhf \
511 _strtof _strtold _fabsf _sincos _sincosf _sincosl _finite _finitef _qfinite \
512 _fpclass _qfpclass)
513
514 LIBS="$save_LIBS"
515 ])
516
517
518 dnl
519 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
520 dnl
521 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
522 dnl Define _GLIBCPP_NEED_MBSTATE_T if mbstate_t is not in wchar.h
523 dnl Define _GLIBCPP_HAS_WCHAR_MIN_MAX if WCHAR_MIN, WCHAR_MAX in wchar.h
524 dnl
525 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
526 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
527   AC_CHECK_HEADER(wchar.h,[
528   dnl Test wchar.h for mbstate_t, which is needed for char_traits and others.
529   AC_MSG_CHECKING([for native mbstate_t])
530   AC_TRY_COMPILE([#include <wchar.h>],
531   [mbstate_t teststate;], 
532   use_native_mbstatet=yes, use_native_mbstatet=no)
533   AC_MSG_RESULT($use_native_mbstatet)
534   if test $use_native_mbstatet = "no"; then
535     AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
536   fi
537   
538   dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
539   dnl numeric_limits can instantiate type_traits<wchar_t>
540   AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
541   AC_TRY_COMPILE([#include <wchar.h>],
542   [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
543   has_wchar_minmax=yes, has_wchar_minmax=no)
544   AC_MSG_RESULT($has_wchar_minmax)
545   if test $has_wchar_minmax = "yes"; then
546     AC_DEFINE(_GLIBCPP_HAS_WCHAR_MIN_MAX)
547   fi
548   
549   # Test wchar.h for WEOF, which is what we use to determine whether
550   # to specialize for wchar_t or not.
551   AC_MSG_CHECKING([for WEOF])
552   AC_TRY_COMPILE([
553     #include <wchar.h>
554     #include <stddef.h>],
555   [wint_t i = WEOF;],
556   has_weof=yes, has_weof=no)
557   AC_MSG_RESULT($has_weof)
558
559   dnl Tests for wide character functions.
560   AC_REPLACE_STRINGFUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset)
561   AC_SUBST(libinst_wstring_la)
562
563   AC_MSG_CHECKING([for wide character support])
564   if test $has_weof = "yes" && test $has_wchar_minmax = "yes"; then
565     libinst_wstring_la="libinst-wstring.la"
566     AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
567     AC_MSG_RESULT(ok)
568   else
569     libinst_wstring_la=""
570     AC_MSG_RESULT("not specializing for wchar_t")
571   fi
572   ],[
573   AC_MSG_WARN([<wchar.h> not found])
574   AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
575   ])
576 ])
577
578
579 dnl
580 dnl Check to see if this version of GNU C++ is afflicted by bugs in
581 dnl __complex__ float support.
582 dnl
583 dnl Define _GLIBCPP_BUGGY_FLOAT_COMPLEX if buggy.
584 dnl
585 dnl GLIBCPP_CHECK_COMPLEX_FLOAT_SUPPORT
586 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_FLOAT_SUPPORT, [
587   AC_REQUIRE([AC_PROG_CXX])
588   AC_MSG_CHECKING([for GNU C++ __complex__ float support])
589   AC_CACHE_VAL(glibcpp_cv_float_complex, [
590     AC_LANG_SAVE
591     AC_LANG_CPLUSPLUS
592     rm -f conftest.h
593     cat > conftest.h <<EOB
594       //
595       // Check for buggy __complex__ that causes ICE in most versions of egcs
596       // and gcc-2.95.x on certain platforms (eg., x86-win32).
597       //
598       // See http://egcs.cygnus.com/ml/gcc-bugs/1999-07/msg00845.html for
599       // more info on the bug itself.
600       //
601       struct
602       float_complex
603       {
604        __complex__ float m_value;
605        float_complex (float = 0.0f, float = 0.0f);
606        float_complex (__complex__ float val) : m_value (val) {}
607        float_complex foo (const float_complex &val)
608          { return float_complex (~val.m_value); }
609       };
610 EOB
611     AC_TRY_COMPILE([#include "conftest.h"], ,
612       glibcpp_cv_float_complex=ok,
613       glibcpp_cv_float_complex=buggy
614     )
615     AC_LANG_RESTORE
616   ])
617   AC_MSG_RESULT($glibcpp_cv_float_complex)
618   if test $glibcpp_cv_float_complex = buggy; then
619     AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
620   fi
621 ])
622
623
624 dnl
625 dnl 
626 dnl Check to see if this version of GNU C++ is afflicted by bugs in 
627 dnl __complex__ support.Check for buggy __complex__ that will cause ICE in
628 dnl gcc-2.95.x when using the library, unless we define the default copy
629 dnl ctor in the specializations of complex<>. 
630 dnl 
631 dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
632 dnl
633 dnl GLIBCPP_CHECK_COMPLEX_SUPPORT
634 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_SUPPORT, [
635   AC_REQUIRE([AC_PROG_CXX])
636   AC_MSG_CHECKING([for GNU C++ __complex__ support])
637   AC_CACHE_VAL(glibcpp_cv_complex, [
638     AC_LANG_SAVE
639     AC_LANG_CPLUSPLUS
640     AC_TRY_COMPILE([struct dcomplex { __complex__ double x; }; \
641                     dcomplex f(const dcomplex& x) { return dcomplex(x); }], \
642                     [ dcomplex x; f(x); ],
643       glibcpp_cv_complex=ok,
644       glibcpp_cv_complex=buggy
645     )
646     AC_LANG_RESTORE
647   ])
648   AC_MSG_RESULT($glibcpp_cv_complex)
649   if test $glibcpp_cv_complex = buggy; then
650     AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
651   fi
652 ])
653
654
655 dnl
656 dnl Check for special debugging mode; not for production use.
657 dnl
658 dnl GLIBCPP_ENABLE_DEBUG
659 dnl --enable-debug sets '-ggdb -O0'.
660 dnl --disable-debug sets '-g' and whatever optimization options the
661 dnl     compiler can handle.
662 dnl  +  Perhaps --enable-maintainer-mode should automatically turn this on?
663 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
664 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
665 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
666 dnl       defaults to `no'.
667 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
668 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
669 AC_ARG_ENABLE(debug,
670 changequote(<<, >>)dnl
671 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
672 changequote([, ])dnl
673 [case "$enableval" in
674  yes) enable_debug=yes ;;
675  no)  enable_debug=no ;;
676  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
677  esac],
678 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
679 dnl Option parsed, now set things appropriately
680 case "$enable_debug" in
681     yes) 
682         DEBUGFLAGS='-O0 -ggdb'                  
683         ;;
684     no)   
685         DEBUGFLAGS='-g'
686         ;;
687 esac
688 AC_SUBST(DEBUGFLAGS)
689 ])
690
691
692 dnl
693 dnl Check for "unusual" flags to pass to the compiler while building.
694 dnl
695 dnl GLIBCPP_ENABLE_CXX_FLAGS
696 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
697 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
698 dnl     Somehow this same set of flags must be passed when [re]building
699 dnl     libgcc.
700 dnl --disable-cxx-flags passes nothing.
701 dnl  +  See http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00131.html
702 dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q2/msg00284.html
703 dnl         http://sourceware.cygnus.com/ml/libstdc++/2000-q1/msg00035.html
704 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
705 dnl       If "default flags" is an empty string (or "none"), the effect is
706 dnl       the same as --disable or --enable=no.
707 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
708 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
709 AC_ARG_ENABLE(cxx-flags,
710 changequote(<<, >>)dnl
711 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
712                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
713 changequote([, ])dnl
714 [case "x$enableval" in
715  xyes)   AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
716  xno|x)  enable_cxx_flags='' ;;
717  *)      enable_cxx_flags="$enableval" ;;
718  esac],
719 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')dnl
720 dnl Thinko on my part during design.  This kludge is the workaround.
721 if test "$enable_cxx_flags" = "none"; then enable_cxx_flags=''; fi
722 dnl Run through flags (either default or command-line) and set anything
723 dnl extra (e.g., #defines) that must accompany particular g++ options.
724 if test -n "$enable_cxx_flags"; then
725     for f in $enable_cxx_flags; do
726         case "$f" in
727             -fhonor-std)  ;;
728             -*)  ;;
729             *)   # and we're trying to pass /what/ exactly?
730                  AC_MSG_ERROR([compiler flags start with a -]) ;;
731         esac
732     done
733 fi
734 EXTRA_CXX_FLAGS="$enable_cxx_flags"
735 AC_SUBST(EXTRA_CXX_FLAGS)
736 ])
737
738
739 dnl
740 dnl Check for instructions to automatically rebuild libgcc.a.  Requires,
741 dnl of course, the location of the gcc objdir.  Note that if --disable-
742 dnl namespaces is in effect, rebuilding libgcc.a is an expensive no-op.
743 dnl
744 dnl GLIBCPP_ENABLE_RELIBGCC
745 dnl --enable-libgcc-rebuild=/absolute/path/to/gcc/objdir sets GCC_OBJDIR
746 dnl     (presumably in the top-level Makefile) to /absol.../objdir
747 dnl --disable-libgcc-rebuild will not touch libgcc.a at all (maybe print
748 dnl     a warning if this is given along with --enable-namespaces), by
749 dnl     setting GCC_OBJDIR to `no'.
750 dnl  +  Doing this by default is going to be interesting.  What default
751 dnl     "on" value can there be?
752 dnl  +  Usage:  GLIBCPP_ENABLE_RELIBGCC[(DEFAULT)]
753 dnl       The default path should be ../.. if bundled with GCC source.
754 dnl       If ommitted, it defaults to `no'.
755 dnl
756 AC_DEFUN(GLIBCPP_ENABLE_RELIBGCC, [dnl
757 define([GLIBCPP_ENABLE_RELIBGCC_DEFAULT], ifelse($1,, no, $1))dnl
758 AC_ARG_ENABLE(libgcc-rebuild,
759 changequote(<<, >>)dnl
760 <<  --enable-libgcc-rebuild=DIR     also rebuild libgcc.a; DIR is
761                                   the GCC objdir; see install.html>>,
762 changequote([, ])dnl
763 [case "$enableval" in
764  yes) AC_MSG_ERROR([--enable-libgcc-rebuild needs a pathname]) ;;
765  no)  enable_libgcc_rebuild=no ;;
766  *)   if test -d "$enableval" && test -d "${enableval}/gcc" && \
767          test -d "${enableval}/libiberty"
768       then
769          enable_libgcc_rebuild="$enableval"
770       else
771          AC_MSG_ERROR(["$enableval" does not appear to be the GCC objdir])
772       fi
773       ;;
774  esac],
775 enable_libgcc_rebuild=GLIBCPP_ENABLE_RELIBGCC_DEFAULT)dnl
776 GCC_OBJDIR="$enable_libgcc_rebuild"
777 AC_SUBST(GCC_OBJDIR)
778 ])
779
780
781 dnl
782 dnl Check for which I/O library to use:  libio, or something specific.
783 dnl
784 dnl GLIBCPP_ENABLE_CSTDIO
785 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
786 dnl 
787 dnl default is libio
788 dnl
789 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
790   AC_MSG_CHECKING([for cstdio to use])
791   AC_ARG_ENABLE(cstdio,
792   [  --enable-cstdio         enable GNU libio for target io package. (default)
793   --enable-cstdio=LIB     use LIB target-speific io package.], 
794   if test x$enable_cstdio = xno; then
795     enable_cstdio=libio
796   fi,
797      enable_cstdio=libio)
798
799   enable_cstdio_flag=$enable_cstdio
800
801   dnl Check if a valid thread package
802   case x${enable_cstdio_flag} in
803         xlibio | x | xno | xnone | xyes)
804                 # default
805                 CSTDIO_H=c_io_libio.h
806                 CSTDIO_CC=c_io_libio.cc
807                 AC_MSG_RESULT(libio)
808
809                 # see if we are on a system with libio native (ie, linux)
810                 AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
811                 if test $has_libio = "yes"; then
812                   BUILD_LIBIO_INCLUDE=
813                   need_libio=no
814                 else
815                   BUILD_LIBIO_INCLUDE='-I../libio'
816                   need_libio=yes
817                 fi
818                 AC_SUBST(BUILD_LIBIO_INCLUDE)
819
820                 # see if the _G_config.h header needs to be built. 
821                 # NB: This replaces the _G_CONFIG_H machinery in libio-v2
822                 AC_CHECK_HEADER(_G_config.h,  has_gconf_h=yes, has_gconf_h=no)
823                 AM_CONDITIONAL(GLIBCPP_NEED_LIBIO_CONFIG_H, test "$has_gconf_h" = no)
824                 ;;
825         xwince)
826                 CSTDIO_H=c_io_wince.h
827                 CSTDIO_CC=c_io_wince.cc
828                 AC_MSG_RESULT(wince)
829
830                 need_libio=no
831                 BUILD_LIBIO_INCLUDE=
832                 AC_SUBST(BUILD_LIBIO_INCLUDE)
833                 ;;
834         *)
835                 echo "$enable_cstdio is an unknown io package" 1>&2
836                 exit 1
837                 ;;
838   esac
839   AC_SUBST(CSTDIO_H)
840   AC_SUBST(CSTDIO_CC)
841   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
842 ])
843
844
845 dnl
846 dnl Check for which threading library to use.
847 dnl
848 dnl GLIBCPP_ENABLE_THREADS
849 dnl --enable-threads=posix sets config/threads-posix.h et. al.
850 dnl 
851 dnl default is no threads
852 dnl
853 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
854   dnl Note this comes from the gcc/config.in and libjava/config.in
855   dnl Efforts should be made to keep this in sync.
856   AC_MSG_CHECKING([for threads package to use])
857   AC_ARG_ENABLE(threads,
858   [  --enable-threads        enable thread usage for target GCC.
859   --enable-threads=LIB    use LIB thread package for target GCC.],
860   if test x$enable_threads = xno; then
861     enable_threads=''
862   fi,
863     enable_threads='')
864
865   enable_threads_flag=$enable_threads
866
867   dnl Check if a valid thread package
868   case x${enable_threads_flag} in
869         x | xno | xnone)
870                 # No threads
871                 target_thread_file='single'
872                 ;;
873         xyes)
874                 # default
875                 target_thread_file=''
876                 ;;
877         xdecosf1 | xirix | xmach | xos2 | xposix | xpthreads | xsingle | \
878         xsolaris | xwin32 | xdce | xvxworks)
879                 target_thread_file=$enable_threads_flag
880                 ;;
881         *)
882                 echo "$enable_threads is an unknown thread package" 1>&2
883                 exit 1
884                 ;;
885   esac
886
887   dnl Check for thread package actually supported in libstdc++ 
888   case "$target_thread_file" in
889     no | none | single)
890       THREADS=none
891       ;;
892     posix | pthreads)
893       THREADS=posix
894       case "$host" in
895         *-*-linux*)
896         ;;
897       esac
898       ;;
899     decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
900       AC_MSG_ERROR(thread package $THREADS not yet supported)
901       ;;
902     *)
903       AC_MSG_ERROR($THREADS is an unknown thread package)
904       ;;
905   esac
906   AC_MSG_RESULT($THREADS)
907
908   THREADLIBS=
909   THREADINCS=
910   THREADDEPS=
911   THREADOBJS=
912   THREADH=
913   THREADSPEC=
914   case "$THREADS" in
915     posix)
916       AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
917       THREADLIBS=-lpthread
918       THREADSPEC=-lpthread
919       dnl Not presently used
920       dnl THREADOBJS=threads-posix.lo
921       THREADH=threads-posix.h
922       ;;
923     none)
924       dnl Not presently used
925       dnl THREADOBJS=threads-no.lo
926       THREADH=threads-no.h
927       ;;
928   esac
929   AC_SUBST(THREADLIBS)
930   AC_SUBST(THREADINCS)
931   AC_SUBST(THREADDEPS)
932   AC_SUBST(THREADOBJS)
933   AC_SUBST(THREADSPEC)
934 ])
935
936
937 dnl
938 dnl Check for template specializations for the 'long long' type extension.
939 dnl
940 dnl GLIBCPP_ENABLE_LONG_LONG
941 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
942 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
943 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
944 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
945 dnl       defaults to `no'.
946 dnl
947 dnl GLIBCPP_ENABLE_LONG_LONG
948 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
949   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
950   AC_MSG_CHECKING([for enabled long long])
951   AC_ARG_ENABLE(long-long,
952   changequote(<<, >>)dnl
953   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
954   changequote([, ])dnl
955   [case "$enableval" in
956    yes) enable_long_long=yes ;;
957    no)  enable_long_long=no ;;
958    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
959    esac],
960   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
961   AC_MSG_RESULT($enable_long_long)
962   dnl Option parsed, now set things appropriately
963   case "$enable_long_long" in
964     yes)  AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
965           ;;
966   esac
967 ])
968
969
970 dnl
971 dnl Check for whether or not to do shadowed C headers.
972 dnl
973 dnl GLIBCPP_ENABLE_SHADOW
974 dnl --enable-cshadow-headers [does stuff].
975 dnl --disable-cshadow-headers [does not do stuff].
976 dnl  +  This will eventually need to be on by default.
977 dnl  +  Usage:  GLIBCPP_ENABLE_SHADOW[(DEFAULT)]
978 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
979 dnl       defaults to `no'.
980 AC_DEFUN(GLIBCPP_ENABLE_SHADOW, [dnl
981 define([GLIBCPP_ENABLE_SHADOW_DEFAULT], ifelse($1, yes, yes, no))dnl
982 AC_MSG_CHECKING([for enabled cshadow headers])
983 AC_ARG_ENABLE(cshadow-headers,
984 changequote(<<, >>)dnl
985 <<  --enable-cshadow-headers construct "shadowed" C header files for
986                            g++ [default=>>GLIBCPP_ENABLE_SHADOW_DEFAULT],
987 changequote([, ])dnl
988 [case "$enableval" in
989  yes) enable_cshadow_headers=yes 
990         ;;
991  no)  enable_cshadow_headers=no 
992         ;;
993  *)   AC_MSG_ERROR([Unknown argument to enable/disable shadowed C headers]) 
994         ;;
995  esac],
996 enable_cshadow_headers=GLIBCPP_ENABLE_SHADOW_DEFAULT)dnl
997 AC_MSG_RESULT($enable_cshadow_headers)
998 dnl Option parsed, now set things appropriately
999 case "$enable_cshadow_headers" in
1000     yes) 
1001         SHADOW_INCLUDES="-I$srcdir/shadow -I$blddir/cshadow"
1002         $srcdir/inclosure "-I $blddir/../../gcc/include/ -I /usr/include/ -G machine/ansi.h" | $srcdir/mkcshadow
1003         ;;
1004     no)   
1005         SHADOW_INCLUDES=''
1006         ;;
1007 esac
1008 # SHADOW_INCLUDES is currently not used anywhere in the source
1009 AC_SUBST(SHADOW_INCLUDES)
1010 ])
1011
1012
1013 # Check whether LC_MESSAGES is available in <locale.h>.
1014 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1015 #
1016 # This file file be copied and used freely without restrictions.  It can
1017 # be used in projects which are not available under the GNU Public License
1018 # but which still want to provide support for the GNU gettext functionality.
1019 # Please note that the actual code is *not* freely available.
1020
1021 # serial 1
1022
1023 AC_DEFUN(AC_LC_MESSAGES,
1024   [if test $ac_cv_header_locale_h = yes; then
1025     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
1026       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1027        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
1028     if test $ac_cv_val_LC_MESSAGES = yes; then
1029       AC_DEFINE(HAVE_LC_MESSAGES)
1030     fi
1031   fi])
1032
1033
1034 # Check for functions in math library.
1035 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1036 #
1037 # This file can be copied and used freely without restrictions.  It can
1038 # be used in projects which are not available under the GNU Public License
1039 # but which still want to provide support for the GNU gettext functionality.
1040 # Please note that the actual code is *not* freely available.
1041
1042 # serial 1
1043
1044 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1045 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1046 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1047 AC_SUBST(LIBMATHOBJS)dnl
1048 ])
1049
1050
1051 # Check for string functions.
1052 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1053 #
1054 # This file can be copied and used freely without restrictions.  It can
1055 # be used in projects which are not available under the GNU Public License
1056 # but which still want to provide support for the GNU gettext functionality.
1057 # Please note that the actual code is *not* freely available.
1058
1059 # serial 1
1060
1061 dnl AC_REPLACE_STRINGFUNCS(FUNCTION...)
1062 AC_DEFUN(AC_REPLACE_STRINGFUNCS,
1063 [AC_CHECK_FUNCS([$1], , [LIBSTRINGOBJS="$LIBSTRINGOBJS ${ac_func}.lo"])
1064 AC_SUBST(LIBSTRINGOBJS)dnl
1065 ])