OSDN Git Service

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