OSDN Git Service

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