]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/acinclude.m4
re PR libgomp/25884 (libgomp should not require perl to compile)
[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.
52 m4_define([glibcxx_SUBDIRS],[include libmath libsupc++ src po testsuite])
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 # We're almost certainly being configured before anything else which uses
83 # C++, so all of our AC_PROG_* discoveries will be cached. It's vital that
84 # we not cache the value of CXX that we "discover" here, because it's set
85 # to something unique for us and libjava. Other target libraries need to
86 # find CXX for themselves. We yank the rug out from under the normal AC_*
87 # process by sneakily renaming the cache variable. This also lets us debug
88 # the value of "our" CXX in postmortems.
89 #
90 # We must also force CXX to /not/ be a precious variable, otherwise the
91 # wrong (non-multilib-adjusted) value will be used in multilibs. This
92 # little trick also affects CPPFLAGS, CXXFLAGS, and LDFLAGS. And as a side
93 # effect, CXXFLAGS is no longer automagically subst'd, so we have to do
f6dda651 94 # that ourselves. Un-preciousing AC_PROG_CC also affects CC and CFLAGS.
ff66d28f
PE
95 #
96 # -fno-builtin must be present here so that a non-conflicting form of
97 # std::exit can be guessed by AC_PROG_CXX, and used in later tests.
fbe057bb 98
ff66d28f
PE
99 m4_define([ac_cv_prog_CXX],[glibcxx_cv_prog_CXX])
100 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibcxx_PRECIOUS])
101 m4_define([_AC_ARG_VAR_PRECIOUS],[])
102 save_CXXFLAGS="$CXXFLAGS"
103 CXXFLAGS="$CXXFLAGS -fno-builtin"
f6dda651 104 AC_PROG_CC
ff66d28f
PE
105 AC_PROG_CXX
106 CXXFLAGS="$save_CXXFLAGS"
107 m4_rename([glibcxx_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
f6dda651 108 AC_SUBST(CFLAGS)
ff66d28f 109 AC_SUBST(CXXFLAGS)
b2dad0e3 110
ff66d28f
PE
111 # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
112 # available). Uncomment the next line to force a particular method.
113 AC_PROG_LN_S
114 #LN_S='cp -p'
115
5780a46b
BK
116 AC_CHECK_TOOL(AS, as)
117 AC_CHECK_TOOL(AR, ar)
46840bcd 118 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
b2dad0e3 119
5780a46b 120 AM_MAINTAINER_MODE
b2dad0e3 121
92eabea2
PE
122 # Set up safe default values for all subsequent AM_CONDITIONAL tests
123 # which are themselves conditionally expanded.
124 ## (Right now, this only matters for enable_wchar_t, but nothing prevents
125 ## other macros from doing the same. This should be automated.) -pme
16da539b 126 need_libmath=no
16da539b 127
ff66d28f
PE
128 # Find platform-specific directories containing configuration info.
129 # Also possibly modify flags used elsewhere, as needed by the platform.
3d7c150e 130 GLIBCXX_CHECK_HOST
b2dad0e3
BK
131])
132
133
c470c17d 134dnl
52b55e7d
PE
135dnl Tests for newer compiler features, or features that are present in newer
136dnl compiler versions but not older compiler versions still in use, should
137dnl be placed here.
b2dad0e3 138dnl
ff66d28f
PE
139dnl Defines:
140dnl WERROR='-Werror' if requested and possible; g++'s that lack the
141dnl new inlining code or the new system_header pragma will die on -Werror.
142dnl Leave it out by default and use maint-mode to use it.
143dnl SECTION_FLAGS='-ffunction-sections -fdata-sections' if
144dnl compiler supports it and the user has not requested debug mode.
c21b6f87 145dnl
f214923c 146AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURES], [
a4e99046 147 # All these tests are for C++; save the language and the compiler flags.
52b55e7d 148 # The CXXFLAGS thing is suspicious, but based on similar bits previously
3d7c150e 149 # found in GLIBCXX_CONFIGURE.
a4e99046
PE
150 AC_LANG_SAVE
151 AC_LANG_CPLUSPLUS
152 ac_test_CXXFLAGS="${CXXFLAGS+set}"
153 ac_save_CXXFLAGS="$CXXFLAGS"
a4e99046 154
7f586614
BK
155 # Check for maintainer-mode bits.
156 if test x"$USE_MAINTAINER_MODE" = xno; then
157 WERROR=''
8bd636c5 158 else
7f586614 159 WERROR='-Werror'
8bd636c5
PE
160 fi
161
c470c17d
BK
162 # Check for -ffunction-sections -fdata-sections
163 AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
0517cb99 164 CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
ff66d28f 165 AC_TRY_COMPILE(, [int foo;], [ac_fdsections=yes], [ac_fdsections=no])
c470c17d
BK
166 if test "$ac_test_CXXFLAGS" = set; then
167 CXXFLAGS="$ac_save_CXXFLAGS"
168 else
169 # this is the suspicious part
170 CXXFLAGS=''
171 fi
6aa43d99 172 if test x"$ac_fdsections" = x"yes"; then
c470c17d
BK
173 SECTION_FLAGS='-ffunction-sections -fdata-sections'
174 fi
175 AC_MSG_RESULT($ac_fdsections)
176
a4e99046 177 AC_LANG_RESTORE
8bd636c5 178 AC_SUBST(WERROR)
c470c17d 179 AC_SUBST(SECTION_FLAGS)
b2dad0e3
BK
180])
181
c470c17d
BK
182
183dnl
421173e6
PE
184dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
185dnl the native linker is in use, all variables will be defined to something
186dnl safe (like an empty string).
187dnl
ff66d28f
PE
188dnl Defines:
189dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
a429affe 190dnl OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible
ff66d28f
PE
191dnl LD (as a side effect of testing)
192dnl Sets:
193dnl with_gnu_ld
194dnl glibcxx_gnu_ld_version (possibly)
195dnl
196dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
197dnl set glibcxx_gnu_ld_version to 12345. Zeros cause problems.
c470c17d 198dnl
f214923c 199AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
421173e6
PE
200 # If we're not using GNU ld, then there's no point in even trying these
201 # tests. Check for that first. We should have already tested for gld
202 # by now (in libtool), but require it now just to be safe...
654421eb
DE
203 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
204 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
421173e6 205 AC_REQUIRE([AC_PROG_LD])
ff66d28f 206 AC_REQUIRE([AC_PROG_AWK])
5bd17d39 207
c98b201b
PE
208 # The name set by libtool depends on the version of libtool. Shame on us
209 # for depending on an impl detail, but c'est la vie. Older versions used
210 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
211 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
212 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
213 # set (hence we're using an older libtool), then set it.
214 if test x${with_gnu_ld+set} != xset; then
215 if test x${ac_cv_prog_gnu_ld+set} != xset; then
216 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
217 with_gnu_ld=no
218 else
219 with_gnu_ld=$ac_cv_prog_gnu_ld
220 fi
221 fi
222
223 # Start by getting the version number. I think the libtool test already
224 # does some of this, but throws away the result.
ac2b2479 225 AC_MSG_CHECKING([for ld version])
c98b201b
PE
226 changequote(,)
227 ldver=`$LD --version 2>/dev/null | head -1 | \
228 sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
229 changequote([,])
3d7c150e 230 glibcxx_gnu_ld_version=`echo $ldver | \
c98b201b 231 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
ac2b2479 232 AC_MSG_RESULT($glibcxx_gnu_ld_version)
c98b201b 233
5bd17d39 234 # Set --gc-sections.
ac2b2479
BK
235 glibcxx_gcsections_min_ld=21602
236 if test x"$with_gnu_ld" = x"yes" &&
237 test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
238
239 # Sufficiently young GNU ld it is! Joy and bunny rabbits!
240 # NB: This flag only works reliably after 2.16.1. Configure tests
241 # for this are difficult, so hard wire a value that should work.
421173e6 242
acb6e9be
BK
243 # All these tests are for C++, but run with the "C" compiler driver.
244 # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
421173e6
PE
245 ac_test_CFLAGS="${CFLAGS+set}"
246 ac_save_CFLAGS="$CFLAGS"
360e8759 247 CFLAGS='-x c++ -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
347669a0
BK
302dnl Check to see if this target can enable the iconv specializations.
303dnl If --disable-c-mbchar was given, no wchar_t specialization is enabled.
304dnl (This must have been previously checked, along with the rest of C99
305dnl support.) By default, iconv support is disabled.
b2dad0e3 306dnl
ff66d28f 307dnl Defines:
347669a0 308dnl _GLIBCXX_USE_ICONV if all the bits are found.
d54bc1d8
PE
309dnl Substs:
310dnl LIBICONV to a -l string containing the iconv library, if needed.
b2dad0e3 311dnl
347669a0 312AC_DEFUN([GLIBCXX_CHECK_ICONV_SUPPORT], [
37bc6ca2 313
347669a0 314 enable_iconv=no
ff66d28f 315 # Only continue checking if the ISO C99 headers exist and support is on.
347669a0 316 if test x"$enable_wchar_t" = xyes; then
37bc6ca2 317
ff66d28f
PE
318 # Use iconv for wchar_t to char conversions. As such, check for
319 # X/Open Portability Guide, version 2 features (XPG2).
7b331228
BK
320 AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
321 AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
322
ff66d28f 323 # Check for existence of libiconv.a providing XPG2 wchar_t support.
d54bc1d8 324 AC_CHECK_LIB(iconv, iconv, LIBICONV="-liconv")
7b331228 325 ac_save_LIBS="$LIBS"
d54bc1d8
PE
326 LIBS="$LIBS $LIBICONV"
327 AC_SUBST(LIBICONV)
7b331228 328
ff66d28f
PE
329 AC_CHECK_FUNCS([iconv_open iconv_close iconv nl_langinfo],
330 [ac_XPG2funcs=yes], [ac_XPG2funcs=no])
37bc6ca2 331
7b331228 332 LIBS="$ac_save_LIBS"
5b20f7a0 333
a0cb1aa7
PE
334 if test x"$ac_has_iconv_h" = xyes &&
335 test x"$ac_has_langinfo_h" = xyes &&
ff66d28f
PE
336 test x"$ac_XPG2funcs" = xyes;
337 then
347669a0
BK
338 AC_DEFINE([_GLIBCXX_USE_ICONV],1,
339 [Define if iconv and related functions exist and are usable.])
340 enable_iconv=yes
15bcd79a 341 fi
b2dad0e3 342 fi
347669a0
BK
343 AC_MSG_CHECKING([for enabled iconv specializations])
344 AC_MSG_RESULT($enable_iconv)
b2dad0e3
BK
345])
346
347
b2dad0e3 348dnl
ff66d28f
PE
349dnl Check for headers for, and arguments to, the setrlimit() function.
350dnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE.
6aa43d99 351dnl
ff66d28f 352dnl Defines:
2ae6e982
PC
353dnl _GLIBCXX_RES_LIMITS if we can set artificial resource limits
354dnl various HAVE_LIMIT_* for individual limit names
6aa43d99 355dnl
f214923c 356AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT_ancilliary], [
e0103440 357 AC_MSG_CHECKING([for RLIMIT_$1])
ff66d28f
PE
358 AC_TRY_COMPILE(
359 [#include <unistd.h>
360 #include <sys/time.h>
361 #include <sys/resource.h>
362 ],
363 [ int f = RLIMIT_$1 ; ],
364 [glibcxx_mresult=1], [glibcxx_mresult=0])
2ae6e982 365 AC_DEFINE_UNQUOTED(HAVE_LIMIT_$1, $glibcxx_mresult,
ff66d28f 366 [Only used in build directory testsuite_hooks.h.])
e0103440
GK
367 if test $glibcxx_mresult = 1 ; then res=yes ; else res=no ; fi
368 AC_MSG_RESULT($res)
ff66d28f
PE
369])
370
f214923c 371AC_DEFUN([GLIBCXX_CHECK_SETRLIMIT], [
ff66d28f
PE
372 setrlimit_have_headers=yes
373 AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
374 [],
375 [setrlimit_have_headers=no])
376 # If don't have the headers, then we can't run the tests now, and we
377 # won't be seeing any of these during testsuite compilation.
378 if test $setrlimit_have_headers = yes; then
379 # Can't do these in a loop, else the resulting syntax is wrong.
380 GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA)
381 GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
382 GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
383 GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
2ae6e982 384 GLIBCXX_CHECK_SETRLIMIT_ancilliary(FSIZE)
ff66d28f
PE
385
386 # Check for rlimit, setrlimit.
387 AC_CACHE_VAL(ac_setrlimit, [
388 AC_TRY_COMPILE(
389 [#include <unistd.h>
390 #include <sys/time.h>
391 #include <sys/resource.h>
392 ],
393 [struct rlimit r;
394 setrlimit(0, &r);],
395 [ac_setrlimit=yes], [ac_setrlimit=no])
396 ])
397 fi
398
2ae6e982 399 AC_MSG_CHECKING([for testsuite resource limits support])
ff66d28f 400 if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
2ae6e982 401 ac_res_limits=yes
4651e622
KC
402 AC_DEFINE(_GLIBCXX_RES_LIMITS, 1,
403 [Define if using setrlimit to set resource limits during
404 "make check"])
ff66d28f 405 else
2ae6e982 406 ac_res_limits=no
ff66d28f 407 fi
2ae6e982 408 AC_MSG_RESULT($ac_res_limits)
6aa43d99
BK
409])
410
411
6aa43d99 412dnl
ff66d28f
PE
413dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
414dnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately.
6aa43d99 415dnl
f214923c 416AC_DEFUN([GLIBCXX_CHECK_S_ISREG_OR_S_IFREG], [
e0103440 417 AC_MSG_CHECKING([for S_ISREG or S_IFREG])
ff66d28f
PE
418 AC_CACHE_VAL(glibcxx_cv_S_ISREG, [
419 AC_TRY_LINK(
420 [#include <sys/stat.h>],
421 [struct stat buffer;
422 fstat(0, &buffer);
423 S_ISREG(buffer.st_mode);],
424 [glibcxx_cv_S_ISREG=yes],
425 [glibcxx_cv_S_ISREG=no])
426 ])
427 AC_CACHE_VAL(glibcxx_cv_S_IFREG, [
428 AC_TRY_LINK(
429 [#include <sys/stat.h>],
430 [struct stat buffer;
431 fstat(0, &buffer);
432 S_IFREG & buffer.st_mode;],
433 [glibcxx_cv_S_IFREG=yes],
434 [glibcxx_cv_S_IFREG=no])
435 ])
e0103440 436 res=no
ff66d28f 437 if test $glibcxx_cv_S_ISREG = yes; then
4651e622
KC
438 AC_DEFINE(HAVE_S_ISREG, 1,
439 [Define if S_IFREG is available in <sys/stat.h>.])
e0103440 440 res=S_ISREG
ff66d28f 441 elif test $glibcxx_cv_S_IFREG = yes; then
4651e622
KC
442 AC_DEFINE(HAVE_S_IFREG, 1,
443 [Define if S_IFREG is available in <sys/stat.h>.])
e0103440 444 res=S_IFREG
ff66d28f 445 fi
e0103440 446 AC_MSG_RESULT($res)
b2dad0e3
BK
447])
448
449
dcfa0bc8 450dnl
ff66d28f 451dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
dcfa0bc8 452dnl
f214923c 453AC_DEFUN([GLIBCXX_CHECK_POLL], [
e0103440 454 AC_MSG_CHECKING([for poll])
ff66d28f 455 AC_CACHE_VAL(glibcxx_cv_POLL, [
3d05b345 456 AC_TRY_LINK(
ff66d28f
PE
457 [#include <poll.h>],
458 [struct pollfd pfd[1];
459 pfd[0].events = POLLIN;
460 poll(pfd, 1, 0);],
461 [glibcxx_cv_POLL=yes],
462 [glibcxx_cv_POLL=no])
463 ])
464 if test $glibcxx_cv_POLL = yes; then
4651e622 465 AC_DEFINE(HAVE_POLL, 1, [Define if poll is available in <poll.h>.])
ff66d28f 466 fi
e0103440 467 AC_MSG_RESULT($glibcxx_cv_POLL)
ff66d28f
PE
468])
469
470
471dnl
472dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
473dnl
f214923c 474AC_DEFUN([GLIBCXX_CHECK_WRITEV], [
e0103440 475 AC_MSG_CHECKING([for writev])
ff66d28f 476 AC_CACHE_VAL(glibcxx_cv_WRITEV, [
3d05b345 477 AC_TRY_LINK(
ff66d28f
PE
478 [#include <sys/uio.h>],
479 [struct iovec iov[2];
480 writev(0, iov, 0);],
481 [glibcxx_cv_WRITEV=yes],
482 [glibcxx_cv_WRITEV=no])
483 ])
484 if test $glibcxx_cv_WRITEV = yes; then
4651e622 485 AC_DEFINE(HAVE_WRITEV, 1, [Define if writev is available in <sys/uio.h>.])
ff66d28f 486 fi
e0103440 487 AC_MSG_RESULT($glibcxx_cv_WRITEV)
ff66d28f
PE
488])
489
490
3d05b345
PC
491dnl
492dnl Check whether int64_t is available in <stdint.h>, and define HAVE_INT64_T.
493dnl
f214923c 494AC_DEFUN([GLIBCXX_CHECK_INT64_T], [
e0103440 495 AC_MSG_CHECKING([for int64_t])
3d05b345
PC
496 AC_CACHE_VAL(glibcxx_cv_INT64_T, [
497 AC_TRY_COMPILE(
498 [#include <stdint.h>],
499 [int64_t var;],
500 [glibcxx_cv_INT64_T=yes],
501 [glibcxx_cv_INT64_T=no])
502 ])
503 if test $glibcxx_cv_INT64_T = yes; then
4651e622 504 AC_DEFINE(HAVE_INT64_T, 1, [Define if int64_t is available in <stdint.h>.])
3d05b345 505 fi
e0103440 506 AC_MSG_RESULT($glibcxx_cv_INT64_T)
3d05b345
PC
507])
508
509
510dnl
511dnl Check whether LFS support is available.
512dnl
f214923c 513AC_DEFUN([GLIBCXX_CHECK_LFS], [
0c6b814a 514 AC_LANG_SAVE
9d47bc51
PC
515 AC_LANG_CPLUSPLUS
516 ac_save_CXXFLAGS="$CXXFLAGS"
517 CXXFLAGS="$CXXFLAGS -fno-exceptions"
e0103440 518 AC_MSG_CHECKING([for LFS support])
3d05b345
PC
519 AC_CACHE_VAL(glibcxx_cv_LFS, [
520 AC_TRY_LINK(
0c6b814a
PC
521 [#include <unistd.h>
522 #include <stdio.h>
dd5d134b 523 #include <sys/stat.h>
0c6b814a 524 ],
5c89246d
PC
525 [FILE* fp;
526 fopen64("t", "w");
527 fseeko64(fp, 0, SEEK_CUR);
528 ftello64(fp);
dd5d134b
PC
529 lseek64(1, 0, SEEK_CUR);
530 struct stat64 buf;
531 fstat64(1, &buf);],
3d05b345
PC
532 [glibcxx_cv_LFS=yes],
533 [glibcxx_cv_LFS=no])
534 ])
535 if test $glibcxx_cv_LFS = yes; then
4651e622 536 AC_DEFINE(_GLIBCXX_USE_LFS, 1, [Define if LFS support is available.])
3d05b345 537 fi
e0103440 538 AC_MSG_RESULT($glibcxx_cv_LFS)
9d47bc51
PC
539 CXXFLAGS="$ac_save_CXXFLAGS"
540 AC_LANG_RESTORE
3d05b345
PC
541])
542
543
1165dc50
PC
544dnl
545dnl Check for whether a fully dynamic basic_string implementation should
546dnl be turned on, that does not put empty objects in per-process static
547dnl memory (mostly useful together with shared memory allocators, see PR
548dnl libstdc++/16612 for details).
549dnl
550dnl --enable-fully-dynamic-string defines _GLIBCXX_FULLY_DYNAMIC_STRING
551dnl --disable-fully-dynamic-string leaves _GLIBCXX_FULLY_DYNAMIC_STRING undefined
552dnl + Usage: GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING[(DEFAULT)]
553dnl Where DEFAULT is either `yes' or `no'.
554dnl
555AC_DEFUN([GLIBCXX_ENABLE_FULLY_DYNAMIC_STRING], [
556 GLIBCXX_ENABLE(fully-dynamic-string,$1,,[do not put empty strings in per-process static memory])
557 if test $enable_fully_dynamic_string = yes; then
4651e622
KC
558 AC_DEFINE(_GLIBCXX_FULLY_DYNAMIC_STRING, 1,
559 [Define if a fully dynamic basic_string is wanted.])
1165dc50
PC
560 fi
561])
562
563
ff66d28f
PE
564dnl
565dnl Does any necessary configuration of the testsuite directory. Generates
566dnl the testsuite_hooks.h header.
567dnl
568dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this.
569dnl
570dnl Sets:
84946e72 571dnl enable_abi_check
e3f78d9b
BK
572dnl GLIBCXX_TEST_WCHAR_T
573dnl GLIBCXX_TEST_THREAD
ff66d28f
PE
574dnl Substs:
575dnl baseline_dir
576dnl
f214923c 577AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [
0646b059 578 if $GLIBCXX_IS_NATIVE ; then
2ae6e982 579 # Do checks for resource limit functions.
ff66d28f
PE
580 GLIBCXX_CHECK_SETRLIMIT
581
582 # Look for setenv, so that extended locale tests can be performed.
583 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
0646b059 584 fi
dbc66058 585
0646b059
GK
586 if $GLIBCXX_IS_NATIVE && test $is_hosted = yes &&
587 test $enable_symvers != no; then
588 case "$host" in
589 *-*-cygwin*)
590 enable_abi_check=no ;;
591 *)
592 enable_abi_check=yes ;;
593 esac
dbc66058
DJ
594 else
595 # Only build this as native, since automake does not understand
596 # CXX_FOR_BUILD.
597 enable_abi_check=no
ff66d28f 598 fi
84946e72 599
ff66d28f 600 # Export file names for ABI checking.
fb5c309d 601 baseline_dir="$glibcxx_srcdir/config/abi/post/${abi_baseline_pair}\$(MULTISUBDIR)"
ff66d28f 602 AC_SUBST(baseline_dir)
ff66d28f
PE
603])
604
605
606dnl
607dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
608dnl
609dnl Substs:
610dnl GLIBCXX_INCLUDES
611dnl TOPLEVEL_INCLUDES
ff66d28f 612dnl
f214923c 613AC_DEFUN([GLIBCXX_EXPORT_INCLUDES], [
0df3f383
PE
614 # Used for every C++ compile we perform.
615 GLIBCXX_INCLUDES="\
616-I$glibcxx_builddir/include/$host_alias \
617-I$glibcxx_builddir/include \
618-I$glibcxx_srcdir/libsupc++"
ff66d28f 619
0df3f383 620 # For Canadian crosses, pick this up too.
ff66d28f 621 if test $CANADIAN = yes; then
37e0ff11 622 GLIBCXX_INCLUDES="$GLIBCXX_INCLUDES -I\${includedir}"
ff66d28f
PE
623 fi
624
0df3f383
PE
625 # Stuff in the actual top level. Currently only used by libsupc++ to
626 # get unwind* headers from the gcc dir.
627 #TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc -I$(toplevel_srcdir)/include'
628 TOPLEVEL_INCLUDES='-I$(toplevel_srcdir)/gcc'
ff66d28f
PE
629
630 # Now, export this to all the little Makefiles....
631 AC_SUBST(GLIBCXX_INCLUDES)
632 AC_SUBST(TOPLEVEL_INCLUDES)
ff66d28f
PE
633])
634
635
636dnl
637dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
638dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
639dnl
640dnl Substs:
641dnl OPTIMIZE_CXXFLAGS
642dnl WARN_FLAGS
643dnl
f214923c 644AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
ff66d28f
PE
645 # Optimization flags that are probably a good idea for thrill-seekers. Just
646 # uncomment the lines below and make, everything else is ready to go...
647 # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
648 OPTIMIZE_CXXFLAGS=
649 AC_SUBST(OPTIMIZE_CXXFLAGS)
650
dc7c62ae 651 WARN_FLAGS='-Wall -Wextra -Wwrite-strings -Wcast-qual'
ff66d28f
PE
652 AC_SUBST(WARN_FLAGS)
653])
654
655
656dnl
657dnl All installation directory information is determined here.
658dnl
659dnl Substs:
660dnl gxx_install_dir
661dnl glibcxx_prefixdir
662dnl glibcxx_toolexecdir
663dnl glibcxx_toolexeclibdir
664dnl
665dnl Assumes cross_compiling bits already done, and with_cross_host in
666dnl particular.
667dnl
f214923c 668AC_DEFUN([GLIBCXX_EXPORT_INSTALL_INFO], [
ff66d28f
PE
669 glibcxx_toolexecdir=no
670 glibcxx_toolexeclibdir=no
671 glibcxx_prefixdir=$prefix
672
673 AC_MSG_CHECKING([for gxx-include-dir])
674 AC_ARG_WITH([gxx-include-dir],
675 AC_HELP_STRING([--with-gxx-include-dir=DIR],
676 [installation directory for include files]),
677 [case "$withval" in
678 yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
679 no) gxx_include_dir=no ;;
680 *) gxx_include_dir=$withval ;;
681 esac],
682 [gxx_include_dir=no])
683 AC_MSG_RESULT($gxx_include_dir)
684
685 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
686 AC_ARG_ENABLE([version-specific-runtime-libs],
687 AC_HELP_STRING([--enable-version-specific-runtime-libs],
688 [Specify that runtime libraries should be installed in a compiler-specific directory]),
689 [case "$enableval" in
690 yes) version_specific_libs=yes ;;
691 no) version_specific_libs=no ;;
692 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
693 esac],
694 [version_specific_libs=no])
695 AC_MSG_RESULT($version_specific_libs)
696
697 # Default case for install directory for include files.
698 if test $version_specific_libs = no && test $gxx_include_dir = no; then
47194af4 699 gxx_include_dir='${prefix}/include/c++/${gcc_version}'
ff66d28f
PE
700 fi
701
702 # Version-specific runtime libs processing.
703 if test $version_specific_libs = yes; then
704 # Need the gcc compiler version to know where to install libraries
705 # and header files if --enable-version-specific-runtime-libs option
0314451d
GK
706 # is selected. FIXME: these variables are misnamed, there are
707 # no executables installed in _toolexecdir or _toolexeclibdir.
ff66d28f 708 if test x"$gxx_include_dir" = x"no"; then
47194af4 709 gxx_include_dir='${libdir}/gcc/${host_alias}/${gcc_version}/include/c++'
ff66d28f 710 fi
0314451d 711 glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
47194af4 712 glibcxx_toolexeclibdir='${toolexecdir}/${gcc_version}$(MULTISUBDIR)'
ff66d28f
PE
713 fi
714
715 # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
716 # Install a library built with a cross compiler in tooldir, not libdir.
717 if test x"$glibcxx_toolexecdir" = x"no"; then
718 if test -n "$with_cross_host" &&
719 test x"$with_cross_host" != x"no"; then
fbe057bb
PE
720 glibcxx_toolexecdir='${exec_prefix}/${host_alias}'
721 glibcxx_toolexeclibdir='${toolexecdir}/lib'
ff66d28f 722 else
0314451d 723 glibcxx_toolexecdir='${libdir}/gcc/${host_alias}'
fbe057bb 724 glibcxx_toolexeclibdir='${libdir}'
ff66d28f 725 fi
fbe057bb 726 multi_os_directory=`$CXX -print-multi-os-directory`
ff66d28f
PE
727 case $multi_os_directory in
728 .) ;; # Avoid trailing /.
729 *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
730 esac
731 fi
732
733 AC_MSG_CHECKING([for install location])
734 AC_MSG_RESULT($gxx_include_dir)
735
736 AC_SUBST(glibcxx_prefixdir)
737 AC_SUBST(gxx_include_dir)
738 AC_SUBST(glibcxx_toolexecdir)
739 AC_SUBST(glibcxx_toolexeclibdir)
740])
741
742
743dnl
744dnl GLIBCXX_ENABLE
745dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
746dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
747dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
748dnl
749dnl See docs/html/17_intro/configury.html#enable for documentation.
750dnl
751m4_define([GLIBCXX_ENABLE],[dnl
752m4_define([_g_switch],[--enable-$1])dnl
753m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
754 AC_ARG_ENABLE($1,_g_help,
755 m4_bmatch([$5],
756 [^permit ],
757 [[
758 case "$enableval" in
759 m4_bpatsubst([$5],[permit ])) ;;
760 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
761 dnl Idea for future: generate a URL pointing to
762 dnl "onlinedocs/configopts.html#whatever"
763 esac
764 ]],
765 [^$],
766 [[
767 case "$enableval" in
768 yes|no) ;;
769 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
770 esac
771 ]],
772 [[$5]]),
773 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
774m4_undefine([_g_switch])dnl
775m4_undefine([_g_help])dnl
776])
777
778
779dnl
780dnl Check for ISO/IEC 9899:1999 "C99" support.
781dnl
782dnl --enable-c99 defines _GLIBCXX_USE_C99
783dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
784dnl + Usage: GLIBCXX_ENABLE_C99[(DEFAULT)]
785dnl Where DEFAULT is either `yes' or `no'.
786dnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
787dnl
f214923c 788AC_DEFUN([GLIBCXX_ENABLE_C99], [
ff66d28f
PE
789 GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
790
347669a0
BK
791 # Test wchar.h for mbstate_t, which is needed for char_traits and fpos
792 # even if C99 support is turned off.
793 AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
794 AC_MSG_CHECKING([for mbstate_t])
795 AC_TRY_COMPILE([#include <wchar.h>],
796 [mbstate_t teststate;],
797 have_mbstate_t=yes, have_mbstate_t=no)
798 AC_MSG_RESULT($have_mbstate_t)
799 if test x"$have_mbstate_t" = xyes; then
4651e622 800 AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
347669a0
BK
801 fi
802
803 if test x"$enable_c99" = x"yes"; then
804
ff66d28f
PE
805 AC_LANG_SAVE
806 AC_LANG_CPLUSPLUS
807
808 # Check for the existence of <math.h> functions used if C99 is enabled.
ff66d28f 809 AC_MSG_CHECKING([for ISO C99 support in <math.h>])
347669a0 810 AC_CACHE_VAL(ac_c99_math, [
ff66d28f 811 AC_TRY_COMPILE([#include <math.h>],
347669a0
BK
812 [fpclassify(0.0);
813 isfinite(0.0);
814 isinf(0.0);
815 isnan(0.0);
816 isnormal(0.0);
817 signbit(0.0);
818 isgreater(0.0,0.0);
819 isgreaterequal(0.0,0.0);
820 isless(0.0,0.0);
821 islessequal(0.0,0.0);
822 islessgreater(0.0,0.0);
823 islessgreater(0.0,0.0);
824 isunordered(0.0,0.0);
825 ],[ac_c99_math=yes], [ac_c99_math=no])
826 ])
ff66d28f 827 AC_MSG_RESULT($ac_c99_math)
517da0ce 828 if test x"$ac_c99_math" = x"yes"; then
4651e622
KC
829 AC_DEFINE(_GLIBCXX_USE_C99_MATH, 1,
830 [Define if C99 functions or macros in <math.h> should be imported
831 in <cmath> in namespace std.])
517da0ce
MM
832 fi
833
225962a0 834 # Check for the existence of <complex.h> complex math functions.
52e6723c
BK
835 # This is necessary even though libstdc++ uses the builtin versions
836 # of these functions, because if the builtin cannot be used, a reference
837 # to the library function is emitted.
838 AC_CHECK_HEADERS(complex.h, ac_has_complex_h=yes, ac_has_complex_h=no)
839 ac_c99_complex=no;
840 if test x"$ac_has_complex_h" = x"yes"; then
52e6723c
BK
841 AC_MSG_CHECKING([for ISO C99 support in <complex.h>])
842 AC_TRY_COMPILE([#include <complex.h>],
347669a0
BK
843 [typedef __complex__ float float_type; float_type tmpf;
844 cabsf(tmpf);
845 cargf(tmpf);
846 ccosf(tmpf);
847 ccoshf(tmpf);
848 cexpf(tmpf);
9d997b96 849 clogf(tmpf);
347669a0
BK
850 csinf(tmpf);
851 csinhf(tmpf);
852 csqrtf(tmpf);
853 ctanf(tmpf);
854 ctanhf(tmpf);
855 cpowf(tmpf, tmpf);
856 typedef __complex__ double double_type; double_type tmpd;
857 cabs(tmpd);
858 carg(tmpd);
859 ccos(tmpd);
860 ccosh(tmpd);
861 cexp(tmpd);
9d997b96 862 clog(tmpd);
347669a0
BK
863 csin(tmpd);
864 csinh(tmpd);
865 csqrt(tmpd);
866 ctan(tmpd);
867 ctanh(tmpd);
868 cpow(tmpd, tmpd);
869 typedef __complex__ long double ld_type; ld_type tmpld;
870 cabsl(tmpld);
871 cargl(tmpld);
872 ccosl(tmpld);
873 ccoshl(tmpld);
874 cexpl(tmpld);
9d997b96 875 clogl(tmpld);
347669a0
BK
876 csinl(tmpld);
877 csinhl(tmpld);
878 csqrtl(tmpld);
879 ctanl(tmpld);
880 ctanhl(tmpld);
881 cpowl(tmpld, tmpld);
882 ],[ac_c99_complex=yes], [ac_c99_complex=no])
52e6723c
BK
883 fi
884 AC_MSG_RESULT($ac_c99_complex)
52e6723c 885 if test x"$ac_c99_complex" = x"yes"; then
4651e622
KC
886 AC_DEFINE(_GLIBCXX_USE_C99_COMPLEX, 1,
887 [Define if C99 functions in <complex.h> should be used in
888 <complex>. Using compiler builtins for these functions requires
889 corresponding C99 library functions to be present.])
52e6723c
BK
890 fi
891
ff66d28f 892 # Check for the existence in <stdio.h> of vscanf, et. al.
ff66d28f 893 AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
347669a0 894 AC_CACHE_VAL(ac_c99_stdio, [
ff66d28f 895 AC_TRY_COMPILE([#include <stdio.h>
347669a0 896 #include <stdarg.h>
ff66d28f 897 void foo(char* fmt, ...)
347669a0
BK
898 {
899 va_list args; va_start(args, fmt);
900 vfscanf(stderr, "%i", args);
901 vscanf("%i", args);
902 vsnprintf(fmt, 0, "%i", args);
903 vsscanf(fmt, "%i", args);
904 }],
905 [snprintf("12", 0, "%i");],
906 [ac_c99_stdio=yes], [ac_c99_stdio=no])
907 ])
ff66d28f
PE
908 AC_MSG_RESULT($ac_c99_stdio)
909
910 # Check for the existence in <stdlib.h> of lldiv_t, et. al.
ff66d28f 911 AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
347669a0 912 AC_CACHE_VAL(ac_c99_stdlib, [
ff66d28f 913 AC_TRY_COMPILE([#include <stdlib.h>],
10d877a8
PC
914 [char* tmp;
915 strtof("gnu", &tmp);
347669a0 916 strtold("gnu", &tmp);
10d877a8
PC
917 strtoll("gnu", &tmp, 10);
918 strtoull("gnu", &tmp, 10);
919 llabs(10);
920 lldiv(10,1);
921 atoll("10");
347669a0
BK
922 _Exit(0);
923 lldiv_t mydivt;],[ac_c99_stdlib=yes], [ac_c99_stdlib=no])
924 ])
ff66d28f
PE
925 AC_MSG_RESULT($ac_c99_stdlib)
926
347669a0
BK
927 # Check for the existence in <wchar.h> of wcstoull, WEOF, etc.
928 AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
929 ac_c99_wchar=no;
930 if test x"$ac_has_wchar_h" = xyes &&
931 test x"$ac_has_wctype_h" = xyes; then
932 AC_TRY_COMPILE([#include <wchar.h>
933 #include <stddef.h>
934 wint_t i;
935 long l = WEOF;
936 long j = WCHAR_MIN;
937 long k = WCHAR_MAX;
938 namespace test
939 {
940 using ::btowc;
941 using ::fgetwc;
942 using ::fgetws;
943 using ::fputwc;
944 using ::fputws;
945 using ::fwide;
946 using ::fwprintf;
947 using ::fwscanf;
948 using ::getwc;
949 using ::getwchar;
950 using ::mbrlen;
951 using ::mbrtowc;
952 using ::mbsinit;
953 using ::mbsrtowcs;
954 using ::putwc;
955 using ::putwchar;
956 using ::swprintf;
957 using ::swscanf;
958 using ::ungetwc;
959 using ::vfwprintf;
960 using ::vswprintf;
961 using ::vwprintf;
962 using ::wcrtomb;
963 using ::wcscat;
964 using ::wcschr;
965 using ::wcscmp;
966 using ::wcscoll;
967 using ::wcscpy;
968 using ::wcscspn;
969 using ::wcsftime;
970 using ::wcslen;
971 using ::wcsncat;
972 using ::wcsncmp;
973 using ::wcsncpy;
974 using ::wcspbrk;
975 using ::wcsrchr;
976 using ::wcsrtombs;
977 using ::wcsspn;
978 using ::wcsstr;
979 using ::wcstod;
980 using ::wcstok;
981 using ::wcstol;
982 using ::wcstold;
983 using ::wcstoll;
984 using ::wcstoul;
985 using ::wcstoull;
986 using ::wcsxfrm;
987 using ::wctob;
988 using ::wmemchr;
989 using ::wmemcmp;
990 using ::wmemcpy;
991 using ::wmemmove;
992 using ::wmemset;
993 using ::wprintf;
994 using ::wscanf;
995 }
996 ],[],[ac_c99_wchar=yes], [ac_c99_wchar=no])
997
998 # Checks for wide character functions that may not be present.
999 # Injection of these is wrapped with guard macros.
1000 # NB: only put functions here, instead of immediately above, if
1001 # absolutely necessary.
1002 AC_TRY_COMPILE([#include <wchar.h>
1003 namespace test { using ::vfwscanf; } ], [],
1004 [AC_DEFINE(HAVE_VFWSCANF,1,
1005 [Defined if vfwscanf exists.])],[])
1006
1007 AC_TRY_COMPILE([#include <wchar.h>
1008 namespace test { using ::vswscanf; } ], [],
1009 [AC_DEFINE(HAVE_VSWSCANF,1,
1010 [Defined if vswscanf exists.])],[])
1011
1012 AC_TRY_COMPILE([#include <wchar.h>
1013 namespace test { using ::vwscanf; } ], [],
1014 [AC_DEFINE(HAVE_VWSCANF,1,[Defined if vwscanf exists.])],[])
1015
1016 AC_TRY_COMPILE([#include <wchar.h>
1017 namespace test { using ::wcstof; } ], [],
1018 [AC_DEFINE(HAVE_WCSTOF,1,[Defined if wcstof exists.])],[])
1019
1020 AC_TRY_COMPILE([#include <wctype.h>],
1021 [ wint_t t; int i = iswblank(t);],
1022 [AC_DEFINE(HAVE_ISWBLANK,1,
1023 [Defined if iswblank exists.])],[])
1024
1025 AC_MSG_CHECKING([for ISO C99 support in <wchar.h>])
1026 AC_MSG_RESULT($ac_c99_wchar)
1027 fi
ff66d28f 1028
347669a0 1029 # Option parsed, now set things appropriately.
ff66d28f 1030 if test x"$ac_c99_math" = x"no" ||
02a65d23 1031 test x"$ac_c99_complex" = x"no" ||
ff66d28f
PE
1032 test x"$ac_c99_stdio" = x"no" ||
1033 test x"$ac_c99_stdlib" = x"no" ||
1034 test x"$ac_c99_wchar" = x"no"; then
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
1042 AC_LANG_RESTORE
347669a0
BK
1043 fi
1044
1045 AC_MSG_CHECKING([for fully enabled ISO C99 support])
1046 AC_MSG_RESULT($enable_c99)
dcfa0bc8
PE
1047])
1048
1049
0214010c 1050dnl
ff66d28f
PE
1051dnl Check for what type of C headers to use.
1052dnl
1053dnl --enable-cheaders= [does stuff].
1054dnl --disable-cheaders [does not do anything, really].
1055dnl + Usage: GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
1056dnl Where DEFAULT is either `c' or `c_std'.
1057dnl
f214923c 1058AC_DEFUN([GLIBCXX_ENABLE_CHEADERS], [
ff66d28f
PE
1059 GLIBCXX_ENABLE(cheaders,$1,[=KIND],
1060 [construct "C" headers for g++], [permit c|c_std])
1061 AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
1062
1063 C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
1064
1065 AC_SUBST(C_INCLUDE_DIR)
92eabea2
PE
1066 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
1067 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
1068 GLIBCXX_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
ff66d28f
PE
1069])
1070
1071
0214010c 1072dnl
ff66d28f
PE
1073dnl Check for which locale library to use. The choice is mapped to
1074dnl a subdirectory of config/locale.
37bc6ca2 1075dnl
ff66d28f 1076dnl Default is generic.
0214010c 1077dnl
f214923c 1078AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
ff66d28f
PE
1079 AC_MSG_CHECKING([for C locale to use])
1080 GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
1081 [use MODEL for target locale package],
1082 [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
1083
1084 # If they didn't use this option switch, or if they specified --enable
1085 # with no specific model, we'll have to look for one. If they
1086 # specified --disable (???), do likewise.
1087 if test $enable_clocale = no || test $enable_clocale = yes; then
1088 enable_clocale=auto
1089 fi
0214010c 1090
ff66d28f 1091 # Either a known package, or "auto"
0214010c
BK
1092 enable_clocale_flag=$enable_clocale
1093
ff66d28f
PE
1094 # Probe for locale support if no specific model is specified.
1095 # Default to "generic".
1096 if test $enable_clocale_flag = auto; then
7d3998a4
PE
1097 case ${target_os} in
1098 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
ff66d28f 1099 AC_EGREP_CPP([_GLIBCXX_ok], [
56deb74c 1100 #include <features.h>
37bc6ca2 1101 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
3d7c150e 1102 _GLIBCXX_ok
56deb74c
BK
1103 #endif
1104 ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1451a492 1105
ff66d28f 1106 # Test for bugs early in glibc-2.2.x series
7d3998a4 1107 if test $enable_clocale_flag = gnu; then
ff66d28f
PE
1108 AC_TRY_RUN([
1109 #define _GNU_SOURCE 1
1110 #include <locale.h>
1111 #include <string.h>
1112 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
1113 extern __typeof(newlocale) __newlocale;
1114 extern __typeof(duplocale) __duplocale;
1115 extern __typeof(strcoll_l) __strcoll_l;
1116 #endif
1117 int main()
1118 {
1119