OSDN Git Service

2002-02-14 Phil Edwards <pme@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / acinclude.m4
1 dnl
2 dnl Initialize configure bits.
3 dnl
4 dnl GLIBCPP_CONFIGURE
5 AC_DEFUN(GLIBCPP_CONFIGURE, [
6   dnl Default to --enable-multilib
7   AC_ARG_ENABLE(multilib,
8   [  --enable-multilib       build hella library versions (default)],
9   [case "${enableval}" in
10     yes) multilib=yes ;;
11     no)  multilib=no ;;
12     *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
13    esac], [multilib=yes])dnl
14
15 # When building with srcdir == objdir, links to the source files will
16 # be created in directories within the target_subdir.  We have to
17 # adjust toplevel_srcdir accordingly, so that configure finds
18 # install-sh and other auxiliary files that live in the top-level
19 # source directory.
20 if test "${srcdir}" = "."; then
21   if test -z "${with_target_subdir}"; then
22     toprel=".."
23   else
24     if test "${with_target_subdir}" != "."; then
25       toprel="${with_multisrctop}../.."
26     else
27       toprel="${with_multisrctop}.."
28     fi
29   fi
30 else
31   toprel=".."
32 fi
33 AC_CONFIG_AUX_DIR(${srcdir}/$toprel)
34 toplevel_srcdir=\${top_srcdir}/$toprel
35 AC_SUBST(toplevel_srcdir)
36
37 # Export build and source directories.
38 # These need to be absolute paths, yet at the same time need to
39 # canonicalize only relative paths, because then amd will not unmount
40 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
41 glibcpp_builddir=`pwd`
42 case $srcdir in
43 [\\/$]* | ?:[\\/]*) glibcpp_srcdir=${srcdir} ;;
44 *) glibcpp_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
45 esac
46 AC_SUBST(glibcpp_builddir)
47 AC_SUBST(glibcpp_srcdir)
48
49 dnl This is here just to satisfy automake.
50 ifelse(not,equal,[AC_CONFIG_AUX_DIR(..)])
51
52 # Will set LN_S to either 'ln -s' or 'ln'.  With autoconf 2.50+, can also
53 # be 'cp -p' if linking isn't available.
54 #ac_cv_prog_LN_S='cp -p'
55 AC_PROG_LN_S
56
57 # We use these options to decide which functions to include.
58 AC_ARG_WITH(target-subdir,
59 [  --with-target-subdir=SUBDIR
60                            configuring in a subdirectory])
61 AC_ARG_WITH(cross-host,
62 [  --with-cross-host=HOST  configuring with a cross compiler])
63
64   glibcpp_basedir=$srcdir/$toprel/$1/libstdc++-v3
65   AC_SUBST(glibcpp_basedir)
66
67   # Never versions of autoconf add an underscore to these functions.
68   # Prevent future problems ...
69   ifdef([AC_PROG_CC_G],[],[define([AC_PROG_CC_G],defn([_AC_PROG_CC_G]))])
70   ifdef([AC_PROG_CC_GNU],[],[define([AC_PROG_CC_GNU],defn([_AC_PROG_CC_GNU]))])
71   ifdef([AC_PROG_CXX_G],[],[define([AC_PROG_CXX_G],defn([_AC_PROG_CXX_G]))])
72   ifdef([AC_PROG_CXX_GNU],[],[define([AC_PROG_CXX_GNU],defn([_AC_PROG_CXX_GNU]))])
73
74 #  AC_PROG_CC
75
76 # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
77 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
78 # are probably using a cross compiler, which will not be able to fully
79 # link an executable.  This should really be fixed in autoconf
80 # itself.
81
82 AC_DEFUN(LIB_AC_PROG_CC,
83 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
84 dnl Fool anybody using AC_PROG_CC.
85 AC_PROVIDE([AC_PROG_CC])
86 AC_CHECK_PROG(CC, gcc, gcc)
87 if test -z "$CC"; then
88   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
89   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
90 fi
91
92 AC_PROG_CC_GNU
93
94 if test $ac_cv_prog_gcc = yes; then
95   GCC=yes
96 dnl Check whether -g works, even if CFLAGS is set, in case the package
97 dnl plays around with CFLAGS (such as to build both debugging and
98 dnl normal versions of a library), tasteless as that idea is.
99   ac_test_CFLAGS="${CFLAGS+set}"
100   ac_save_CFLAGS="$CFLAGS"
101   CFLAGS=
102   AC_PROG_CC_G
103   if test "$ac_test_CFLAGS" = set; then
104     CFLAGS="$ac_save_CFLAGS"
105   elif test $ac_cv_prog_cc_g = yes; then
106     CFLAGS="-g -O2"
107   else
108     CFLAGS="-O2"
109   fi
110 else
111   GCC=
112   test "${CFLAGS+set}" = set || CFLAGS="-g"
113 fi
114 ])
115
116 LIB_AC_PROG_CC
117
118 # Can't just call these here as g++ requires libstc++ to be built....
119 #  AC_PROG_CXX
120
121 # Likewise for AC_PROG_CXX.
122 AC_DEFUN(LIB_AC_PROG_CXX,
123 [AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl
124 dnl Fool anybody using AC_PROG_CXX.
125 AC_PROVIDE([AC_PROG_CXX])
126 # Use glibcpp_CXX so that we do not cause CXX to be cached with the
127 # flags that come in CXX while configuring libstdc++.  They're different
128 # from those used for all other target libraries.  If CXX is set in
129 # the environment, respect that here.
130 glibcpp_CXX=$CXX
131 AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
132 AC_SUBST(glibcpp_CXX)
133 CXX=$glibcpp_CXX
134 test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
135
136 AC_PROG_CXX_GNU
137
138 if test $ac_cv_prog_gxx = yes; then
139   GXX=yes
140 dnl Check whether -g works, even if CXXFLAGS is set, in case the package
141 dnl plays around with CXXFLAGS (such as to build both debugging and
142 dnl normal versions of a library), tasteless as that idea is.
143   ac_test_CXXFLAGS="${CXXFLAGS+set}"
144   ac_save_CXXFLAGS="$CXXFLAGS"
145   CXXFLAGS=
146   AC_PROG_CXX_G
147   if test "$ac_test_CXXFLAGS" = set; then
148     CXXFLAGS="$ac_save_CXXFLAGS"
149   elif test $ac_cv_prog_cxx_g = yes; then
150     CXXFLAGS="-g -O2"
151   else
152     CXXFLAGS="-O2"
153   fi
154 else
155   GXX=
156   test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
157 fi
158 ])
159
160 LIB_AC_PROG_CXX
161
162    # For some reason, gettext needs this.
163    AC_ISC_POSIX
164
165   AC_CHECK_TOOL(AS, as)
166   AC_CHECK_TOOL(AR, ar)
167   AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
168   AC_PROG_INSTALL
169
170   AM_MAINTAINER_MODE
171
172   # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
173   # at least currently, we never actually build a program, so we never
174   # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
175   # fails, because we are probably configuring with a cross compiler
176   # which can't create executables.  So we include AC_EXEEXT to keep
177   # automake happy, but we don't execute it, since we don't care about
178   # the result.
179   if false; then
180     # autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
181     # to nothing, so nothing would remain between `then' and `fi' if it
182     # were not for the `:' below.
183     :
184     AC_EXEEXT
185   fi
186
187   . [$]{glibcpp_basedir}/configure.host
188
189   case [$]{glibcpp_basedir} in
190     /* | [A-Za-z]:[\\/]*) libgcj_flagbasedir=[$]{glibcpp_basedir} ;;
191     *) glibcpp_flagbasedir='[$](top_builddir)/'[$]{glibcpp_basedir} ;;
192   esac
193
194   # This does for the target what configure.host does for the host.  In
195   # addition to possibly modifying the same flags, it also sets up symlinks.
196   GLIBCPP_CHECK_TARGET
197
198   # 
199 ])
200
201
202 dnl
203 dnl Check to see if g++ can compile this library, and if so, if any version-
204 dnl specific precautions need to be taken. 
205 dnl 
206 dnl GLIBCPP_CHECK_COMPILER_VERSION
207 AC_DEFUN(GLIBCPP_CHECK_COMPILER_VERSION, [
208 if test ! -f stamp-sanity-compiler; then
209   AC_MSG_CHECKING([for g++ that will successfully compile libstdc++-v3])
210   AC_LANG_SAVE
211   AC_LANG_CPLUSPLUS
212   AC_TRY_COMPILE(, [
213   #if __GNUC__ < 3
214     not_ok
215   #endif
216   ], gpp_satisfactory=yes, AC_MSG_ERROR([please upgrade to GCC 3.0 or above]))
217   AC_LANG_RESTORE
218   AC_MSG_RESULT($gpp_satisfactory)
219   touch stamp-sanity-compiler
220 fi
221 ])
222
223
224 dnl
225 dnl Tests for newer compiler features, or features that are present in newer
226 dnl compiler versions but not older compiler versions still in use, should
227 dnl be placed here.
228 dnl
229 dnl Define WERROR='-Werror' if requested and possible; g++'s that lack the
230 dnl new inlining code or the new system_header pragma will die on -Werror.
231 dnl Leave it out by default and use maint-mode to use it.
232 dnl
233 dnl Define SECTION_FLAGS='-ffunction-sections -fdata-sections' if
234 dnl compiler supports it and the user has not requested debug mode.
235 dnl
236 dnl GLIBCPP_CHECK_COMPILER_FEATURES
237 AC_DEFUN(GLIBCPP_CHECK_COMPILER_FEATURES, [
238   # All these tests are for C++; save the language and the compiler flags.
239   # The CXXFLAGS thing is suspicious, but based on similar bits previously
240   # found in GLIBCPP_CONFIGURE.
241   AC_LANG_SAVE
242   AC_LANG_CPLUSPLUS
243   ac_test_CXXFLAGS="${CXXFLAGS+set}"
244   ac_save_CXXFLAGS="$CXXFLAGS"
245
246   # Check for maintainer-mode bits.
247   if test x"$USE_MAINTAINER_MODE" = xno; then
248     WERROR=''
249   else
250     WERROR='-Werror'
251   fi
252
253   # Check for -ffunction-sections -fdata-sections
254   AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
255   CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
256   AC_TRY_COMPILE(, [int foo;
257   ], [ac_fdsections=yes], [ac_fdsections=no])
258   if test "$ac_test_CXXFLAGS" = set; then
259     CXXFLAGS="$ac_save_CXXFLAGS"
260   else
261     # this is the suspicious part
262     CXXFLAGS=''
263   fi
264   if test x"$ac_fdsections" = x"yes" &&
265      test x"$enable_debug" = x"no"; then
266     SECTION_FLAGS='-ffunction-sections -fdata-sections'
267   fi
268   AC_MSG_RESULT($ac_fdsections)
269
270   AC_LANG_RESTORE
271   AC_SUBST(WERROR)
272   AC_SUBST(SECTION_FLAGS)
273 ])
274
275
276 dnl
277 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
278 dnl the native linker is in use, all variables will be defined to something
279 dnl safe (like an empty string).
280 dnl
281 dnl Define SECTION_LDFLAGS='-Wl,--gc-sections' if possible.
282 dnl Define OPT_LDFLAGS='-Wl,-O1' if possible.
283 dnl
284 dnl GLIBCPP_CHECK_LINKER_FEATURES
285 AC_DEFUN(GLIBCPP_CHECK_LINKER_FEATURES, [
286   # If we're not using GNU ld, then there's no point in even trying these
287   # tests.  Check for that first.  We should have already tested for gld
288   # by now (in libtool), but require it now just to be safe...
289   test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
290   test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
291   AC_REQUIRE([AC_PROG_LD])
292
293   # Set --gc-sections.
294   if test "$ac_cv_prog_gnu_ld" = "notbroken"; then
295     # GNU ld it is!  Joy and bunny rabbits!
296
297     # All these tests are for C++; save the language and the compiler flags.
298     # Need to do this so that g++ won't try to link in libstdc++
299     ac_test_CFLAGS="${CFLAGS+set}"
300     ac_save_CFLAGS="$CFLAGS"
301     CFLAGS='-x c++  -Wl,--gc-sections'
302
303     # Check for -Wl,--gc-sections
304     # XXX This test is broken at the moment, as symbols required for
305     # linking are now in libsupc++ (not built yet.....). In addition, 
306     # this test has cored on solaris in the past. In addition,
307     # --gc-sections doesn't really work at the moment (keeps on discarding
308     # used sections, first .eh_frame and now some of the glibc sections for
309     # iconv). Bzzzzt. Thanks for playing, maybe next time.
310     AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
311     AC_TRY_RUN([
312      int main(void) 
313      {
314        try { throw 1; }
315        catch (...) { };
316        return 0;
317      }
318     ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
319     if test "$ac_test_CFLAGS" = set; then
320       CFLAGS="$ac_save_CFLAGS"
321     else
322       # this is the suspicious part
323       CFLAGS=''
324     fi
325     if test "$ac_sectionLDflags" = "yes"; then
326       SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
327     fi
328     AC_MSG_RESULT($ac_sectionLDflags)
329   fi
330
331   # Set linker optimization flags.
332   if test x"$ac_cv_prog_gnu_ld" = x"yes" &&
333      test x"$enable_debug" = x"no"; then
334     OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
335   fi
336
337   AC_SUBST(SECTION_LDFLAGS)
338   AC_SUBST(OPT_LDFLAGS)
339 ])
340
341
342 dnl
343 dnl Check to see if the (math function) argument passed is
344 dnl declared when using the c++ compiler
345 dnl ASSUMES argument is a math function with ONE parameter
346 dnl
347 dnl GLIBCPP_CHECK_MATH_DECL_1
348 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_1, [
349   AC_MSG_CHECKING([for $1 declaration])
350   if test x${glibcpp_cv_func_$1_use+set} != xset; then
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                       #ifdef HAVE_IEEEFP_H
356                       #include <ieeefp.h>
357                       #endif
358                      ], 
359                      [ $1(0);], 
360                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
361       AC_LANG_RESTORE
362     ])
363   fi
364   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
365 ])
366
367 dnl
368 dnl Check to see if the (math function) argument passed is
369 dnl 1) declared when using the c++ compiler
370 dnl 2) has "C" linkage
371 dnl 3) if not, see if 1) and 2) for argument prepended with '_'
372 dnl
373 dnl Define HAVE_CARGF etc if "cargf" is declared and links
374 dnl
375 dnl argument 1 is name of function to check
376 dnl
377 dnl ASSUMES argument is a math function with ONE parameter
378 dnl
379 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1
380 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, [
381   GLIBCPP_CHECK_MATH_DECL_1($1)
382   if test x$glibcpp_cv_func_$1_use = x"yes"; then
383     AC_CHECK_FUNCS($1)    
384   else
385     GLIBCPP_CHECK_MATH_DECL_1(_$1)
386     if test x$glibcpp_cv_func__$1_use = x"yes"; then
387       AC_CHECK_FUNCS(_$1)    
388     fi
389   fi
390 ])
391
392
393 dnl
394 dnl Like GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1, but does a bunch of
395 dnl of functions at once.  It's an all-or-nothing check -- either 
396 dnl HAVE_XYZ is defined for each of the functions, or for none of them.
397 dnl Doing it this way saves significant configure time.
398 AC_DEFUN(GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1, [
399   AC_MSG_CHECKING([for $1 functions])
400   AC_CACHE_VAL(glibcpp_cv_func_$2_use, [
401     AC_LANG_SAVE
402     AC_LANG_CPLUSPLUS
403     AC_TRY_COMPILE([#include <math.h>],
404                    [ `for x in $3; do echo "$x (0);"; done` ],
405                    [glibcpp_cv_func_$2_use=yes],
406                    [glibcpp_cv_func_$2_use=no])
407     AC_LANG_RESTORE])
408   AC_MSG_RESULT($glibcpp_cv_func_$2_use)
409   if test x$glibcpp_cv_func_$2_use = x"yes"; then
410     AC_CHECK_FUNCS($3)
411   fi
412 ])
413
414 dnl
415 dnl Check to see if the (math function) argument passed is
416 dnl declared when using the c++ compiler
417 dnl ASSUMES argument is a math function with TWO parameters
418 dnl
419 dnl GLIBCPP_CHECK_MATH_DECL_2
420 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_2, [
421   AC_MSG_CHECKING([for $1 declaration])
422   if test x${glibcpp_cv_func_$1_use+set} != xset; then
423     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
424       AC_LANG_SAVE
425       AC_LANG_CPLUSPLUS
426       AC_TRY_COMPILE([#include <math.h>], 
427                      [ $1(0, 0);], 
428                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
429       AC_LANG_RESTORE
430     ])
431   fi
432   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
433 ])
434
435 dnl
436 dnl Check to see if the (math function) argument passed is
437 dnl 1) declared when using the c++ compiler
438 dnl 2) has "C" linkage
439 dnl
440 dnl Define HAVE_CARGF etc if "cargf" is declared and links
441 dnl
442 dnl argument 1 is name of function to check
443 dnl
444 dnl ASSUMES argument is a math function with TWO parameters
445 dnl
446 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2
447 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2, [
448   GLIBCPP_CHECK_MATH_DECL_2($1)
449   if test x$glibcpp_cv_func_$1_use = x"yes"; then
450     AC_CHECK_FUNCS($1)    
451   else
452     GLIBCPP_CHECK_MATH_DECL_2(_$1)
453     if test x$glibcpp_cv_func__$1_use = x"yes"; then
454       AC_CHECK_FUNCS(_$1)    
455     fi
456   fi
457 ])
458
459
460 dnl
461 dnl Check to see if the (math function) argument passed is
462 dnl declared when using the c++ compiler
463 dnl ASSUMES argument is a math function with THREE parameters
464 dnl
465 dnl GLIBCPP_CHECK_MATH_DECL_3
466 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_3, [
467   AC_MSG_CHECKING([for $1 declaration])
468   if test x${glibcpp_cv_func_$1_use+set} != xset; then
469     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
470       AC_LANG_SAVE
471       AC_LANG_CPLUSPLUS
472       AC_TRY_COMPILE([#include <math.h>], 
473                      [ $1(0, 0, 0);], 
474                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
475       AC_LANG_RESTORE
476     ])
477   fi
478   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
479 ])
480
481 dnl
482 dnl Check to see if the (math function) argument passed is
483 dnl 1) declared when using the c++ compiler
484 dnl 2) has "C" linkage
485 dnl
486 dnl Define HAVE_CARGF etc if "cargf" is declared and links
487 dnl
488 dnl argument 1 is name of function to check
489 dnl
490 dnl ASSUMES argument is a math function with THREE parameters
491 dnl
492 dnl GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3
493 AC_DEFUN(GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3, [
494   GLIBCPP_CHECK_MATH_DECL_3($1)
495   if test x$glibcpp_cv_func_$1_use = x"yes"; then
496     AC_CHECK_FUNCS($1)    
497   else
498     GLIBCPP_CHECK_MATH_DECL_3(_$1)
499     if test x$glibcpp_cv_func__$1_use = x"yes"; then
500       AC_CHECK_FUNCS(_$1)    
501     fi
502   fi
503 ])
504
505
506 dnl
507 dnl Check to see if the (stdlib function) argument passed is
508 dnl 1) declared when using the c++ compiler
509 dnl 2) has "C" linkage
510 dnl
511 dnl argument 1 is name of function to check
512 dnl
513 dnl ASSUMES argument is a math function with TWO parameters
514 dnl
515 dnl GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2
516 AC_DEFUN(GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2, [
517   AC_MSG_CHECKING([for $1 declaration])
518   if test x${glibcpp_cv_func_$1_use+set} != xset; then
519     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
520       AC_LANG_SAVE
521       AC_LANG_CPLUSPLUS
522       AC_TRY_COMPILE([#include <stdlib.h>], 
523                      [ $1(0, 0);], 
524                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
525       AC_LANG_RESTORE
526     ])
527   fi
528   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
529   if test x$glibcpp_cv_func_$1_use = x"yes"; then
530     AC_CHECK_FUNCS($1)    
531   fi
532 ])
533
534
535 dnl
536 dnl Because the builtins are picky picky picky about the arguments they take, 
537 dnl do an explict linkage tests here.
538 dnl Check to see if the (math function) argument passed is
539 dnl 1) declared when using the c++ compiler
540 dnl 2) has "C" linkage
541 dnl
542 dnl Define HAVE_CARGF etc if "cargf" is declared and links
543 dnl
544 dnl argument 1 is name of function to check
545 dnl
546 dnl ASSUMES argument is a math function with ONE parameter
547 dnl
548 dnl GLIBCPP_CHECK_BUILTIN_MATH_DECL_LINKAGE_1
549 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1, [
550   AC_MSG_CHECKING([for $1 declaration])
551   if test x${glibcpp_cv_func_$1_use+set} != xset; then
552     AC_CACHE_VAL(glibcpp_cv_func_$1_use, [
553       AC_LANG_SAVE
554       AC_LANG_CPLUSPLUS
555       AC_TRY_COMPILE([#include <math.h>], 
556                      [ $1(0);], 
557                      [glibcpp_cv_func_$1_use=yes], [glibcpp_cv_func_$1_use=no])
558       AC_LANG_RESTORE
559     ])
560   fi
561   AC_MSG_RESULT($glibcpp_cv_func_$1_use)
562   if test x$glibcpp_cv_func_$1_use = x"yes"; then
563     AC_MSG_CHECKING([for $1 linkage])
564     if test x${glibcpp_cv_func_$1_link+set} != xset; then
565       AC_CACHE_VAL(glibcpp_cv_func_$1_link, [
566         AC_TRY_LINK([#include <math.h>], 
567                     [ $1(0);], 
568                     [glibcpp_cv_func_$1_link=yes], [glibcpp_cv_func_$1_link=no])
569       ])
570     fi
571     AC_MSG_RESULT($glibcpp_cv_func_$1_link)
572     if test x$glibcpp_cv_func_$1_link = x"yes"; then
573       ac_tr_func=HAVE_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
574       AC_DEFINE_UNQUOTED(${ac_tr_func})
575     fi
576   fi
577 ])
578
579
580 dnl
581 dnl Check to see what builtin math functions are supported
582 dnl
583 dnl check for __builtin_abs
584 dnl check for __builtin_fabsf
585 dnl check for __builtin_fabs
586 dnl check for __builtin_fabl
587 dnl check for __builtin_labs
588 dnl check for __builtin_sqrtf
589 dnl check for __builtin_sqrtl
590 dnl check for __builtin_sqrt
591 dnl check for __builtin_sinf
592 dnl check for __builtin_sin
593 dnl check for __builtin_sinl
594 dnl check for __builtin_cosf
595 dnl check for __builtin_cos
596 dnl check for __builtin_cosl
597 dnl
598 dnl GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT
599 AC_DEFUN(GLIBCPP_CHECK_BUILTIN_MATH_SUPPORT, [
600   dnl Test for builtin math functions.
601   dnl These are made in gcc/c-common.c 
602   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_abs)
603   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsf)
604   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabs)
605   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_fabsl)
606   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_labs)
607
608   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtf)
609   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrt)
610   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sqrtl)
611
612   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinf)
613   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sin)
614   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_sinl)
615
616   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosf)
617   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cos)
618   GLIBCPP_CHECK_BUILTIN_MATH_DECL_AND_LINKAGE_1(__builtin_cosl)
619
620   dnl There is, without a doubt, a more elegant way to have these
621   dnl names exported so that they won't be stripped out of acconfig.h by
622   dnl autoheader. I leave this as an exercise to somebody less frustrated
623   dnl than I.... please email the libstdc++ list if you can figure out a
624   dnl more elegant approach (see autoconf/acgen.m4 and specifically
625   dnl AC_CHECK_FUNC for things to steal.)
626   dummyvar=no
627   if test x$dummyvar = x"yes"; then
628     AC_DEFINE(HAVE___BUILTIN_ABS)
629     AC_DEFINE(HAVE___BUILTIN_LABS)
630     AC_DEFINE(HAVE___BUILTIN_COS)
631     AC_DEFINE(HAVE___BUILTIN_COSF)
632     AC_DEFINE(HAVE___BUILTIN_COSL)
633     AC_DEFINE(HAVE___BUILTIN_FABS)
634     AC_DEFINE(HAVE___BUILTIN_FABSF)
635     AC_DEFINE(HAVE___BUILTIN_FABSL)
636     AC_DEFINE(HAVE___BUILTIN_SIN)
637     AC_DEFINE(HAVE___BUILTIN_SINF)
638     AC_DEFINE(HAVE___BUILTIN_SINL)
639     AC_DEFINE(HAVE___BUILTIN_SQRT)
640     AC_DEFINE(HAVE___BUILTIN_SQRTF)
641     AC_DEFINE(HAVE___BUILTIN_SQRTL)
642   fi
643 ])
644
645
646 dnl
647 dnl Check to see what the underlying c library 
648 dnl These checks need to do two things: 
649 dnl 1) make sure the name is declared when using the c++ compiler
650 dnl 2) make sure the name has "C" linkage
651 dnl This might seem like overkill but experience has shown that it's not...
652 dnl
653 dnl Define HAVE_STRTOLD if "strtold" is declared and links
654 dnl Define HAVE_STRTOF if "strtof" is declared and links
655 dnl Define HAVE_DRAND48 if "drand48" is declared and links
656 dnl
657 dnl GLIBCPP_CHECK_STDLIB_SUPPORT
658 AC_DEFUN(GLIBCPP_CHECK_STDLIB_SUPPORT, [
659   ac_test_CXXFLAGS="${CXXFLAGS+set}"
660   ac_save_CXXFLAGS="$CXXFLAGS"
661   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
662
663   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
664   GLIBCPP_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
665   AC_CHECK_FUNCS(drand48)
666
667   CXXFLAGS="$ac_save_CXXFLAGS"
668 ])
669
670
671 dnl
672 dnl Check to see what the underlying c library or math library is like.
673 dnl These checks need to do two things: 
674 dnl 1) make sure the name is declared when using the c++ compiler
675 dnl 2) make sure the name has "C" linkage
676 dnl This might seem like overkill but experience has shown that it's not...
677 dnl
678 dnl Define HAVE_CARGF etc if "cargf" is found.
679 dnl
680 dnl GLIBCPP_CHECK_MATH_SUPPORT
681 AC_DEFUN(GLIBCPP_CHECK_MATH_SUPPORT, [
682   ac_test_CXXFLAGS="${CXXFLAGS+set}"
683   ac_save_CXXFLAGS="$CXXFLAGS"
684   CXXFLAGS='-fno-builtins -D_GNU_SOURCE'
685
686   dnl Check libm
687   AC_CHECK_LIB(m, sin, libm="-lm")
688   ac_save_LIBS="$LIBS"
689   LIBS="$LIBS $libm"
690
691   dnl Check to see if certain C math functions exist.
692   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinf)
693   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnan)
694   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finite)
695   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysign)
696   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincos)
697   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fpclass)
698   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(qfpclass)
699   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypot)
700
701   dnl Check to see if basic C math functions have float versions.
702   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float trig,
703                                           float_trig,
704                                           acosf asinf atanf \
705                                           cosf sinf tanf \
706                                           coshf sinhf tanhf)
707   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(float round,
708                                           float_round,
709                                           ceilf floorf)
710   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanf)
711   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinff)
712   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2f)
713   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsf)
714   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodf)
715   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpf)
716   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotf)
717   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpf)
718   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logf)
719   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10f)
720   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modff)
721   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powf)
722   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtf)
723   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosf)
724   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitef)
725
726   dnl Check to see if basic C math functions have long double versions.
727   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double trig,
728                                           long_double_trig,
729                                           acosl asinl atanl \
730                                           cosl sinl tanl \
731                                           coshl sinhl tanhl)
732   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(long double round,
733                                           long_double_round,
734                                           ceill floorl)
735   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isnanl)
736   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(isinfl)
737   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(copysignl)
738   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(atan2l)
739   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(expl)
740   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(fabsl)
741   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(fmodl)
742   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(frexpl)
743   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(hypotl)
744   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(ldexpl)
745   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(logl)
746   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(log10l)
747   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(modfl)
748   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_2(powl)
749   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(sqrtl)
750   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_3(sincosl)
751   GLIBCPP_CHECK_MATH_DECL_AND_LINKAGE_1(finitel)
752
753   dnl Some runtimes have these functions with a preceding underscore. Please
754   dnl keep this sync'd with the one above. And if you add any new symbol,
755   dnl please add the corresponding block in the @BOTTOM@ section of acconfig.h.
756   dnl Check to see if certain C math functions exist.
757
758   dnl Check to see if basic C math functions have float versions.
759   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float trig,
760                                           _float_trig,
761                                           _acosf _asinf _atanf \
762                                           _cosf _sinf _tanf \
763                                           _coshf _sinhf _tanhf)
764   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_float round,
765                                           _float_round,
766                                           _ceilf _floorf)
767
768   dnl Check to see if basic C math functions have long double versions.
769   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double trig,
770                                           _long_double_trig,
771                                           _acosl _asinl _atanl \
772                                           _cosl _sinl _tanl \
773                                           _coshl _sinhl _tanhl)
774   GLIBCPP_CHECK_MATH_DECLS_AND_LINKAGES_1(_long double round,
775                                           _long_double_round,
776                                           _ceill _floorl)
777
778   LIBS="$ac_save_LIBS"
779   CXXFLAGS="$ac_save_CXXFLAGS"
780 ])
781
782
783 dnl
784 dnl Check to see if there is native support for complex 
785 dnl
786 dnl Don't compile bits in math/* if native support exits.
787 dnl
788 dnl Define USE_COMPLEX_LONG_DOUBLE etc if "copysignl" is found.
789 dnl
790 dnl GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
791 AC_DEFUN(GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT, [
792   dnl Check for complex versions of math functions of platform.
793   AC_CHECK_LIB(m, main)
794   AC_REPLACE_MATHFUNCS(nan copysignf)
795
796   dnl Compile the long double complex functions only if the function 
797   dnl provides the non-complex long double functions that are needed.
798   dnl Currently this includes copysignl, which should be
799   dnl cached from the GLIBCPP_CHECK_MATH_SUPPORT macro, above.
800   USE_COMPLEX_LONG_DOUBLE=no
801   if test x$ac_cv_func_copysignl = x"yes"; then
802     USE_COMPLEX_LONG_DOUBLE=yes
803     AC_REPLACE_MATHFUNCS(signbitl)
804   fi
805
806   AC_SUBST(USE_COMPLEX_LONG_DOUBLE)
807 ])
808
809
810 dnl Check to see what architecture and operating system we are compiling
811 dnl for.  Also, if architecture- or OS-specific flags are required for
812 dnl compilation, pick them up here.
813 dnl 
814 dnl GLIBCPP_CHECK_TARGET
815 AC_DEFUN(GLIBCPP_CHECK_TARGET, [
816     . [$]{glibcpp_basedir}/configure.target
817     AC_MSG_RESULT(CPU config directory is $cpu_include_dir)
818     AC_MSG_RESULT(OS config directory is $os_include_dir)
819 ])
820
821
822 dnl
823 dnl Check to see if this target can enable the wchar_t parts of libstdc++.
824 dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled.  (This
825 dnl must have been previously checked.)
826 dnl
827 dnl Define _GLIBCPP_USE_WCHAR_T if all the bits are found 
828 dnl Define HAVE_MBSTATE_T if mbstate_t is not in wchar.h
829 dnl
830 dnl GLIBCPP_CHECK_WCHAR_T_SUPPORT
831 AC_DEFUN(GLIBCPP_CHECK_WCHAR_T_SUPPORT, [
832
833   dnl Test wchar.h for mbstate_t, which is needed for char_traits and
834   dnl others even if wchar_t support is not on.
835   AC_MSG_CHECKING([for mbstate_t])
836   AC_TRY_COMPILE([#include <wchar.h>],
837   [mbstate_t teststate;], 
838   have_mbstate_t=yes, have_mbstate_t=no)
839   AC_MSG_RESULT($have_mbstate_t)
840   if test x"$have_mbstate_t" = xyes; then
841     AC_DEFINE(HAVE_MBSTATE_T)
842   fi
843
844   dnl Sanity check for existence of ISO C99 headers for extended encoding.
845   AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
846   AC_CHECK_HEADER(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
847   
848   dnl Only continue checking if the ISO C99 headers exist and support is on.
849   if test x"$ac_has_wchar_h" = xyes &&
850      test x"$ac_has_wctype_h" = xyes &&
851      test x"$enable_c_mbchar" != xno; then
852       
853     dnl Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
854     dnl numeric_limits can instantiate type_traits<wchar_t>
855     AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
856     AC_TRY_COMPILE([#include <wchar.h>],
857     [int i = WCHAR_MIN; int j = WCHAR_MAX;], 
858     has_wchar_minmax=yes, has_wchar_minmax=no)
859     AC_MSG_RESULT($has_wchar_minmax)
860     
861     dnl Test wchar.h for WEOF, which is what we use to determine whether
862     dnl to specialize for char_traits<wchar_t> or not.
863     AC_MSG_CHECKING([for WEOF])
864     AC_TRY_COMPILE([
865       #include <wchar.h>
866       #include <stddef.h>],
867     [wint_t i = WEOF;],
868     has_weof=yes, has_weof=no)
869     AC_MSG_RESULT($has_weof)
870   
871     dnl Tests for wide character functions used in char_traits<wchar_t>.
872     ac_wfuncs=yes
873     AC_CHECK_FUNCS(wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset,, \
874     ac_wfuncs=no)
875   
876     dnl Checks for names injected into std:: by the c_std headers.
877     AC_CHECK_FUNCS(btowc wctob fgetwc fgetwc fgetws fputwc fputws fwide \
878     fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
879     vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
880     mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
881     wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
882     wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr,, \
883     ac_wfuncs=no)
884
885     AC_MSG_CHECKING([for ISO C99 wchar_t support])
886     if test x"$has_weof" = xyes &&
887        test x"$has_wchar_minmax" = xyes &&
888        test x"$ac_wfuncs" = xyes; then
889       ac_isoC99_wchar_t=yes
890     else
891       ac_isoC99_wchar_t=no
892     fi
893     AC_MSG_RESULT($ac_isoC99_wchar_t)
894   
895     dnl Use iconv for wchar_t to char conversions. As such, check for 
896     dnl X/Open Portability Guide, version 2 features (XPG2).
897     AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
898     AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
899
900     dnl Check for existence of libiconv.a providing XPG2 wchar_t support.
901     AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
902     ac_save_LIBS="$LIBS"
903     LIBS="$LIBS $libiconv"
904
905     AC_CHECK_FUNCS(iconv_open iconv_close iconv nl_langinfo, \
906     ac_XPG2funcs=yes, ac_XPG2funcs=no)
907   
908     LIBS="$ac_save_LIBS"
909
910     AC_MSG_CHECKING([for XPG2 wchar_t support])
911     if test x"$ac_has_iconv_h" = xyes &&
912        test x"$ac_has_langinfo_h" = xyes &&
913        test x"$ac_XPG2funcs" = xyes; then
914       ac_XPG2_wchar_t=yes
915     else
916       ac_XPG2_wchar_t=no
917     fi
918     AC_MSG_RESULT($ac_XPG2_wchar_t)
919   
920     dnl At the moment, only enable wchar_t specializations if all the
921     dnl above support is present.
922     AC_MSG_CHECKING([for enabled wchar_t specializations])
923     if test x"$ac_isoC99_wchar_t" = xyes &&
924        test x"$ac_XPG2_wchar_t" = xyes; then
925       AC_DEFINE(_GLIBCPP_USE_WCHAR_T)
926       AC_MSG_RESULT("yes")
927     else
928       AC_MSG_RESULT("no")
929     fi
930   else
931     dnl Wide characters disabled by the user. 
932     AC_MSG_WARN([wchar_t support disabled.])
933   fi
934 ])
935
936
937 dnl
938 dnl Check for special debugging mode; not for production use.
939 dnl
940 dnl GLIBCPP_ENABLE_DEBUG
941 dnl --enable-debug sets '-ggdb3 -O0'.
942 dnl --disable-debug sets '-g' and whatever optimization options the
943 dnl     compiler can handle.
944 dnl  +  --enable-maintainer-mode automatically defaults this to on.
945 dnl  +  Perhaps -D/-U of NDEBUG, DEBUG, DEBUG_ASSERT, ...?
946 dnl  +  Usage:  GLIBCPP_ENABLE_DEBUG[(DEFAULT)]
947 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
948 dnl       defaults to `no'.
949 AC_DEFUN(GLIBCPP_ENABLE_DEBUG, [dnl
950 define([GLIBCPP_ENABLE_DEBUG_DEFAULT], ifelse($1, yes, yes, no))dnl
951 AC_ARG_ENABLE(debug,
952 changequote(<<, >>)dnl
953 <<  --enable-debug          extra debugging, turn off optimization [default=>>GLIBCPP_ENABLE_DEBUG_DEFAULT],
954 changequote([, ])dnl
955 [case "${enableval}" in
956  yes) enable_debug=yes ;;
957  no)  enable_debug=no ;;
958  *)   AC_MSG_ERROR([Unknown argument to enable/disable extra debugging]) ;;
959  esac],
960 enable_debug=GLIBCPP_ENABLE_DEBUG_DEFAULT)dnl
961
962 dnl Option parsed, now set things appropriately
963 case "${enable_debug}" in
964     yes) 
965         DEBUG_FLAGS='-O0 -ggdb3'                        
966         ;; 
967     no)   
968         DEBUG_FLAGS='-g'
969         ;;
970 esac
971 AC_SUBST(DEBUG_FLAGS)
972 ])
973
974
975 dnl
976 dnl Check for "unusual" flags to pass to the compiler while building.
977 dnl
978 dnl GLIBCPP_ENABLE_CXX_FLAGS
979 dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
980 dnl     experimental flags such as -fhonor-std, -fsquangle, -Dfloat=char, etc.
981 dnl     Somehow this same set of flags must be passed when [re]building
982 dnl     libgcc.
983 dnl --disable-cxx-flags passes nothing.
984 dnl  +  See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
985 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
986 dnl         http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
987 dnl  +  Usage:  GLIBCPP_ENABLE_CXX_FLAGS(default flags)
988 dnl       If "default flags" is an empty string (or "none"), the effect is
989 dnl       the same as --disable or --enable=no.
990 AC_DEFUN(GLIBCPP_ENABLE_CXX_FLAGS, [dnl
991 define([GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT], ifelse($1,,, $1))dnl
992 AC_ARG_ENABLE(cxx-flags,
993 changequote(<<, >>)dnl
994 <<  --enable-cxx-flags=FLAGS      pass compiler FLAGS when building library;
995                                 [default=>>GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT],
996 changequote([, ])dnl
997 [case "x$enableval" in
998  xyes)   
999         AC_MSG_ERROR([--enable-cxx-flags needs compiler flags as arguments]) ;;
1000  xno|x)  
1001         enable_cxx_flags='' ;;
1002  *)      
1003         enable_cxx_flags="$enableval" ;;
1004  esac],
1005 enable_cxx_flags='GLIBCPP_ENABLE_CXX_FLAGS_DEFAULT')
1006
1007 dnl Thinko on my part during design.  This kludge is the workaround.
1008 if test "$enable_cxx_flags" = "none"; then 
1009   enable_cxx_flags=''; 
1010 fi
1011
1012 dnl Run through flags (either default or command-line) and set anything
1013 dnl extra (e.g., #defines) that must accompany particular g++ options.
1014 if test -n "$enable_cxx_flags"; then
1015     for f in $enable_cxx_flags; do
1016         case "$f" in
1017             -fhonor-std)  ;;
1018             -*)  ;;
1019             *)   # and we're trying to pass /what/ exactly?
1020                  AC_MSG_ERROR([compiler flags start with a -]) ;;
1021         esac
1022     done
1023 fi
1024 EXTRA_CXX_FLAGS="$enable_cxx_flags"
1025 AC_SUBST(EXTRA_CXX_FLAGS)
1026 ])
1027
1028
1029 dnl
1030 dnl Check for which locale library to use:  gnu or generic.
1031 dnl
1032 dnl GLIBCPP_ENABLE_CLOCALE
1033 dnl --enable-clocale=gnu sets config/locale/c_locale_gnu.cc and friends
1034 dnl --enable-clocale=generic sets config/locale/c_locale_generic.cc and friends
1035 dnl 
1036 dnl default is generic
1037 dnl
1038 AC_DEFUN(GLIBCPP_ENABLE_CLOCALE, [
1039   AC_MSG_CHECKING([for clocale to use])
1040   AC_ARG_ENABLE(clocale,
1041   [  --enable-clocale        enable model for target locale package. 
1042   --enable-clocale=MODEL  use MODEL target-speific locale package. [default=generic]
1043   ], 
1044   if test x$enable_clocale = xno; then
1045      enable_clocale=no
1046   fi,
1047      enable_clocale=no)
1048
1049   enable_clocale_flag=$enable_clocale
1050
1051   dnl Probe for locale support if no specific model is specified.
1052   dnl Default to "generic"
1053   if test x$enable_clocale_flag = xno; then
1054     case x${target_os} in
1055       xlinux* | xgnu*)
1056         AC_EGREP_CPP([_GLIBCPP_ok], [
1057         #include <features.h>
1058         #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1059           _GLIBCPP_ok
1060         #endif
1061         ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1062
1063         # Test for bugs early in glibc-2.2.x series
1064         if test x$enable_clocale_flag = xgnu; then
1065           AC_TRY_RUN([
1066           #define _GNU_SOURCE 1
1067           #include <locale.h>
1068           int main()
1069           {
1070             const char __one[] = "Äuglein Augmen";
1071             const char __two[] = "Äuglein";
1072             int i;
1073             int j;
1074             __locale_t  loc;
1075             __locale_t  loc_dup;
1076             loc = __newlocale(1 << LC_ALL, "de_DE", 0);
1077             loc_dup = __duplocale(loc);
1078             i = __strcoll_l(__one, __two, loc);
1079             j = __strcoll_l(__one, __two, loc_dup);
1080             return 0;
1081           }
1082           ], 
1083           [enable_clocale_flag=gnu],[enable_clocale_flag=generic],
1084           [enable_clocale_flag=generic])
1085         fi
1086
1087         # ... at some point put __strxfrm_l tests in as well.
1088         ;;
1089       *)
1090         enable_clocale_flag=generic
1091         ;;
1092     esac
1093   fi
1094
1095   dnl Set configure bits for specified locale package
1096   case x${enable_clocale_flag} in
1097     xgeneric)
1098       AC_MSG_RESULT(generic)
1099
1100       # Don't use gettext.
1101       USE_NLS=no
1102
1103       CLOCALE_H=config/locale/c_locale_generic.h
1104       CLOCALE_CC=config/locale/c_locale_generic.cc
1105       CCODECVT_H=config/locale/codecvt_specializations_generic.h
1106       CCOLLATE_CC=config/locale/collate_members_generic.cc
1107       CCTYPE_CC=config/locale/ctype_members_generic.cc
1108       CMESSAGES_H=config/locale/messages_members_generic.h
1109       CMESSAGES_CC=config/locale/messages_members_generic.cc
1110       CMONEY_CC=config/locale/moneypunct_members_generic.cc
1111       CNUMERIC_CC=config/locale/numpunct_members_generic.cc
1112       CTIME_CC=config/locale/time_members_generic.cc
1113       ;;
1114     xgnu)
1115       AC_MSG_RESULT(gnu)
1116
1117       # Declare intention to use gettext, and add support for specific
1118       # languages.
1119       # For some reason, ALL_LINGUAS has to be before AM_GNU_GETTEXT
1120       ALL_LINGUAS="de fr"
1121       # Don't call AM_GNU_GETTEXT here. Instead, assume glibc.
1122       # Need to deal with MSGFMT, USE_NLS, and glibcpp_[P,M]OFILES
1123       USE_NLS=yes
1124
1125       # Export the build objects.
1126       for ling in $ALL_LINGUAS; do \
1127         glibcpp_MOFILES="$glibcpp_MOFILES $ling.mo"; \
1128         glibcpp_POFILES="$glibcpp_POFILES $ling.po"; \
1129       done
1130       AC_SUBST(glibcpp_MOFILES)
1131       AC_SUBST(glibcpp_POFILES)
1132
1133       CLOCALE_H=config/locale/c_locale_gnu.h
1134       CLOCALE_CC=config/locale/c_locale_gnu.cc
1135       CCODECVT_H=config/locale/codecvt_specializations_ieee_1003.1-200x.h
1136       CCOLLATE_CC=config/locale/collate_members_gnu.cc
1137       CCTYPE_CC=config/locale/ctype_members_gnu.cc
1138       CMESSAGES_H=config/locale/messages_members_gnu.h
1139       CMESSAGES_CC=config/locale/messages_members_gnu.cc
1140       CMONEY_CC=config/locale/moneypunct_members_gnu.cc
1141       CNUMERIC_CC=config/locale/numpunct_members_gnu.cc
1142       CTIME_CC=config/locale/time_members_gnu.cc
1143       ;;
1144     xieee_1003.1)
1145       AC_MSG_RESULT(generic)
1146
1147       # Don't use gettext.
1148       USE_NLS=no
1149
1150       CLOCALE_H=config/locale/c_locale_ieee_1003.1-200x.h
1151       CLOCALE_CC=config/locale/c_locale_ieee_1003.1-200x.cc
1152       CCODECVT_H=config/locale/codecvt_specializations_ieee_1003.1-200x.h
1153       CCOLLATE_CC=config/locale/collate_members_generic.cc
1154       CCTYPE_CC=config/locale/ctype_members_generic.cc
1155       CMESSAGES_H=config/locale/messages_members_ieee_1003.1-200x.h
1156       CMESSAGES_CC=config/locale/messages_members_ieee_1003.1-200x.cc
1157       CMONEY_CC=config/locale/moneypunct_members_generic.cc
1158       CNUMERIC_CC=config/locale/numpunct_members_generic.cc
1159       CTIME_CC=config/locale/time_members_generic.cc
1160       ;;
1161     *)
1162       echo "$enable_clocale is an unknown locale package" 1>&2
1163       exit 1
1164       ;;
1165   esac
1166
1167   # This is where the testsuite looks for locale catalogs, using the
1168   # -DLOCALEDIR define during testsuite compilation.
1169   glibcpp_localedir=${glibcpp_builddir}/po/share/locale
1170   AC_SUBST(glibcpp_localedir)
1171
1172   AC_SUBST(USE_NLS)
1173   AC_SUBST(CLOCALE_H)
1174   AC_SUBST(CCODECVT_H)
1175   AC_SUBST(CMESSAGES_H)
1176   AC_LINK_FILES($CLOCALE_CC, src/c++locale.cc)
1177   AC_LINK_FILES($CCOLLATE_CC, src/collate.cc)
1178   AC_LINK_FILES($CCTYPE_CC, src/ctype.cc)
1179   AC_LINK_FILES($CMESSAGES_CC, src/messages.cc)
1180   AC_LINK_FILES($CMONEY_CC, src/moneypunct.cc)
1181   AC_LINK_FILES($CNUMERIC_CC, src/numpunct.cc)
1182   AC_LINK_FILES($CTIME_CC, src/time.cc)
1183 ])
1184
1185
1186 dnl
1187 dnl Check for which I/O library to use:  libio, or something specific.
1188 dnl
1189 dnl GLIBCPP_ENABLE_CSTDIO
1190 dnl --enable-cstdio=libio sets config/io/c_io_libio.h and friends
1191 dnl 
1192 dnl default is stdio
1193 dnl
1194 AC_DEFUN(GLIBCPP_ENABLE_CSTDIO, [
1195   AC_MSG_CHECKING([for cstdio to use])
1196   AC_ARG_ENABLE(cstdio,
1197   [  --enable-cstdio         enable stdio for target io package. 
1198   --enable-cstdio=LIB     use LIB target-speific io package. [default=stdio]
1199   ], 
1200   if test x$enable_cstdio = xno; then
1201      enable_cstdio=stdio
1202   fi,
1203      enable_cstdio=stdio)
1204
1205   enable_cstdio_flag=$enable_cstdio
1206
1207   dnl Check if a valid I/O package
1208   case x${enable_cstdio_flag} in
1209     xlibio)
1210       CSTDIO_H=config/io/c_io_libio.h
1211       BASIC_FILE_H=config/io/basic_file_libio.h
1212       BASIC_FILE_CC=config/io/basic_file_libio.cc
1213       AC_MSG_RESULT(libio)
1214
1215       # see if we are on a system with libio native (ie, linux)
1216       AC_CHECK_HEADER(libio.h,  has_libio=yes, has_libio=no)
1217
1218       # Need to check and see what version of glibc is being used. If
1219       # it's not glibc-2.2 or higher, then we'll need to go ahead and 
1220       # compile most of libio for linux systems.
1221       if test x$has_libio = x"yes"; then
1222         case "$target" in
1223           *-*-linux*)
1224               AC_MSG_CHECKING([for glibc version >= 2.2])
1225               AC_EGREP_CPP([ok], [
1226             #include <features.h>
1227               #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
1228                     ok
1229               #endif
1230               ], glibc_satisfactory=yes, glibc_satisfactory=no)
1231               AC_MSG_RESULT($glibc_satisfactory)
1232             ;;
1233         esac
1234
1235         # XXX at the moment, admit defeat and force the recompilation
1236         # XXX of glibc even on glibc-2.2 systems, because libio is not synched.
1237         glibc_satisfactory=no        
1238
1239         if test x$glibc_satisfactory = x"yes"; then
1240            need_libio=no
1241            need_wlibio=no        
1242         else
1243            need_libio=yes
1244            # bkoz XXX need to add checks to enable this
1245            # pme XXX here's a first pass at such a check
1246            if test x$enable_c_mbchar != xno; then
1247               need_wlibio=yes
1248            else
1249               need_wlibio=no
1250            fi
1251         fi
1252
1253       else
1254          # Using libio, but <libio.h> doesn't exist on the target system. . .
1255          need_libio=yes
1256          # bkoz XXX need to add checks to enable this
1257          # pme XXX here's a first pass at such a check
1258          if test x$enable_c_mbchar != xno; then
1259              need_wlibio=yes
1260          else
1261              need_wlibio=no
1262          fi
1263       fi
1264       ;;
1265     xstdio | x | xno | xnone | xyes)
1266       # default
1267       CSTDIO_H=config/io/c_io_stdio.h
1268       BASIC_FILE_H=config/io/basic_file_stdio.h
1269       BASIC_FILE_CC=config/io/basic_file_stdio.cc
1270       AC_MSG_RESULT(stdio)
1271
1272       # We're not using stdio.
1273       need_libio=no
1274       need_wlibio=no
1275       ;;
1276     *)
1277       echo "$enable_cstdio is an unknown io package" 1>&2
1278       exit 1
1279       ;;
1280   esac
1281   AC_SUBST(CSTDIO_H)
1282   AC_SUBST(BASIC_FILE_H)
1283   AC_LINK_FILES($BASIC_FILE_CC, src/basic_file.cc)
1284
1285   # 2000-08-04 bkoz hack
1286   CCODECVT_C=config/io/c_io_libio_codecvt.c
1287   AC_SUBST(CCODECVT_C)
1288   # 2000-08-04 bkoz hack
1289
1290   AM_CONDITIONAL(GLIBCPP_BUILD_LIBIO,
1291                  test "$need_libio" = yes || test "$need_wlibio" = yes)
1292   AM_CONDITIONAL(GLIBCPP_NEED_LIBIO, test "$need_libio" = yes)
1293   AM_CONDITIONAL(GLIBCPP_NEED_WLIBIO, test "$need_wlibio" = yes)
1294   if test "$need_libio" = yes || test "$need_wlibio" = yes; then
1295     libio_la=../libio/libio.la
1296   else
1297     libio_la=
1298   fi
1299   AC_SUBST(libio_la)
1300 ])
1301
1302
1303 dnl
1304 dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
1305 dnl We must stage the required headers so that they will be installed
1306 dnl with the library (unlike libgcc, the STL implementation is provided
1307 dnl solely within headers).  Since we must not inject random user-space
1308 dnl macro names into user-provided C++ code, we first stage into <file>-in
1309 dnl and process to <file> with an output command.  The reason for a two-
1310 dnl stage process here is to correctly handle $srcdir!=$objdir without
1311 dnl having to write complex code (the sed commands to clean the macro
1312 dnl namespace are complex and fragile enough as it is).  We must also
1313 dnl add a relative path so that -I- is supported properly.
1314 dnl
1315 AC_DEFUN(GLIBCPP_ENABLE_THREADS, [
1316   AC_MSG_CHECKING([for thread model used by GCC])
1317   target_thread_file=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
1318   AC_MSG_RESULT([$target_thread_file])
1319
1320   if test $target_thread_file != single; then
1321     AC_DEFINE(HAVE_GTHR_DEFAULT)
1322     AC_DEFINE(_GLIBCPP_SUPPORTS_WEAK, __GXX_WEAK__)
1323   fi
1324
1325   glibcpp_thread_h=gthr-$target_thread_file.h
1326   AC_SUBST(glibcpp_thread_h)
1327 ])
1328
1329
1330 dnl
1331 dnl Check for exception handling support.  If an explicit enable/disable
1332 dnl sjlj exceptions is given, we don't have to detect.  Otherwise the
1333 dnl target may or may not support call frame exceptions.
1334 dnl
1335 dnl GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
1336 dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
1337 dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1338 dnl
1339 dnl Define _GLIBCPP_SJLJ_EXCEPTIONS if the compiler is configured for it.
1340 dnl
1341 AC_DEFUN(GLIBCPP_ENABLE_SJLJ_EXCEPTIONS, [
1342   AC_MSG_CHECKING([for exception model to use])
1343   AC_LANG_SAVE
1344   AC_LANG_CPLUSPLUS
1345   AC_ARG_ENABLE(sjlj-exceptions,
1346   [  --enable-sjlj-exceptions  force use of builtin_setjmp for exceptions],
1347   [:],
1348   [dnl Botheration.  Now we've got to detect the exception model.
1349    dnl Link tests against libgcc.a are problematic since -- at least
1350    dnl as of this writing -- we've not been given proper -L bits for
1351    dnl single-tree newlib and libgloss.
1352    dnl
1353    dnl This is what AC_TRY_COMPILE would do if it didn't delete the
1354    dnl conftest files before we got a change to grep them first.
1355    cat > conftest.$ac_ext << EOF
1356 [#]line __oline__ "configure"
1357 struct S { ~S(); };
1358 void bar();
1359 void foo()
1360 {
1361   S s;
1362   bar();
1363 }
1364 EOF
1365    old_CXXFLAGS="$CXXFLAGS"  
1366    CXXFLAGS=-S
1367    if AC_TRY_EVAL(ac_compile); then
1368      if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
1369        enable_sjlj_exceptions=yes
1370      elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
1371        enable_sjlj_exceptions=no
1372      fi
1373    fi
1374    CXXFLAGS="$old_CXXFLAGS"
1375    rm -f conftest*])
1376    if test x$enable_sjlj_exceptions = xyes; then
1377      AC_DEFINE(_GLIBCPP_SJLJ_EXCEPTIONS, 1,
1378         [Define if the compiler is configured for setjmp/longjmp exceptions.])
1379      ac_exception_model_name=sjlj
1380    elif test x$enable_sjlj_exceptions = xno; then
1381      ac_exception_model_name="call frame"
1382    else
1383      AC_MSG_ERROR([unable to detect exception model])
1384    fi
1385    AC_LANG_RESTORE
1386    AC_MSG_RESULT($ac_exception_model_name)
1387 ])
1388
1389
1390 dnl
1391 dnl Check for ISO/IEC 9899:1999 "C99" support.
1392 dnl
1393 dnl GLIBCPP_ENABLE_C99
1394 dnl --enable-c99 defines _GLIBCPP_USE_C99
1395 dnl --disable-c99 leaves _GLIBCPP_USE_C99 undefined
1396 dnl  +  Usage:  GLIBCPP_ENABLE_C99[(DEFAULT)]
1397 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1398 dnl       defaults to `no'.
1399 dnl  +  If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
1400 dnl
1401 dnl GLIBCPP_ENABLE_C99
1402 AC_DEFUN(GLIBCPP_ENABLE_C99, [dnl
1403   define([GLIBCPP_ENABLE_C99_DEFAULT], ifelse($1, yes, yes, no))dnl
1404
1405   AC_ARG_ENABLE(c99,
1406   changequote(<<, >>)dnl
1407   <<--enable-c99            turns on 'ISO/IEC 9899:1999 support' [default=>>GLIBCPP_ENABLE_C99_DEFAULT],
1408   changequote([, ])dnl
1409   [case "$enableval" in
1410    yes) enable_c99=yes ;;
1411    no)  enable_c99=no ;;
1412    *)   AC_MSG_ERROR([Unknown argument to enable/disable C99]) ;;
1413    esac],
1414   enable_c99=GLIBCPP_ENABLE_C99_DEFAULT)dnl
1415  
1416   AC_LANG_SAVE
1417   AC_LANG_CPLUSPLUS
1418
1419   # Check for the existence of <math.h> functions used if C99 is enabled.
1420   ac_c99_math=yes;
1421   AC_MSG_CHECKING([for ISO C99 support in <math.h>])
1422   AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
1423   AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
1424   AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
1425   AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
1426   AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
1427   AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
1428   AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
1429   AC_TRY_COMPILE([#include <math.h>],
1430                  [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
1431   AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
1432   AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
1433   AC_TRY_COMPILE([#include <math.h>],
1434                  [islessgreater(0.0,0.0);],, [ac_c99_math=no])
1435   AC_TRY_COMPILE([#include <math.h>],
1436                  [isunordered(0.0,0.0);],, [ac_c99_math=no])
1437   AC_MSG_RESULT($ac_c99_math)
1438
1439   # Check for the existence in <stdio.h> of vscanf, et. al.
1440   ac_c99_stdio=yes;
1441   AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
1442   AC_TRY_COMPILE([#include <stdio.h>],
1443                  [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
1444   AC_TRY_COMPILE([#include <stdio.h>
1445                   #include <stdarg.h>
1446                   void foo(char* fmt, ...)
1447                   {va_list args; va_start(args, fmt);
1448                   vfscanf(stderr, "%i", args);}],
1449                   [],, [ac_c99_stdio=no])
1450   AC_TRY_COMPILE([#include <stdio.h>
1451                   #include <stdarg.h>
1452                   void foo(char* fmt, ...)
1453                   {va_list args; va_start(args, fmt);
1454                   vscanf("%i", args);}],
1455                   [],, [ac_c99_stdio=no])
1456   AC_TRY_COMPILE([#include <stdio.h>
1457                   #include <stdarg.h>
1458                   void foo(char* fmt, ...)
1459                   {va_list args; va_start(args, fmt);
1460                   vsnprintf(fmt, 0, "%i", args);}],
1461                   [],, [ac_c99_stdio=no])
1462   AC_TRY_COMPILE([#include <stdio.h>
1463                   #include <stdarg.h>
1464                   void foo(char* fmt, ...)
1465                   {va_list args; va_start(args, fmt);
1466                   vsscanf(fmt, "%i", args);}],
1467                   [],, [ac_c99_stdio=no])
1468   AC_MSG_RESULT($ac_c99_stdio)
1469
1470   # Check for the existence in <stdlib.h> of lldiv_t, et. al.
1471   ac_c99_stdlib=yes;
1472   AC_MSG_CHECKING([for lldiv_t declaration])
1473   AC_CACHE_VAL(ac_c99_lldiv_t, [
1474   AC_TRY_COMPILE([#include <stdlib.h>], 
1475                    [ lldiv_t mydivt;], 
1476                    [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
1477   ])
1478   AC_MSG_RESULT($ac_c99_lldiv_t)
1479
1480   AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
1481   AC_TRY_COMPILE([#include <stdlib.h>],
1482                  [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
1483   AC_TRY_COMPILE([#include <stdlib.h>],
1484                  [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
1485   AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
1486   AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
1487   AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
1488   AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
1489   if test x"$ac_c99_lldiv_t" = x"no"; then
1490     ac_c99_stdlib=no; 
1491   fi; 
1492   AC_MSG_RESULT($ac_c99_stdlib)
1493
1494   # Check for the existence of <wchar.h> functions used if C99 is enabled.
1495   # XXX the wchar.h checks should be rolled into the general C99 bits.
1496   ac_c99_wchar=yes;
1497   AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
1498   AC_TRY_COMPILE([#include <wchar.h>], 
1499                  [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
1500   AC_TRY_COMPILE([#include <wchar.h>], 
1501                  [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
1502   AC_TRY_COMPILE([#include <wchar.h>], 
1503                  [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
1504   AC_MSG_RESULT($ac_c99_wchar)
1505
1506   AC_MSG_CHECKING([for enabled ISO C99 support])
1507   if test x"$ac_c99_math" = x"no" ||
1508      test x"$ac_c99_stdio" = x"no" ||
1509      test x"$ac_c99_stdlib" = x"no" ||
1510      test x"$ac_c99_wchar" = x"no"; then
1511     enable_c99=no; 
1512   fi; 
1513   AC_MSG_RESULT($enable_c99)
1514
1515   # Option parsed, now set things appropriately
1516   if test x"$enable_c99" = x"yes"; then
1517     AC_DEFINE(_GLIBCPP_USE_C99)
1518   fi
1519
1520   AC_LANG_RESTORE
1521 ])
1522
1523
1524 dnl
1525 dnl Check for template specializations for the 'long long' type extension.
1526 dnl The result determines only whether 'long long' I/O is enabled; things
1527 dnl like numeric_limits<> specializations are always available.
1528 dnl
1529 dnl GLIBCPP_ENABLE_LONG_LONG
1530 dnl --enable-long-long defines _GLIBCPP_USE_LONG_LONG
1531 dnl --disable-long-long leaves _GLIBCPP_USE_LONG_LONG undefined
1532 dnl  +  Usage:  GLIBCPP_ENABLE_LONG_LONG[(DEFAULT)]
1533 dnl       Where DEFAULT is either `yes' or `no'.  If omitted, it
1534 dnl       defaults to `no'.
1535 dnl  +  If 'long long' stuff is not available, ignores DEFAULT and sets `no'.
1536 dnl
1537 dnl GLIBCPP_ENABLE_LONG_LONG
1538 AC_DEFUN(GLIBCPP_ENABLE_LONG_LONG, [dnl
1539   define([GLIBCPP_ENABLE_LONG_LONG_DEFAULT], ifelse($1, yes, yes, no))dnl
1540
1541   AC_ARG_ENABLE(long-long,
1542   changequote(<<, >>)dnl
1543   <<--enable-long-long      turns on 'long long' [default=>>GLIBCPP_ENABLE_LONG_LONG_DEFAULT],
1544   changequote([, ])dnl
1545   [case "$enableval" in
1546    yes) enable_long_long=yes ;;
1547    no)  enable_long_long=no ;;
1548    *)   AC_MSG_ERROR([Unknown argument to enable/disable long long]) ;;
1549    esac],
1550   enable_long_long=GLIBCPP_ENABLE_LONG_LONG_DEFAULT)dnl
1551
1552   AC_LANG_SAVE
1553   AC_LANG_CPLUSPLUS
1554
1555   AC_MSG_CHECKING([for enabled long long I/O support])
1556   # iostreams require strtoll, strtoull to compile
1557   AC_TRY_COMPILE([#include <stdlib.h>],
1558                  [char* tmp; strtoll("gnu", &tmp, 10);],,[enable_long_long=no])
1559   AC_TRY_COMPILE([#include <stdlib.h>],
1560                  [char* tmp; strtoull("gnu", &tmp, 10);],,[enable_long_long=no])
1561
1562   # Option parsed, now set things appropriately
1563   if test x"$enable_long_long" = xyes; then
1564     AC_DEFINE(_GLIBCPP_USE_LONG_LONG)
1565   fi
1566   AC_MSG_RESULT($enable_long_long)
1567
1568   AC_LANG_RESTORE
1569 ])
1570
1571
1572 dnl
1573 dnl Check for what kind of C headers to use.
1574 dnl
1575 dnl GLIBCPP_ENABLE_CHEADERS
1576 dnl --enable-cheaders= [does stuff].
1577 dnl --disable-cheaders [does not do anything, really].
1578 dnl  +  This will eventually need to be 'c_shadow' by default.
1579 dnl  +  Usage:  GLIBCPP_ENABLE_CHEADERS[(DEFAULT)]
1580 dnl       Where DEFAULT is either `c' or `c_std' or 'c_shadow'.  
1581 dnl       If ommitted, it defaults to `c_std'.
1582 AC_DEFUN(GLIBCPP_ENABLE_CHEADERS, [dnl
1583 define([GLIBCPP_ENABLE_CHEADERS_DEFAULT], ifelse($1, c_std, c_std, c_std))dnl
1584 AC_MSG_CHECKING([for c header strategy to use])
1585 AC_ARG_ENABLE(cheaders,
1586 changequote(<<, >>)dnl
1587 <<  --enable-cheaders       construct "C" header files for g++ [default=>>GLIBCPP_ENABLE_CHEADERS_DEFAULT],
1588 changequote([, ])
1589   [case "$enableval" in
1590    c) 
1591         enable_cheaders=c 
1592         ;;
1593    c_std)  
1594         enable_cheaders=c_std 
1595         ;;
1596    c_shadow)  
1597         enable_cheaders=c_shadow 
1598         ;;
1599    *)   AC_MSG_ERROR([Unknown argument to enable/disable "C" headers]) 
1600         ;;
1601   esac],
1602   enable_cheaders=GLIBCPP_ENABLE_CHEADERS_DEFAULT)
1603   AC_MSG_RESULT($enable_cheaders)
1604
1605   dnl Option parsed, now set things appropriately
1606   case "$enable_cheaders" in
1607     c_shadow) 
1608         CSHADOW_FLAGS="-fno-builtin"
1609         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_shadow'
1610         AC_DEFINE(_GLIBCPP_USE_SHADOW_HEADERS)
1611         ;;
1612     c_std)   
1613         CSHADOW_FLAGS=""
1614         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c_std'
1615         ;;
1616     c)   
1617         CSHADOW_FLAGS=""
1618         C_INCLUDE_DIR='${glibcpp_srcdir}/include/c'
1619         ;;
1620   esac
1621
1622   AC_SUBST(CSHADOW_FLAGS)
1623   AC_SUBST(C_INCLUDE_DIR)
1624   AM_CONDITIONAL(GLIBCPP_USE_CSHADOW, test "$enable_cheaders" = c_shadow)
1625 ])
1626
1627
1628 dnl
1629 dnl Check for wide character support.  Has the same effect as the option
1630 dnl in gcc's configure, but in a form that autoconf can mess with.
1631 dnl
1632 dnl GLIBCPP_ENABLE_C_MBCHAR
1633 dnl --enable-c-mbchar requests all the wchar_t stuff.
1634 dnl --disable-c-mbchar doesn't.
1635 dnl  +  Usage:  GLIBCPP_ENABLE_C_MBCHAR[(DEFAULT)]
1636 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1637 dnl       defaults to `no'.
1638 AC_DEFUN(GLIBCPP_ENABLE_C_MBCHAR, [dnl
1639 define([GLIBCPP_ENABLE_C_MBCHAR_DEFAULT], ifelse($1, yes, yes, no))dnl
1640 AC_ARG_ENABLE(c-mbchar,
1641 changequote(<<, >>)dnl
1642 <<  --enable-c-mbchar       enable multibyte (wide) characters [default=>>GLIBCPP_ENABLE_C_MBCHAR_DEFAULT],
1643 changequote([, ])dnl
1644 [case "$enableval" in
1645  yes) enable_c_mbchar=yes ;;
1646  no)  enable_c_mbchar=no ;;
1647  *)   AC_MSG_ERROR([Unknown argument to enable/disable c-mbchar]) ;;
1648  esac],
1649 enable_c_mbchar=GLIBCPP_ENABLE_C_MBCHAR_DEFAULT)dnl
1650 dnl Option parsed, now other scripts can test enable_c_mbchar for yes/no.
1651 ])
1652
1653
1654 dnl
1655 dnl Set up *_INCLUDES and *_INCLUDE_DIR variables for all sundry Makefile.am's.
1656 dnl
1657 dnl TOPLEVEL_INCLUDES
1658 dnl LIBMATH_INCLUDES
1659 dnl LIBSUPCXX_INCLUDES
1660 dnl LIBIO_INCLUDES
1661 dnl CSHADOW_INCLUDES
1662 dnl
1663 dnl GLIBCPP_EXPORT_INCLUDES
1664 AC_DEFUN(GLIBCPP_EXPORT_INCLUDES, [
1665   # Root level of the build directory include sources.
1666   GLIBCPP_INCLUDES="-I${glibcpp_builddir}/include/${target_alias} -I${glibcpp_builddir}/include"
1667
1668   # Passed down for canadian crosses.
1669   if test x"$CANADIAN" = xyes; then
1670     TOPLEVEL_INCLUDES='-I$(includedir)'
1671   fi
1672
1673   LIBMATH_INCLUDES='-I$(top_srcdir)/libmath'
1674
1675   LIBSUPCXX_INCLUDES='-I$(top_srcdir)/libsupc++'
1676
1677   if test x"$need_libio" = xyes; then
1678     LIBIO_INCLUDES='-I$(top_builddir)/libio -I$(top_srcdir)/libio'
1679     AC_SUBST(LIBIO_INCLUDES)
1680   fi
1681
1682   # Now, export this to all the little Makefiles....
1683   AC_SUBST(GLIBCPP_INCLUDES)
1684   AC_SUBST(TOPLEVEL_INCLUDES)
1685   AC_SUBST(LIBMATH_INCLUDES)
1686   AC_SUBST(LIBSUPCXX_INCLUDES)
1687 ])
1688
1689
1690 dnl
1691 dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
1692 dnl
1693 AC_DEFUN(GLIBCPP_EXPORT_FLAGS, [
1694   # Optimization flags that are probably a good idea for thrill-seekers. Just
1695   # uncomment the lines below and make, everything else is ready to go... 
1696   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc 
1697   OPTIMIZE_CXXFLAGS=
1698   AC_SUBST(OPTIMIZE_CXXFLAGS)
1699
1700   WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings -Winline'
1701   AC_SUBST(WARN_FLAGS)
1702 ])
1703
1704 dnl
1705 dnl  GLIBCPP_EXPORT_INSTALL_INFO
1706 dnl  calculates gxx_install_dir
1707 dnl  exports glibcpp_toolexecdir
1708 dnl  exports glibcpp_toolexeclibdir
1709 dnl  exports glibcpp_prefixdir
1710 dnl
1711 dnl Assumes cross_compiling bits already done, and with_cross_host in
1712 dnl particular
1713 dnl
1714 dnl GLIBCPP_EXPORT_INSTALL_INFO
1715 AC_DEFUN(GLIBCPP_EXPORT_INSTALL_INFO, [
1716 # Assumes glibcpp_builddir, glibcpp_srcdir are alreay set up and
1717 # exported correctly in GLIBCPP_CONFIGURE.
1718 glibcpp_toolexecdir=no
1719 glibcpp_toolexeclibdir=no
1720 glibcpp_prefixdir=${prefix}
1721
1722 AC_MSG_CHECKING([for interface version number])
1723 libstdcxx_interface=$INTERFACE
1724 AC_MSG_RESULT($libstdcxx_interface)
1725
1726 # Process the option --with-gxx-include-dir=<path to include-files directory>
1727 AC_MSG_CHECKING([for --with-gxx-include-dir])
1728 AC_ARG_WITH(gxx-include-dir,
1729 [  --with-gxx-include-dir  the installation directory for include files],
1730 [case "${withval}" in
1731   yes)
1732     AC_MSG_ERROR(Missing directory for --with-gxx-include-dir)
1733     gxx_include_dir=no
1734     ;;
1735   no)
1736     gxx_include_dir=no
1737     ;;
1738   *)
1739     gxx_include_dir=${withval}
1740     ;;
1741 esac], [gxx_include_dir=no])
1742 AC_MSG_RESULT($gxx_include_dir)
1743
1744 # Process the option "--enable-version-specific-runtime-libs"
1745 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
1746 AC_ARG_ENABLE(version-specific-runtime-libs,
1747 [  --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory ],
1748 [case "$enableval" in
1749  yes) version_specific_libs=yes ;;
1750  no)  version_specific_libs=no ;;
1751  *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
1752  esac],
1753 version_specific_libs=no)dnl
1754 # Option set, now we can test it.
1755 AC_MSG_RESULT($version_specific_libs)
1756
1757 if test $version_specific_libs = yes; then
1758   # Need the gcc compiler version to know where to install libraries
1759   # and header files if --enable-version-specific-runtime-libs option
1760   # is selected.
1761   changequote(,)dnl
1762   gcc_version_trigger=${srcdir}/../gcc/version.c
1763   gcc_version_full=`grep version_string ${gcc_version_trigger} | sed -e 's/.*\"\([^\"]*\)\".*/\1/'`
1764   gcc_version=`echo ${gcc_version_full} | sed -e 's/\([^ ]*\) .*/\1/'`
1765   gxx_include_dir='$(libdir)/gcc-lib/$(target_alias)/'${gcc_version}/include/g++
1766   glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1767   glibcpp_toolexeclibdir='$(toolexecdir)/'${gcc_version}'$(MULTISUBDIR)'
1768   changequote([,])dnl
1769 fi
1770
1771 # Default case for install directory for include files.
1772 if test $version_specific_libs = no &&
1773    test $gxx_include_dir = no; then
1774   gxx_include_dir='$(prefix)'/include/g++-${libstdcxx_interface}
1775 fi
1776
1777 # Calculate glibcpp_toolexecdir, glibcpp_toolexeclibdir
1778 # Install a library built with a cross compiler in tooldir, not libdir.
1779 if test x"$glibcpp_toolexecdir" = x"no"; then 
1780   if test -n "$with_cross_host" &&
1781      test x"$with_cross_host" != x"no"; then
1782     glibcpp_toolexecdir='$(exec_prefix)/$(target_alias)'
1783     glibcpp_toolexeclibdir='$(toolexecdir)/lib$(MULTISUBDIR)'
1784   else
1785     glibcpp_toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
1786     glibcpp_toolexeclibdir='$(libdir)$(MULTISUBDIR)'
1787   fi
1788 fi
1789
1790 AC_MSG_CHECKING([for install location])
1791 AC_MSG_RESULT($gxx_include_dir)
1792
1793 AC_SUBST(glibcpp_prefixdir)
1794 AC_SUBST(gxx_include_dir)
1795 AC_SUBST(glibcpp_toolexecdir)
1796 AC_SUBST(glibcpp_toolexeclibdir)
1797 ])
1798
1799
1800 # Check for functions in math library.
1801 # Ulrich Drepper <drepper@cygnus.com>, 1998.
1802 #
1803 # This file can be copied and used freely without restrictions.  It can
1804 # be used in projects which are not available under the GNU Public License
1805 # but which still want to provide support for the GNU gettext functionality.
1806 # Please note that the actual code is *not* freely available.
1807
1808 # serial 1
1809
1810 dnl AC_REPLACE_MATHFUNCS(FUNCTION...)
1811 AC_DEFUN(AC_REPLACE_MATHFUNCS,
1812 [AC_CHECK_FUNCS([$1], , [LIBMATHOBJS="$LIBMATHOBJS ${ac_func}.lo"])
1813 AC_SUBST(LIBMATHOBJS)dnl
1814 ])
1815
1816
1817
1818 dnl This macro searches for a GNU version of make.  If a match is found, the
1819 dnl makefile variable `ifGNUmake' is set to the empty string, otherwise it is
1820 dnl set to "#". This is useful for  including a special features in a Makefile,
1821 dnl which cannot be handled by other versions of make.  The variable
1822 dnl _cv_gnu_make_command is set to the command to invoke GNU make if it exists,
1823 dnl the empty string otherwise.
1824 dnl
1825 dnl Here is an example of its use:
1826 dnl
1827 dnl Makefile.in might contain:
1828 dnl
1829 dnl     # A failsafe way of putting a dependency rule into a makefile
1830 dnl     $(DEPEND):
1831 dnl             $(CC) -MM $(srcdir)/*.c > $(DEPEND)
1832 dnl
1833 dnl     @ifGNUmake@ ifeq ($(DEPEND),$(wildcard $(DEPEND)))
1834 dnl     @ifGNUmake@ include $(DEPEND)
1835 dnl     @ifGNUmake@ endif
1836 dnl
1837 dnl Then configure.in would normally contain:
1838 dnl
1839 dnl     CHECK_GNU_MAKE()
1840 dnl     AC_OUTPUT(Makefile)
1841 dnl
1842 dnl Then perhaps to cause gnu make to override any other make, we could do
1843 dnl something like this (note that GNU make always looks for GNUmakefile first):
1844 dnl
1845 dnl     if  ! test x$_cv_gnu_make_command = x ; then
1846 dnl             mv Makefile GNUmakefile
1847 dnl             echo .DEFAULT: > Makefile ;
1848 dnl             echo \  $_cv_gnu_make_command \$@ >> Makefile;
1849 dnl     fi
1850 dnl
1851 dnl Then, if any (well almost any) other make is called, and GNU make also
1852 dnl exists, then the other make wraps the GNU make.
1853 dnl
1854 dnl @author John Darrington <j.darrington@elvis.murdoch.edu.au>
1855 dnl @version 1.1 #### replaced Id string now that Id is for lib-v3; pme
1856 dnl
1857 dnl #### Changes for libstdc++-v3:  reformatting and linewrapping; prepending
1858 dnl #### GLIBCPP_ to the macro name; adding the :-make fallback in the
1859 dnl #### conditional's subshell (" --version" is not a command), using a
1860 dnl #### different option to grep(1).
1861 dnl #### -pme
1862 dnl #### Fixed Bourne shell portability bug (use ${MAKE-make}, not
1863 dnl #### ${MAKE:-make}).
1864 dnl #### -msokolov
1865 AC_DEFUN(
1866   GLIBCPP_CHECK_GNU_MAKE, [AC_CACHE_CHECK( for GNU make,_cv_gnu_make_command,
1867           _cv_gnu_make_command='' ;
1868 dnl Search all the common names for GNU make
1869           for a in "${MAKE-make}" make gmake gnumake ; do
1870                   if ( $a --version 2> /dev/null | grep -c GNU > /dev/null )
1871                   then
1872                           _cv_gnu_make_command=$a ;
1873                           break;
1874                   fi
1875           done ;
1876   ) ;
1877 dnl If there was a GNU version, then set @ifGNUmake@ to the empty
1878 dnl string, '#' otherwise
1879   if test  "x$_cv_gnu_make_command" != "x"  ; then
1880           ifGNUmake='' ;
1881   else
1882           ifGNUmake='#' ;
1883   fi
1884   AC_SUBST(ifGNUmake)
1885 ])
1886
1887
1888 dnl Check for headers for, and arguments to, the setrlimit() function.
1889 dnl Used only in testsuite_hooks.h.
1890 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
1891   AC_TRY_COMPILE([#include <sys/resource.h>
1892                   #include <unistd.h>
1893                  ], [ int f = RLIMIT_$1 ; ],
1894                  [glibcpp_mresult=1], [glibcpp_mresult=0])
1895   AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
1896                      [Only used in build directory testsuite_hooks.h.])
1897 ])
1898 AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
1899   setrlimit_have_headers=yes
1900   AC_CHECK_HEADERS(sys/resource.h unistd.h,
1901                    [],
1902                    setrlimit_have_headers=no)
1903   # If don't have the headers, then we can't run the tests now, and we
1904   # won't be seeing any of these during testsuite compilation.
1905   if test $setrlimit_have_headers = yes; then
1906     # Can't do these in a loop, else the resulting syntax is wrong.
1907     GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
1908     GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
1909     GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
1910     GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
1911
1912     # Check for rlimit, setrlimit.
1913     AC_CACHE_VAL(ac_setrlimit, [
1914       AC_TRY_COMPILE([#include <sys/resource.h>
1915                       #include <unistd.h>
1916                      ], 
1917                      [ struct rlimit r; setrlimit(0, &r);], 
1918                      [ac_setrlimit=yes], [ac_setrlimit=no])
1919     ])
1920   fi
1921
1922   AC_MSG_CHECKING([for testsuite memory limit support])
1923   if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
1924     ac_mem_limits=yes
1925     AC_DEFINE(_GLIBCPP_MEM_LIMITS)
1926   else
1927     ac_mem_limits=no
1928   fi
1929   AC_MSG_RESULT($ac_mem_limits)
1930 ])
1931
1932
1933 dnl
1934 dnl Does any necessary configuration of the testsuite directory.  Generates
1935 dnl the testsuite_hooks.h header.
1936 dnl
1937 dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
1938 AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
1939   GLIBCPP_CHECK_SETRLIMIT
1940
1941   # Look for setenv, so that extended locale tests can be performed.
1942   AC_CHECK_FUNCS(setenv)
1943 ])
1944
1945
1946 sinclude(../libtool.m4)
1947 dnl The lines below arrange for aclocal not to bring an installed
1948 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
1949 dnl add a definition of LIBTOOL to Makefile.in.
1950 ifelse(,,,[AC_SUBST(LIBTOOL)
1951 AC_DEFUN([AM_PROG_LIBTOOL])
1952 AC_DEFUN([AC_LIBTOOL_DLOPEN])
1953 AC_DEFUN([AC_PROG_LD])
1954 ])
1955
1956
1957 # Check whether LC_MESSAGES is available in <locale.h>.
1958 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1959 #
1960 # This file file be copied and used freely without restrictions.  It can
1961 # be used in projects which are not available under the GNU Public License
1962 # but which still want to provide support for the GNU gettext functionality.
1963 # Please note that the actual code is *not* freely available.
1964
1965 # serial 1
1966
1967 AC_DEFUN(AC_LC_MESSAGES, [
1968   AC_CHECK_HEADER(locale.h, [
1969     AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
1970       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1971        ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
1972     if test $ac_cv_val_LC_MESSAGES = yes; then
1973       AC_DEFINE(HAVE_LC_MESSAGES)
1974     fi
1975   ])
1976 ])
1977
1978
1979 dnl
1980 dnl Check for whether the Boost-derived checks should be turned on.
1981 dnl
1982 dnl GLIBCPP_ENABLE_CONCEPT_CHECKS
1983 dnl --enable-concept-checks turns them on.
1984 dnl --disable-concept-checks leaves them off.
1985 dnl  +  Usage:  GLIBCPP_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
1986 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
1987 dnl       defaults to `no'.
1988 AC_DEFUN(GLIBCPP_ENABLE_CONCEPT_CHECKS, [dnl
1989 define([GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT], ifelse($1, yes, yes, no))dnl
1990 AC_ARG_ENABLE(concept-checks,
1991 changequote(<<, >>)dnl
1992 <<  --enable-concept-checks use Boost-derived template checks [default=>>GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT],
1993 changequote([, ])dnl
1994 [case "$enableval" in
1995  yes) enable_concept_checks=yes ;;
1996  no)  enable_concept_checks=no ;;
1997  *)   AC_MSG_ERROR([Unknown argument to enable/disable concept checks]) ;;
1998  esac],
1999 enable_concept_checks=GLIBCPP_ENABLE_CONCEPT_CHECKS_DEFAULT)dnl
2000 dnl Option parsed, now set things appropriately
2001 if test x"$enable_concept_checks" = xyes; then
2002   AC_DEFINE(_GLIBCPP_CONCEPT_CHECKS)
2003 fi
2004 ])
2005
2006
2007 dnl
2008 dnl Add version tags to symbols in shared library (or not), additionally
2009 dnl marking other symbols as private/local (or not).
2010 dnl
2011 dnl GLIBCPP_ENABLE_SYMVERS
2012 dnl --enable-symvers adds a version script to the linker call when creating
2013 dnl       the shared library.
2014 dnl --disable-symvers does not.
2015 dnl  +  Usage:  GLIBCPP_ENABLE_SYMVERS[(DEFAULT)]
2016 dnl       Where DEFAULT is either `yes' or `no'.  If ommitted, it
2017 dnl       defaults to `no'.
2018 AC_DEFUN(GLIBCPP_ENABLE_SYMVERS, [dnl
2019 AC_REQUIRE([AC_PROG_LD])
2020 define([GLIBCPP_ENABLE_SYMVERS_DEFAULT], ifelse($1, yes, yes, no))dnl
2021 AC_ARG_ENABLE(symvers,
2022 changequote(<<, >>)dnl
2023 <<  --enable-symvers        enables symbol versioning of the shared library [default=>>GLIBCPP_ENABLE_SYMVERS_DEFAULT],
2024 changequote([, ])dnl
2025 [case "$enableval" in
2026  yes) enable_symvers=yes ;;
2027  no)  enable_symvers=no ;;
2028  *)   AC_MSG_ERROR([Unknown argument to enable/disable symvers]) ;;
2029  esac],
2030 enable_symvers=GLIBCPP_ENABLE_SYMVERS_DEFAULT)dnl
2031 dnl Option parsed, now set things appropriately
2032 AC_MSG_CHECKING([whether to version shared lib symbols])
2033 if test $enable_shared = no; then
2034   enable_symvers=irrelevant
2035 fi
2036 # placeholder -- maybe have a fallback later
2037 LINKER_MAP=config/linker-map.gnu
2038 # symvers variable may evolve into holding the type of linker map someday
2039 if test $enable_symvers = yes; then
2040   # flat-out assume a whole bunch of things right now
2041   #
2042   # The name of this variable changed between autoconf versions (our problem
2043   # for depending on an impl detail, tsk tsk).  It used to be
2044   # ac_cv_prog_gnu_ld but is now lt_cv_prog_gnu_ld, and is copied back into
2045   # with_gnu_ld which can also be user-settable.  Let's use that one.
2046   if test $with_gnu_ld = yes; then
2047     # we also assume that the gnu ld in question has phil's patches... can't
2048     # think today of an easy way to programatically test for that; revisit
2049     LINKER_MAP=config/linker-map.gnu
2050   else
2051     # placeholder -- maybe have a fallback later
2052     LINKER_MAP=config/linker-map.gnu
2053     enable_symvers=no
2054   fi
2055 fi
2056 AC_LINK_FILES($LINKER_MAP, src/linker.map)
2057 AM_CONDITIONAL(GLIBCPP_BUILD_VERSIONED_SHLIB, test "$enable_symvers" = yes)
2058 AC_MSG_RESULT($enable_symvers)
2059 ])
2060
2061