OSDN Git Service

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