OSDN Git Service

* index-prop: Fix occasional problem when using cvs diff -p
[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. 
158 dnl
159 dnl Define OPTLEVEL='-O2' if new inlining code present.
160 dnl
161 dnl GLIBCPP_CHECK_COMPILER_VERSION
162 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
163   AC_MSG_CHECKING([for g++ that will successfullly 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   AC_MSG_CHECKING([for g++ that supports new inlining mechanism])
172   AC_EGREP_CPP([ok], [
173   #if  __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
174     ok
175   #endif
176   ], [OPTLEVEL='-O2'
177       WERRORSUPPRESS=
178   ], [OPTLEVEL=
179       WERRORSUPPRESS=-Wno-error
180   ])
181   if test "$OPTLEVEL" = ""; then
182     AC_MSG_RESULT(no)
183   else
184     AC_MSG_RESULT(yes)
185   fi
186   AC_SUBST(OPTLEVEL)
187   AC_SUBST(WERRORSUPPRESS)
188 ])
189
190
191 dnl
192 dnl Check to see what builtin math functions are supported
193 dnl
194 dnl Define _GLIBCPP_HAS_BUILTIN_SINF if __builtin_sinf
195 dnl Define _GLIBCPP_HAS_BUILTIN_COSF if __builtin_cosf
196 dnl Define _GLIBCPP_HAS_BUILTIN_FABSF if __builtin_fabsf
197 dnl Define _GLIBCPP_HAS_BUILTIN_SQRTF if __builtin_sqrtf
198 dnl
199 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
200 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
201   dnl Test for builtin math functions.
202   AC_MSG_CHECKING([for __builtin_sinf])
203   AC_TRY_COMPILE([#include <math.h>], 
204   [float foo(void) { __builtin_sinf(0.0); }], 
205   use_builtin_sinf=yes, use_builtin_sinf=no)
206   AC_MSG_RESULT($use_builtin_sinf)
207   if test $use_builtin_sinf = "yes"; then
208     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_SINF)
209   fi
210
211   AC_MSG_CHECKING([for __builtin_cosf])
212   AC_TRY_COMPILE([#include <math.h>], 
213   [float foo(void) { __builtin_cosf(0.0); }], 
214   use_builtin_cosf=yes, use_builtin_cosf=no)
215   AC_MSG_RESULT($use_builtin_cosf)
216   if test $use_builtin_cosf = "yes"; then
217     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_COSF)
218   fi
219
220   AC_MSG_CHECKING([for __builtin_fabsf])
221   AC_TRY_COMPILE([#include <math.h>], 
222   [float foo(void) { __builtin_fabsf(0.0); }], 
223   use_builtin_fabsf=yes, use_builtin_fabsf=no)
224   AC_MSG_RESULT($use_builtin_fabsf)
225   if test $use_builtin_fabsf = "yes"; then
226     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_FABSF)
227   fi
228
229   AC_MSG_CHECKING([for __builtin_sqrtf])
230   AC_TRY_COMPILE([#include <math.h>], 
231   [float foo(void) { __builtin_sqrtf(0.0); }], 
232   use_builtin_sqrtf=yes, use_builtin_sqrtf=no)
233   AC_MSG_RESULT($use_builtin_sqrtf)
234   if test $use_builtin_sqrtf = "yes"; then
235     AC_DEFINE(_GLIBCPP_HAS_BUILTIN_SQRTF)
236   fi
237 ])
238
239
240 dnl
241 dnl Check to see what architecture we are compiling for. If it's
242 dnl supported, use special hand-crafted routines to provide thread
243 dnl primitives.
244 dnl 
245 dnl Depending on what is found, select various configure/cpu/*/atomicity.h 
246 dnl If not found, select configure/cpu/generic/atomicity.h
247 dnl
248 dnl GLIBCPP_CHECK_CPU
249 AC_DEFUN(GLIBCPP_CHECK_CPU, [
250     AC_MSG_CHECKING([for cpu primitives directory])
251     case "$target_cpu" in
252       alpha*)
253         cpu_include_dir="config/cpu/alpha"
254         ;;
255       arm*)
256         cpu_include_dir="config/cpu/arm"
257         ;;
258       i486 | i586 | i686 | i786)
259         cpu_include_dir="config/cpu/i386"
260         ;;
261       powerpc | rs6000)
262         cpu_include_dir="config/cpu/powerpc"
263         ;;
264       sparc64 | ultrasparc)
265         cpu_include_dir="config/cpu/sparc/sparc64"
266         ;;
267       sparc*)
268         cpu_include_dir="config/cpu/sparc/sparc32"
269         ;;
270       *)
271         cpu_include_dir="config/cpu/generic"
272         ;;
273     esac
274     AC_MSG_RESULT($cpu_include_dir)
275     AC_SUBST(cpu_include_dir)
276 ])
277
278  
279 dnl
280 dnl Check to see what the underlying c library's interface to ctype looks
281 dnl like. Bits of locale rely on things like isspace, toupper, etc. This
282 dnl stuff makes sure the right bits from the clibrary get called.
283 dnl 
284 dnl Depending on what is found, select various configure/*/bits/ctype_base.h 
285 dnl Depending on what is found, select various configure/*/ctype.cc
286 dnl
287 dnl GLIBCPP_CHECK_CTYPE
288 AC_DEFUN(GLIBCPP_CHECK_CTYPE, [
289   AC_CHECK_HEADER(ctype.h, [
290     
291     dnl If doesn't match any specified, go with defaults.
292     ctype_default=yes
293
294     dnl Test for <ctype> functionality -- gnu-linux
295     AC_MSG_CHECKING([for gnu-linux <ctype>])
296     AC_TRY_COMPILE([#include <ctype.h>],
297     [int
298     foo (int a)
299     { return _ISspace + _ISprint + _IScntrl + _ISupper + _ISlower + _ISalpha \
300         + _ISdigit + _ISpunct + _ISxdigit + _ISalnum + _ISgraph \
301         + __ctype_tolower[a] + __ctype_toupper[a] + __ctype_b[a];}], \
302     ctype_linux=yes, ctype_linux=no)
303     AC_MSG_RESULT($ctype_linux)
304     if test $ctype_linux = "yes"; then
305       ctype_include_dir="config/gnu-linux"
306       ctype_default=no
307     fi
308
309     dnl Test for <ctype> functionality -- solaris 2.6 and 2.7
310     if test $ctype_default = "yes"; then
311     AC_MSG_CHECKING([for solaris 2.6 or 2.7 <ctype>])
312     AC_TRY_COMPILE([#include <ctype.h>],
313     [int
314     foo (int a)
315     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
316         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
317         + __trans_lower[a] + __trans_upper[a] + __ctype_mask[a];}], \
318     ctype_solaris=yes, ctype_solaris=no)
319     AC_MSG_RESULT($ctype_solaris)
320
321     if test $ctype_solaris = "yes"; then
322       AC_MSG_CHECKING([  for version])
323       AC_LANG_CPLUSPLUS 
324       AC_TRY_COMPILE([#include <ctype.h>],
325       [typedef long* __to_type; __to_type const& _M_toupper = __trans_upper;],\
326       ctype_solaris26=yes, ctype_solaris26=no)
327       AC_LANG_C
328       if test $ctype_solaris26 = "yes"; then
329         ctype_include_dir="config/solaris/solaris2.6"
330         AC_MSG_RESULT("solaris2.6")
331         ctype_default=no
332       else
333         ctype_include_dir="config/solaris/solaris2.7"
334         AC_MSG_RESULT("solaris2.7")
335         ctype_default=no
336       fi
337     fi
338     fi  
339
340     dnl Test for <ctype> functionality -- solaris 2.5.1
341     if test $ctype_default = "yes"; then
342     AC_MSG_CHECKING([for solaris 2.5.1 <ctype>])
343     AC_TRY_COMPILE([#include <ctype.h>],
344     [int
345     foo (int a)
346     { return _U + _L + _N + _S + _P + _C + _X + _B \
347         + __ctype[a];}], \
348     ctype_solaris25=yes, ctype_solaris25=no)
349     AC_MSG_RESULT($ctype_solaris25)
350     if test $ctype_solaris25 = "yes"; then
351       ctype_include_dir="config/solaris/solaris2.5"
352       ctype_default=no
353     fi
354     fi
355
356     dnl Test for <ctype> functionality -- aix
357     if test $ctype_default = "yes"; then
358     AC_MSG_CHECKING([for aix <ctype>])
359     AC_TRY_COMPILE([#include <ctype.h>],
360     [int
361     foo (int a)
362     { return _ISSPACE + _ISPRINT + _ISCNTRL + _ISUPPER + _ISLOWER + _ISALPHA \
363         + _ISDIGIT + _ISPUNCT + _ISXDIGIT + _ISALNUM + _ISGRAPH \
364         + _VALC('a') + _IS('c', 0);}], \
365     ctype_aix=yes, ctype_aix=no)
366     AC_MSG_RESULT($ctype_aix)
367     if test $ctype_aix = "yes"; then
368       ctype_include_dir="config/aix"
369       ctype_default=no
370     fi
371     fi
372
373     dnl Test for <ctype> functionality -- newlib
374     if test $ctype_default = "yes"; then
375     AC_MSG_CHECKING([for newlib <ctype>])
376     AC_TRY_COMPILE([#include <ctype.h>],
377     [int
378     foo (int a)
379     { return _U + _L + _N + _S + _P + _C + _X + _B \
380         + _ctype_[a];}], \
381     ctype_newlib=yes, ctype_newlib=no)
382     AC_MSG_RESULT($ctype_newlib)
383     if test $ctype_newlib = "yes"; then
384       ctype_include_dir="config/newlib"
385       ctype_default=no
386     fi
387     fi
388
389     if test $ctype_default = "yes"; then
390       ctype_include_dir="config/generic"
391       AC_MSG_WARN("Using default ctype headers.")
392     fi
393     AC_SUBST(ctype_include_dir)
394   ])
395 ])
396
397
398 dnl
399 dnl Check to see what the underlying c library or math library is like.
400 dnl
401 dnl Define HAVE_CARGF etc if "cargf" is found.
402 dnl
403 dnl GLIBCPP_CHECK_MATH_SUPPORT
404 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
405   AC_CHECK_LIB(m, sin, libm="-lm")
406   save_LIBS="$LIBS"
407   LIBS="$LIBS $libm"
408
409   dnl Check for complex versions of math functions of platform.
410   AC_CHECK_HEADERS([complex.h])
411   AC_REPLACE_MATHFUNCS(ccos ccosf ccosh ccoshf cexp cexpf c_log c_logf \
412   clog10 clog10f cpow cpowf csin csinf csinh csinhf csqrt csqrtf \
413   ctan ctanf ctanh ctanhf \
414   carg cargf nan hypot hypotf atan2f expf copysignf)
415
416   dnl We compile the long double complex functions only if the function 
417   dnl provides the non-complex functions.
418   USE_LONG_DOUBLE=no
419   AC_CHECK_FUNC(sinl,
420   USE_LONG_DOUBLE=yes
421   AC_REPLACE_MATHFUNCS(ccoshl ccosl cexpl cpowl csinhl csinl \
422   csqrtl ctanhl ctanl cargl hypotl signbitl c_logl clog10l))
423   AC_SUBST(USE_LONG_DOUBLE)
424
425   dnl Check to see if basic C math functions have faster float versions.
426   AC_CHECK_FUNCS(modf isnan isnanf isnanl isinf isinff isinfl copysign \
427   copysignl cosf coshf logf log10f powf sinf sinhf sqrtf tanf tanhf \
428   strtof strtold fabsf sincos sincosf sincosl finite finite fqfinite \
429   fpclass qfpclass)
430
431 #Some runtimes have these functions with a preceding underscore. Please
432 # keep this sync'd with the one above. And if you add any new symbol,
433 # please add the corresponding block in the @BOTTOM@ section of
434 # acconfig.h.
435 AC_CHECK_FUNCS(_modf _isnan _isnanf _isnanl _isinf _isinff _isinfl _copysign \
436 _copysignl _cosf _coshf _logf _log10f _powf _sinf _sinhf _sqrtf _tanf _tanhf \
437 _strtof _strtold _fabsf _sincos _sincosf _sincosl _finite _finitef _qfinite \
438 _fpclass _qfpclass)
439
440 LIBS="$save_LIBS"
441 ])
442
443
444 dnl
445 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
446 dnl
447 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
448 dnl Define _GLIBCPP_NEED_MBSTATE_T if mbstate_t is not in wchar.h
449 dnl Define _GLIBCPP_HAS_WCHAR_MIN_MAX if WCHAR_MIN, WCHAR_MAX in wchar.h
450 dnl
451 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
452 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
453   AC_CHECK_HEADER(wchar.h,[
454   dnl Test wchar.h for mbstate_t, which is needed for char_traits and others.
455   AC_MSG_CHECKING([for native mbstate_t])
456   AC_TRY_COMPILE([#include <wchar.h>],
457   [mbstate_t teststate;], 
458   use_native_mbstatet=yes, use_native_mbstatet=no)
459   AC_MSG_RESULT($use_native_mbstatet)
460   if test $use_native_mbstatet = "no"; then
461     AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
462   fi
463   
464   dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
465   dnl numeric_limits can instantiate type_traits<wchar_t>
466   AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
467   AC_TRY_COMPILE([#include <wchar.h>],
468   [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
469   has_wchar_minmax=yes, has_wchar_minmax=no)
470   AC_MSG_RESULT($has_wchar_minmax)
471   if test $has_wchar_minmax = "yes"; then
472     AC_DEFINE(_GLIBCPP_HAS_WCHAR_MIN_MAX)
473   fi
474   
475   # Test wchar.h for WEOF, which is what we use to determine whether
476   # to specialize for wchar_t or not.
477   AC_MSG_CHECKING([for WEOF])
478   AC_TRY_COMPILE([
479     #include <wchar.h>
480     #include <stddef.h>],
481   [wint_t i = WEOF;],
482   has_weof=yes, has_weof=no)
483   AC_MSG_RESULT($has_weof)
484
485   dnl Tests for wide character functions.
486   AC_REPLACE_STRINGFUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset)
487   AC_SUBST(libinst_wstring_la)
488
489   AC_MSG_CHECKING([for wide character support])
490   if test $has_weof = "yes" && test $has_wchar_minmax = "yes"; then
491     libinst_wstring_la="libinst-wstring.la"
492     AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
493     AC_MSG_RESULT(ok)
494   else
495     libinst_wstring_la=""
496     AC_MSG_RESULT("not specializing for wchar_t")
497   fi
498   ],[
499   AC_MSG_WARN([<wchar.h> not found])
500   AC_DEFINE(_GLIBCPP_NEED_MBSTATE_T)
501   ])
502 ])
503
504
505 dnl
506 dnl Check to see if this version of GNU C++ is afflicted by bugs in
507 dnl __complex__ float support.
508 dnl
509 dnl Define _GLIBCPP_BUGGY_FLOAT_COMPLEX if buggy.
510 dnl
511 dnl GLIBCPP_CHECK_COMPLEX_FLOAT_SUPPORT
512 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_FLOAT_SUPPORT, [
513   AC_REQUIRE([AC_PROG_CXX])
514   AC_MSG_CHECKING([for GNU C++ __complex__ float support])
515   AC_CACHE_VAL(glibcpp_cv_float_complex, [
516     AC_LANG_SAVE
517     AC_LANG_CPLUSPLUS
518     rm -f conftest.h
519     cat > conftest.h <<EOB
520       //
521       // Check for buggy __complex__ that causes ICE in most versions of egcs
522       // and gcc-2.95.x on certain platforms (eg., x86-win32).
523       //
524       // See http://egcs.cygnus.com/ml/gcc-bugs/1999-07/msg00845.html for
525       // more info on the bug itself.
526       //
527       struct
528       float_complex
529       {
530        __complex__ float m_value;
531        float_complex (float = 0.0f, float = 0.0f);
532        float_complex (__complex__ float val) : m_value (val) {}
533        float_complex foo (const float_complex &val)
534          { return float_complex (~val.m_value); }
535       };
536 EOB
537     AC_TRY_COMPILE([#include "conftest.h"], ,
538       glibcpp_cv_float_complex=ok,
539       glibcpp_cv_float_complex=buggy
540     )
541     AC_LANG_RESTORE
542   ])
543   AC_MSG_RESULT($glibcpp_cv_float_complex)
544   if test $glibcpp_cv_float_complex = buggy; then
545     AC_DEFINE(_GLIBCPP_BUGGY_FLOAT_COMPLEX)
546   fi
547 ])
548
549
550 dnl
551 dnl 
552 dnl Check to see if this version of GNU C++ is afflicted by bugs in 
553 dnl __complex__ support.Check for buggy __complex__ that will cause ICE in
554 dnl gcc-2.95.x when using the library, unless we define the default copy
555 dnl ctor in the specializations of complex<>. 
556 dnl 
557 dnl Define _GLIBCPP_BUGGY_COMPLEX if buggy.
558 dnl
559 dnl GLIBCPP_CHECK_COMPLEX_SUPPORT
560 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_SUPPORT, [
561   AC_REQUIRE([AC_PROG_CXX])
562   AC_MSG_CHECKING([for GNU C++ __complex__ support])
563   AC_CACHE_VAL(glibcpp_cv_complex, [
564     AC_LANG_SAVE
565     AC_LANG_CPLUSPLUS
566     AC_TRY_COMPILE([struct dcomplex { __complex__ double x; }; \
567                     dcomplex f(const dcomplex& x) { return dcomplex(x); }], \
568                     [ dcomplex x; f(x); ],
569       glibcpp_cv_complex=ok,
570       glibcpp_cv_complex=buggy
571     )
572     AC_LANG_RESTORE
573   ])
574   AC_MSG_RESULT($glibcpp_cv_complex)
575   if test $glibcpp_cv_complex = buggy; then
576     AC_DEFINE(_GLIBCPP_BUGGY_COMPLEX)
577   fi
578 ])
579
580
581 dnl
582 dnl Check for certain special build configurations.
583 dnl
584 dnl GLIBCPP_ENABLE_DEBUG
585 dnl --enable-debug sets '-ggdb -O0'.
586 dnl --disable-debug sets '-g' and whatever optimization options the
587 dnl     compiler can handle.
588 dnl  +  Perhaps --enable-maintainer-mode should automatically turn this on?
589 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
590 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
591 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
592 dnl       defaults to `no'.
593 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
594 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
595 AC_ARG_ENABLE(debug,
596 changequote(<<, >>)dnl
597 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
598 changequote([, ])dnl
599 [case "$enableval" in
600  yes) enable_debug=yes ;;
601  no)  enable_debug=no ;;
602  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
603  esac],
604 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
605 dnl Option parsed, now set things appropriately
606 case "$enable_debug" in
607     yes)  DEBUGFLAGS='-ggdb -O0'
608           ;;
609     no)   DEBUGFLAGS='-g'
610           ;;
611 esac
612 AC_SUBST(DEBUGFLAGS)
613 ])
614
615
616 dnl
617 dnl Check for certain special build configurations.
618 dnl
619 dnl GLIBCPP_ENABLE_NAMESPACES
620 dnl --enable-namespaces sets '-fhonor-std' and defines _GLIBCPP_USE_NAMESPACES
621 dnl --disable-namespaces sets '-fno-honor-std' (the macro should be
622 dnl     undefined by default in whatever.h.in).
623 dnl  +  Eventually, this will go away.
624 dnl  +  Usage:  GLIBCPP_ENABLE_NAMESPACES[(DEFAULT)]
625 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
626 dnl       defaults to `no'.
627 AC_DEFUN(GLIBCPP_ENABLE_NAMESPACES, [dnl
628 define([GLIBCPP_ENABLE_NAMESPACES_DEFAULT], ifelse($1, yes, yes, no))dnl
629 AC_ARG_ENABLE(namespaces,
630 changequote(<<, >>)dnl
631 <<  --enable-namespaces     turns on 'std' [default=>>GLIBCPP_ENABLE_NAMESPACES_DEFAULT],
632 changequote([, ])dnl
633 [case "$enableval" in
634  yes) enable_namespaces=yes ;;
635  no)  enable_namespaces=no ;;
636  *)   AC_MSG_ERROR([Unknown argument to enable/disable namespaces]) ;;
637  esac],
638 enable_namespaces=GLIBCPP_ENABLE_NAMESPACES_DEFAULT)dnl
639 dnl Option parsed, now set things appropriately
640 case "$enable_namespaces" in
641     yes)  NAMESPACES='-fhonor-std'
642           AC_DEFINE(_GLIBCPP_USE_NAMESPACES)
643           ;;
644     no)   NAMESPACES='-fno-honor-std'
645           ;;
646 esac
647 AC_SUBST(NAMESPACES)
648 ])
649
650
651 dnl
652 dnl Check for instructions to automatically rebuild libgcc.a.  Requires,
653 dnl of course, the location of the gcc objdir.  Note that if --disable-
654 dnl namespaces is in effect, rebuilding libgcc.a is an expensive no-op.
655 dnl
656 dnl GLIBCPP_ENABLE_RELIBGCC
657 dnl --enable-libgcc-rebuild=/absolute/path/to/gcc/objdir sets GCC_OBJDIR
658 dnl     (presumably in the top-level Makefile) to /absol.../objdir
659 dnl --disable-libgcc-rebuild will not touch libgcc.a at all (maybe print
660 dnl     a warning if this is given along with --enable-namespaces), by
661 dnl     setting GCC_OBJDIR to `no'.
662 dnl  +  Doing this by default is going to be interesting.  What default
663 dnl     "on" value can there be?
664 dnl  +  Usage:  GLIBCPP_ENABLE_RELIBGCC[(DEFAULT)]
665 dnl       The default path should be ../.. if bundled with GCC source.
666 dnl       If ommitted, it defaults to `no'.
667 dnl
668 AC_DEFUN(GLIBCPP_ENABLE_RELIBGCC, [dnl
669 define([GLIBCPP_ENABLE_RELIBGCC_DEFAULT], ifelse($1,, no, $1))dnl
670 AC_ARG_ENABLE(libgcc-rebuild,
671 changequote(<<, >>)dnl
672 <<  --enable-libgcc-rebuild=DIR     also rebuild libgcc.a; DIR is
673                                   the GCC objdir; see install.html>>,
674 changequote([, ])dnl
675 [case "$enableval" in
676  yes) AC_MSG_ERROR([--enable-libgcc-rebuild needs a pathname]) ;;
677  no)  enable_libgcc_rebuild=no ;;
678  *)   if test -d "$enableval" && test -d "${enableval}/gcc" && \
679          test -d "${enableval}/libiberty"
680       then
681          enable_libgcc_rebuild="$enableval"
682       else
683          AC_MSG_ERROR(["$enableval" does not appear to be the GCC objdir])
684       fi
685       ;;
686  esac],
687 enable_libgcc_rebuild=GLIBCPP_ENABLE_RELIBGCC_DEFAULT)dnl
688 GCC_OBJDIR="$enable_libgcc_rebuild"
689 AC_SUBST(GCC_OBJDIR)
690 ])
691
692
693 dnl
694 dnl Check for certain special build configurations.
695 dnl
696 dnl GLIBCPP_ENABLE_CSTDIO
697 dnl --enable-cstdio=libio sets config/c_io_libio.h and friends
698 dnl 
699 dnl default is libio
700 dnl
701 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
702   AC_MSG_CHECKING([for cstdio to use])
703   AC_ARG_ENABLE(cstdio,
704   [  --enable-cstdio         enable GNU libio for target io package. (default)
705   --enable-cstdio=LIB     use LIB target-speific io package.], 
706   if test x$enable_cstdio = xno; then
707     enable_cstdio=libio
708   fi,
709      enable_cstdio=libio)
710
711   enable_cstdio_flag=$enable_cstdio
712
713   dnl Check if a valid thread package
714   case x${enable_cstdio_flag} in
715         xlibio | x | xno | xnone | xyes)
716                 # default
717                 CSTDIO_H=c_io_libio.h
718                 CSTDIO_CC=c_io_libio.cc
719                 AC_MSG_RESULT(libio)
720
721                 # see if we are on a system with libio native (ie, linux)
722                 AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
723                 if test $has_libio = "yes"; then
724                   BUILD_LIBIO_INCLUDE=
725                   need_libio=no
726                 else
727                   BUILD_LIBIO_INCLUDE='-I../libio'
728                   need_libio=yes
729                 fi
730                 AC_SUBST(BUILD_LIBIO_INCLUDE)
731                 ;;
732         xwince)
733                 CSTDIO_H=c_io_wince.h
734                 CSTDIO_CC=c_io_wince.cc
735                 AC_MSG_RESULT(wince)
736
737                 need_libio=no
738                 BUILD_LIBIO_INCLUDE=
739                 AC_SUBST(BUILD_LIBIO_INCLUDE)
740                 ;;
741         *)
742                 echo "$enable_cstdio is an unknown io package" 1>&2
743                 exit 1
744                 ;;
745   esac
746   AC_SUBST(CSTDIO_H)
747   AC_SUBST(CSTDIO_CC)
748   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
749 ])
750
751
752 dnl
753 dnl Check for certain special build configurations.
754 dnl
755 dnl GLIBCPP_ENABLE_THREADS
756 dnl --enable-threads=posix sets config/threads-posix.h et. al.
757 dnl 
758 dnl default is no threads
759 dnl
760 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
761   dnl Note this comes from the gcc/config.in and libjava/config.in
762   dnl Efforts should be made to keep this in sync.
763   AC_MSG_CHECKING([for threads package to use])
764   AC_ARG_ENABLE(threads,
765   [  --enable-threads        enable thread usage for target GCC.
766   --enable-threads=LIB    use LIB thread package for target GCC.],
767   if test x$enable_threads = xno; then
768     enable_threads=''
769   fi,
770     enable_threads='')
771
772   enable_threads_flag=$enable_threads
773
774   dnl Check if a valid thread package
775   case x${enable_threads_flag} in
776         x | xno | xnone)
777                 # No threads
778                 target_thread_file='single'
779                 ;;
780         xyes)
781                 # default
782                 target_thread_file=''
783                 ;;
784         xdecosf1 | xirix | xmach | xos2 | xposix | xpthreads | xsingle | \
785         xsolaris | xwin32 | xdce | xvxworks)
786                 target_thread_file=$enable_threads_flag
787                 ;;
788         *)
789                 echo "$enable_threads is an unknown thread package" 1>&2
790                 exit 1
791                 ;;
792   esac
793
794   dnl Check for thread package actually supported in libstdc++ 
795   case "$target_thread_file" in
796     no | none | single)
797       THREADS=none
798       ;;
799     posix | pthreads)
800       THREADS=posix
801       case "$host" in
802         *-*-linux*)
803         ;;
804       esac
805       ;;
806     decosf1 | irix | mach | os2 | solaris | win32 | dce | vxworks)
807       AC_MSG_ERROR(thread package $THREADS not yet supported)
808       ;;
809     *)
810       AC_MSG_ERROR($THREADS is an unknown thread package)
811       ;;
812   esac
813   AC_MSG_RESULT($THREADS)
814
815   THREADLIBS=
816   THREADINCS=
817   THREADDEPS=
818   THREADOBJS=
819   THREADH=
820   THREADSPEC=
821   case "$THREADS" in
822     posix)
823       AC_CHECK_HEADER(pthread.h, [have_pthread_h=yes], [have_pthread_h=])
824       THREADLIBS=-lpthread
825       THREADSPEC=-lpthread
826       dnl Not presently used
827       dnl THREADOBJS=threads-posix.lo
828       THREADH=threads-posix.h
829       ;;
830     none)
831       dnl Not presently used
832       dnl THREADOBJS=threads-no.lo
833       THREADH=threads-no.h
834       ;;
835   esac
836   AC_SUBST(THREADLIBS)
837   AC_SUBST(THREADINCS)
838   AC_SUBST(THREADDEPS)
839   AC_SUBST(THREADOBJS)
840   AC_SUBST(THREADSPEC)
841 ])
842
843
844 dnl
845 dnl Check for certain special build configurations.
846 dnl
847 dnl GLIBCPP_ENABLE_LONG_LONG
848 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
849 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
850 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
851 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
852 dnl       defaults to `no'.
853 dnl
854 dnl GLIBCPP_ENABLE_LONG_LONG
855 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
856   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
857   AC_ARG_ENABLE(long-long,
858   changequote(<<, >>)dnl
859   <<--enable-long_long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
860   changequote([, ])dnl
861   [case "$enableval" in
862    yes) enable_long_long=yes ;;
863    no)  enable_long_long=no ;;
864    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
865    esac],
866   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
867   dnl Option parsed, now set things appropriately
868   case "$enable_long_long" in
869     yes)  AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
870           ;;
871   esac
872 ])
873
874
875
876
877
878
879
880
881
882
883
884