source: trunk/gcc/libstdc++-v3/acinclude.m4

Last change on this file was 1477, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1476,
which included commits to RCS files with non-trunk default branches.

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