]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/acinclude.m4
re PR middle-end/44777 (ICE: SIGSEGV with -fprofile-use in gcc.c-torture/execute...
[thirdparty/gcc.git] / libstdc++-v3 / acinclude.m4
CommitLineData
ff66d28f 1
92eabea2
PE
2dnl
3dnl GLIBCXX_CONDITIONAL (NAME, SHELL-TEST)
4dnl
5dnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the
6dnl end of configure. This lets tested variables be reassigned, and the
7dnl conditional will depend on the final state of the variable. For a simple
8dnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED.
9dnl
10m4_define([_m4_divert(glibcxx_diversion)], 8000)dnl
f214923c 11AC_DEFUN([GLIBCXX_CONDITIONAL], [dnl
92eabea2
PE
12 m4_divert_text([glibcxx_diversion],dnl
13 AM_CONDITIONAL([$1],[$2])
14 )dnl
15])dnl
f214923c 16AC_DEFUN([GLIBCXX_EVALUATE_CONDITIONALS], [m4_undivert([glibcxx_diversion])])dnl
92eabea2
PE
17
18
ff66d28f
PE
19dnl
20dnl Check to see what architecture and operating system we are compiling
21dnl for. Also, if architecture- or OS-specific flags are required for
22dnl compilation, pick them up here.
23dnl
f214923c 24AC_DEFUN([GLIBCXX_CHECK_HOST], [
ff66d28f 25 . $glibcxx_srcdir/configure.host
f214923c
BK
26 AC_MSG_NOTICE([CPU config directory is $cpu_include_dir])
27 AC_MSG_NOTICE([OS config directory is $os_include_dir])
ff66d28f
PE
28])
29
ff66d28f
PE
30dnl
31dnl Initialize the rest of the library configury. At this point we have
32dnl variables like $host.
aebb8c22 33dnl
ff66d28f 34dnl Sets:
82ba99d5 35dnl SUBDIRS
ff66d28f
PE
36dnl Substs:
37dnl glibcxx_builddir (absolute path)
38dnl glibcxx_srcdir (absolute path)
39dnl toplevel_srcdir (absolute path)
40dnl with_cross_host
41dnl with_newlib
42dnl with_target_subdir
43dnl plus
44dnl - the variables in GLIBCXX_CHECK_HOST / configure.host
45dnl - default settings for all AM_CONFITIONAL test variables
46dnl - lots of tools, like CC and CXX
aebb8c22 47dnl
f214923c 48AC_DEFUN([GLIBCXX_CONFIGURE], [
82ba99d5
PE
49 # Keep these sync'd with the list in Makefile.am. The first provides an
50 # expandable list at autoconf time; the second provides an expandable list
51 # (i.e., shell variable) at configure time.
41850419 52 m4_define([glibcxx_SUBDIRS],[include libsupc++ python src doc po testsuite])
82ba99d5
PE
53 SUBDIRS='glibcxx_SUBDIRS'
54
d2caef2e
PE
55 # These need to be absolute paths, yet at the same time need to
56 # canonicalize only relative paths, because then amd will not unmount
57 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
3d7c150e 58 glibcxx_builddir=`${PWDCMD-pwd}`
d2caef2e 59 case $srcdir in
ff66d28f
PE
60 [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
61 *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
d2caef2e 62 esac
ff66d28f 63 toplevel_srcdir=${glibcxx_srcdir}/..
3d7c150e
BK
64 AC_SUBST(glibcxx_builddir)
65 AC_SUBST(glibcxx_srcdir)
ff66d28f 66 AC_SUBST(toplevel_srcdir)
d2caef2e 67
ff66d28f
PE
68 # We use these options to decide which functions to include. They are
69 # set from the top level.
70 AC_ARG_WITH([target-subdir],
71 AC_HELP_STRING([--with-target-subdir=SUBDIR],
72 [configuring in a subdirectory]))
73
74 AC_ARG_WITH([cross-host],
75 AC_HELP_STRING([--with-cross-host=HOST],
76 [configuring with a cross compiler]))
77
78 AC_ARG_WITH([newlib],
79 AC_HELP_STRING([--with-newlib],
80 [assume newlib as a system C library]))
81
ff66d28f
PE
82 # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
83 # available). Uncomment the next line to force a particular method.
84 AC_PROG_LN_S
85 #LN_S='cp -p'
86
5780a46b
BK
87 AC_CHECK_TOOL(AS, as)
88 AC_CHECK_TOOL(AR, ar)
46840bcd 89 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
b2dad0e3 90
5780a46b 91 AM_MAINTAINER_MODE
b2dad0e3 92
92eabea2
PE
93 # Set up safe default values for all subsequent AM_CONDITIONAL tests
94 # which are themselves conditionally expanded.
95 ## (Right now, this only matters for enable_wchar_t, but nothing prevents
96 ## other macros from doing the same. This should be automated.) -pme
16da539b 97
aa6a73b9 98 # Check for C library flavor since Linux platforms use different configuration
464aea98
JM
99 # directories depending on the C library in use.
100 AC_EGREP_CPP([_using_uclibc], [
101 #include <stdio.h>
102 #if __UCLIBC__
103 _using_uclibc
104 #endif
105 ], uclibc=yes, uclibc=no)
106
aa6a73b9
MK
107 AC_EGREP_CPP([_using_bionic], [
108 #include <stdio.h>
109 #if __BIONIC__
110 _using_bionic
111 #endif
112 ], bionic=yes, bionic=no)
113
ff66d28f
PE
114 # Find platform-specific directories containing configuration info.
115 # Also possibly modify flags used elsewhere, as needed by the platform.
3d7c150e 116 GLIBCXX_CHECK_HOST
b2dad0e3
BK
117])
118
119
c470c17d 120dnl
52b55e7d
PE
121dnl Tests for newer compiler features, or features that are present in newer
122dnl compiler versions but not older compiler versions still in use, should
123dnl be placed here.
b2dad0e3 124dnl
ff66d28f
PE
125dnl Defines:
126dnl WERROR='-Werror' if requested and possible; g++'s that lack the
127dnl new inlining code or the new system_header pragma will die on -Werror.
128dnl Leave it out by default and use maint-mode to use it.
129dnl SECTION_FLAGS='-ffunction-sections -fdata-sections' if
130dnl compiler supports it and the user has not requested debug mode.
c21b6f87 131dnl
f214923c 132AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [
a4e99046 133 # All these tests are for C++; save the language and the compiler flags.
52b55e7d 134 # The CXXFLAGS thing is suspicious, but based on similar bits previously
3d7c150e 135 # found in GLIBCXX_CONFIGURE.
a4e99046
PE
136 AC_LANG_SAVE
137 AC_LANG_CPLUSPLUS
138 ac_test_CXXFLAGS="${CXXFLAGS+set}"
139 ac_save_CXXFLAGS="$CXXFLAGS"
a4e99046 140
7f586614
BK
141 # Check for maintainer-mode bits.
142 if test x"$USE_MAINTAINER_MODE" = xno; then
143 WERROR=''
8bd636c5 144 else
7f586614 145 WERROR='-Werror'
8bd636c5
PE
146 fi
147
c470c17d
BK
148 # Check for -ffunction-sections -fdata-sections
149 AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
85ee35ca
BK
150 CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
151 AC_TRY_COMPILE([int foo; void bar() { };],, [ac_fdsections=yes], [ac_fdsections=no])
c470c17d
BK
152 if test "$ac_test_CXXFLAGS" = set; then
153 CXXFLAGS="$ac_save_CXXFLAGS"
154 else
155 # this is the suspicious part
156 CXXFLAGS=''
157 fi
6aa43d99 158 if test x"$ac_fdsections" = x"yes"; then
c470c17d
BK
159 SECTION_FLAGS='-ffunction-sections -fdata-sections'
160 fi
161 AC_MSG_RESULT($ac_fdsections)
162
a4e99046 163 AC_LANG_RESTORE
8bd636c5 164 AC_SUBST(WERROR)
c470c17d 165 AC_SUBST(SECTION_FLAGS)
b2dad0e3
BK
166])
167
c470c17d
BK
168
169dnl
421173e6
PE
170dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
171dnl the native linker is in use, all variables will be defined to something
172dnl safe (like an empty string).
173dnl
ff66d28f
PE
174dnl Defines:
175dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
a429affe 176dnl OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible
ff66d28f
PE
177dnl LD (as a side effect of testing)
178dnl Sets:
179dnl with_gnu_ld
d60a2d4d 180dnl glibcxx_ld_is_gold (set to "no" or "yes")
ff66d28f
PE
181dnl glibcxx_gnu_ld_version (possibly)
182dnl
183dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
184dnl set glibcxx_gnu_ld_version to 12345. Zeros cause problems.
c470c17d 185dnl
f214923c 186AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
421173e6
PE
187 # If we're not using GNU ld, then there's no point in even trying these
188 # tests. Check for that first. We should have already tested for gld
189 # by now (in libtool), but require it now just to be safe...
654421eb
DE
190 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
191 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
421173e6 192 AC_REQUIRE([AC_PROG_LD])
ff66d28f 193 AC_REQUIRE([AC_PROG_AWK])
5bd17d39 194
c98b201b
PE
195 # The name set by libtool depends on the version of libtool. Shame on us
196 # for depending on an impl detail, but c'est la vie. Older versions used
197 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
198 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
199 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
200 # set (hence we're using an older libtool), then set it.
201 if test x${with_gnu_ld+set} != xset; then
202 if test x${ac_cv_prog_gnu_ld+set} != xset; then
203 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
204 with_gnu_ld=no
205 else
206 with_gnu_ld=$ac_cv_prog_gnu_ld
207 fi
208 fi
209
210 # Start by getting the version number. I think the libtool test already
211 # does some of this, but throws away the result.
d60a2d4d 212 glibcxx_ld_is_gold=no
e2c104d8
BK
213 if test x"$with_gnu_ld" = x"yes"; then
214 AC_MSG_CHECKING([for ld version])
215 changequote(,)
d60a2d4d
ILT
216 if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
217 glibcxx_ld_is_gold=yes
218 fi
c82852f7 219 ldver=`$LD --version 2>/dev/null |
89c74f4a 220 sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
e2c104d8
BK
221 changequote([,])
222 glibcxx_gnu_ld_version=`echo $ldver | \
223 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
224 AC_MSG_RESULT($glibcxx_gnu_ld_version)
225 fi
c98b201b 226
5bd17d39 227 # Set --gc-sections.
d60a2d4d
ILT
228 glibcxx_have_gc_sections=no
229 if test "$glibcxx_ld_is_gold" = "yes"; then
230 if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
231 glibcxx_have_gc_sections=yes
232 fi
233 else
234 glibcxx_gcsections_min_ld=21602
235 if test x"$with_gnu_ld" = x"yes" &&
ac2b2479 236 test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
d60a2d4d
ILT
237 glibcxx_have_gc_sections=yes
238 fi
239 fi
240 if test "$glibcxx_have_gc_sections" = "yes"; then
ac2b2479
BK
241 # Sufficiently young GNU ld it is! Joy and bunny rabbits!
242 # NB: This flag only works reliably after 2.16.1. Configure tests
243 # for this are difficult, so hard wire a value that should work.
421173e6 244
421173e6
PE
245 ac_test_CFLAGS="${CFLAGS+set}"
246 ac_save_CFLAGS="$CFLAGS"
2a0ab51c 247 CFLAGS='-Wl,--gc-sections'
421173e6
PE
248
249 # Check for -Wl,--gc-sections
250 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
acb6e9be
BK
251 AC_TRY_LINK([ int one(void) { return 1; }
252 int two(void) { return 2; }
253 ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no])
360e8759
L
254 if test "$ac_gcsections" = "yes"; then
255 rm -f conftest.c
256 touch conftest.c
257 if $CC -c conftest.c; then
258 if $LD --gc-sections -o conftest conftest.o 2>&1 | \
259 grep "Warning: gc-sections option ignored" > /dev/null; then
260 ac_gcsections=no
261 fi
262 fi
263 rm -f conftest.c conftest.o conftest
264 fi
acb6e9be
BK
265 if test "$ac_gcsections" = "yes"; then
266 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
267 fi
268 AC_MSG_RESULT($ac_gcsections)
269
421173e6
PE
270 if test "$ac_test_CFLAGS" = set; then
271 CFLAGS="$ac_save_CFLAGS"
272 else
273 # this is the suspicious part
274 CFLAGS=''
275 fi
5bd17d39 276 fi
a9117427 277
a429affe 278 # Set -z,relro.
952c7b74 279 # Note this is only for shared objects.
a429affe
BK
280 ac_ld_relro=no
281 if test x"$with_gnu_ld" = x"yes"; then
282 AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
283 cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
284 if test -n "$cxx_z_relo"; then
285 OPT_LDFLAGS="-Wl,-z,relro"
286 ac_ld_relro=yes
287 fi
288 AC_MSG_RESULT($ac_ld_relro)
289 fi
290
5bd17d39 291 # Set linker optimization flags.
6aa43d99 292 if test x"$with_gnu_ld" = x"yes"; then
654421eb 293 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
421173e6 294 fi
5bd17d39 295
c470c17d 296 AC_SUBST(SECTION_LDFLAGS)
421173e6 297 AC_SUBST(OPT_LDFLAGS)
c470c17d
BK
298])
299
300
b2dad0e3 301dnl
ff66d28f
PE
302dnl Check for headers for, and arguments to, the setrlimit() function.
303dnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE.
6aa43d99 304dnl
ff66d28f 305dnl Defines:
2ae6e982
PC
306dnl _GLIBCXX_RES_LIMITS if we can set artificial resource limits
307dnl various HAVE_LIMIT_* for individual limit names
6aa43d99 308dnl
f214923c 309AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
e0103440 310 AC_MSG_CHECKING([for RLIMIT_$1])
ff66d28f
PE
311 AC_TRY_COMPILE(
312 [#include <unistd.h>
313 #include <sys/time.h>
314 #include <sys/resource.h>
315 ],
316 [ int f = RLIMIT_$1 ; ],
317 [glibcxx_mresult=1], [glibcxx_mresult=0])
2ae6e982 318 AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult,
ff66d28f 319 [Only used in build directory testsuite_hooks.h.])
e0103440
GK
320 if test $glibcxx_mresult = 1 ; then res=yes ; else res=no ; fi
321 AC_MSG_RESULT($res)
ff66d28f
PE
322])
323
f214923c 324AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
ff66d28f
PE
325 setrlimit_have_headers=yes
326 AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
327 [],
328 [setrlimit_have_headers=no])
329 # If don't have the headers, then we can't run the tests now, and we
330 # won't be seeing any of these during testsuite compilation.
331 if test $setrlimit_have_headers = yes; then
332 # Can't do these in a loop, else the resulting syntax is wrong.
333 GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA)
334 GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
335 GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
336 GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
2ae6e982 337 GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE)
ff66d28f
PE
338
339 # Check for rlimit, setrlimit.
6d26724a 340 AC_CACHE_VAL(glibcxx_cv_setrlimit, [
ff66d28f
PE
341 AC_TRY_COMPILE(
342 [#include <unistd.h>
343 #include <sys/time.h>
344 #include <sys/resource.h>
345 ],
346 [struct rlimit r;
347 setrlimit(0, &r);],
6d26724a 348 [glibcxx_cv_setrlimit=yes], [glibcxx_cv_setrlimit=no])
ff66d28f
PE
349 ])
350 fi
351
2ae6e982 352 AC_MSG_CHECKING([for testsuite resource limits support])
6d26724a 353 if test $setrlimit_have_headers = yes && test $glibcxx_cv_setrlimit = yes; then
2ae6e982 354 ac_res_limits=yes
4651e622
KC
355 AC_DEFINE(_GLIBCXX_RES_LIMITS, 1,
356 [Define if using setrlimit to set resource limits during
357 "make check"])
ff66d28f 358 else
2ae6e982 359 ac_res_limits=no
ff66d28f 360 fi
2ae6e982 361 AC_MSG_RESULT($ac_res_limits)
6aa43d99
BK
362])
363
364
6aa43d99 365dnl
ff66d28f
PE
366dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
367dnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately.
6aa43d99 368dnl
f214923c 369AC_DEFUN([GLIBCXX_CHECK_S_ISREG_OR_S_IFREG], [
74745ec5
PC
370
371 AC_LANG_SAVE
372 AC_LANG_CPLUSPLUS
373 ac_save_CXXFLAGS="$CXXFLAGS"
374 CXXFLAGS="$CXXFLAGS -fno-exceptions"
375
e0103440 376 AC_MSG_CHECKING([for S_ISREG or S_IFREG])
ff66d28f 377 AC_CACHE_VAL(glibcxx_cv_S_ISREG, [
74745ec5 378 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
379 [#include <sys/stat.h>],
380 [struct stat buffer;
381 fstat(0, &buffer);
382 S_ISREG(buffer.st_mode);],
383 [glibcxx_cv_S_ISREG=yes],
384 [glibcxx_cv_S_ISREG=no])
385 ])
386 AC_CACHE_VAL(glibcxx_cv_S_IFREG, [
74745ec5 387 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
388 [#include <sys/stat.h>],
389 [struct stat buffer;
390 fstat(0, &buffer);
391 S_IFREG & buffer.st_mode;],
392 [glibcxx_cv_S_IFREG=yes],
393 [glibcxx_cv_S_IFREG=no])
394 ])
e0103440 395 res=no
ff66d28f 396 if test $glibcxx_cv_S_ISREG = yes; then
4651e622
KC
397 AC_DEFINE(HAVE_S_ISREG, 1,
398 [Define if S_IFREG is available in <sys/stat.h>.])
e0103440 399 res=S_ISREG
ff66d28f 400 elif test $glibcxx_cv_S_IFREG = yes; then
4651e622
KC
401 AC_DEFINE(HAVE_S_IFREG, 1,
402 [Define if S_IFREG is available in <sys/stat.h>.])
e0103440 403 res=S_IFREG
ff66d28f 404 fi
e0103440 405 AC_MSG_RESULT($res)
74745ec5
PC
406
407 CXXFLAGS="$ac_save_CXXFLAGS"
408 AC_LANG_RESTORE
b2dad0e3
BK
409])
410
411
dcfa0bc8 412dnl
ff66d28f 413dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
dcfa0bc8 414dnl
f214923c 415AC_DEFUN([GLIBCXX_CHECK_POLL], [
74745ec5
PC
416
417 AC_LANG_SAVE
418 AC_LANG_CPLUSPLUS
419 ac_save_CXXFLAGS="$CXXFLAGS"
420 CXXFLAGS="$CXXFLAGS -fno-exceptions"
421
e0103440 422 AC_MSG_CHECKING([for poll])
ff66d28f 423 AC_CACHE_VAL(glibcxx_cv_POLL, [
74745ec5 424 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
425 [#include <poll.h>],
426 [struct pollfd pfd[1];
427 pfd[0].events = POLLIN;
428 poll(pfd, 1, 0);],
429 [glibcxx_cv_POLL=yes],
430 [glibcxx_cv_POLL=no])
431 ])
432 if test $glibcxx_cv_POLL = yes; then
4651e622 433 AC_DEFINE(HAVE_POLL, 1, [Define if poll is available in <poll.h>.])
ff66d28f 434 fi
e0103440 435 AC_MSG_RESULT($glibcxx_cv_POLL)
74745ec5
PC
436
437 CXXFLAGS="$ac_save_CXXFLAGS"
438 AC_LANG_RESTORE
ff66d28f
PE
439])
440
441
442dnl
443dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
444dnl
f214923c 445AC_DEFUN([GLIBCXX_CHECK_WRITEV], [
74745ec5
PC
446
447 AC_LANG_SAVE
448 AC_LANG_CPLUSPLUS
449 ac_save_CXXFLAGS="$CXXFLAGS"
450 CXXFLAGS="$CXXFLAGS -fno-exceptions"
451
e0103440 452 AC_MSG_CHECKING([for writev])
ff66d28f 453 AC_CACHE_VAL(glibcxx_cv_WRITEV, [
74745ec5 454 GCC_TRY_COMPILE_OR_LINK(
ff66d28f
PE
455 [#include <sys/uio.h>],
456 [struct iovec iov[2];
457 writev(0, iov, 0);],
458 [glibcxx_cv_WRITEV=yes],
459 [glibcxx_cv_WRITEV=no])
460 ])
461 if test $glibcxx_cv_WRITEV = yes; then
4651e622 462 AC_DEFINE(HAVE_WRITEV, 1, [Define if writev is available in <sys/uio.h>.])
ff66d28f 463 fi
e0103440 464 AC_MSG_RESULT($glibcxx_cv_WRITEV)
74745ec5
PC
465
466 CXXFLAGS="$ac_save_CXXFLAGS"
467 AC_LANG_RESTORE
ff66d28f
PE
468])
469
470
3d05b345
PC
471dnl
472dnl Check whether int64_t is available in <stdint.h>, and define HAVE_INT64_T.
fc9ab7b4 473dnl Also check whether int64_t is actually a typedef to long or long long.
3d05b345 474dnl
f214923c 475AC_DEFUN([GLIBCXX_CHECK_INT64_T], [
fc9ab7b4
PC
476
477 AC_LANG_SAVE
478 AC_LANG_CPLUSPLUS
479
e0103440 480 AC_MSG_CHECKING([for int64_t])
3d05b345
PC
481 AC_CACHE_VAL(glibcxx_cv_INT64_T, [
482 AC_TRY_COMPILE(
483 [#include <stdint.h>],
484 [int64_t var;],
485 [glibcxx_cv_INT64_T=yes],
486 [glibcxx_cv_INT64_T=no])
487 ])
fc9ab7b4 488
3d05b345 489 if test $glibcxx_cv_INT64_T = yes; then
4651e622 490 AC_DEFINE(HAVE_INT64_T, 1, [Define if int64_t is available in <stdint.h>.])
fc9ab7b4
PC
491 AC_MSG_RESULT($glibcxx_cv_INT64_T)
492
493 AC_MSG_CHECKING([for int64_t as long])
494 AC_CACHE_VAL(glibcxx_cv_int64_t_long, [
495 AC_TRY_COMPILE(
496 [#include <stdint.h>
497 template<typename, typename> struct same { enum { value = -1 }; };
498 template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
499 int array[same<int64_t, long>::value];], [],
500 [glibcxx_cv_int64_t_long=yes], [glibcxx_cv_int64_t_long=no])
501 ])
502
503 if test $glibcxx_cv_int64_t_long = yes; then
504 AC_DEFINE(HAVE_INT64_T_LONG, 1, [Define if int64_t is a long.])
505 AC_MSG_RESULT($glibcxx_cv_int64_t_long)
506 fi
507
508 AC_MSG_CHECKING([for int64_t as long long])
509 AC_CACHE_VAL(glibcxx_cv_int64_t_long_long, [
510 AC_TRY_COMPILE(
511 [#include <stdint.h>
512 template<typename, typename> struct same { enum { value = -1 }; };
513 template<typename Tp> struct same<Tp, Tp> { enum { value = 1 }; };
514 int array[same<int64_t, long long>::value];], [],
515 [glibcxx_cv_int64_t_long_long=yes], [glibcxx_cv_int64_t_long_long=no])
516 ])
517
518 if test $glibcxx_cv_int64_t_long_long = yes; then
519 AC_DEFINE(HAVE_INT64_T_LONG_LONG, 1, [Define if int64_t is a long long.])
520 AC_MSG_RESULT($glibcxx_cv_int64_t_long_long)
521 fi
3d05b345 522 fi
fc9ab7b4
PC
523
524 AC_LANG_RESTORE
3d05b345
PC
525])
526
527
528dnl
529dnl Check whether LFS support is available.
530dnl
f214923c 531AC_DEFUN([GLIBCXX_CHECK_LFS], [
0c6b814a 532 AC_LANG_SAVE
9d47bc51
PC
533 AC_LANG_CPLUSPLUS
534 ac_save_CXXFLAGS="$CXXFLAGS"
535 CXXFLAGS="$CXXFLAGS -fno-exceptions"
e0103440 536 AC_MSG_CHECKING([for LFS support])
3d05b345 537 AC_CACHE_VAL(glibcxx_cv_LFS, [
74745ec5 538 GCC_TRY_COMPILE_OR_LINK(
0c6b814a
PC
539 [#include <unistd.h>
540 #include <stdio.h>
dd5d134b 541 #include <sys/stat.h>
0c6b814a 542 ],
5c89246d
PC
543 [FILE* fp;
544 fopen64("t", "w");
545 fseeko64(fp, 0, SEEK_CUR);
546 ftello64(fp);
dd5d134b
PC
547 lseek64(1, 0, SEEK_CUR);
548 struct stat64 buf;
549 fstat64(1, &buf);],
3d05b345
PC
550 [glibcxx_cv_LFS=yes],
551 [glibcxx_cv_LFS=no])
552 ])
553 if test $glibcxx_cv_LFS = yes; then
4651e622 554 AC_DEFINE(_GLIBCXX_USE_LFS, 1, [Define if LFS support is available.])
3d05b345 555 fi
e0103440 556 AC_MSG_RESULT($glibcxx_cv_LFS)
9d47bc51
PC
557 CXXFLAGS="$ac_save_CXXFLAGS"
558 AC_LANG_RESTORE
3d05b345
PC
559])
560
561
1165dc50
PC
562dnl
563dnl Check for whether a fully dynamic basic_string implementation should
564dnl be turned on, that does not put empty objects in per-process static
565dnl memory (mostly useful together with shared memory allocators, see PR
566dnl libstdc++/16612 for details).
567dnl
568dnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING
569dnl --disable-fully-dynamic-string leaves _GLIBCXX_FULLY_DYNAMIC_STRING undefined
570dnl + Usage: GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
571dnl Where DEFAULT is either `yes' or `no'.
572dnl
573AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
574 GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory])
575 if test $enable_fully_dynamic_string = yes; then
4651e622
KC
576 AC_DEFINE(_GLIBCXX_FULLY_DYNAMIC_STRING, 1,
577 [Define if a fully dynamic basic_string is wanted.])
1165dc50
PC
578 fi
579])
580
581
ff66d28f
PE
582dnl
583dnl Does any necessary configuration of the testsuite directory. Generates
584dnl the testsuite_hooks.h header.
585dnl
586dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this.
587dnl
588dnl Sets:
84946e72 589dnl enable_abi_check
e3f78d9b
BK
590dnl GLIBCXX_TEST_WCHAR_T
591dnl GLIBCXX_TEST_THREAD
ff66d28f
PE
592dnl Substs:
593dnl baseline_dir
594dnl
f214923c 595AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
0646b059 596 if $GLIBCXX_IS_NATIVE ; then
2ae6e982 597 # Do checks for resource limit functions.
ff66d28f
PE
598 GLIBCXX_CHECK_SETRLIMIT
599
600 # Look for setenv, so that extended locale tests can be performed.
601 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
0646b059 602 fi
dbc66058 603
0646b059
GK
604 if $GLIBCXX_IS_NATIVE && test $is_hosted = yes &&
605 test $enable_symvers != no; then
606 case "$host" in
607 *-*-cygwin*)
608 enable_abi_check=no ;;
609 *)
610 enable_abi_check=yes ;;
611 esac
dbc66058
DJ
612 else
613 # Only build this as native, since automake does not understand
614 # CXX_FOR_BUILD.
615 enable_abi_check=no
ff66d28f 616 fi
84946e72 617
ff66d28f 618 # Export file names for ABI checking.
68c512f6 619 baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}"
ff66d28f 620 AC_SUBST(baseline_dir)
ff66d28f
PE
621])
622
623
624dnl
625dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
626dnl
627dnl Substs:
628dnl GLIBCXX_INCLUDES
629dnl TOPLEVEL_INCLUDES
ff66d28f 630dnl
f214923c 631AC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [
0df3f383
PE
632 # Used for every C++ compile we perform.
633 GLIBCXX_INCLUDES="\
634-I$glibcxx_builddir/include/$host_alias \
635-I$glibcxx_builddir/include \
636-I$glibcxx_srcdir/libsupc++"
ff66d28f 637
0df3f383 638 # For Canadian crosses, pick this up too.
ff66d28f 639 if test $CANADIAN = yes; then
37e0ff11 640 GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
ff66d28f
PE
641 fi
642
0df3f383
PE
643 # Stuff in the actual top level. Currently only used by libsupc++ to
644 # get unwind* headers from the gcc dir.
645 #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include'
646 TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc'
ff66d28f
PE
647
648 # Now, export this to all the little Makefiles....
649 AC_SUBST(GLIBCXX_INCLUDES)
650 AC_SUBST(TOPLEVEL_INCLUDES)
ff66d28f
PE
651])
652
653
654dnl
655dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
656dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
657dnl
658dnl Substs:
659dnl OPTIMIZE_CXXFLAGS
660dnl WARN_FLAGS
661dnl
f214923c 662AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
ff66d28f
PE
663 # Optimization flags that are probably a good idea for thrill-seekers. Just
664 # uncomment the lines below and make, everything else is ready to go...
62801a96 665 # Alternatively OPTIMIZE_CXXFLAGS can be set in configure.host.
ff66d28f 666 # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
ff66d28f
PE
667 AC_SUBST(OPTIMIZE_CXXFLAGS)
668
dc7c62ae 669 WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
ff66d28f
PE
670 AC_SUBST(WARN_FLAGS)
671])
672
673
674dnl
675dnl All installation directory information is determined here.
676dnl
677dnl Substs:
678dnl gxx_install_dir
679dnl glibcxx_prefixdir
680dnl glibcxx_toolexecdir
681dnl glibcxx_toolexeclibdir
682dnl
683dnl Assumes cross_compiling bits already done, and with_cross_host in
684dnl particular.
685dnl
0f57bf40 686dnl This logic must match gcc/configure.ac's setting of gcc_gxx_include_dir.
505692b0 687dnl config/gxx-include-dir.m4 must be kept consistant with this as well.
f214923c 688AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
ff66d28f
PE
689 glibcxx_toolexecdir=no
690 glibcxx_toolexeclibdir=no
691 glibcxx_prefixdir=$prefix
692
693 AC_MSG_CHECKING([for gxx-include-dir])
694 AC_ARG_WITH([gxx-include-dir],
695 AC_HELP_STRING([--with-gxx-include-dir=DIR],
696 [installation directory for include files]),
697 [case "$withval" in
698 yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
699 no) gxx_include_dir=no ;;
700 *) gxx_include_dir=$withval ;;
701 esac],
702 [gxx_include_dir=no])
703 AC_MSG_RESULT($gxx_include_dir)
704
705 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
706 AC_ARG_ENABLE([version-specific-runtime-libs],
707 AC_HELP_STRING([--enable-version-specific-runtime-libs],
708 [Specify that runtime libraries should be installed in a compiler-specific directory]),
709 [case "$enableval" in
710 yes) version_specific_libs=yes ;;
711 no) version_specific_libs=no ;;
712 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
713 esac],
714 [version_specific_libs=no])
715 AC_MSG_RESULT($version_specific_libs)
716
717 # Default case for install directory for include files.
718 if test $version_specific_libs = no && test $gxx_include_dir = no; then
0f57bf40
MM
719 gxx_include_dir='include/c++/${gcc_version}'
720 if test -n "$with_cross_host" &&
721 test x"$with_cross_host" != x"no"; then
722 gxx_include_dir='${prefix}/${target_alias}/'"$gxx_include_dir"
723 else
724 gxx_include_dir='${prefix}/'"$gxx_include_dir"
725 fi
ff66d28f
PE
726 fi
727
728 # Version-specific runtime libs processing.
729 if test $version_specific_libs = yes; then
730 # Need the gcc compiler version to know where to install libraries
731 # and header files if --enable-version-specific-runtime-libs option
0314451d
GK
732 # is selected. FIXME: these variables are misnamed, there are
733 # no executables installed in _toolexecdir or _toolexeclibdir.
ff66d28f 734 if test x"$gxx_include_dir" = x"no"; then
47194af4 735 gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
ff66d28f 736 fi
0314451d 737 glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
47194af4 738 glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
ff66d28f
PE
739 fi
740
741 # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
742 # Install a library built with a cross compiler in tooldir, not libdir.
743 if test x"$glibcxx_toolexecdir" = x"no"; then
744 if test -n "$with_cross_host" &&
745 test x"$with_cross_host" != x"no"; then
fbe057bb
PE
746 glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
747 glibcxx_toolexeclibdir='${toolexecdir}/lib'
ff66d28f 748 else
0314451d 749 glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
fbe057bb 750 glibcxx_toolexeclibdir='${libdir}'
ff66d28f 751 fi
fbe057bb 752 multi_os_directory=`$CXX -print-multi-os-directory`
ff66d28f
PE
753 case $multi_os_directory in
754 .) ;; # Avoid trailing /.
755 *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
756 esac
757 fi
758
759 AC_MSG_CHECKING([for install location])
760 AC_MSG_RESULT($gxx_include_dir)
761
762 AC_SUBST(glibcxx_prefixdir)
763 AC_SUBST(gxx_include_dir)
764 AC_SUBST(glibcxx_toolexecdir)
765 AC_SUBST(glibcxx_toolexeclibdir)
766])
767
768
769dnl
770dnl GLIBCXX_ENABLE
771dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
772dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
773dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
774dnl
775dnl See docs/html/17_intro/configury.html#enable for documentation.
776dnl
777m4_define([GLIBCXX_ENABLE],[dnl
778m4_define([_g_switch],[--enable-$1])dnl
779m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
780 AC_ARG_ENABLE($1,_g_help,
781 m4_bmatch([$5],
782 [^permit ],
783 [[
784 case "$enableval" in
785 m4_bpatsubst([$5],[permit ])) ;;
786 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
787 dnl Idea for future: generate a URL pointing to
788 dnl "onlinedocs/configopts.html#whatever"
789 esac
790 ]],
791 [^$],
792 [[
793 case "$enableval" in
794 yes|no) ;;
795 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
796 esac
797 ]],
798 [[$5]]),
799 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
800m4_undefine([_g_switch])dnl
801m4_undefine([_g_help])dnl
802])
803
804
805dnl
806dnl Check for ISO/IEC 9899:1999 "C99" support.
807dnl
808dnl --enable-c99 defines _GLIBCXX_USE_C99
809dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
810dnl + Usage: GLIBCXX_ENABLE_C99[(DEFAULT)]
811dnl Where DEFAULT is either `yes' or `no'.
812dnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
813dnl
f214923c 814AC_DEFUN([GLIBCXX_ENABLE_C99], [
ff66d28f
PE
815 GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
816
347669a0
BK
817 if test x"$enable_c99" = x"yes"; then
818
ff66d28f
PE
819 AC_LANG_SAVE
820 AC_LANG_CPLUSPLUS
821
18f310b7
PC
822 # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
823 # undefined and fake C99 facilities - like pre-standard snprintf - may be
824 # spuriously enabled.
825 # Long term, -std=c++0x could be even better, could manage to explicitely
826 # request C99 facilities to the underlying C headers.
b6f914f6 827 ac_save_CXXFLAGS="$CXXFLAGS"
18f310b7 828 CXXFLAGS="$CXXFLAGS -std=c++98"
b6f914f6
RS
829 ac_save_LIBS="$LIBS"
830 ac_save_gcc_no_link="$gcc_no_link"
831
832 if test x$gcc_no_link != xyes; then
833 # Use -fno-exceptions to that the C driver can link these tests without
834 # hitting undefined references to personality routines.
835 CXXFLAGS="$CXXFLAGS -fno-exceptions"
836 AC_CHECK_LIB(m, sin, [
837 LIBS="$LIBS -lm"
838 ], [
839 # Use the default compile-only tests in GCC_TRY_COMPILE_OR_LINK
840 gcc_no_link=yes
841 ])
842 fi
843
ff66d28f 844 # Check for the existence of <math.h> functions used if C99 is enabled.
ff66d28f 845 AC_MSG_CHECKING([for ISO C99 support in <math.h>])
6d26724a 846 AC_CACHE_VAL(glibcxx_cv_c99_math, [
b6f914f6
RS
847 GCC_TRY_COMPILE_OR_LINK(
848 [#include <math.h>
849 volatile double d1, d2;
850 volatile int i;],
851 [i = fpclassify(d1);
852 i = isfinite(d1);
853 i = isinf(d1);
854 i = isnan(d1);
855 i = isnormal(d1);
856 i = signbit(d1);
857 i = isgreater(d1, d2);
858 i = isgreaterequal(d1, d2);
859 i = isless(d1, d2);
860 i = islessequal(d1, d2);
861 i = islessgreater(d1, d2);
862 i = islessgreater(d1, d2);
863 i = isunordered(d1, d2);
6d26724a 864 ],[glibcxx_cv_c99_math=yes], [glibcxx_cv_c99_math=no])
347669a0 865 ])
6d26724a
RW
866 AC_MSG_RESULT($glibcxx_cv_c99_math)
867 if test x"$glibcxx_cv_c99_math" = x"yes"; then
4651e622
KC
868 AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
869 [Define if C99 functions or macros in <math.h> should be imported
870 in <cmath> in namespace std.])
517da0ce
MM
871 fi
872
225962a0 873 # Check for the existence of <complex.h> complex math functions.
52e6723c
BK
874 # This is necessary even though libstdc++ uses the builtin versions
875 # of these functions, because if the builtin cannot be used, a reference
876 # to the library function is emitted.
5ad2f32d 877 AC_CHECK_HEADERS(tgmath.h, ac_has_tgmath_h=yes, ac_has_tgmath_h=no)
52e6723c 878 AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
6d26724a 879 glibcxx_cv_c99_complex=no;
52e6723c 880 if test x"$ac_has_complex_h" = x"yes"; then
52e6723c 881 AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
b6f914f6
RS
882 GCC_TRY_COMPILE_OR_LINK(
883 [#include <complex.h>
884 typedef __complex__ float float_type;
885 typedef __complex__ double double_type;
886 typedef __complex__ long double ld_type;
887 volatile float_type tmpf;
888 volatile double_type tmpd;
889 volatile ld_type tmpld;
890 volatile float f;
891 volatile double d;
892 volatile long double ld;],
893 [f = cabsf(tmpf);
894 f = cargf(tmpf);
895 tmpf = ccosf(tmpf);
896 tmpf = ccoshf(tmpf);
897 tmpf = cexpf(tmpf);
898 tmpf = clogf(tmpf);
899 tmpf = csinf(tmpf);
900 tmpf = csinhf(tmpf);
901 tmpf = csqrtf(tmpf);
902 tmpf = ctanf(tmpf);
903 tmpf = ctanhf(tmpf);
904 tmpf = cpowf(tmpf, tmpf);
3cd54fc9 905 tmpf = cprojf(tmpf);
b6f914f6
RS
906 d = cabs(tmpd);
907 d = carg(tmpd);
908 tmpd = ccos(tmpd);
909 tmpd = ccosh(tmpd);
910 tmpd = cexp(tmpd);
911 tmpd = clog(tmpd);
912 tmpd = csin(tmpd);
913 tmpd = csinh(tmpd);
914 tmpd = csqrt(tmpd);
915 tmpd = ctan(tmpd);
916 tmpd = ctanh(tmpd);
917 tmpd = cpow(tmpd, tmpd);
3cd54fc9 918 tmpd = cproj(tmpd);
b6f914f6
RS
919 ld = cabsl(tmpld);
920 ld = cargl(tmpld);
921 tmpld = ccosl(tmpld);
922 tmpld = ccoshl(tmpld);
923 tmpld = cexpl(tmpld);
924 tmpld = clogl(tmpld);
925 tmpld = csinl(tmpld);
926 tmpld = csinhl(tmpld);
927 tmpld = csqrtl(tmpld);
928 tmpld = ctanl(tmpld);
929 tmpld = ctanhl(tmpld);
930 tmpld = cpowl(tmpld, tmpld);
3cd54fc9 931 tmpld = cprojl(tmpld);
6d26724a 932 ],[glibcxx_cv_c99_complex=yes], [glibcxx_cv_c99_complex=no])
52e6723c 933 fi
6d26724a
RW
934 AC_MSG_RESULT($glibcxx_cv_c99_complex)
935 if test x"$glibcxx_cv_c99_complex" = x"yes"; then
4651e622
KC
936 AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
937 [Define if C99 functions in <complex.h> should be used in
938 <complex>. Using compiler builtins for these functions requires
939 corresponding C99 library functions to be present.])
52e6723c
BK
940 fi
941
ff66d28f 942 # Check for the existence in <stdio.h> of vscanf, et. al.
ff66d28f 943 AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
6d26724a 944 AC_CACHE_VAL(glibcxx_cv_c99_stdio, [
b6f914f6
RS
945 GCC_TRY_COMPILE_OR_LINK(
946 [#include <stdio.h>
947 #include <stdarg.h>
948 void foo(char* fmt, ...)
949 {
950 va_list args; va_start(args, fmt);
951 vfscanf(stderr, "%i", args);
952 vscanf("%i", args);
953 vsnprintf(fmt, 0, "%i", args);
954 vsscanf(fmt, "%i", args);
955 }],
956 [snprintf("12", 0, "%i");],
6d26724a 957 [glibcxx_cv_c99_stdio=yes], [glibcxx_cv_c99_stdio=no])
347669a0 958 ])
6d26724a 959 AC_MSG_RESULT($glibcxx_cv_c99_stdio)
ff66d28f
PE
960
961 # Check for the existence in <stdlib.h> of lldiv_t, et. al.
ff66d28f 962 AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
6d26724a 963 AC_CACHE_VAL(glibcxx_cv_c99_stdlib, [
b6f914f6
RS
964 GCC_TRY_COMPILE_OR_LINK(
965 [#include <stdlib.h>
966 volatile float f;
967 volatile long double ld;
968 volatile unsigned long long ll;
969 lldiv_t mydivt;],
970 [char* tmp;
971 f = strtof("gnu", &tmp);
972 ld = strtold("gnu", &tmp);
973 ll = strtoll("gnu", &tmp, 10);
974 ll = strtoull("gnu", &tmp, 10);
975 ll = llabs(10);
976 mydivt = lldiv(10,1);
977 ll = mydivt.quot;
978 ll = mydivt.rem;
979 ll = atoll("10");
980 _Exit(0);
6d26724a 981 ],[glibcxx_cv_c99_stdlib=yes], [glibcxx_cv_c99_stdlib=no])
347669a0 982 ])
6d26724a 983 AC_MSG_RESULT($glibcxx_cv_c99_stdlib)
ff66d28f 984
8a9b2875 985 # Check for the existence in <wchar.h> of wcstold, etc.
6d26724a 986 glibcxx_cv_c99_wchar=no;
347669a0
BK
987 if test x"$ac_has_wchar_h" = xyes &&
988 test x"$ac_has_wctype_h" = xyes; then
8a9b2875 989 AC_MSG_CHECKING([for ISO C99 support in <wchar.h>])
347669a0 990 AC_TRY_COMPILE([#include <wchar.h>
347669a0
BK
991 namespace test
992 {
347669a0
BK
993 using ::wcstold;
994 using ::wcstoll;
347669a0 995 using ::wcstoull;
347669a0 996 }
6d26724a 997 ],[],[glibcxx_cv_c99_wchar=yes], [glibcxx_cv_c99_wchar=no])
347669a0
BK
998
999 # Checks for wide character functions that may not be present.
1000 # Injection of these is wrapped with guard macros.
1001 # NB: only put functions here, instead of immediately above, if
1002 # absolutely necessary.
1003 AC_TRY_COMPILE([#include <wchar.h>
1004 namespace test { using ::vfwscanf; } ], [],
1005 [AC_DEFINE(HAVE_VFWSCANF,1,
1006 [Defined if vfwscanf exists.])],[])
1007
1008 AC_TRY_COMPILE([#include <wchar.h>
1009 namespace test { using ::vswscanf; } ], [],
1010 [AC_DEFINE(HAVE_VSWSCANF,1,
1011 [Defined if vswscanf exists.])],[])
1012
1013 AC_TRY_COMPILE([#include <wchar.h>
1014 namespace test { using ::vwscanf; } ], [],
1015 [AC_DEFINE(HAVE_VWSCANF,1,[Defined if vwscanf exists.])],[])
1016
1017 AC_TRY_COMPILE([#include <wchar.h>
1018 namespace test { using ::wcstof; } ], [],
1019 [AC_DEFINE(HAVE_WCSTOF,1,[Defined if wcstof exists.])],[])
1020
1021 AC_TRY_COMPILE([#include <wctype.h>],
1022 [ wint_t t; int i = iswblank(t);],
1023 [AC_DEFINE(HAVE_ISWBLANK,1,
1024 [Defined if iswblank exists.])],[])
1025
6d26724a 1026 AC_MSG_RESULT($glibcxx_cv_c99_wchar)
347669a0 1027 fi
ff66d28f 1028
347669a0 1029 # Option parsed, now set things appropriately.
6d26724a
RW
1030 if test x"$glibcxx_cv_c99_math" = x"no" ||
1031 test x"$glibcxx_cv_c99_complex" = x"no" ||
1032 test x"$glibcxx_cv_c99_stdio" = x"no" ||
1033 test x"$glibcxx_cv_c99_stdlib" = x"no" ||
1034 test x"$glibcxx_cv_c99_wchar" = x"no"; then
ff66d28f 1035 enable_c99=no;
347669a0 1036 else
4651e622
KC
1037 AC_DEFINE(_GLIBCXX_USE_C99, 1,
1038 [Define if C99 functions or macros from <wchar.h>, <math.h>,
1039 <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed.])
ff66d28f
PE
1040 fi
1041
b6f914f6
RS
1042 gcc_no_link="$ac_save_gcc_no_link"
1043 LIBS="$ac_save_LIBS"
1044 CXXFLAGS="$ac_save_CXXFLAGS"
ff66d28f 1045 AC_LANG_RESTORE
347669a0
BK
1046 fi
1047
1048 AC_MSG_CHECKING([for fully enabled ISO C99 support])
1049 AC_MSG_RESULT($enable_c99)
dcfa0bc8
PE
1050])
1051
1052
15e38d0d 1053dnl
959d14e1
CF
1054dnl Check for clock_gettime, nanosleep and sched_yield, used in the
1055dnl implementation of 20.8.5 [time.clock], and 30.2.2 [thread.thread.this]
1056dnl in the current C++0x working draft.
15e38d0d 1057dnl
959d14e1
CF
1058dnl --enable-libstdcxx-time
1059dnl --enable-libstdcxx-time=yes
1060dnl checks for the availability of monotonic and realtime clocks,
1061dnl nanosleep and sched_yield in libc and libposix4 and, in case, links
1062dnl the latter
1063dnl --enable-libstdcxx-time=rt
6c3385c1 1064dnl also searches (and, in case, links) librt. Note that this is
610870b2 1065dnl not always desirable because, in glibc, for example, in turn it
6c3385c1
PC
1066dnl triggers the linking of libpthread too, which activates locking,
1067dnl a large overhead for single-thread programs.
959d14e1
CF
1068dnl --enable-libstdcxx-time=no
1069dnl --disable-libstdcxx-time
610870b2
PC
1070dnl disables the checks completely
1071dnl
959d14e1 1072AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [
610870b2 1073
959d14e1
CF
1074 AC_MSG_CHECKING([for clock_gettime, nanosleep and sched_yield])
1075 GLIBCXX_ENABLE(libstdcxx-time,$1,[=KIND],
610870b2
PC
1076 [use KIND for check type],
1077 [permit yes|no|rt])
15e38d0d
CF
1078
1079 AC_LANG_SAVE
1080 AC_LANG_CPLUSPLUS
1081 ac_save_CXXFLAGS="$CXXFLAGS"
1082 CXXFLAGS="$CXXFLAGS -fno-exceptions"
ec6fa56a
PB
1083 ac_save_LIBS="$LIBS"
1084
1ac5e52c
MK
1085 ac_has_clock_monotonic=no
1086 ac_has_clock_realtime=no
1087 AC_MSG_RESULT($enable_libstdcxx_time)
ec6fa56a 1088
959d14e1 1089 if test x"$enable_libstdcxx_time" != x"no"; then
ec6fa56a 1090
959d14e1 1091 if test x"$enable_libstdcxx_time" = x"rt"; then
610870b2 1092 AC_SEARCH_LIBS(clock_gettime, [rt posix4])
959d14e1 1093 AC_SEARCH_LIBS(nanosleep, [rt posix4])
610870b2
PC
1094 else
1095 AC_SEARCH_LIBS(clock_gettime, [posix4])
959d14e1 1096 AC_SEARCH_LIBS(nanosleep, [posix4])
610870b2
PC
1097 fi
1098
1099 case "$ac_cv_search_clock_gettime" in
1100 -l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime
959d14e1
CF
1101 ;;
1102 esac
1103 case "$ac_cv_search_nanosleep" in
1104 -l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep"
1105 ;;
1106 esac
1107
1108 AC_SEARCH_LIBS(sched_yield, [rt posix4])
1109
1110 case "$ac_cv_search_sched_yield" in
1111 -lposix4*)
1112 GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1113 AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1114 [ Defined if sched_yield is available. ])
1115 ;;
1116 -lrt*)
1117 if test x"$enable_libstdcxx_time" = x"rt"; then
1118 GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield"
1119 AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1120 [ Defined if sched_yield is available. ])
1121 fi
1122 ;;
1123 *)
1124 AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1,
1125 [ Defined if sched_yield is available. ])
1126 ;;
610870b2
PC
1127 esac
1128
1129 AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no)
1130
1131 if test x"$ac_has_unistd_h" = x"yes"; then
1132 AC_MSG_CHECKING([for monotonic clock])
1133 AC_TRY_LINK(
1134 [#include <unistd.h>
1135 #include <time.h>
1136 ],
1137 [#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
1138 timespec tp;
1139 #endif
1140 clock_gettime(CLOCK_MONOTONIC, &tp);
1141 ], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no])
1142
1143 AC_MSG_RESULT($ac_has_clock_monotonic)
15e38d0d 1144
610870b2
PC
1145 AC_MSG_CHECKING([for realtime clock])
1146 AC_TRY_LINK(
1147 [#include <unistd.h>
1148 #include <time.h>
1149 ],
1150 [#if _POSIX_TIMERS > 0
1151 timespec tp;
1152 #endif
1153 clock_gettime(CLOCK_REALTIME, &tp);
1154 ], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no])
1155
1156 AC_MSG_RESULT($ac_has_clock_realtime)
610870b2 1157
959d14e1
CF
1158 AC_MSG_CHECKING([for nanosleep])
1159 AC_TRY_LINK(
1160 [#include <unistd.h>
1161 #include <time.h>
1162 ],
1163 [#if _POSIX_TIMERS > 0
1164 timespec tp;
1165 #endif
1166 nanosleep(&tp, 0);
1167 ], [ac_has_nanosleep=yes], [ac_has_nanosleep=no])
1168
1169 AC_MSG_RESULT($ac_has_nanosleep)
1170 fi
610870b2
PC
1171 fi
1172
15e38d0d
CF
1173 if test x"$ac_has_clock_monotonic" = x"yes"; then
1174 AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1,
1175 [ Defined if clock_gettime has monotonic clock support. ])
1176 fi
ec6fa56a 1177
15e38d0d
CF
1178 if test x"$ac_has_clock_realtime" = x"yes"; then
1179 AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1,
1180 [ Defined if clock_gettime has realtime clock support. ])
1181 fi
ec6fa56a 1182
959d14e1
CF
1183 if test x"$ac_has_nanosleep" = x"yes"; then
1184 AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1,
1185 [ Defined if nanosleep is available. ])
1186 fi
1187
ec6fa56a
PB
1188 AC_SUBST(GLIBCXX_LIBS)
1189
15e38d0d 1190 CXXFLAGS="$ac_save_CXXFLAGS"
ec6fa56a 1191 LIBS="$ac_save_LIBS"
15e38d0d
CF
1192 AC_LANG_RESTORE
1193])
1194
1195dnl
610870b2
PC
1196dnl Check for gettimeofday, used in the implementation of 20.8.5
1197dnl [time.clock] in the current C++0x working draft.
15e38d0d
CF
1198dnl
1199AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [
1200
610870b2
PC
1201 AC_MSG_CHECKING([for gettimeofday])
1202
15e38d0d
CF
1203 AC_LANG_SAVE
1204 AC_LANG_CPLUSPLUS
1205 ac_save_CXXFLAGS="$CXXFLAGS"
1206 CXXFLAGS="$CXXFLAGS -fno-exceptions"
1207
1208 ac_has_gettimeofday=no;
1209 AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no)
1210 if test x"$ac_has_sys_time_h" = x"yes"; then
1211 AC_MSG_CHECKING([for gettimeofday])
610870b2 1212 GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>],
15e38d0d
CF
1213 [timeval tv; gettimeofday(&tv, 0);],
1214 [ac_has_gettimeofday=yes], [ac_has_gettimeofday=no])
1215
1216 AC_MSG_RESULT($ac_has_gettimeofday)
1217 fi
1218
1219 if test x"$ac_has_gettimeofday" = x"yes"; then
1220 AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1,
1221 [ Defined if gettimeofday is available. ])
1222 fi
1223
1224 CXXFLAGS="$ac_save_CXXFLAGS"
1225 AC_LANG_RESTORE
1226])
1227
bd2bb1ea
PC
1228dnl
1229dnl Check for ISO/IEC 9899:1999 "C99" support to ISO/IEC DTR 19768 "TR1"
1230dnl facilities in Chapter 8, "C compatibility".
1231dnl
1232AC_DEFUN([GLIBCXX_CHECK_C99_TR1], [
1233
1234 AC_LANG_SAVE
1235 AC_LANG_CPLUSPLUS
1236
18f310b7
PC
1237 # Use -std=c++98 because the default (-std=gnu++98) leaves __STRICT_ANSI__
1238 # undefined and fake C99 facilities may be spuriously enabled.
1239 ac_save_CXXFLAGS="$CXXFLAGS"
1240 CXXFLAGS="$CXXFLAGS -std=c++98"
1241
bd2bb1ea
PC
1242 # Check for the existence of <complex.h> complex math functions used
1243 # by tr1/complex.
1244 AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
1245 ac_c99_complex_tr1=no;
1246 if test x"$ac_has_complex_h" = x"yes"; then
1247 AC_MSG_CHECKING([for ISO C99 support to TR1 in <complex.h>])
1248 AC_TRY_COMPILE([#include <complex.h>],
1249 [typedef __complex__ float float_type; float_type tmpf;
1250 cacosf(tmpf);
1251 casinf(tmpf);
1252 catanf(tmpf);
1253 cacoshf(tmpf);
1254 casinhf(tmpf);
1255 catanhf(tmpf);
1256 typedef __complex__ double double_type; double_type tmpd;
1257 cacos(tmpd);
1258 casin(tmpd);
1259 catan(tmpd);
1260 cacosh(tmpd);
1261 casinh(tmpd);
1262 catanh(tmpd);
1263 typedef __complex__ long double ld_type; ld_type tmpld;
1264 cacosl(tmpld);
1265 casinl(tmpld);
1266 catanl(tmpld);
1267 cacoshl(tmpld);
1268 casinhl(tmpld);
1269 catanhl(tmpld);
1270 ],[ac_c99_complex_tr1=yes], [ac_c99_complex_tr1=no])
1271 fi
1272 AC_MSG_RESULT($ac_c99_complex_tr1)
1273 if test x"$ac_c99_complex_tr1" = x"yes"; then
1274 AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX_TR1, 1,
1275 [Define if C99 functions in <complex.h> should be used in
1276 <tr1/complex>. Using compiler builtins for these functions
1277 requires corresponding C99 library functions to be present.])
1278 fi
1279
1280 # Check for the existence of <ctype.h> functions.
1281 AC_MSG_CHECKING([for ISO C99 support to TR1 in <ctype.h>])
6d26724a 1282 AC_CACHE_VAL(glibcxx_cv_c99_ctype_tr1, [
bd2bb1ea 1283 AC_TRY_COMPILE([#include <ctype.h>],
20921e53 1284 [int ch;
98fb1d29
PC
1285 int ret;
1286 ret = isblank(ch);
0f24e8de
PC
1287 ],[glibcxx_cv_c99_ctype_tr1=yes],
1288 [glibcxx_cv_c99_ctype_tr1=no])
bd2bb1ea 1289 ])
6d26724a
RW
1290 AC_MSG_RESULT($glibcxx_cv_c99_ctype_tr1)
1291 if test x"$glibcxx_cv_c99_ctype_tr1" = x"yes"; then
bd2bb1ea
PC
1292 AC_DEFINE(_GLIBCXX_USE_C99_CTYPE_TR1, 1,
1293 [Define if C99 functions in <ctype.h> should be imported in
1294 <tr1/cctype> in namespace std::tr1.])
1295 fi
1296
20921e53
PC
1297 # Check for the existence of <fenv.h> functions.
1298 AC_CHECK_HEADERS(fenv.h, ac_has_fenv_h=yes, ac_has_fenv_h=no)
1299 ac_c99_fenv_tr1=no;
1300 if test x"$ac_has_fenv_h" = x"yes"; then
1301 AC_MSG_CHECKING([for ISO C99 support to TR1 in <fenv.h>])
1302 AC_TRY_COMPILE([#include <fenv.h>],
1303 [int except, mode;
1304 fexcept_t* pflag;
1305 fenv_t* penv;
98fb1d29
PC
1306 int ret;
1307 ret = feclearexcept(except);
1308 ret = fegetexceptflag(pflag, except);
1309 ret = feraiseexcept(except);
1310 ret = fesetexceptflag(pflag, except);
1311 ret = fetestexcept(except);
1312 ret = fegetround();
1313 ret = fesetround(mode);
1314 ret = fegetenv(penv);
1315 ret = feholdexcept(penv);
1316 ret = fesetenv(penv);
1317 ret = feupdateenv(penv);
20921e53
PC
1318 ],[ac_c99_fenv_tr1=yes], [ac_c99_fenv_tr1=no])
1319 fi
1320 AC_MSG_RESULT($ac_c99_fenv_tr1)
1321 if test x"$ac_c99_fenv_tr1" = x"yes"; then
1322 AC_DEFINE(_GLIBCXX_USE_C99_FENV_TR1, 1,
1323 [Define if C99 functions in <fenv.h> should be imported in
1324 <tr1/cfenv> in namespace std::tr1.])
1325 fi
1326
2a1d6346
PC
1327 # Check for the existence of <stdint.h> types.
1328 AC_MSG_CHECKING([for ISO C99 support to TR1 in <stdint.h>])
6d26724a 1329 AC_CACHE_VAL(glibcxx_cv_c99_stdint_tr1, [
5289e808
PC
1330 AC_TRY_COMPILE([#define __STDC_LIMIT_MACROS
1331 #define __STDC_CONSTANT_MACROS
1332 #include <stdint.h>],
2a1d6346 1333 [typedef int8_t my_int8_t;
5289e808
PC
1334 my_int8_t i8 = INT8_MIN;
1335 i8 = INT8_MAX;
2a1d6346 1336 typedef int16_t my_int16_t;
5289e808
PC
1337 my_int16_t i16 = INT16_MIN;
1338 i16 = INT16_MAX;
2a1d6346 1339 typedef int32_t my_int32_t;
5289e808
PC
1340 my_int32_t i32 = INT32_MIN;
1341 i32 = INT32_MAX;
2a1d6346 1342 typedef int64_t my_int64_t;
5289e808
PC
1343 my_int64_t i64 = INT64_MIN;
1344 i64 = INT64_MAX;
2a1d6346 1345 typedef int_fast8_t my_int_fast8_t;
5289e808
PC
1346 my_int_fast8_t if8 = INT_FAST8_MIN;
1347 if8 = INT_FAST8_MAX;
2a1d6346 1348 typedef int_fast16_t my_int_fast16_t;
5289e808
PC
1349 my_int_fast16_t if16 = INT_FAST16_MIN;
1350 if16 = INT_FAST16_MAX;
2a1d6346 1351 typedef int_fast32_t my_int_fast32_t;
5289e808
PC
1352 my_int_fast32_t if32 = INT_FAST32_MIN;
1353 if32 = INT_FAST32_MAX;
1354 typedef int_fast64_t my_int_fast64_t;
1355 my_int_fast64_t if64 = INT_FAST64_MIN;
1356 if64 = INT_FAST64_MAX;
2a1d6346 1357 typedef int_least8_t my_int_least8_t;
5289e808
PC
1358 my_int_least8_t il8 = INT_LEAST8_MIN;
1359 il8 = INT_LEAST8_MAX;
2a1d6346 1360 typedef int_least16_t my_int_least16_t;
5289e808
PC
1361 my_int_least16_t il16 = INT_LEAST16_MIN;
1362 il16 = INT_LEAST16_MAX;
2a1d6346 1363 typedef int_least32_t my_int_least32_t;
5289e808
PC
1364 my_int_least32_t il32 = INT_LEAST32_MIN;
1365 il32 = INT_LEAST32_MAX;
2a1d6346 1366 typedef int_least64_t my_int_least64_t;
5289e808
PC
1367 my_int_least64_t il64 = INT_LEAST64_MIN;
1368 il64 = INT_LEAST64_MAX;
2a1d6346 1369 typedef intmax_t my_intmax_t;
5289e808
PC
1370 my_intmax_t im = INTMAX_MAX;
1371 im = INTMAX_MIN;
2a1d6346 1372 typedef intptr_t my_intptr_t;
5289e808
PC
1373 my_intptr_t ip = INTPTR_MAX;
1374 ip = INTPTR_MIN;
2a1d6346 1375 typedef uint8_t my_uint8_t;
5289e808
PC
1376 my_uint8_t ui8 = UINT8_MAX;
1377 ui8 = UINT8_MAX;
2a1d6346 1378 typedef uint16_t my_uint16_t;
5289e808
PC
1379 my_uint16_t ui16 = UINT16_MAX;
1380 ui16 = UINT16_MAX;
2a1d6346 1381 typedef uint32_t my_uint32_t;
5289e808
PC
1382 my_uint32_t ui32 = UINT32_MAX;
1383 ui32 = UINT32_MAX;
2a1d6346 1384 typedef uint64_t my_uint64_t;
5289e808
PC
1385 my_uint64_t ui64 = UINT64_MAX;
1386 ui64 = UINT64_MAX;
2a1d6346 1387 typedef uint_fast8_t my_uint_fast8_t;
5289e808
PC
1388 my_uint_fast8_t uif8 = UINT_FAST8_MAX;
1389 uif8 = UINT_FAST8_MAX;
2a1d6346 1390 typedef uint_fast16_t my_uint_fast16_t;
5289e808
PC
1391 my_uint_fast16_t uif16 = UINT_FAST16_MAX;
1392 uif16 = UINT_FAST16_MAX;
2a1d6346 1393 typedef uint_fast32_t my_uint_fast32_t;
5289e808
PC
1394 my_uint_fast32_t uif32 = UINT_FAST32_MAX;
1395 uif32 = UINT_FAST32_MAX;
1396 typedef uint_fast64_t my_uint_fast64_t;
1397 my_uint_fast64_t uif64 = UINT_FAST64_MAX;
1398 uif64 = UINT_FAST64_MAX;
2a1d6346 1399 typedef uint_least8_t my_uint_least8_t;
5289e808
PC
1400 my_uint_least8_t uil8 = UINT_LEAST8_MAX;
1401 uil8 = UINT_LEAST8_MAX;
2a1d6346 1402 typedef uint_least16_t my_uint_least16_t;
5289e808
PC
1403 my_uint_least16_t uil16 = UINT_LEAST16_MAX;
1404 uil16 = UINT_LEAST16_MAX;
2a1d6346 1405 typedef uint_least32_t my_uint_least32_t;
5289e808
PC
1406 my_uint_least32_t uil32 = UINT_LEAST32_MAX;
1407 uil32 = UINT_LEAST32_MAX;
2a1d6346 1408 typedef uint_least64_t my_uint_least64_t;
5289e808
PC
1409 my_uint_least64_t uil64 = UINT_LEAST64_MAX;
1410 uil64 = UINT_LEAST64_MAX;
2a1d6346 1411 typedef uintmax_t my_uintmax_t;
5289e808
PC
1412 my_uintmax_t uim = UINTMAX_MAX;
1413 uim = UINTMAX_MAX;
2a1d6346 1414 typedef uintptr_t my_uintptr_t;
5289e808
PC
1415 my_uintptr_t uip = UINTPTR_MAX;
1416 uip = UINTPTR_MAX;
0f24e8de
PC
1417 ],[glibcxx_cv_c99_stdint_tr1=yes],
1418 [glibcxx_cv_c99_stdint_tr1=no])
2a1d6346 1419 ])
6d26724a
RW
1420 AC_MSG_RESULT($glibcxx_cv_c99_stdint_tr1)
1421 if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
2a1d6346
PC
1422 AC_DEFINE(_GLIBCXX_USE_C99_STDINT_TR1, 1,
1423 [Define if C99 types in <stdint.h> should be imported in
1424 <tr1/cstdint> in namespace std::tr1.])
1425 fi
1426
4f0de5dd
PC
1427 # Check for the existence of <math.h> functions.
1428 AC_MSG_CHECKING([for ISO C99 support to TR1 in <math.h>])
6d26724a 1429 AC_CACHE_VAL(glibcxx_cv_c99_math_tr1, [
4f0de5dd 1430 AC_TRY_COMPILE([#include <math.h>],
9a7ab578
PC
1431 [typedef double_t my_double_t;
1432 typedef float_t my_float_t;
1433 acosh(0.0);
4f0de5dd
PC
1434 acoshf(0.0f);
1435 acoshl(0.0l);
1436 asinh(0.0);
1437 asinhf(0.0f);
1438 asinhl(0.0l);
1439 atanh(0.0);
1440 atanhf(0.0f);
1441 atanhl(0.0l);
1442 cbrt(0.0);
1443 cbrtf(0.0f);
1444 cbrtl(0.0l);
1445 copysign(0.0, 0.0);
1446 copysignf(0.0f, 0.0f);
1447 copysignl(0.0l, 0.0l);
1448 erf(0.0);
1449 erff(0.0f);
1450 erfl(0.0l);
1451 erfc(0.0);
1452 erfcf(0.0f);
1453 erfcl(0.0l);
1454 exp2(0.0);
1455 exp2f(0.0f);
1456 exp2l(0.0l);
1457 expm1(0.0);
1458 expm1f(0.0f);
1459 expm1l(0.0l);
1460 fdim(0.0, 0.0);
1461 fdimf(0.0f, 0.0f);
1462 fdiml(0.0l, 0.0l);
1463 fma(0.0, 0.0, 0.0);
1464 fmaf(0.0f, 0.0f, 0.0f);
1465 fmal(0.0l, 0.0l, 0.0l);
1466 fmax(0.0, 0.0);
1467 fmaxf(0.0f, 0.0f);
1468 fmaxl(0.0l, 0.0l);
1469 fmin(0.0, 0.0);
1470 fminf(0.0f, 0.0f);
1471 fminl(0.0l, 0.0l);
1472 hypot(0.0, 0.0);
1473 hypotf(0.0f, 0.0f);
1474 hypotl(0.0l, 0.0l);
1475 ilogb(0.0);
1476 ilogbf(0.0f);
1477 ilogbl(0.0l);
1478 lgamma(0.0);
1479 lgammaf(0.0f);
1480 lgammal(0.0l);
1481 llrint(0.0);
1482 llrintf(0.0f);
1483 llrintl(0.0l);
1484 llround(0.0);
1485 llroundf(0.0f);
1486 llroundl(0.0l);
1487 log1p(0.0);
1488 log1pf(0.0f);
1489 log1pl(0.0l);
1490 log2(0.0);
1491 log2f(0.0f);
1492 log2l(0.0l);
1493 logb(0.0);
1494 logbf(0.0f);
1495 logbl(0.0l);
1496 lrint(0.0);
1497 lrintf(0.0f);
1498 lrintl(0.0l);
1499 lround(0.0);
1500 lroundf(0.0f);
1501 lroundl(0.0l);
1502 nan(0);
1503 nanf(0);
1504 nanl(0);
1505 nearbyint(0.0);
1506 nearbyintf(0.0f);
1507 nearbyintl(0.0l);
1508 nextafter(0.0, 0.0);
1509 nextafterf(0.0f, 0.0f);
1510 nextafterl(0.0l, 0.0l);
1511 nexttoward(0.0, 0.0);
1512 nexttowardf(0.0f, 0.0f);
1513 nexttowardl(0.0l, 0.0l);
1514 remainder(0.0, 0.0);
1515 remainderf(0.0f, 0.0f);
1516 remainderl(0.0l, 0.0l);
1517 remquo(0.0, 0.0, 0);
a5d137be
PC
1518 remquof(0.0f, 0.0f, 0);
1519 remquol(0.0l, 0.0l, 0);
4f0de5dd
PC
1520 rint(0.0);
1521 rintf(0.0f);
1522 rintl(0.0l);
1523 round(0.0);
1524 roundf(0.0f);
1525 roundl(0.0l);
1526 scalbln(0.0, 0l);
1527 scalblnf(0.0f, 0l);
1528 scalblnl(0.0l, 0l);
1529 scalbn(0.0, 0);
1530 scalbnf(0.0f, 0);
1531 scalbnl(0.0l, 0);
1532 tgamma(0.0);
1533 tgammaf(0.0f);
1534 tgammal(0.0l);
1535 trunc(0.0);
1536 truncf(0.0f);
1537 truncl(0.0l);
6d26724a 1538 ],[glibcxx_cv_c99_math_tr1=yes], [glibcxx_cv_c99_math_tr1=no])
4f0de5dd 1539 ])
6d26724a
RW
1540 AC_MSG_RESULT($glibcxx_cv_c99_math_tr1)
1541 if test x"$glibcxx_cv_c99_math_tr1" = x"yes"; then
4f0de5dd
PC
1542 AC_DEFINE(_GLIBCXX_USE_C99_MATH_TR1, 1,
1543 [Define if C99 functions or macros in <math.h> should be imported
1544 in <tr1/cmath> in namespace std::tr1.])
1545 fi
1546
03bf3bc1 1547 # Check for the existence of <inttypes.h> functions (NB: doesn't make
a834e097 1548 # sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
03bf3bc1 1549 ac_c99_inttypes_tr1=no;
6d26724a 1550 if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
03bf3bc1
PC
1551 AC_MSG_CHECKING([for ISO C99 support to TR1 in <inttypes.h>])
1552 AC_TRY_COMPILE([#include <inttypes.h>],
1553 [intmax_t i, numer, denom, base;
1554 const char* s;
1555 char** endptr;
af66a43e
PC
1556 intmax_t ret = imaxabs(i);
1557 imaxdiv_t dret = imaxdiv(numer, denom);
03bf3bc1 1558 ret = strtoimax(s, endptr, base);
af66a43e 1559 uintmax_t uret = strtoumax(s, endptr, base);
03bf3bc1
PC
1560 ],[ac_c99_inttypes_tr1=yes], [ac_c99_inttypes_tr1=no])
1561 fi
52a64bd3
PC
1562 AC_MSG_RESULT($ac_c99_inttypes_tr1)
1563 if test x"$ac_c99_inttypes_tr1" = x"yes"; then
1564 AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_TR1, 1,
1565 [Define if C99 functions in <inttypes.h> should be imported in
03bf3bc1 1566 <tr1/cinttypes> in namespace std::tr1.])
52a64bd3
PC
1567 fi
1568
a834e097
PC
1569 # Check for the existence of whcar_t <inttypes.h> functions (NB: doesn't
1570 # make sense if the glibcxx_cv_c99_stdint_tr1 check fails, per C99, 7.8/1).
1571 ac_c99_inttypes_wchar_t_tr1=no;
1572 if test x"$glibcxx_cv_c99_stdint_tr1" = x"yes"; then
1573 AC_MSG_CHECKING([for wchar_t ISO C99 support to TR1 in <inttypes.h>])
1574 AC_TRY_COMPILE([#include <inttypes.h>],
1575 [intmax_t base;
1576 const wchar_t* s;
1577 wchar_t** endptr;
1578 intmax_t ret = wcstoimax(s, endptr, base);
1579 uintmax_t uret = wcstoumax(s, endptr, base);
1580 ],[ac_c99_inttypes_wchar_t_tr1=yes],
1581 [ac_c99_inttypes_wchar_t_tr1=no])
1582 fi
1583 AC_MSG_RESULT($ac_c99_inttypes_wchar_t_tr1)
1584 if test x"$ac_c99_inttypes_wchar_t_tr1" = x"yes"; then
1585 AC_DEFINE(_GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1, 1,
1586 [Define if wchar_t C99 functions in <inttypes.h> should be
1587 imported in <tr1/cinttypes> in namespace std::tr1.])
1588 fi
1589
1e41a98c
PC
1590 # Check for the existence of the <stdbool.h> header.
1591 AC_CHECK_HEADERS(stdbool.h)
1592
18f310b7 1593 CXXFLAGS="$ac_save_CXXFLAGS"
bd2bb1ea
PC
1594 AC_LANG_RESTORE
1595])
1596
d8bc9819 1597dnl
9ce0a22e 1598dnl Check whether "/dev/random" and "/dev/urandom" are available for the
d8bc9819
PC
1599dnl random_device of "TR1" (Chapter 5.1, "Random number generation").
1600dnl
1601AC_DEFUN([GLIBCXX_CHECK_RANDOM_TR1], [
1602
9ce0a22e 1603 AC_MSG_CHECKING([for "/dev/random" and "/dev/urandom" for TR1 random_device])
6d26724a 1604 AC_CACHE_VAL(glibcxx_cv_random_tr1, [
9ce0a22e
PC
1605 if test -r /dev/random && test -r /dev/urandom; then
1606 glibcxx_cv_random_tr1=yes;
1607 else
1608 glibcxx_cv_random_tr1=no;
1609 fi
d8bc9819 1610 ])
6d26724a 1611 AC_MSG_RESULT($glibcxx_cv_random_tr1)
9ce0a22e 1612
6d26724a 1613 if test x"$glibcxx_cv_random_tr1" = x"yes"; then
d8bc9819 1614 AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1, 1,
9ce0a22e 1615 [Define if /dev/random and /dev/urandom are available for
d8bc9819
PC
1616 the random_device of TR1 (Chapter 5.1).])
1617 fi
1618
1619])
bd2bb1ea 1620
1814157e
PC
1621dnl
1622dnl Check whether EOF, SEEK_CUR, and SEEK_END have the most common values:
1623dnl in that case including <cstdio> in some C++ headers can be avoided.
1624dnl
1625AC_DEFUN([GLIBCXX_CHECK_STDIO_MACROS], [
1626
1627 AC_MSG_CHECKING([for EOF == -1, SEEK_CUR == 1, SEEK_END == 2])
1628 AC_CACHE_VAL(glibcxx_cv_stdio_macros, [
1629 AC_TRY_COMPILE([#include <stdio.h>],
1630 [#if ((EOF != -1) || (SEEK_CUR != 1) || (SEEK_END != 2))
1631 unusual values...
1632 #endif
1633 ], [glibcxx_cv_stdio_macros=yes],
1634 [glibcxx_cv_stdio_macros=no])
1635 ])
1636 AC_MSG_RESULT($glibcxx_cv_stdio_macros)
1637 if test x"$glibcxx_cv_stdio_macros" = x"yes"; then
1638 AC_DEFINE(_GLIBCXX_STDIO_MACROS, 1,
1639 [Define if EOF == -1, SEEK_CUR == 1, SEEK_END == 2.])
1640 fi
1641
1642])
1643
0646d8a3
BK
1644dnl
1645dnl Check whether macros, etc are present for <system_error>
1646dnl
1647AC_DEFUN([GLIBCXX_CHECK_SYSTEM_ERROR], [
1648
6d26724a
RW
1649m4_pushdef([n_syserr], [1])dnl
1650m4_foreach([syserr], [EOWNERDEAD, ENOTRECOVERABLE, ENOLINK, EPROTO, ENODATA,
70593ad2 1651 ENOSR, ENOSTR, ETIME, EBADMSG, ECANCELED,
6d26724a
RW
1652 EOVERFLOW, ENOTSUP, EIDRM, ETXTBSY],
1653[m4_pushdef([SYSERR], m4_toupper(syserr))dnl
1654AC_MSG_CHECKING([for syserr])
1655AC_CACHE_VAL([glibcxx_cv_system_error[]n_syserr], [
1656AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]],
1657 [int i = syserr;])],
1658 [glibcxx_cv_system_error[]n_syserr=yes],
1659 [glibcxx_cv_system_error[]n_syserr=no])
1660])
1661AC_MSG_RESULT([$glibcxx_cv_system_error[]n_syserr])
1662if test x"$glibcxx_cv_system_error[]n_syserr" = x"yes"; then
1663 AC_DEFINE([HAVE_]SYSERR, 1, [Define if ]syserr[ exists.])
1664fi
1665m4_define([n_syserr], m4_incr(n_syserr))dnl
1666m4_popdef([SYSERR])dnl
1667])
1668m4_popdef([n_syserr])dnl
0646d8a3
BK
1669])
1670
0214010c 1671dnl
ff66d28f
PE
1672dnl Check for what type of C headers to use.
1673dnl
1674dnl --enable-cheaders= [does stuff].
1675dnl --disable-cheaders [does not do anything, really].
1676dnl + Usage: GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
af13a7a6 1677dnl Where DEFAULT is either 'c' or 'c_std' or 'c_global'.
ff66d28f 1678dnl
f214923c 1679AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
ff66d28f 1680 GLIBCXX_ENABLE(cheaders,$1,[=KIND],
af13a7a6 1681 [construct "C" headers for g++], [permit c|c_std|c_global])
ff66d28f
PE
1682 AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
1683
1684 C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
1685
af13a7a6
BK
1686 # Allow overrides to configure.host here.
1687 if test $enable_cheaders = c_global; then
1688 c_compatibility=yes
1689 fi
1690
1691 if test $enable_cheaders = c_global || test $enable_cheaders = c_std; then
1692 c_extra=yes
1693 fi
1694
ff66d28f 1695 AC_SUBST(C_INCLUDE_DIR)
92eabea2
PE
1696 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
1697 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
af13a7a6 1698 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_GLOBAL, test $enable_cheaders = c_global)
92eabea2 1699 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
af13a7a6 1700 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_EXTRA, test $c_extra = yes)
ff66d28f
PE
1701])
1702
1703
0214010c 1704dnl
ff66d28f
PE
1705dnl Check for which locale library to use. The choice is mapped to
1706dnl a subdirectory of config/locale.
37bc6ca2 1707dnl
ff66d28f 1708dnl Default is generic.
0214010c 1709dnl
f214923c 1710AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
ff66d28f
PE
1711 GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
1712 [use MODEL for target locale package],
1713 [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
0258dc3a
BK
1714
1715 # Deal with gettext issues. Default to not using it (=no) until we detect
1716 # support for it later. Let the user turn it off via --e/d, but let that
1717 # default to on for easier handling.
1718 USE_NLS=no
1719 AC_ARG_ENABLE(nls,
1720 AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]),
1721 [],
1722 [enable_nls=yes])
ff66d28f 1723
0258dc3a 1724 # Either a known packaage, or "auto"
ff66d28f
PE
1725 if test $enable_clocale = no || test $enable_clocale = yes; then
1726 enable_clocale=auto
1727 fi
0214010c
BK
1728 enable_clocale_flag=$enable_clocale
1729
0258dc3a 1730 # Probe for locale model to use if none specified.
ff66d28f
PE
1731 # Default to "generic".
1732 if test $enable_clocale_flag = auto; then
7d3998a4
PE
1733 case ${target_os} in
1734 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
0258dc3a 1735 enable_clocale_flag=gnu
56deb74c 1736 ;;
a7f7b334 1737 darwin* | freebsd*)
f9686024
GK
1738 enable_clocale_flag=darwin
1739 ;;
56deb74c 1740 *)
ff66d28f
PE
1741 enable_clocale_flag=generic
1742 ;;
56deb74c
BK
1743 esac
1744 fi
1745
0258dc3a
BK
1746 # Sanity check model, and test for special functionality.
1747 if test $enable_clocale_flag = gnu; then
1748 AC_EGREP_CPP([_GLIBCXX_ok], [
1749 #include <features.h>
22b36782 1750 #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(__UCLIBC__)
0258dc3a
BK
1751 _GLIBCXX_ok
1752 #endif
1753 ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1754
0258dc3a
BK
1755 # Set it to scream when it hurts.
1756 ac_save_CFLAGS="$CFLAGS"
1757 CFLAGS="-Wimplicit-function-declaration -Werror"
1758
1759 # Use strxfrm_l if available.
1760 AC_TRY_COMPILE([#define _GNU_SOURCE 1
1761 #include <string.h>
1762 #include <locale.h>],
1763 [char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);],
1764 AC_DEFINE(HAVE_STRXFRM_L, 1,
1765 [Define if strxfrm_l is available in <string.h>.]),)
1766
1767 # Use strerror_l if available.
1768 AC_TRY_COMPILE([#define _GNU_SOURCE 1
1769 #include <string.h>
1770 #include <locale.h>],
1771 [__locale_t loc; strerror_l(5, loc);],
1772 AC_DEFINE(HAVE_STRERROR_L, 1,
1773 [Define if strerror_l is available in <string.h>.]),)
1774
1775 CFLAGS="$ac_save_CFLAGS"
1776 fi
1777
1778 # Perhaps use strerror_r if available, and strerror_l isn't.
1779 ac_save_CFLAGS="$CFLAGS"
1780 CFLAGS="-Wimplicit-function-declaration -Werror"
1781 AC_TRY_COMPILE([#define _GNU_SOURCE 1
1782 #include <string.h>
1783 #include <locale.h>],
1784 [char s[128]; strerror_r(5, s, 128);],
1785 AC_DEFINE(HAVE_STRERROR_R, 1,
1786 [Define if strerror_r is available in <string.h>.]),)
1787 CFLAGS="$ac_save_CFLAGS"
501e321e 1788
ff66d28f 1789 # Set configure bits for specified locale package
0258dc3a 1790 AC_MSG_CHECKING([for C locale to use])
ff66d28f
PE
1791 case ${enable_clocale_flag} in
1792 generic)
33590f13
BK
1793 AC_MSG_RESULT(generic)
1794
1fa4bed7
BK
1795 CLOCALE_H=config/locale/generic/c_locale.h
1796 CLOCALE_CC=config/locale/generic/c_locale.cc
38cca750 1797 CCODECVT_CC=config/locale/generic/codecvt_members.cc
1fa4bed7
BK
1798 CCOLLATE_CC=config/locale/generic/collate_members.cc
1799 CCTYPE_CC=config/locale/generic/ctype_members.cc
1800 CMESSAGES_H=config/locale/generic/messages_members.h
1801 CMESSAGES_CC=config/locale/generic/messages_members.cc
1802 CMONEY_CC=config/locale/generic/monetary_members.cc
1803 CNUMERIC_CC=config/locale/generic/numeric_members.cc
1c26d8fd 1804 CTIME_H=config/locale/generic/time_members.h
1fa4bed7 1805 CTIME_CC=config/locale/generic/time_members.cc
89671b70 1806 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
33590f13 1807 ;;
f9686024 1808 darwin)
a7f7b334 1809 AC_MSG_RESULT(darwin or freebsd)
f9686024
GK
1810
1811 CLOCALE_H=config/locale/generic/c_locale.h
1812 CLOCALE_CC=config/locale/generic/c_locale.cc
f9686024
GK
1813 CCODECVT_CC=config/locale/generic/codecvt_members.cc
1814 CCOLLATE_CC=config/locale/generic/collate_members.cc
1815 CCTYPE_CC=config/locale/darwin/ctype_members.cc
1816 CMESSAGES_H=config/locale/generic/messages_members.h
1817 CMESSAGES_CC=config/locale/generic/messages_members.cc
1818 CMONEY_CC=config/locale/generic/monetary_members.cc
1819 CNUMERIC_CC=config/locale/generic/numeric_members.cc
1820 CTIME_H=config/locale/generic/time_members.h
1821 CTIME_CC=config/locale/generic/time_members.cc
1822 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
1823 ;;
1824
ff66d28f 1825 gnu)
0214010c 1826 AC_MSG_RESULT(gnu)
33590f13
BK
1827
1828 # Declare intention to use gettext, and add support for specific
1829 # languages.
248a9163 1830 # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
33590f13 1831 ALL_LINGUAS="de fr"
501e321e 1832
248a9163 1833 # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
501e321e
BK
1834 AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
1835 if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
ff66d28f 1836 USE_NLS=yes
501e321e 1837 fi
33590f13
BK
1838 # Export the build objects.
1839 for ling in $ALL_LINGUAS; do \
3d7c150e
BK
1840 glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
1841 glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
33590f13 1842 done
3d7c150e
BK
1843 AC_SUBST(glibcxx_MOFILES)
1844 AC_SUBST(glibcxx_POFILES)
33590f13 1845
1fa4bed7
BK
1846 CLOCALE_H=config/locale/gnu/c_locale.h
1847 CLOCALE_CC=config/locale/gnu/c_locale.cc
38cca750 1848 CCODECVT_CC=config/locale/gnu/codecvt_members.cc
1fa4bed7
BK
1849 CCOLLATE_CC=config/locale/gnu/collate_members.cc
1850 CCTYPE_CC=config/locale/gnu/ctype_members.cc
1851 CMESSAGES_H=config/locale/gnu/messages_members.h
1852 CMESSAGES_CC=config/locale/gnu/messages_members.cc
1853 CMONEY_CC=config/locale/gnu/monetary_members.cc
1854 CNUMERIC_CC=config/locale/gnu/numeric_members.cc
1c26d8fd 1855 CTIME_H=config/locale/gnu/time_members.h
1fa4bed7 1856 CTIME_CC=config/locale/gnu/time_members.cc
89671b70 1857 CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h
0214010c 1858 ;;
ff66d28f 1859 ieee_1003.1-2001)
7f78b6ca 1860 AC_MSG_RESULT(IEEE 1003.1)
33590f13 1861
1fa4bed7
BK
1862 CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
1863 CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
38cca750 1864 CCODECVT_CC=config/locale/generic/codecvt_members.cc
1fa4bed7
BK
1865 CCOLLATE_CC=config/locale/generic/collate_members.cc
1866 CCTYPE_CC=config/locale/generic/ctype_members.cc
1867 CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h
1868 CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc
1869 CMONEY_CC=config/locale/generic/monetary_members.cc
1870 CNUMERIC_CC=config/locale/generic/numeric_members.cc
1c26d8fd 1871 CTIME_H=config/locale/generic/time_members.h
1fa4bed7 1872 CTIME_CC=config/locale/generic/time_members.cc
89671b70 1873 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
0214010c 1874 ;;
0214010c
BK
1875 esac
1876
33590f13
BK
1877 # This is where the testsuite looks for locale catalogs, using the
1878 # -DLOCALEDIR define during testsuite compilation.
3d7c150e
BK
1879 glibcxx_localedir=${glibcxx_builddir}/po/share/locale
1880 AC_SUBST(glibcxx_localedir)
33590f13 1881
7f78b6ca
PE
1882 # A standalone libintl (e.g., GNU libintl) may be in use.
1883 if test $USE_NLS = yes; then
c67528fe
PE
1884 AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no)
1885 AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no)
1886 fi
1887 if test $USE_NLS = yes; then
4651e622
KC
1888 AC_DEFINE(_GLIBCXX_USE_NLS, 1,
1889 [Define if NLS translations are to be used.])
7f78b6ca
PE
1890 fi
1891
4e10943d 1892 AC_SUBST(USE_NLS)
4a9d5109 1893 AC_SUBST(CLOCALE_H)
33590f13 1894 AC_SUBST(CMESSAGES_H)
6aa43d99
BK
1895 AC_SUBST(CCODECVT_CC)
1896 AC_SUBST(CCOLLATE_CC)
1897 AC_SUBST(CCTYPE_CC)
1898 AC_SUBST(CMESSAGES_CC)
1899 AC_SUBST(CMONEY_CC)
1900 AC_SUBST(CNUMERIC_CC)
1c26d8fd 1901 AC_SUBST(CTIME_H)
6aa43d99
BK
1902 AC_SUBST(CTIME_CC)
1903 AC_SUBST(CLOCALE_CC)
1904 AC_SUBST(CLOCALE_INTERNAL_H)
0214010c
BK
1905])
1906
1907
8b0d6051
BK
1908dnl
1909dnl Check for which std::allocator base class to use. The choice is
1910dnl mapped from a subdirectory of include/ext.
1911dnl
1912dnl Default is new.
1913dnl
1914AC_DEFUN([GLIBCXX_ENABLE_ALLOCATOR], [
347669a0 1915 AC_MSG_CHECKING([for std::allocator base class])
8b0d6051
BK
1916 GLIBCXX_ENABLE(libstdcxx-allocator,auto,[=KIND],
1917 [use KIND for target std::allocator base],
29d4adf4 1918 [permit new|malloc|mt|bitmap|pool|yes|no|auto])
7d3998a4 1919
8b0d6051
BK
1920 # If they didn't use this option switch, or if they specified --enable
1921 # with no specific model, we'll have to look for one. If they
1922 # specified --disable (???), do likewise.
7d3998a4
PE
1923 if test $enable_libstdcxx_allocator = no ||
1924 test $enable_libstdcxx_allocator = yes;
1925 then
8b0d6051
BK
1926 enable_libstdcxx_allocator=auto
1927 fi
1928
780028b6
BK
1929 # Either a known package, or "auto". Auto implies the default choice
1930 # for a particular platform.
8b0d6051
BK
1931 enable_libstdcxx_allocator_flag=$enable_libstdcxx_allocator
1932
1933 # Probe for host-specific support if no specific model is specified.
1934 # Default to "new".
1935 if test $enable_libstdcxx_allocator_flag = auto; then
1936 case ${target_os} in
780028b6 1937 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
797308b2 1938 enable_libstdcxx_allocator_flag=new
780028b6 1939 ;;
8b0d6051
BK
1940 *)
1941 enable_libstdcxx_allocator_flag=new
1942 ;;
1943 esac
1944 fi
1945 AC_MSG_RESULT($enable_libstdcxx_allocator_flag)
1946
1947
1948 # Set configure bits for specified locale package
1949 case ${enable_libstdcxx_allocator_flag} in
1950 bitmap)
1951 ALLOCATOR_H=config/allocator/bitmap_allocator_base.h
1952 ALLOCATOR_NAME=__gnu_cxx::bitmap_allocator
1953 ;;
1954 malloc)
1955 ALLOCATOR_H=config/allocator/malloc_allocator_base.h
1956 ALLOCATOR_NAME=__gnu_cxx::malloc_allocator
1957 ;;
1958 mt)
1959 ALLOCATOR_H=config/allocator/mt_allocator_base.h
1960 ALLOCATOR_NAME=__gnu_cxx::__mt_alloc
1961 ;;
1962 new)
1963 ALLOCATOR_H=config/allocator/new_allocator_base.h
1964 ALLOCATOR_NAME=__gnu_cxx::new_allocator
1965 ;;
29d4adf4
PC
1966 pool)
1967 ALLOCATOR_H=config/allocator/pool_allocator_base.h
1968 ALLOCATOR_NAME=__gnu_cxx::__pool_alloc
1969 ;;
8b0d6051
BK
1970 esac
1971
1972 AC_SUBST(ALLOCATOR_H)
1973 AC_SUBST(ALLOCATOR_NAME)
1974])
1975
1976
b2dad0e3 1977dnl
ff66d28f
PE
1978dnl Check for whether the Boost-derived checks should be turned on.
1979dnl
1980dnl --enable-concept-checks turns them on.
1981dnl --disable-concept-checks leaves them off.
1982dnl + Usage: GLIBCXX_ENABLE_CONCEPT_CHECKS[(DEFAULT)]
1983dnl Where DEFAULT is either `yes' or `no'.
1984dnl
f214923c 1985AC_DEFUN([GLIBCXX_ENABLE_CONCEPT_CHECKS], [
ff66d28f
PE
1986 GLIBCXX_ENABLE(concept-checks,$1,,[use Boost-derived template checks])
1987 if test $enable_concept_checks = yes; then
4651e622
KC
1988 AC_DEFINE(_GLIBCXX_CONCEPT_CHECKS, 1,
1989 [Define to use concept checking code from the boost libraries.])
ff66d28f
PE
1990 fi
1991])
1992
c2ba9709
JS
1993dnl
1994dnl Check for parallel mode pre-requisites, including OpenMP support.
1995dnl
1996dnl + Usage: GLIBCXX_ENABLE_PARALLEL
1997dnl
1998AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
1999
2000 enable_parallel=no;
6995087d 2001
0aec205c
BK
2002 # See if configured libgomp/omp.h exists. (libgomp may be in
2003 # noconfigdirs but not explicitly disabled.)
aae29963 2004 if echo " ${TARGET_CONFIGDIRS} " | grep " libgomp " > /dev/null 2>&1 ; then
0aec205c
BK
2005 enable_parallel=yes;
2006 else
aae29963 2007 AC_MSG_NOTICE([target-libgomp not built])
c2ba9709
JS
2008 fi
2009
2010 AC_MSG_CHECKING([for parallel mode support])
2011 AC_MSG_RESULT([$enable_parallel])
2012 GLIBCXX_CONDITIONAL(ENABLE_PARALLEL, test $enable_parallel = yes)
2013])
2014
ff66d28f 2015
b2dad0e3 2016dnl
ff66d28f 2017dnl Check for which I/O library to use: stdio, or something specific.
37bc6ca2 2018dnl
ff66d28f 2019dnl Default is stdio.
b2dad0e3 2020dnl
f214923c 2021AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
ff66d28f
PE
2022 AC_MSG_CHECKING([for underlying I/O to use])
2023 GLIBCXX_ENABLE(cstdio,stdio,[=PACKAGE],
2024 [use target-specific I/O package], [permit stdio])
2025
2026 # Now that libio has been removed, you can have any color you want as long
2027 # as it's black. This is one big no-op until other packages are added, but
2028 # showing the framework never hurts.
2029 case ${enable_cstdio} in
2030 stdio)
33590f13
BK
2031 CSTDIO_H=config/io/c_io_stdio.h
2032 BASIC_FILE_H=config/io/basic_file_stdio.h
2033 BASIC_FILE_CC=config/io/basic_file_stdio.cc
9717c75c 2034 AC_MSG_RESULT(stdio)
dd75251f 2035 ;;
b2dad0e3 2036 esac
cc5112c9 2037
4a9d5109
SW
2038 AC_SUBST(CSTDIO_H)
2039 AC_SUBST(BASIC_FILE_H)
6aa43d99 2040 AC_SUBST(BASIC_FILE_CC)
b2dad0e3
BK
2041])
2042
2043
9e57d5ca 2044dnl
ff66d28f 2045dnl Check for "unusual" flags to pass to the compiler while building.
9e57d5ca 2046dnl
ff66d28f
PE
2047dnl --enable-cxx-flags='-foo -bar -baz' is a general method for passing
2048dnl experimental flags such as -fpch, -fIMI, -Dfloat=char, etc.
2049dnl --disable-cxx-flags passes nothing.
2050dnl + See http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00131.html
2051dnl http://gcc.gnu.org/ml/libstdc++/2000-q2/msg00284.html
2052dnl http://gcc.gnu.org/ml/libstdc++/2000-q1/msg00035.html
2053dnl + Usage: GLIBCXX_ENABLE_CXX_FLAGS(default flags)
2054dnl If "default flags" is an empty string, the effect is the same
2055dnl as --disable or --enable=no.
44f0760e 2056dnl
f214923c 2057AC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl
ff66d28f
PE
2058 AC_MSG_CHECKING([for extra compiler flags for building])
2059 GLIBCXX_ENABLE(cxx-flags,$1,[=FLAGS],
2060 [pass compiler FLAGS when building library],
2061 [case "x$enable_cxx_flags" in
2062 xno | x) enable_cxx_flags= ;;
2063 x-*) ;;
2064 *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2065 esac])
2066
2067 # Run through flags (either default or command-line) and set anything
2068 # extra (e.g., #defines) that must accompany particular g++ options.
2069 if test -n "$enable_cxx_flags"; then
2070 for f in $enable_cxx_flags; do
2071 case "$f" in
2072 -fhonor-std) ;;
2073 -*) ;;
2074 *) # and we're trying to pass /what/ exactly?
2075 AC_MSG_ERROR([compiler flags start with a -]) ;;
2076 esac
2077 done
44f0760e
BK
2078 fi
2079
ff66d28f
PE
2080 EXTRA_CXX_FLAGS="$enable_cxx_flags"
2081 AC_MSG_RESULT($EXTRA_CXX_FLAGS)
2082 AC_SUBST(EXTRA_CXX_FLAGS)
9e57d5ca
BK
2083])
2084
ff66d28f 2085
ff66d28f
PE
2086dnl
2087dnl Check to see if debugging libraries are to be built.
2088dnl
2089dnl --enable-libstdcxx-debug
2090dnl builds a separate set of debugging libraries in addition to the
2091dnl normal (shared, static) libstdc++ binaries.
2092dnl
2093dnl --disable-libstdcxx-debug
2094dnl builds only one (non-debug) version of libstdc++.
2095dnl
2096dnl --enable-libstdcxx-debug-flags=FLAGS
2097dnl iff --enable-debug == yes, then use FLAGS to build the debug library.
2098dnl
2099dnl + Usage: GLIBCXX_ENABLE_DEBUG[(DEFAULT)]
2100dnl Where DEFAULT is either `yes' or `no'.
2101dnl
f214923c 2102AC_DEFUN([GLIBCXX_ENABLE_DEBUG], [
ff66d28f
PE
2103 AC_MSG_CHECKING([for additional debug build])
2104 GLIBCXX_ENABLE(libstdcxx-debug,$1,,[build extra debug library])
2105 AC_MSG_RESULT($enable_libstdcxx_debug)
92eabea2 2106 GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_DEBUG, test $enable_libstdcxx_debug = yes)
b2dad0e3
BK
2107])
2108
2109
52a11cbf 2110dnl
ff66d28f 2111dnl Check for explicit debug flags.
52a11cbf 2112dnl
ff66d28f
PE
2113dnl --enable-libstdcxx-debug-flags='-O1'
2114dnl is a general method for passing flags to be used when
2115dnl building debug libraries with --enable-debug.
52a11cbf 2116dnl
ff66d28f
PE
2117dnl --disable-libstdcxx-debug-flags does nothing.
2118dnl + Usage: GLIBCXX_ENABLE_DEBUG_FLAGS(default flags)
2119dnl If "default flags" is an empty string, the effect is the same
2120dnl as --disable or --enable=no.
2121dnl
f214923c 2122AC_DEFUN([GLIBCXX_ENABLE_DEBUG_FLAGS], [
ff66d28f
PE
2123 GLIBCXX_ENABLE(libstdcxx-debug-flags,[$1],[=FLAGS],
2124 [pass compiler FLAGS when building debug library],
2125 [case "x$enable_libstdcxx_debug_flags" in
2126 xno | x) enable_libstdcxx_debug_flags= ;;
2127 x-*) ;;
2128 *) AC_MSG_ERROR(_g_switch needs compiler flags as arguments) ;;
2129 esac])
2130
2131 # Option parsed, now set things appropriately
2132 DEBUG_FLAGS="$enable_libstdcxx_debug_flags"
2133 AC_SUBST(DEBUG_FLAGS)
2134
2135 AC_MSG_NOTICE([Debug build flags set to $DEBUG_FLAGS])
52a11cbf
RH
2136])
2137
2138
92eabea2
PE
2139dnl
2140dnl Check if the user only wants a freestanding library implementation.
2141dnl
2142dnl --disable-hosted-libstdcxx will turn off most of the library build,
2143dnl installing only the headers required by [17.4.1.3] and the language
2144dnl support library. More than that will be built (to keep the Makefiles
2145dnl conveniently clean), but not installed.
2146dnl
2147dnl Sets:
2148dnl is_hosted (yes/no)
2149dnl
3660e02f
PE
2150dnl Defines:
2151dnl _GLIBCXX_HOSTED (always defined, either to 1 or 0)
2152dnl
f214923c 2153AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [
92eabea2
PE
2154 AC_ARG_ENABLE([hosted-libstdcxx],
2155 AC_HELP_STRING([--disable-hosted-libstdcxx],
2156 [only build freestanding C++ runtime support]),,
4c24b21a
MM
2157 [case "$host" in
2158 arm*-*-symbianelf*)
2159 enable_hosted_libstdcxx=no
2160 ;;
2161 *)
2162 enable_hosted_libstdcxx=yes
2163 ;;
2164 esac])
92eabea2
PE
2165 if test "$enable_hosted_libstdcxx" = no; then
2166 AC_MSG_NOTICE([Only freestanding libraries will be built])
2167 is_hosted=no
3660e02f 2168 hosted_define=0
92eabea2
PE
2169 enable_abi_check=no
2170 enable_libstdcxx_pch=no
2171 else
2172 is_hosted=yes
3660e02f 2173 hosted_define=1
92eabea2
PE
2174 fi
2175 GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes)
3660e02f
PE
2176 AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define,
2177 [Define to 1 if a full hosted library is built, or 0 if freestanding.])
92eabea2
PE
2178])
2179
2180
6c3a9f72 2181dnl
347669a0 2182dnl Check for template specializations for the 'long long' type.
22248545
PE
2183dnl The result determines only whether 'long long' I/O is enabled; things
2184dnl like numeric_limits<> specializations are always available.
6c3a9f72 2185dnl
3d7c150e
BK
2186dnl --enable-long-long defines _GLIBCXX_USE_LONG_LONG
2187dnl --disable-long-long leaves _GLIBCXX_USE_LONG_LONG undefined
2188dnl + Usage: GLIBCXX_ENABLE_LONG_LONG[(DEFAULT)]
ff66d28f 2189dnl Where DEFAULT is either `yes' or `no'.
6c3a9f72 2190dnl
f214923c 2191AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
347669a0 2192 GLIBCXX_ENABLE(long-long,$1,,[enable template specializations for 'long long'])
ff66d28f 2193 if test $enable_long_long = yes; then
4651e622
KC
2194 AC_DEFINE(_GLIBCXX_USE_LONG_LONG, 1,
2195 [Define if code specialized for long long should be used.])
6c3a9f72 2196 fi
347669a0
BK
2197 AC_MSG_CHECKING([for enabled long long specializations])
2198 AC_MSG_RESULT([$enable_long_long])
2199])
2200
2201
4cdc8761
BK
2202dnl
2203dnl Check for decimal floating point.
2204dnl See:
2205dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
2206dnl
2207dnl This checks to see if the host supports decimal floating point types.
2208dnl
2209dnl Defines:
2210dnl _GLIBCXX_USE_DECIMAL_FLOAT
2211dnl
2212AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
2213
2214 # Fake what AC_TRY_COMPILE does, without linking as this is
2215 # unnecessary for this test.
2216
2217 cat > conftest.$ac_ext << EOF
2218[#]line __oline__ "configure"
2219int main()
2220{
2221 _Decimal32 d1;
2222 _Decimal64 d2;
2223 _Decimal128 d3;
2224 return 0;
2225}
2226EOF
2227
2228 AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
2229 if AC_TRY_EVAL(ac_compile); then
2230 AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
2231 [Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
2232 enable_dfp=yes
2233 else
2234 enable_dfp=no
2235 fi
2236 AC_MSG_RESULT($enable_dfp)
2237 rm -f conftest*
2238])
2239
347669a0
BK
2240dnl
2241dnl Check for template specializations for the 'wchar_t' type.
2242dnl
2243dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
2244dnl --disable-wchar_t leaves _GLIBCXX_USE_WCHAR_T undefined
2245dnl + Usage: GLIBCXX_ENABLE_WCHAR_T[(DEFAULT)]
2246dnl Where DEFAULT is either `yes' or `no'.
2247dnl
8a9b2875 2248dnl Necessary support must also be present.
347669a0
BK
2249dnl
2250AC_DEFUN([GLIBCXX_ENABLE_WCHAR_T], [
2251 GLIBCXX_ENABLE(wchar_t,$1,,[enable template specializations for 'wchar_t'])
8a9b2875
PC
2252
2253 # Test wchar.h for mbstate_t, which is needed for char_traits and fpos.
2254 AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
2255 AC_MSG_CHECKING([for mbstate_t])
2256 AC_TRY_COMPILE([#include <wchar.h>],
2257 [mbstate_t teststate;],
2258 have_mbstate_t=yes, have_mbstate_t=no)
2259 AC_MSG_RESULT($have_mbstate_t)
2260 if test x"$have_mbstate_t" = xyes; then
2261 AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
2262 fi
2263
d814595c
PC
2264 # Test it always, for use in GLIBCXX_ENABLE_C99, together with
2265 # ac_has_wchar_h.
2266 AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
2267
8a9b2875
PC
2268 if test x"$enable_wchar_t" = x"yes"; then
2269
2270 AC_LANG_SAVE
2271 AC_LANG_CPLUSPLUS
2272
8a9b2875
PC
2273 if test x"$ac_has_wchar_h" = xyes &&
2274 test x"$ac_has_wctype_h" = xyes; then
2275 AC_TRY_COMPILE([#include <wchar.h>
2276 #include <stddef.h>
2277 wint_t i;
2278 long l = WEOF;
2279 long j = WCHAR_MIN;
2280 long k = WCHAR_MAX;
2281 namespace test
2282 {
2283 using ::btowc;
2284 using ::fgetwc;
2285 using ::fgetws;
2286 using ::fputwc;
2287 using ::fputws;
2288 using ::fwide;
2289 using ::fwprintf;
2290 using ::fwscanf;
2291 using ::getwc;
2292 using ::getwchar;
2293 using ::mbrlen;
2294 using ::mbrtowc;
2295 using ::mbsinit;
2296 using ::mbsrtowcs;
2297 using ::putwc;
2298 using ::putwchar;
2299 using ::swprintf;
2300 using ::swscanf;
2301 using ::ungetwc;
2302 using ::vfwprintf;
2303 using ::vswprintf;
2304 using ::vwprintf;
2305 using ::wcrtomb;
2306 using ::wcscat;
2307 using ::wcschr;
2308 using ::wcscmp;
2309 using ::wcscoll;
2310 using ::wcscpy;
2311 using ::wcscspn;
2312 using ::wcsftime;
2313 using ::wcslen;
2314 using ::wcsncat;
2315 using ::wcsncmp;
2316 using ::wcsncpy;
2317 using ::wcspbrk;
2318 using ::wcsrchr;
2319 using ::wcsrtombs;
2320 using ::wcsspn;
2321 using ::wcsstr;
2322 using ::wcstod;
2323 using ::wcstok;
2324 using ::wcstol;
2325 using ::wcstoul;
2326 using ::wcsxfrm;
2327 using ::wctob;
2328 using ::wmemchr;
2329 using ::wmemcmp;
2330 using ::wmemcpy;
2331 using ::wmemmove;
2332 using ::wmemset;
2333 using ::wprintf;
2334 using ::wscanf;
2335 }
2336 ],[],[], [enable_wchar_t=no])
2337 else
2338 enable_wchar_t=no
2339 fi
2340
2341 AC_LANG_RESTORE
2342 fi
2343
2344 if test x"$enable_wchar_t" = x"yes"; then
4651e622
KC
2345 AC_DEFINE(_GLIBCXX_USE_WCHAR_T, 1,
2346 [Define if code specialized for wchar_t should be used.])
347669a0 2347 fi
8a9b2875 2348
347669a0
BK
2349 AC_MSG_CHECKING([for enabled wchar_t specializations])
2350 AC_MSG_RESULT([$enable_wchar_t])
6c3a9f72
BK
2351])
2352
2353
99246c90 2354dnl
ff66d28f 2355dnl Check to see if building and using a C++ precompiled header can be done.
72ed2836 2356dnl
ff66d28f
PE
2357dnl --enable-libstdcxx-pch=yes
2358dnl default, this shows intent to use stdc++.h.gch If it looks like it
2359dnl may work, after some light-hearted attempts to puzzle out compiler
2360dnl support, flip bits on in include/Makefile.am
43ba4a58 2361dnl
ff66d28f
PE
2362dnl --disable-libstdcxx-pch
2363dnl turns off attempts to use or build stdc++.h.gch.
fe413112 2364dnl
ff66d28f
PE
2365dnl Substs:
2366dnl glibcxx_PCHFLAGS
fe413112 2367dnl
f214923c 2368AC_DEFUN([GLIBCXX_ENABLE_PCH], [
ff66d28f 2369 GLIBCXX_ENABLE(libstdcxx-pch,$1,,[build pre-compiled libstdc++ headers])
ff66d28f
PE
2370 if test $enable_libstdcxx_pch = yes; then
2371 AC_CACHE_CHECK([for compiler with PCH support],
2372 [glibcxx_cv_prog_CXX_pch],
2373 [ac_save_CXXFLAGS="$CXXFLAGS"
2374 CXXFLAGS="$CXXFLAGS -Werror -Winvalid-pch -Wno-deprecated"
2375 AC_LANG_SAVE
2376 AC_LANG_CPLUSPLUS
2377 echo '#include <math.h>' > conftest.h
2378 if $CXX $CXXFLAGS $CPPFLAGS -x c++-header conftest.h \
2379 -o conftest.h.gch 1>&5 2>&1 &&
2380 echo '#error "pch failed"' > conftest.h &&
2381 echo '#include "conftest.h"' > conftest.cc &&
2382 $CXX -c $CXXFLAGS $CPPFLAGS conftest.cc 1>&5 2>&1 ;
2383 then
2384 glibcxx_cv_prog_CXX_pch=yes
2385 else
2386 glibcxx_cv_prog_CXX_pch=no
2387 fi
2388 rm -f conftest*
2389 CXXFLAGS=$ac_save_CXXFLAGS
2390 AC_LANG_RESTORE
2391 ])
2392 enable_libstdcxx_pch=$glibcxx_cv_prog_CXX_pch
c4c064e7 2393 fi
747d0967 2394
797308b2
BK
2395 AC_MSG_CHECKING([for enabled PCH])
2396 AC_MSG_RESULT([$enable_libstdcxx_pch])
2397
92eabea2 2398 GLIBCXX_CONDITIONAL(GLIBCXX_BUILD_PCH, test $enable_libstdcxx_pch = yes)
ff66d28f 2399 if test $enable_libstdcxx_pch = yes; then
c2ba9709 2400 glibcxx_PCHFLAGS="-include bits/stdc++.h"
c4c064e7 2401 else
ff66d28f 2402 glibcxx_PCHFLAGS=""
bbacb998 2403 fi
ff66d28f 2404 AC_SUBST(glibcxx_PCHFLAGS)
bbacb998
PC
2405])
2406
7cda84dc 2407
701a3eee
BK
2408dnl
2409dnl Check for atomic builtins.
2410dnl See:
2411dnl http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html#Atomic-Builtins
2412dnl
2413dnl This checks to see if the host supports the compiler-generated
35648b45
BK
2414dnl builtins for atomic operations for various integral sizes. Note, this
2415dnl is intended to be an all-or-nothing switch, so all the atomic operations
2416dnl that are used should be checked.
701a3eee
BK
2417dnl
2418dnl Note:
2cd9cdcc 2419dnl libgomp and libgfortran use a link test, see CHECK_SYNC_FETCH_AND_ADD.
701a3eee
BK
2420dnl
2421dnl Defines:
35648b45 2422dnl _GLIBCXX_ATOMIC_BUILTINS_1
50ce8d3d 2423dnl _GLIBCXX_ATOMIC_BUILTINS_2
35648b45 2424dnl _GLIBCXX_ATOMIC_BUILTINS_4
50ce8d3d 2425dnl _GLIBCXX_ATOMIC_BUILTINS_8
701a3eee
BK
2426dnl
2427AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
701a3eee
BK
2428 AC_LANG_SAVE
2429 AC_LANG_CPLUSPLUS
35648b45 2430 old_CXXFLAGS="$CXXFLAGS"
2cd9cdcc
PC
2431
2432 # Do link tests if possible, instead asm tests, limited to some platforms
2433 # see discussion in PR target/40134, PR libstdc++/40133 and the thread
2434 # starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
2435 atomic_builtins_link_tests=no
2436 if test x$gcc_no_link != xyes; then
2437 # Can do link tests. Limit to some tested platforms
2438 case "$host" in
2439 *-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
2440 atomic_builtins_link_tests=yes
2441 ;;
2442 esac
2443 fi
2444
2445 if test x$atomic_builtins_link_tests = xyes; then
2446
2447 # Do link tests.
2448
2449 CXXFLAGS="$CXXFLAGS -fno-exceptions"
2450
2451 AC_MSG_CHECKING([for atomic builtins for bool])
2452 AC_CACHE_VAL(glibcxx_cv_atomic_bool, [
2453 AC_TRY_LINK(
2454 [ ],
2455 [typedef bool atomic_type;
2456 atomic_type c1;
2457 atomic_type c2;
2458 const atomic_type c3(0);
2459 __sync_fetch_and_add(&c1, c2);
2460 __sync_val_compare_and_swap(&c1, c3, c2);
2461 __sync_lock_test_and_set(&c1, c3);
2462 __sync_lock_release(&c1);
2463 __sync_synchronize();],
2464 [glibcxx_cv_atomic_bool=yes],
2465 [glibcxx_cv_atomic_bool=no])
2466 ])
2467 if test $glibcxx_cv_atomic_bool = yes; then
2468 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2469 [Define if builtin atomic operations for bool are supported on this host.])
2470 fi
2471 AC_MSG_RESULT($glibcxx_cv_atomic_bool)
2472
2473 AC_MSG_CHECKING([for atomic builtins for short])
2474 AC_CACHE_VAL(glibcxx_cv_atomic_short, [
2475 AC_TRY_LINK(
2476 [ ],
2477 [typedef short atomic_type;
2478 atomic_type c1;
2479 atomic_type c2;
2480 const atomic_type c3(0);
2481 __sync_fetch_and_add(&c1, c2);
2482 __sync_val_compare_and_swap(&c1, c3, c2);
2483 __sync_lock_test_and_set(&c1, c3);
2484 __sync_lock_release(&c1);
2485 __sync_synchronize();],
2486 [glibcxx_cv_atomic_short=yes],
2487 [glibcxx_cv_atomic_short=no])
2488 ])
2489 if test $glibcxx_cv_atomic_short = yes; then
2490 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2491 [Define if builtin atomic operations for short are supported on this host.])
2492 fi
2493 AC_MSG_RESULT($glibcxx_cv_atomic_short)
2494
2495 AC_MSG_CHECKING([for atomic builtins for int])
2496 AC_CACHE_VAL(glibcxx_cv_atomic_int, [
2497 AC_TRY_LINK(
2498 [ ],
2499 [typedef int atomic_type;
2500 atomic_type c1;
2501 atomic_type c2;
2502 const atomic_type c3(0);
2503 __sync_fetch_and_add(&c1, c2);
2504 __sync_val_compare_and_swap(&c1, c3, c2);
2505 __sync_lock_test_and_set(&c1, c3);
2506 __sync_lock_release(&c1);
2507 __sync_synchronize();],
2508 [glibcxx_cv_atomic_int=yes],
2509 [glibcxx_cv_atomic_int=no])
2510 ])
2511 if test $glibcxx_cv_atomic_int = yes; then
2512 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2513 [Define if builtin atomic operations for int are supported on this host.])
2514 fi
2515 AC_MSG_RESULT($glibcxx_cv_atomic_int)
2516
2517 AC_MSG_CHECKING([for atomic builtins for long long])
2518 AC_CACHE_VAL(glibcxx_cv_atomic_long_long, [
2519 AC_TRY_LINK(
2520 [ ],
2521 [typedef long long atomic_type;
2522 atomic_type c1;
2523 atomic_type c2;
2524 const atomic_type c3(0);
2525 __sync_fetch_and_add(&c1, c2);
2526 __sync_val_compare_and_swap(&c1, c3, c2);
2527 __sync_lock_test_and_set(&c1, c3);
2528 __sync_lock_release(&c1);
2529 __sync_synchronize();],
2530 [glibcxx_cv_atomic_long_long=yes],
2531 [glibcxx_cv_atomic_long_long=no])
2532 ])
2533 if test $glibcxx_cv_atomic_long_long = yes; then
2534 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2535 [Define if builtin atomic operations for long long are supported on this host.])
2536 fi
2537 AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
2538
2539 else
2540
2541 # Do asm tests.
2542
35648b45
BK
2543 # Compile unoptimized.
2544 CXXFLAGS='-O0 -S'
2545
2cd9cdcc 2546 # Fake what AC_TRY_COMPILE does.
701a3eee 2547
701a3eee
BK
2548 cat > conftest.$ac_ext << EOF
2549[#]line __oline__ "configure"
2550int main()
50ce8d3d
BK
2551{
2552 typedef bool atomic_type;
2553 atomic_type c1;
2554 atomic_type c2;
2555 const atomic_type c3(0);
2556 __sync_fetch_and_add(&c1, c2);
2557 __sync_val_compare_and_swap(&c1, c3, c2);
2558 __sync_lock_test_and_set(&c1, c3);
2559 __sync_lock_release(&c1);
2560 __sync_synchronize();
2561 return 0;
2562}
2563EOF
2564
2565 AC_MSG_CHECKING([for atomic builtins for bool])
2566 if AC_TRY_EVAL(ac_compile); then
2567 if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2cd9cdcc 2568 glibcxx_cv_atomic_bool=no
50ce8d3d
BK
2569 else
2570 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_1, 1,
2571 [Define if builtin atomic operations for bool are supported on this host.])
2cd9cdcc 2572 glibcxx_cv_atomic_bool=yes
50ce8d3d
BK
2573 fi
2574 fi
2cd9cdcc 2575 AC_MSG_RESULT($glibcxx_cv_atomic_bool)
50ce8d3d
BK
2576 rm -f conftest*
2577
2578 cat > conftest.$ac_ext << EOF
2579[#]line __oline__ "configure"
2580int main()
2581{
2582 typedef short atomic_type;
2583 atomic_type c1;
2584 atomic_type c2;
2585 const atomic_type c3(0);
2586 __sync_fetch_and_add(&c1, c2);
2587 __sync_val_compare_and_swap(&c1, c3, c2);
2588 __sync_lock_test_and_set(&c1, c3);
2589 __sync_lock_release(&c1);
2590 __sync_synchronize();
2591 return 0;
2592}
2593EOF
2594
2595 AC_MSG_CHECKING([for atomic builtins for short])
2596 if AC_TRY_EVAL(ac_compile); then
2597 if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2cd9cdcc 2598 glibcxx_cv_atomic_short=no
50ce8d3d
BK
2599 else
2600 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_2, 1,
2601 [Define if builtin atomic operations for short are supported on this host.])
2cd9cdcc 2602 glibcxx_cv_atomic_short=yes
50ce8d3d
BK
2603 fi
2604 fi
2cd9cdcc 2605 AC_MSG_RESULT($glibcxx_cv_atomic_short)
50ce8d3d
BK
2606 rm -f conftest*
2607
2608 cat > conftest.$ac_ext << EOF
2609[#]line __oline__ "configure"
2610int main()
701a3eee
BK
2611{
2612 // NB: _Atomic_word not necessarily int.
2613 typedef int atomic_type;
2614 atomic_type c1;
2615 atomic_type c2;
2616 const atomic_type c3(0);
35648b45
BK
2617 __sync_fetch_and_add(&c1, c2);
2618 __sync_val_compare_and_swap(&c1, c3, c2);
2619 __sync_lock_test_and_set(&c1, c3);
2620 __sync_lock_release(&c1);
2621 __sync_synchronize();
2622 return 0;
2623}
2624EOF
2625
2626 AC_MSG_CHECKING([for atomic builtins for int])
2627 if AC_TRY_EVAL(ac_compile); then
2628 if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2cd9cdcc 2629 glibcxx_cv_atomic_int=no
35648b45
BK
2630 else
2631 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_4, 1,
2632 [Define if builtin atomic operations for int are supported on this host.])
2cd9cdcc 2633 glibcxx_cv_atomic_int=yes
35648b45
BK
2634 fi
2635 fi
2cd9cdcc 2636 AC_MSG_RESULT($glibcxx_cv_atomic_int)
35648b45
BK
2637 rm -f conftest*
2638
2639 cat > conftest.$ac_ext << EOF
2640[#]line __oline__ "configure"
2641int main()
2642{
50ce8d3d 2643 typedef long long atomic_type;
35648b45
BK
2644 atomic_type c1;
2645 atomic_type c2;
2646 const atomic_type c3(0);
2647 __sync_fetch_and_add(&c1, c2);
2648 __sync_val_compare_and_swap(&c1, c3, c2);
2649 __sync_lock_test_and_set(&c1, c3);
2650 __sync_lock_release(&c1);
2651 __sync_synchronize();
2652 return 0;
701a3eee
BK
2653}
2654EOF
35648b45 2655
50ce8d3d 2656 AC_MSG_CHECKING([for atomic builtins for long long])
701a3eee 2657 if AC_TRY_EVAL(ac_compile); then
35648b45 2658 if grep __sync_ conftest.s >/dev/null 2>&1 ; then
2cd9cdcc 2659 glibcxx_cv_atomic_long_long=no
701a3eee 2660 else
50ce8d3d
BK
2661 AC_DEFINE(_GLIBCXX_ATOMIC_BUILTINS_8, 1,
2662 [Define if builtin atomic operations for long long are supported on this host.])
2cd9cdcc 2663 glibcxx_cv_atomic_long_long=yes
701a3eee
BK
2664 fi
2665 fi
2cd9cdcc 2666 AC_MSG_RESULT($glibcxx_cv_atomic_long_long)
701a3eee
BK
2667 rm -f conftest*
2668
2cd9cdcc 2669 fi
50ce8d3d 2670
35648b45
BK
2671 CXXFLAGS="$old_CXXFLAGS"
2672 AC_LANG_RESTORE
2673
2674 # Set atomicity_dir to builtins if either of above tests pass.
2cd9cdcc 2675 if test $glibcxx_cv_atomic_int = yes || test $glibcxx_cv_atomic_bool = yes ; then
35648b45
BK
2676 atomicity_dir=cpu/generic/atomicity_builtins
2677 fi
2678
2679 # If still generic, set to mutex.
701a3eee 2680 if test $atomicity_dir = "cpu/generic" ; then
35648b45 2681 atomicity_dir=cpu/generic/atomicity_mutex
6995087d 2682 AC_MSG_WARN([No native atomic operations are provided for this platform.])
dd88bc97 2683 if test "x$target_thread_file" = xsingle; then
6995087d
BK
2684 AC_MSG_WARN([They cannot be faked when thread support is disabled.])
2685 AC_MSG_WARN([Thread-safety of certain classes is not guaranteed.])
2686 else
2687 AC_MSG_WARN([They will be faked using a mutex.])
2688 AC_MSG_WARN([Performance of certain classes will degrade as a result.])
2689 fi
701a3eee 2690 fi
35648b45 2691
701a3eee
BK
2692])
2693
2694
bda243ec 2695dnl
ff66d28f
PE
2696dnl Check for exception handling support. If an explicit enable/disable
2697dnl sjlj exceptions is given, we don't have to detect. Otherwise the
2698dnl target may or may not support call frame exceptions.
bda243ec 2699dnl
ff66d28f
PE
2700dnl --enable-sjlj-exceptions forces the use of builtin setjmp.
2701dnl --disable-sjlj-exceptions forces the use of call frame unwinding.
1260d70f 2702dnl Neither one forces an attempt at detection.
4d16bdbb 2703dnl
ff66d28f
PE
2704dnl Defines:
2705dnl _GLIBCXX_SJLJ_EXCEPTIONS if the compiler is configured for it
4d16bdbb 2706dnl
f214923c 2707AC_DEFUN([GLIBCXX_ENABLE_SJLJ_EXCEPTIONS], [
ff66d28f
PE
2708 AC_MSG_CHECKING([for exception model to use])
2709 AC_LANG_SAVE
2710 AC_LANG_CPLUSPLUS
1260d70f 2711 GLIBCXX_ENABLE(sjlj-exceptions,auto,,
ff66d28f 2712 [force use of builtin_setjmp for exceptions],
1260d70f
PE
2713 [permit yes|no|auto])
2714
2715 if test $enable_sjlj_exceptions = auto; then
2716 # Botheration. Now we've got to detect the exception model. Link tests
2717 # against libgcc.a are problematic since we've not been given proper -L
2718 # bits for single-tree newlib and libgloss.
2719 #
2720 # Fake what AC_TRY_COMPILE does. XXX Look at redoing this new-style.
2721 cat > conftest.$ac_ext << EOF
ff66d28f
PE
2722[#]line __oline__ "configure"
2723struct S { ~S(); };
2724void bar();
2725void foo()
2726{
2727 S s;
2728 bar();
2729}
2730EOF
1260d70f
PE
2731 old_CXXFLAGS="$CXXFLAGS"
2732 CXXFLAGS=-S
2733 if AC_TRY_EVAL(ac_compile); then
2734 if grep _Unwind_SjLj_Resume conftest.s >/dev/null 2>&1 ; then
2735 enable_sjlj_exceptions=yes
2736 elif grep _Unwind_Resume conftest.s >/dev/null 2>&1 ; then
2737 enable_sjlj_exceptions=no
617a1b71
PB
2738 elif grep __cxa_end_cleanup conftest.s >/dev/null 2>&1 ; then
2739 enable_sjlj_exceptions=no
1260d70f
PE
2740 fi
2741 fi
2742 CXXFLAGS="$old_CXXFLAGS"
2743 rm -f conftest*
2744 fi
2745
cddfb1c7
BK
2746 # This is a tad weird, for hysterical raisins. We have to map
2747 # enable/disable to two different models.
1260d70f
PE
2748 case $enable_sjlj_exceptions in
2749 yes)
2750 AC_DEFINE(_GLIBCXX_SJLJ_EXCEPTIONS, 1,
2751 [Define if the compiler is configured for setjmp/longjmp exceptions.])
2752 ac_exception_model_name=sjlj
2753 ;;
2754 no)
2755 ac_exception_model_name="call frame"
2756 ;;
2757 *)
2758 AC_MSG_ERROR([unable to detect exception model])
2759 ;;
2760 esac
ff66d28f
PE
2761 AC_LANG_RESTORE
2762 AC_MSG_RESULT($ac_exception_model_name)
4d16bdbb
PE
2763])
2764
2765
98e615b4
BK
2766dnl
2767dnl Allow visibility attributes to be used on namespaces, objects, etc.
2768dnl
2769dnl --enable-visibility enables attempt to use visibility attributes.
2770dnl --disable-visibility turns off all use of visibility attributes.
2771dnl + Usage: GLIBCXX_ENABLE_VISIBILITY[(DEFAULT)]
2772dnl Where DEFAULT is 'yes'.
2773dnl
2774AC_DEFUN([GLIBCXX_ENABLE_VISIBILITY], [
2775GLIBCXX_ENABLE(visibility,$1,,[enables visibility safe usage])
2776
2777if test x$enable_visibility = xyes ; then
2778 dnl all hail libgfortran
2779 dnl Check whether the target supports hidden visibility.
2780 AC_CACHE_CHECK([whether the target supports hidden visibility],
6d26724a 2781 glibcxx_cv_have_attribute_visibility, [
98e615b4
BK
2782 save_CFLAGS="$CFLAGS"
2783 CFLAGS="$CFLAGS -Werror"
2784 AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
6d26724a
RW
2785 [], glibcxx_cv_have_attribute_visibility=yes,
2786 glibcxx_cv_have_attribute_visibility=no)
98e615b4 2787 CFLAGS="$save_CFLAGS"])
6d26724a 2788 if test $glibcxx_cv_have_attribute_visibility = no; then
98e615b4
BK
2789 enable_visibility=no
2790 fi
2791fi
2792
2793GLIBCXX_CONDITIONAL(ENABLE_VISIBILITY, test $enable_visibility = yes)
2794AC_MSG_NOTICE([visibility supported: $enable_visibility])
2795])
2796
2797
530539d9
PE
2798dnl
2799dnl Add version tags to symbols in shared library (or not), additionally
2800dnl marking other symbols as private/local (or not).
2801dnl
c98b201b
PE
2802dnl --enable-symvers=style adds a version script to the linker call when
2803dnl creating the shared library. The choice of version script is
2804dnl controlled by 'style'.
530539d9 2805dnl --disable-symvers does not.
3d7c150e 2806dnl + Usage: GLIBCXX_ENABLE_SYMVERS[(DEFAULT)]
ff66d28f
PE
2807dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
2808dnl choose a default style based on linker characteristics. Passing
2809dnl 'no' disables versioning.
2810dnl
f214923c 2811AC_DEFUN([GLIBCXX_ENABLE_SYMVERS], [
ff66d28f
PE
2812
2813GLIBCXX_ENABLE(symvers,$1,[=STYLE],
2814 [enables symbol versioning of the shared library],
3cbc7af0 2815 [permit yes|no|gnu|gnu-versioned-namespace|darwin|darwin-export])
c98b201b 2816
3d7c150e 2817# If we never went through the GLIBCXX_CHECK_LINKER_FEATURES macro, then we
37bc6ca2 2818# don't know enough about $LD to do tricks...
ff66d28f 2819AC_REQUIRE([GLIBCXX_CHECK_LINKER_FEATURES])
a9fdd472
GK
2820
2821# Turn a 'yes' into a suitable default.
2822if test x$enable_symvers = xyes ; then
4bd726d0 2823 if test $enable_shared = no || test "x$LD" = x || test x$gcc_no_link = xyes; then
a9fdd472 2824 enable_symvers=no
a9fdd472 2825 else
fb5c309d 2826 if test $with_gnu_ld = yes ; then
d89f0ad6 2827 case ${target_os} in
f7e413e2 2828 hpux*)
d89f0ad6
AL
2829 enable_symvers=no ;;
2830 *)
2831 enable_symvers=gnu ;;
2832 esac
fb5c309d
BK
2833 else
2834 case ${target_os} in
2835 darwin*)
2836 enable_symvers=darwin ;;
2837 *)
2838 enable_symvers=no ;;
2839 esac
2840 fi
a9fdd472 2841 fi
530539d9 2842fi
c98b201b 2843
fb5c309d
BK
2844# Check to see if 'darwin' or 'darwin-export' can win.
2845if test x$enable_symvers = xdarwin-export ; then
2846 enable_symvers=darwin
2847fi
2848
f47bddec 2849# Check to see if 'gnu' can win.
3cbc7af0 2850if test $enable_symvers = gnu || test $enable_symvers = gnu-versioned-namespace; then
f47bddec 2851 # Check to see if libgcc_s exists, indicating that shared libgcc is possible.
2c839a4e
PE
2852 AC_MSG_CHECKING([for shared libgcc])
2853 ac_save_CFLAGS="$CFLAGS"
2854 CFLAGS=' -lgcc_s'
ff66d28f 2855 AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes, glibcxx_shared_libgcc=no)
2c839a4e 2856 CFLAGS="$ac_save_CFLAGS"
d5325238
JJ
2857 if test $glibcxx_shared_libgcc = no; then
2858 cat > conftest.c <<EOF
2859int main (void) { return 0; }
2860EOF
2861changequote(,)dnl
2862 glibcxx_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
2863 -shared -shared-libgcc -o conftest.so \
2864 conftest.c -v 2>&1 >/dev/null \
2865 | sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
2866changequote([,])dnl
2867 rm -f conftest.c conftest.so
2868 if test x${glibcxx_libgcc_s_suffix+set} = xset; then
2869 CFLAGS=" -lgcc_s$glibcxx_libgcc_s_suffix"
2870 AC_TRY_LINK(, [return 0;], glibcxx_shared_libgcc=yes)
2871 CFLAGS="$ac_save_CFLAGS"
2872 fi
2873 fi
3d7c150e 2874 AC_MSG_RESULT($glibcxx_shared_libgcc)
a9fdd472 2875
a9fdd472
GK
2876 # For GNU ld, we need at least this version. The format is described in
2877 # GLIBCXX_CHECK_LINKER_FEATURES above.
2878 glibcxx_min_gnu_ld_version=21400
c98b201b 2879
f47bddec
GK
2880 # If no shared libgcc, can't win.
2881 if test $glibcxx_shared_libgcc != yes; then
2882 AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
2883 AC_MSG_WARN([=== you are not building a shared libgcc_s.])
2884 AC_MSG_WARN([=== Symbol versioning will be disabled.])
2885 enable_symvers=no
2886 elif test $with_gnu_ld != yes ; then
ab3bc736 2887 # just fail for now
a9fdd472
GK
2888 AC_MSG_WARN([=== You have requested GNU symbol versioning, but])
2889 AC_MSG_WARN([=== you are not using the GNU linker.])
2890 AC_MSG_WARN([=== Symbol versioning will be disabled.])
2891 enable_symvers=no
d60a2d4d
ILT
2892 elif test $glibcxx_ld_is_gold = yes ; then
2893 : All versions of gold support symbol versioning.
a9fdd472
GK
2894 elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
2895 # The right tools, the right setup, but too old. Fallbacks?
2896 AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for)
2897 AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
2898 AC_MSG_WARN(=== You would need to upgrade your binutils to version)
2899 AC_MSG_WARN(=== $glibcxx_min_gnu_ld_version or later and rebuild GCC.)
58579a27 2900 AC_MSG_WARN([=== Symbol versioning will be disabled.])
ab3bc736
BK
2901 enable_symvers=no
2902 fi
2903fi
2904
ff66d28f 2905# Everything parsed; figure out what file to use.
c98b201b 2906case $enable_symvers in
ab3bc736 2907 no)
fb5c309d 2908 SYMVER_FILE=config/abi/pre/none.ver
ff66d28f 2909 ;;
c98b201b 2910 gnu)
fb5c309d
BK
2911 SYMVER_FILE=config/abi/pre/gnu.ver
2912 AC_DEFINE(_GLIBCXX_SYMVER_GNU, 1,
2913 [Define to use GNU versioning in the shared library.])
a9fdd472 2914 ;;
3cbc7af0
BK
2915 gnu-versioned-namespace)
2916 SYMVER_FILE=config/abi/pre/gnu-versioned-namespace.ver
2917 AC_DEFINE(_GLIBCXX_SYMVER_GNU_NAMESPACE, 1,
2918 [Define to use GNU namespace versioning in the shared library.])
2919 ;;
fb5c309d
BK
2920 darwin)
2921 SYMVER_FILE=config/abi/pre/gnu.ver
2922 AC_DEFINE(_GLIBCXX_SYMVER_DARWIN, 1,
2923 [Define to use darwin versioning in the shared library.])
ff66d28f 2924 ;;
c98b201b
PE
2925esac
2926
fb5c309d
BK
2927if test x$enable_symvers != xno ; then
2928 AC_DEFINE(_GLIBCXX_SYMVER, 1,
2929 [Define to use symbol versioning in the shared library.])
2930fi
2931
1f93f687
JJ
2932AC_CACHE_CHECK([whether the target supports .symver directive],
2933 glibcxx_cv_have_as_symver_directive, [
2934 AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
2935 [], glibcxx_cv_have_as_symver_directive=yes,
2936 glibcxx_cv_have_as_symver_directive=no)])
2937if test $glibcxx_cv_have_as_symver_directive = yes; then
2938 AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
2939 [Define to 1 if the target assembler supports .symver directive.])
2940fi
2941
fb5c309d
BK
2942AC_SUBST(SYMVER_FILE)
2943AC_SUBST(port_specific_symbol_files)
2944GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
2945GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU, test $enable_symvers = gnu)
3cbc7af0 2946GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_GNU_NAMESPACE, test $enable_symvers = gnu-versioned-namespace)
fb5c309d
BK
2947GLIBCXX_CONDITIONAL(ENABLE_SYMVERS_DARWIN, test $enable_symvers = darwin)
2948AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
2949
2950# Now, set up compatibility support, if any.
bb2b2a24
BK
2951# In addition, need this to deal with std::size_t mangling in
2952# src/compatibility.cc. In a perfect world, could use
2953# typeid(std::size_t).name()[0] to do direct substitution.
2954AC_MSG_CHECKING([for size_t as unsigned int])
2955ac_save_CFLAGS="$CFLAGS"
2956CFLAGS="-Werror"
2957AC_TRY_COMPILE(, [__SIZE_TYPE__* stp; unsigned int* uip; stp = uip;],
2958 [glibcxx_size_t_is_i=yes], [glibcxx_size_t_is_i=no])
2959CFLAGS=$ac_save_CFLAGS
2960if test "$glibcxx_size_t_is_i" = yes; then
2961 AC_DEFINE(_GLIBCXX_SIZE_T_IS_UINT, 1, [Define if size_t is unsigned int.])
2962fi
2963AC_MSG_RESULT([$glibcxx_size_t_is_i])
2964
2965AC_MSG_CHECKING([for ptrdiff_t as int])
2966ac_save_CFLAGS="$CFLAGS"
2967CFLAGS="-Werror"
2968AC_TRY_COMPILE(, [__PTRDIFF_TYPE__* ptp; int* ip; ptp = ip;],
2969 [glibcxx_ptrdiff_t_is_i=yes], [glibcxx_ptrdiff_t_is_i=no])
2970CFLAGS=$ac_save_CFLAGS
2971if test "$glibcxx_ptrdiff_t_is_i" = yes; then
2972 AC_DEFINE(_GLIBCXX_PTRDIFF_T_IS_INT, 1, [Define if ptrdiff_t is int.])
2973fi
2974AC_MSG_RESULT([$glibcxx_ptrdiff_t_is_i])
ff66d28f
PE
2975])
2976
2977
2978dnl
2979dnl Setup to use the gcc gthr.h thread-specific memory and mutex model.
2980dnl We must stage the required headers so that they will be installed
2981dnl with the library (unlike libgcc, the STL implementation is provided
2982dnl solely within headers). Since we must not inject random user-space
2983dnl macro names into user-provided C++ code, we first stage into <file>-in
2984dnl and process to <file> with an output command. The reason for a two-
2985dnl stage process here is to correctly handle $srcdir!=$objdir without
2986dnl having to write complex code (the sed commands to clean the macro
2987dnl namespace are complex and fragile enough as it is). We must also
2988dnl add a relative path so that -I- is supported properly.
2989dnl
2990dnl Substs:
2991dnl glibcxx_thread_h
2992dnl
2993dnl Defines:
2994dnl HAVE_GTHR_DEFAULT
ff66d28f 2995dnl
f214923c 2996AC_DEFUN([GLIBCXX_ENABLE_THREADS], [
ff66d28f 2997 AC_MSG_CHECKING([for thread model used by GCC])
fbe057bb 2998 target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
ff66d28f
PE
2999 AC_MSG_RESULT([$target_thread_file])
3000
3001 if test $target_thread_file != single; then
4651e622
KC
3002 AC_DEFINE(HAVE_GTHR_DEFAULT, 1,
3003 [Define if gthr-default.h exists
3004 (meaning that threading support is enabled).])
ff66d28f
PE
3005 fi
3006
3007 glibcxx_thread_h=gthr-$target_thread_file.h
382c6e2d
BK
3008
3009 dnl Check for __GTHREADS define.
3010 gthread_file=${toplevel_srcdir}/gcc/${glibcxx_thread_h}
3011 if grep __GTHREADS $gthread_file >/dev/null 2>&1 ; then
3012 enable_thread=yes
3013 else
3014 enable_thread=no
3015 fi
3016
ff66d28f
PE
3017 AC_SUBST(glibcxx_thread_h)
3018])
3019
3020
b8c41c8e
CF
3021dnl
3022dnl Check if gthread implementation defines the types and functions
3023dnl required by the c++0x thread library. Conforming gthread
3024dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
3025dnl
3026AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
3027 AC_LANG_SAVE
3028 AC_LANG_CPLUSPLUS
3029
3030 ac_save_CXXFLAGS="$CXXFLAGS"
3031 CXXFLAGS="$CXXFLAGS -fno-exceptions -I${toplevel_srcdir}/gcc"
3032
3033 target_thread_file=`$CXX -v 2>&1 | sed -n 's/^Thread model: //p'`
3034 case $target_thread_file in
3035 posix)
3036 CXXFLAGS="$CXXFLAGS -DSUPPORTS_WEAK -DGTHREAD_USE_WEAK -D_PTHREADS"
3037 esac
3038
3039 AC_MSG_CHECKING([for gthreads library])
3040
3041 AC_TRY_COMPILE([#include "gthr.h"],
3042 [
a1c5742d
PC
3043 #ifndef __GTHREADS_CXX0X
3044 #error
3045 #endif
3046
3047 // In case of POSIX threads check _POSIX_TIMEOUTS too.
3048 #if (defined(_PTHREADS) \
3049 && (!defined(_POSIX_TIMEOUTS) || _POSIX_TIMEOUTS <= 0))
3050 #error
3051 #endif
b8c41c8e
CF
3052 ], [ac_has_gthreads=yes], [ac_has_gthreads=no])
3053
3054 AC_MSG_RESULT([$ac_has_gthreads])
3055
3056 if test x"$ac_has_gthreads" = x"yes"; then
3057 AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
3058 [Define if gthreads library is available.])
3059 fi
3060
3061 CXXFLAGS="$ac_save_CXXFLAGS"
3062 AC_LANG_RESTORE
3063])
3064
3065
ff66d28f
PE
3066# Check whether LC_MESSAGES is available in <locale.h>.
3067# Ulrich Drepper <drepper@cygnus.com>, 1995.
3068#
3069# This file file be copied and used freely without restrictions. It can
3070# be used in projects which are not available under the GNU Public License
3071# but which still want to provide support for the GNU gettext functionality.
3072# Please note that the actual code is *not* freely available.
f214923c 3073AC_DEFUN([AC_LC_MESSAGES], [
ff66d28f
PE
3074 AC_CHECK_HEADER(locale.h, [
3075 AC_CACHE_CHECK([for LC_MESSAGES], ac_cv_val_LC_MESSAGES,
99bf8d16 3076 [AC_TRY_COMPILE([#include <locale.h>], [return LC_MESSAGES],
ff66d28f
PE
3077 ac_cv_val_LC_MESSAGES=yes, ac_cv_val_LC_MESSAGES=no)])
3078 if test $ac_cv_val_LC_MESSAGES = yes; then
4651e622
KC
3079 AC_DEFINE(HAVE_LC_MESSAGES, 1,
3080 [Define if LC_MESSAGES is available in <locale.h>.])
ff66d28f
PE
3081 fi
3082 ])
3083])
3084
cddfb1c7
BK
3085# Macros from the top-level gcc directory.
3086m4_include([../config/tls.m4])
ff66d28f 3087