]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/acinclude.m4
Convert to new autotools.
[thirdparty/gcc.git] / libstdc++-v3 / acinclude.m4
CommitLineData
ff66d28f
PE
1
2dnl
3dnl Check to see what architecture and operating system we are compiling
4dnl for. Also, if architecture- or OS-specific flags are required for
5dnl compilation, pick them up here.
6dnl
7AC_DEFUN(GLIBCXX_CHECK_HOST, [
8 . $glibcxx_srcdir/configure.host
9 AC_MSG_NOTICE(CPU config directory is $cpu_include_dir)
10 AC_MSG_NOTICE(OS config directory is $os_include_dir)
11])
12
13
b2dad0e3 14dnl
ff66d28f
PE
15dnl Initialize basic configure bits.
16dnl
17dnl Substs:
18dnl multi_basedir
b2dad0e3 19dnl
3d7c150e 20AC_DEFUN(GLIBCXX_TOPREL_CONFIGURE, [
ff66d28f
PE
21 # Sets up multi_basedir, which is srcdir/.. plus the usual
22 # "multi_source_toprel_bottom_adjust" lunacy as needed.
23 AM_ENABLE_MULTILIB(, ..)
24
25 # The generated code is exactly the same, except that automake's looks in
26 # ".. $srcdir/.." and autoconf's looks in multi_basedir. Apparently other
27 # things are triggered on the presence of the two ...AUX_DIR[S], but I don't
28 # know what they are or what the other differences might be (and they keep
29 # changing anyhow).
30 #
31 # Looking in multi_basedir seems smarter, so actually execute that branch.
32 if false; then
33 # this is for automake
34 AC_CONFIG_AUX_DIR(..)
d2caef2e 35 else
ff66d28f
PE
36 # this is for autoconf
37 AC_CONFIG_AUX_DIRS(${multi_basedir})
33590f13 38 fi
ff66d28f
PE
39
40 dnl XXX Turn this on.
41 dnl AC_LANG_CPLUSPLUS
aebb8c22
DD
42])
43
ff66d28f
PE
44
45dnl
46dnl Initialize the rest of the library configury. At this point we have
47dnl variables like $host.
aebb8c22 48dnl
ff66d28f
PE
49dnl Sets:
50dnl gcc_version (x.y.z format)
51dnl Substs:
52dnl glibcxx_builddir (absolute path)
53dnl glibcxx_srcdir (absolute path)
54dnl toplevel_srcdir (absolute path)
55dnl with_cross_host
56dnl with_newlib
57dnl with_target_subdir
58dnl plus
59dnl - the variables in GLIBCXX_CHECK_HOST / configure.host
60dnl - default settings for all AM_CONFITIONAL test variables
61dnl - lots of tools, like CC and CXX
aebb8c22 62dnl
3d7c150e 63AC_DEFUN(GLIBCXX_CONFIGURE, [
d2caef2e
PE
64 # These need to be absolute paths, yet at the same time need to
65 # canonicalize only relative paths, because then amd will not unmount
66 # drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd.
3d7c150e 67 glibcxx_builddir=`${PWDCMD-pwd}`
d2caef2e 68 case $srcdir in
ff66d28f
PE
69 [\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;;
70 *) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;;
d2caef2e 71 esac
ff66d28f 72 toplevel_srcdir=${glibcxx_srcdir}/..
3d7c150e
BK
73 AC_SUBST(glibcxx_builddir)
74 AC_SUBST(glibcxx_srcdir)
ff66d28f 75 AC_SUBST(toplevel_srcdir)
d2caef2e 76
ff66d28f
PE
77 # We use these options to decide which functions to include. They are
78 # set from the top level.
79 AC_ARG_WITH([target-subdir],
80 AC_HELP_STRING([--with-target-subdir=SUBDIR],
81 [configuring in a subdirectory]))
82
83 AC_ARG_WITH([cross-host],
84 AC_HELP_STRING([--with-cross-host=HOST],
85 [configuring with a cross compiler]))
86
87 AC_ARG_WITH([newlib],
88 AC_HELP_STRING([--with-newlib],
89 [assume newlib as a system C library]))
90
91 AC_PROG_CC
92
93 # We're almost certainly being configured before anything else which uses
94 # C++, so all of our AC_PROG_* discoveries will be cached. It's vital that
95 # we not cache the value of CXX that we "discover" here, because it's set
96 # to something unique for us and libjava. Other target libraries need to
97 # find CXX for themselves. We yank the rug out from under the normal AC_*
98 # process by sneakily renaming the cache variable. This also lets us debug
99 # the value of "our" CXX in postmortems.
100 #
101 # We must also force CXX to /not/ be a precious variable, otherwise the
102 # wrong (non-multilib-adjusted) value will be used in multilibs. This
103 # little trick also affects CPPFLAGS, CXXFLAGS, and LDFLAGS. And as a side
104 # effect, CXXFLAGS is no longer automagically subst'd, so we have to do
105 # that ourselves.
106 #
107 # -fno-builtin must be present here so that a non-conflicting form of
108 # std::exit can be guessed by AC_PROG_CXX, and used in later tests.
109 m4_define([ac_cv_prog_CXX],[glibcxx_cv_prog_CXX])
110 m4_rename([_AC_ARG_VAR_PRECIOUS],[glibcxx_PRECIOUS])
111 m4_define([_AC_ARG_VAR_PRECIOUS],[])
112 save_CXXFLAGS="$CXXFLAGS"
113 CXXFLAGS="$CXXFLAGS -fno-builtin"
114 AC_PROG_CXX
115 CXXFLAGS="$save_CXXFLAGS"
116 m4_rename([glibcxx_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
117 AC_SUBST(CXXFLAGS)
b2dad0e3 118
2f235b6d
PE
119 # For directory versioning (e.g., headers) and other variables.
120 AC_MSG_CHECKING([for GCC version number])
ff66d28f 121 gcc_version=`$CXX -dumpversion`
2f235b6d
PE
122 AC_MSG_RESULT($gcc_version)
123
d2caef2e
PE
124 # For some reason, gettext needs this.
125 AC_ISC_POSIX
33590f13 126
ff66d28f
PE
127 # Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't
128 # available). Uncomment the next line to force a particular method.
129 AC_PROG_LN_S
130 #LN_S='cp -p'
131
5780a46b
BK
132 AC_CHECK_TOOL(AS, as)
133 AC_CHECK_TOOL(AR, ar)
46840bcd 134 AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
b2dad0e3 135
5780a46b 136 AM_MAINTAINER_MODE
b2dad0e3 137
16da539b
PE
138 # Set up safe default values for all subsequent AM_CONDITIONAL tests.
139 need_libmath=no
140 enable_wchar_t=no
ff66d28f
PE
141 #enable_libstdcxx_debug=no
142 #enable_libstdcxx_pch=no
16da539b
PE
143 #enable_cheaders=c
144 #c_compatibility=no
c4c064e7 145 #enable_abi_check=no
16da539b
PE
146 #enable_symvers=no
147
ff66d28f
PE
148 # Find platform-specific directories containing configuration info.
149 # Also possibly modify flags used elsewhere, as needed by the platform.
3d7c150e 150 GLIBCXX_CHECK_HOST
b2dad0e3
BK
151])
152
153
ff66d28f 154m4_include([linkage.m4])
c470c17d
BK
155
156
157dnl
52b55e7d
PE
158dnl Tests for newer compiler features, or features that are present in newer
159dnl compiler versions but not older compiler versions still in use, should
160dnl be placed here.
b2dad0e3 161dnl
ff66d28f
PE
162dnl Defines:
163dnl WERROR='-Werror' if requested and possible; g++'s that lack the
164dnl new inlining code or the new system_header pragma will die on -Werror.
165dnl Leave it out by default and use maint-mode to use it.
166dnl SECTION_FLAGS='-ffunction-sections -fdata-sections' if
167dnl compiler supports it and the user has not requested debug mode.
c21b6f87 168dnl
3d7c150e 169AC_DEFUN(GLIBCXX_CHECK_COMPILER_FEATURES, [
a4e99046 170 # All these tests are for C++; save the language and the compiler flags.
52b55e7d 171 # The CXXFLAGS thing is suspicious, but based on similar bits previously
3d7c150e 172 # found in GLIBCXX_CONFIGURE.
a4e99046
PE
173 AC_LANG_SAVE
174 AC_LANG_CPLUSPLUS
175 ac_test_CXXFLAGS="${CXXFLAGS+set}"
176 ac_save_CXXFLAGS="$CXXFLAGS"
a4e99046 177
7f586614
BK
178 # Check for maintainer-mode bits.
179 if test x"$USE_MAINTAINER_MODE" = xno; then
180 WERROR=''
8bd636c5 181 else
7f586614 182 WERROR='-Werror'
8bd636c5
PE
183 fi
184
c470c17d
BK
185 # Check for -ffunction-sections -fdata-sections
186 AC_MSG_CHECKING([for g++ that supports -ffunction-sections -fdata-sections])
0517cb99 187 CXXFLAGS='-Werror -ffunction-sections -fdata-sections'
ff66d28f 188 AC_TRY_COMPILE(, [int foo;], [ac_fdsections=yes], [ac_fdsections=no])
c470c17d
BK
189 if test "$ac_test_CXXFLAGS" = set; then
190 CXXFLAGS="$ac_save_CXXFLAGS"
191 else
192 # this is the suspicious part
193 CXXFLAGS=''
194 fi
6aa43d99 195 if test x"$ac_fdsections" = x"yes"; then
c470c17d
BK
196 SECTION_FLAGS='-ffunction-sections -fdata-sections'
197 fi
198 AC_MSG_RESULT($ac_fdsections)
199
a4e99046 200 AC_LANG_RESTORE
8bd636c5 201 AC_SUBST(WERROR)
c470c17d 202 AC_SUBST(SECTION_FLAGS)
b2dad0e3
BK
203])
204
c470c17d
BK
205
206dnl
421173e6
PE
207dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
208dnl the native linker is in use, all variables will be defined to something
209dnl safe (like an empty string).
210dnl
ff66d28f
PE
211dnl Defines:
212dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
213dnl OPT_LDFLAGS='-Wl,-O1' if possible
214dnl LD (as a side effect of testing)
215dnl Sets:
216dnl with_gnu_ld
217dnl glibcxx_gnu_ld_version (possibly)
218dnl
219dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
220dnl set glibcxx_gnu_ld_version to 12345. Zeros cause problems.
c470c17d 221dnl
3d7c150e 222AC_DEFUN(GLIBCXX_CHECK_LINKER_FEATURES, [
421173e6
PE
223 # If we're not using GNU ld, then there's no point in even trying these
224 # tests. Check for that first. We should have already tested for gld
225 # by now (in libtool), but require it now just to be safe...
654421eb
DE
226 test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
227 test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
421173e6 228 AC_REQUIRE([AC_PROG_LD])
ff66d28f 229 AC_REQUIRE([AC_PROG_AWK])
5bd17d39 230
c98b201b
PE
231 # The name set by libtool depends on the version of libtool. Shame on us
232 # for depending on an impl detail, but c'est la vie. Older versions used
233 # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
234 # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
235 # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
236 # set (hence we're using an older libtool), then set it.
237 if test x${with_gnu_ld+set} != xset; then
238 if test x${ac_cv_prog_gnu_ld+set} != xset; then
239 # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
240 with_gnu_ld=no
241 else
242 with_gnu_ld=$ac_cv_prog_gnu_ld
243 fi
244 fi
245
246 # Start by getting the version number. I think the libtool test already
247 # does some of this, but throws away the result.
248 changequote(,)
249 ldver=`$LD --version 2>/dev/null | head -1 | \
250 sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
251 changequote([,])
3d7c150e 252 glibcxx_gnu_ld_version=`echo $ldver | \
c98b201b
PE
253 $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
254
5bd17d39 255 # Set --gc-sections.
c98b201b 256 if test "$with_gnu_ld" = "notbroken"; then
a9117427 257 # GNU ld it is! Joy and bunny rabbits!
421173e6
PE
258
259 # All these tests are for C++; save the language and the compiler flags.
260 # Need to do this so that g++ won't try to link in libstdc++
261 ac_test_CFLAGS="${CFLAGS+set}"
262 ac_save_CFLAGS="$CFLAGS"
5bd17d39 263 CFLAGS='-x c++ -Wl,--gc-sections'
421173e6
PE
264
265 # Check for -Wl,--gc-sections
ff66d28f
PE
266 # XXX This test is broken at the moment, as symbols required for linking
267 # are now in libsupc++ (not built yet). In addition, this test has
268 # cored on solaris in the past. In addition, --gc-sections doesn't
269 # really work at the moment (keeps on discarding used sections, first
270 # .eh_frame and now some of the glibc sections for iconv).
271 # Bzzzzt. Thanks for playing, maybe next time.
421173e6
PE
272 AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
273 AC_TRY_RUN([
37bc6ca2 274 int main(void)
421173e6 275 {
a9117427
BK
276 try { throw 1; }
277 catch (...) { };
421173e6
PE
278 return 0;
279 }
c0abb59e 280 ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
421173e6
PE
281 if test "$ac_test_CFLAGS" = set; then
282 CFLAGS="$ac_save_CFLAGS"
283 else
284 # this is the suspicious part
285 CFLAGS=''
286 fi
287 if test "$ac_sectionLDflags" = "yes"; then
654421eb 288 SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
421173e6
PE
289 fi
290 AC_MSG_RESULT($ac_sectionLDflags)
5bd17d39 291 fi
a9117427 292
5bd17d39 293 # Set linker optimization flags.
6aa43d99 294 if test x"$with_gnu_ld" = x"yes"; then
654421eb 295 OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
421173e6 296 fi
5bd17d39 297
c470c17d 298 AC_SUBST(SECTION_LDFLAGS)
421173e6 299 AC_SUBST(OPT_LDFLAGS)
c470c17d
BK
300])
301
302
b2dad0e3 303dnl
ff66d28f 304dnl Check to see if this target can enable the wchar_t parts.
8b8ab21c 305dnl If --disable-c-mbchar was given, no wchar_t stuff is enabled. (This
ff66d28f
PE
306dnl must have been previously checked.) By default, wide characters are
307dnl disabled.
b2dad0e3 308dnl
ff66d28f
PE
309dnl Defines:
310dnl HAVE_MBSTATE_T if mbstate_t is not in wchar.h
311dnl _GLIBCXX_USE_WCHAR_T if all the bits are found.
b2dad0e3 312dnl
3d7c150e 313AC_DEFUN(GLIBCXX_CHECK_WCHAR_T_SUPPORT, [
ff66d28f
PE
314 # Test wchar.h for mbstate_t, which is needed for char_traits and
315 # others even if wchar_t support is not on.
7b331228
BK
316 AC_MSG_CHECKING([for mbstate_t])
317 AC_TRY_COMPILE([#include <wchar.h>],
37bc6ca2 318 [mbstate_t teststate;],
7b331228
BK
319 have_mbstate_t=yes, have_mbstate_t=no)
320 AC_MSG_RESULT($have_mbstate_t)
321 if test x"$have_mbstate_t" = xyes; then
322 AC_DEFINE(HAVE_MBSTATE_T)
323 fi
324
ff66d28f 325 # Sanity check for existence of ISO C99 headers for extended encoding.
7b331228 326 AC_CHECK_HEADERS(wchar.h, ac_has_wchar_h=yes, ac_has_wchar_h=no)
31f93f90 327 AC_CHECK_HEADERS(wctype.h, ac_has_wctype_h=yes, ac_has_wctype_h=no)
37bc6ca2 328
ff66d28f 329 # Only continue checking if the ISO C99 headers exist and support is on.
a0cb1aa7
PE
330 if test x"$ac_has_wchar_h" = xyes &&
331 test x"$ac_has_wctype_h" = xyes &&
332 test x"$enable_c_mbchar" != xno; then
37bc6ca2 333
ff66d28f
PE
334 # Test wchar.h for WCHAR_MIN, WCHAR_MAX, which is needed before
335 # numeric_limits can instantiate type_traits<wchar_t>
7b331228
BK
336 AC_MSG_CHECKING([for WCHAR_MIN and WCHAR_MAX])
337 AC_TRY_COMPILE([#include <wchar.h>],
37bc6ca2 338 [int i = WCHAR_MIN; int j = WCHAR_MAX;],
7b331228
BK
339 has_wchar_minmax=yes, has_wchar_minmax=no)
340 AC_MSG_RESULT($has_wchar_minmax)
37bc6ca2 341
ff66d28f
PE
342 # Test wchar.h for WEOF, which is what we use to determine whether
343 # to specialize for char_traits<wchar_t> or not.
7b331228
BK
344 AC_MSG_CHECKING([for WEOF])
345 AC_TRY_COMPILE([
346 #include <wchar.h>
347 #include <stddef.h>],
348 [wint_t i = WEOF;],
349 has_weof=yes, has_weof=no)
350 AC_MSG_RESULT($has_weof)
37bc6ca2 351
ff66d28f 352 # Tests for wide character functions used in char_traits<wchar_t>.
68fe6226 353 ac_wfuncs=yes
ff66d28f
PE
354 AC_CHECK_FUNCS([wcslen wmemchr wmemcmp wmemcpy wmemmove wmemset],
355 [],[ac_wfuncs=no])
37bc6ca2 356
ff66d28f
PE
357 # Checks for names injected into std:: by the c_std headers.
358 AC_CHECK_FUNCS([btowc wctob fgetwc fgetws fputwc fputws fwide \
68fe6226
BK
359 fwprintf fwscanf swprintf swscanf vfwprintf vfwscanf vswprintf vswscanf \
360 vwprintf vwscanf wprintf wscanf getwc getwchar mbsinit mbrlen mbrtowc \
361 mbsrtowcs wcsrtombs putwc putwchar ungetwc wcrtomb wcstod wcstof wcstol \
362 wcstoul wcscpy wcsncpy wcscat wcsncat wcscmp wcscoll wcsncmp wcsxfrm \
ff66d28f
PE
363 wcscspn wcsspn wcstok wcsftime wcschr wcspbrk wcsrchr wcsstr],
364 [],[ac_wfuncs=no])
df7b1359 365
7b331228 366 AC_MSG_CHECKING([for ISO C99 wchar_t support])
a0cb1aa7
PE
367 if test x"$has_weof" = xyes &&
368 test x"$has_wchar_minmax" = xyes &&
ff66d28f
PE
369 test x"$ac_wfuncs" = xyes;
370 then
7b331228
BK
371 ac_isoC99_wchar_t=yes
372 else
373 ac_isoC99_wchar_t=no
374 fi
375 AC_MSG_RESULT($ac_isoC99_wchar_t)
37bc6ca2 376
ff66d28f
PE
377 # Use iconv for wchar_t to char conversions. As such, check for
378 # X/Open Portability Guide, version 2 features (XPG2).
7b331228
BK
379 AC_CHECK_HEADER(iconv.h, ac_has_iconv_h=yes, ac_has_iconv_h=no)
380 AC_CHECK_HEADER(langinfo.h, ac_has_langinfo_h=yes, ac_has_langinfo_h=no)
381
ff66d28f 382 # Check for existence of libiconv.a providing XPG2 wchar_t support.
7b331228
BK
383 AC_CHECK_LIB(iconv, iconv, libiconv="-liconv")
384 ac_save_LIBS="$LIBS"
385 LIBS="$LIBS $libiconv"
386
ff66d28f
PE
387 AC_CHECK_FUNCS([iconv_open iconv_close iconv nl_langinfo],
388 [ac_XPG2funcs=yes], [ac_XPG2funcs=no])
37bc6ca2 389
7b331228 390 LIBS="$ac_save_LIBS"
5b20f7a0 391
7b331228 392 AC_MSG_CHECKING([for XPG2 wchar_t support])
a0cb1aa7
PE
393 if test x"$ac_has_iconv_h" = xyes &&
394 test x"$ac_has_langinfo_h" = xyes &&
ff66d28f
PE
395 test x"$ac_XPG2funcs" = xyes;
396 then
7b331228
BK
397 ac_XPG2_wchar_t=yes
398 else
399 ac_XPG2_wchar_t=no
400 fi
401 AC_MSG_RESULT($ac_XPG2_wchar_t)
37bc6ca2 402
ff66d28f
PE
403 # At the moment, only enable wchar_t specializations if all the
404 # above support is present.
405 if test x"$ac_isoC99_wchar_t" = xyes &&
406 test x"$ac_XPG2_wchar_t" = xyes;
407 then
3d7c150e 408 AC_DEFINE(_GLIBCXX_USE_WCHAR_T)
6b543e86 409 enable_wchar_t=yes
15bcd79a 410 fi
b2dad0e3 411 fi
6b543e86 412 AC_MSG_CHECKING([for enabled wchar_t specializations])
ff66d28f 413 AC_MSG_RESULT($enable_wchar_t)
b2dad0e3
BK
414])
415
416
b2dad0e3 417dnl
ff66d28f
PE
418dnl Check for headers for, and arguments to, the setrlimit() function.
419dnl Used only in testsuite_hooks.h. Called from GLIBCXX_CONFIGURE_TESTSUITE.
6aa43d99 420dnl
ff66d28f
PE
421dnl Defines:
422dnl _GLIBCXX_MEM_LIMITS if we can set artificial limits on memory
423dnl various HAVE_MEMLIMIT_* for individual limit names
6aa43d99 424dnl
ff66d28f
PE
425AC_DEFUN(GLIBCXX_CHECK_SETRLIMIT_ancilliary, [
426 AC_TRY_COMPILE(
427 [#include <unistd.h>
428 #include <sys/time.h>
429 #include <sys/resource.h>
430 ],
431 [ int f = RLIMIT_$1 ; ],
432 [glibcxx_mresult=1], [glibcxx_mresult=0])
433 AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcxx_mresult,
434 [Only used in build directory testsuite_hooks.h.])
435])
436
437AC_DEFUN(GLIBCXX_CHECK_SETRLIMIT, [
438 setrlimit_have_headers=yes
439 AC_CHECK_HEADERS(unistd.h sys/time.h sys/resource.h,
440 [],
441 [setrlimit_have_headers=no])
442 # If don't have the headers, then we can't run the tests now, and we
443 # won't be seeing any of these during testsuite compilation.
444 if test $setrlimit_have_headers = yes; then
445 # Can't do these in a loop, else the resulting syntax is wrong.
446 GLIBCXX_CHECK_SETRLIMIT_ancilliary(DATA)
447 GLIBCXX_CHECK_SETRLIMIT_ancilliary(RSS)
448 GLIBCXX_CHECK_SETRLIMIT_ancilliary(VMEM)
449 GLIBCXX_CHECK_SETRLIMIT_ancilliary(AS)
450
451 # Check for rlimit, setrlimit.
452 AC_CACHE_VAL(ac_setrlimit, [
453 AC_TRY_COMPILE(
454 [#include <unistd.h>
455 #include <sys/time.h>
456 #include <sys/resource.h>
457 ],
458 [struct rlimit r;
459 setrlimit(0, &r);],
460 [ac_setrlimit=yes], [ac_setrlimit=no])
461 ])
462 fi
463
464 AC_MSG_CHECKING([for testsuite memory limit support])
465 if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
466 ac_mem_limits=yes
467 AC_DEFINE(_GLIBCXX_MEM_LIMITS)
468 else
469 ac_mem_limits=no
470 fi
471 AC_MSG_RESULT($ac_mem_limits)
6aa43d99
BK
472])
473
474
6aa43d99 475dnl
ff66d28f
PE
476dnl Check whether S_ISREG (Posix) or S_IFREG is available in <sys/stat.h>.
477dnl Define HAVE_S_ISREG / HAVE_S_IFREG appropriately.
6aa43d99 478dnl
ff66d28f
PE
479AC_DEFUN(GLIBCXX_CHECK_S_ISREG_OR_S_IFREG, [
480 AC_CACHE_VAL(glibcxx_cv_S_ISREG, [
481 AC_TRY_LINK(
482 [#include <sys/stat.h>],
483 [struct stat buffer;
484 fstat(0, &buffer);
485 S_ISREG(buffer.st_mode);],
486 [glibcxx_cv_S_ISREG=yes],
487 [glibcxx_cv_S_ISREG=no])
488 ])
489 AC_CACHE_VAL(glibcxx_cv_S_IFREG, [
490 AC_TRY_LINK(
491 [#include <sys/stat.h>],
492 [struct stat buffer;
493 fstat(0, &buffer);
494 S_IFREG & buffer.st_mode;],
495 [glibcxx_cv_S_IFREG=yes],
496 [glibcxx_cv_S_IFREG=no])
497 ])
498 if test $glibcxx_cv_S_ISREG = yes; then
499 AC_DEFINE(HAVE_S_ISREG)
500 elif test $glibcxx_cv_S_IFREG = yes; then
501 AC_DEFINE(HAVE_S_IFREG)
502 fi
b2dad0e3
BK
503])
504
505
dcfa0bc8 506dnl
ff66d28f 507dnl Check whether poll is available in <poll.h>, and define HAVE_POLL.
dcfa0bc8 508dnl
ff66d28f
PE
509AC_DEFUN(GLIBCXX_CHECK_POLL, [
510 AC_CACHE_VAL(glibcxx_cv_POLL, [
511 AC_TRY_COMPILE(
512 [#include <poll.h>],
513 [struct pollfd pfd[1];
514 pfd[0].events = POLLIN;
515 poll(pfd, 1, 0);],
516 [glibcxx_cv_POLL=yes],
517 [glibcxx_cv_POLL=no])
518 ])
519 if test $glibcxx_cv_POLL = yes; then
520 AC_DEFINE(HAVE_POLL)
521 fi
522])
523
524
525dnl
526dnl Check whether writev is available in <sys/uio.h>, and define HAVE_WRITEV.
527dnl
528AC_DEFUN(GLIBCXX_CHECK_WRITEV, [
529 AC_CACHE_VAL(glibcxx_cv_WRITEV, [
530 AC_TRY_COMPILE(
531 [#include <sys/uio.h>],
532 [struct iovec iov[2];
533 writev(0, iov, 0);],
534 [glibcxx_cv_WRITEV=yes],
535 [glibcxx_cv_WRITEV=no])
536 ])
537 if test $glibcxx_cv_WRITEV = yes; then
538 AC_DEFINE(HAVE_WRITEV)
539 fi
540])
541
542
543dnl
544dnl Does any necessary configuration of the testsuite directory. Generates
545dnl the testsuite_hooks.h header.
546dnl
547dnl GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE must be done before this.
548dnl
549dnl Sets:
550dnl enable_abi_check / GLIBCXX_TEST_ABI
551dnl Substs:
552dnl baseline_dir
553dnl
554AC_DEFUN(GLIBCXX_CONFIGURE_TESTSUITE, [
555 if $GLIBCXX_IS_NATIVE; then
556 # Do checks for memory limit functions.
557 GLIBCXX_CHECK_SETRLIMIT
558
559 # Look for setenv, so that extended locale tests can be performed.
560 GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv)
561 fi
562
563 # Export file names for ABI checking.
564 baseline_dir="$glibcxx_srcdir/config/abi/${abi_baseline_pair}\$(MULTISUBDIR)"
565 AC_SUBST(baseline_dir)
566
567 # Determine if checking the ABI is desirable.
568 if test $enable_symvers = no; then
569 enable_abi_check=no
570 else
571 case "$host" in
572 *-*-cygwin*)
573 enable_abi_check=no ;;
574 *)
575 enable_abi_check=yes ;;
974e336b 576 esac
ff66d28f
PE
577 fi
578
579 AM_CONDITIONAL(GLIBCXX_TEST_WCHAR_T, test $enable_wchar_t = yes)
580 AM_CONDITIONAL(GLIBCXX_TEST_ABI, test $enable_abi_check = yes)
581])
582
583
584dnl
585dnl Set up *_INCLUDES variables for all sundry Makefile.am's.
586dnl
587dnl Substs:
588dnl GLIBCXX_INCLUDES
589dnl TOPLEVEL_INCLUDES
590dnl LIBMATH_INCLUDES
591dnl LIBSUPCXX_INCLUDES
592dnl
593AC_DEFUN(GLIBCXX_EXPORT_INCLUDES, [
594 # Root level of the build directory include sources.
595 GLIBCXX_INCLUDES="-I$glibcxx_builddir/include/$host_alias -I$glibcxx_builddir/include"
596
597 # Passed down for canadian crosses.
598 if test $CANADIAN = yes; then
599 TOPLEVEL_INCLUDES='-I${includedir}'
600 fi
601
602 LIBMATH_INCLUDES='-I${glibcxx_srcdir}/libmath'
603
604 LIBSUPCXX_INCLUDES='-I${glibcxx_srcdir}/libsupc++'
605
606 # Now, export this to all the little Makefiles....
607 AC_SUBST(GLIBCXX_INCLUDES)
608 AC_SUBST(TOPLEVEL_INCLUDES)
609 AC_SUBST(LIBMATH_INCLUDES)
610 AC_SUBST(LIBSUPCXX_INCLUDES)
611])
612
613
614dnl
615dnl Set up *_FLAGS and *FLAGS variables for all sundry Makefile.am's.
616dnl (SECTION_FLAGS is done under CHECK_COMPILER_FEATURES.)
617dnl
618dnl Substs:
619dnl OPTIMIZE_CXXFLAGS
620dnl WARN_FLAGS
621dnl
622AC_DEFUN(GLIBCXX_EXPORT_FLAGS, [
623 # Optimization flags that are probably a good idea for thrill-seekers. Just
624 # uncomment the lines below and make, everything else is ready to go...
625 # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
626 OPTIMIZE_CXXFLAGS=
627 AC_SUBST(OPTIMIZE_CXXFLAGS)
628
629 WARN_FLAGS='-Wall -Wno-format -W -Wwrite-strings'
630 AC_SUBST(WARN_FLAGS)
631])
632
633
634dnl
635dnl All installation directory information is determined here.
636dnl
637dnl Substs:
638dnl gxx_install_dir
639dnl glibcxx_prefixdir
640dnl glibcxx_toolexecdir
641dnl glibcxx_toolexeclibdir
642dnl
643dnl Assumes cross_compiling bits already done, and with_cross_host in
644dnl particular.
645dnl
646AC_DEFUN(GLIBCXX_EXPORT_INSTALL_INFO, [
647 glibcxx_toolexecdir=no
648 glibcxx_toolexeclibdir=no
649 glibcxx_prefixdir=$prefix
650
651 AC_MSG_CHECKING([for gxx-include-dir])
652 AC_ARG_WITH([gxx-include-dir],
653 AC_HELP_STRING([--with-gxx-include-dir=DIR],
654 [installation directory for include files]),
655 [case "$withval" in
656 yes) AC_MSG_ERROR([Missing directory for --with-gxx-include-dir]) ;;
657 no) gxx_include_dir=no ;;
658 *) gxx_include_dir=$withval ;;
659 esac],
660 [gxx_include_dir=no])
661 AC_MSG_RESULT($gxx_include_dir)
662
663 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
664 AC_ARG_ENABLE([version-specific-runtime-libs],
665 AC_HELP_STRING([--enable-version-specific-runtime-libs],
666 [Specify that runtime libraries should be installed in a compiler-specific directory]),
667 [case "$enableval" in
668 yes) version_specific_libs=yes ;;
669 no) version_specific_libs=no ;;
670 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
671 esac],
672 [version_specific_libs=no])
673 AC_MSG_RESULT($version_specific_libs)
674
675 # Default case for install directory for include files.
676 if test $version_specific_libs = no && test $gxx_include_dir = no; then
677 gxx_include_dir='${prefix}'/include/c++/${gcc_version}
678 fi
679
680 # Version-specific runtime libs processing.
681 if test $version_specific_libs = yes; then
682 # Need the gcc compiler version to know where to install libraries
683 # and header files if --enable-version-specific-runtime-libs option
684 # is selected.
685 if test x"$gxx_include_dir" = x"no"; then
686 gxx_include_dir='$libdir/gcc-lib/$host_alias/'$gcc_version/include/c++
687 fi
688 glibcxx_toolexecdir='$libdir/gcc-lib/$host_alias'
689 glibcxx_toolexeclibdir='$toolexecdir/'$gcc_version'$(MULTISUBDIR)'
690 fi
691
692 # Calculate glibcxx_toolexecdir, glibcxx_toolexeclibdir
693 # Install a library built with a cross compiler in tooldir, not libdir.
694 if test x"$glibcxx_toolexecdir" = x"no"; then
695 if test -n "$with_cross_host" &&
696 test x"$with_cross_host" != x"no"; then
697 glibcxx_toolexecdir='$(exec_prefix)/$(host_alias)'
698 glibcxx_toolexeclibdir='$(toolexecdir)/lib'
699 else
700 glibcxx_toolexecdir='$(libdir)/gcc-lib/$(host_alias)'
701 glibcxx_toolexeclibdir='$(libdir)'
702 fi
703 multi_os_directory=`$CC -print-multi-os-directory`
704 case $multi_os_directory in
705 .) ;; # Avoid trailing /.
706 *) glibcxx_toolexeclibdir=$glibcxx_toolexeclibdir/$multi_os_directory ;;
707 esac
708 fi
709
710 AC_MSG_CHECKING([for install location])
711 AC_MSG_RESULT($gxx_include_dir)
712
713 AC_SUBST(glibcxx_prefixdir)
714 AC_SUBST(gxx_include_dir)
715 AC_SUBST(glibcxx_toolexecdir)
716 AC_SUBST(glibcxx_toolexeclibdir)
717])
718
719
720dnl
721dnl GLIBCXX_ENABLE
722dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
723dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
724dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
725dnl
726dnl See docs/html/17_intro/configury.html#enable for documentation.
727dnl
728m4_define([GLIBCXX_ENABLE],[dnl
729m4_define([_g_switch],[--enable-$1])dnl
730m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
731 AC_ARG_ENABLE($1,_g_help,
732 m4_bmatch([$5],
733 [^permit ],
734 [[
735 case "$enableval" in
736 m4_bpatsubst([$5],[permit ])) ;;
737 *) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
738 dnl Idea for future: generate a URL pointing to
739 dnl "onlinedocs/configopts.html#whatever"
740 esac
741 ]],
742 [^$],
743 [[
744 case "$enableval" in
745 yes|no) ;;
746 *) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
747 esac
748 ]],
749 [[$5]]),
750 [enable_]m4_bpatsubst([$1],-,_)[=][$2])
751m4_undefine([_g_switch])dnl
752m4_undefine([_g_help])dnl
753])
754
755
756dnl
757dnl Check for ISO/IEC 9899:1999 "C99" support.
758dnl
759dnl --enable-c99 defines _GLIBCXX_USE_C99
760dnl --disable-c99 leaves _GLIBCXX_USE_C99 undefined
761dnl + Usage: GLIBCXX_ENABLE_C99[(DEFAULT)]
762dnl Where DEFAULT is either `yes' or `no'.
763dnl + If 'C99' stuff is not available, ignores DEFAULT and sets `no'.
764dnl
765AC_DEFUN(GLIBCXX_ENABLE_C99, [
766 GLIBCXX_ENABLE(c99,$1,,[turns on ISO/IEC 9899:1999 support])
767
768 AC_LANG_SAVE
769 AC_LANG_CPLUSPLUS
770
771 # Check for the existence of <math.h> functions used if C99 is enabled.
772 ac_c99_math=yes;
773 AC_MSG_CHECKING([for ISO C99 support in <math.h>])
774 AC_TRY_COMPILE([#include <math.h>],[fpclassify(0.0);],, [ac_c99_math=no])
775 AC_TRY_COMPILE([#include <math.h>],[isfinite(0.0);],, [ac_c99_math=no])
776 AC_TRY_COMPILE([#include <math.h>],[isinf(0.0);],, [ac_c99_math=no])
777 AC_TRY_COMPILE([#include <math.h>],[isnan(0.0);],, [ac_c99_math=no])
778 AC_TRY_COMPILE([#include <math.h>],[isnormal(0.0);],, [ac_c99_math=no])
779 AC_TRY_COMPILE([#include <math.h>],[signbit(0.0);],, [ac_c99_math=no])
780 AC_TRY_COMPILE([#include <math.h>],[isgreater(0.0,0.0);],, [ac_c99_math=no])
781 AC_TRY_COMPILE([#include <math.h>],
782 [isgreaterequal(0.0,0.0);],, [ac_c99_math=no])
783 AC_TRY_COMPILE([#include <math.h>],[isless(0.0,0.0);],, [ac_c99_math=no])
784 AC_TRY_COMPILE([#include <math.h>],[islessequal(0.0,0.0);],,[ac_c99_math=no])
785 AC_TRY_COMPILE([#include <math.h>],
786 [islessgreater(0.0,0.0);],, [ac_c99_math=no])
787 AC_TRY_COMPILE([#include <math.h>],
788 [isunordered(0.0,0.0);],, [ac_c99_math=no])
789 AC_MSG_RESULT($ac_c99_math)
790
791 # Check for the existence in <stdio.h> of vscanf, et. al.
792 ac_c99_stdio=yes;
793 AC_MSG_CHECKING([for ISO C99 support in <stdio.h>])
794 AC_TRY_COMPILE([#include <stdio.h>],
795 [snprintf("12", 0, "%i");],, [ac_c99_stdio=no])
796 AC_TRY_COMPILE([#include <stdio.h>
797 #include <stdarg.h>
798 void foo(char* fmt, ...)
799 {va_list args; va_start(args, fmt);
800 vfscanf(stderr, "%i", args);}],
801 [],, [ac_c99_stdio=no])
802 AC_TRY_COMPILE([#include <stdio.h>
803 #include <stdarg.h>
804 void foo(char* fmt, ...)
805 {va_list args; va_start(args, fmt);
806 vscanf("%i", args);}],
807 [],, [ac_c99_stdio=no])
808 AC_TRY_COMPILE([#include <stdio.h>
809 #include <stdarg.h>
810 void foo(char* fmt, ...)
811 {va_list args; va_start(args, fmt);
812 vsnprintf(fmt, 0, "%i", args);}],
813 [],, [ac_c99_stdio=no])
814 AC_TRY_COMPILE([#include <stdio.h>
815 #include <stdarg.h>
816 void foo(char* fmt, ...)
817 {va_list args; va_start(args, fmt);
818 vsscanf(fmt, "%i", args);}],
819 [],, [ac_c99_stdio=no])
820 AC_MSG_RESULT($ac_c99_stdio)
821
822 # Check for the existence in <stdlib.h> of lldiv_t, et. al.
823 ac_c99_stdlib=yes;
824 AC_MSG_CHECKING([for lldiv_t declaration])
825 AC_CACHE_VAL(ac_c99_lldiv_t, [
826 AC_TRY_COMPILE([#include <stdlib.h>],
827 [ lldiv_t mydivt;],
828 [ac_c99_lldiv_t=yes], [ac_c99_lldiv_t=no])
829 ])
830 AC_MSG_RESULT($ac_c99_lldiv_t)
831
832 AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
833 AC_TRY_COMPILE([#include <stdlib.h>],
834 [char* tmp; strtof("gnu", &tmp);],, [ac_c99_stdlib=no])
835 AC_TRY_COMPILE([#include <stdlib.h>],
836 [char* tmp; strtold("gnu", &tmp);],, [ac_c99_stdlib=no])
837 AC_TRY_COMPILE([#include <stdlib.h>], [llabs(10);],, [ac_c99_stdlib=no])
838 AC_TRY_COMPILE([#include <stdlib.h>], [lldiv(10,1);],, [ac_c99_stdlib=no])
839 AC_TRY_COMPILE([#include <stdlib.h>], [atoll("10");],, [ac_c99_stdlib=no])
840 AC_TRY_COMPILE([#include <stdlib.h>], [_Exit(0);],, [ac_c99_stdlib=no])
841 if test x"$ac_c99_lldiv_t" = x"no"; then
842 ac_c99_stdlib=no;
843 fi;
844 AC_MSG_RESULT($ac_c99_stdlib)
845
846 # Check for the existence of <wchar.h> functions used if C99 is enabled.
847 # XXX the wchar.h checks should be rolled into the general C99 bits.
848 ac_c99_wchar=yes;
849 AC_MSG_CHECKING([for additional ISO C99 support in <wchar.h>])
850 AC_TRY_COMPILE([#include <wchar.h>],
851 [wcstold(L"10.0", NULL);],, [ac_c99_wchar=no])
852 AC_TRY_COMPILE([#include <wchar.h>],
853 [wcstoll(L"10", NULL, 10);],, [ac_c99_wchar=no])
854 AC_TRY_COMPILE([#include <wchar.h>],
855 [wcstoull(L"10", NULL, 10);],, [ac_c99_wchar=no])
856 AC_MSG_RESULT($ac_c99_wchar)
857
858 AC_MSG_CHECKING([for enabled ISO C99 support])
859 if test x"$ac_c99_math" = x"no" ||
860 test x"$ac_c99_stdio" = x"no" ||
861 test x"$ac_c99_stdlib" = x"no" ||
862 test x"$ac_c99_wchar" = x"no"; then
863 enable_c99=no;
864 fi;
865 AC_MSG_RESULT($enable_c99)
866
867 # Option parsed, now set things appropriately
868 if test x"$enable_c99" = x"yes"; then
869 AC_DEFINE(_GLIBCXX_USE_C99)
870 fi
871
872 AC_LANG_RESTORE
dcfa0bc8
PE
873])
874
875
0214010c 876dnl
ff66d28f
PE
877dnl Check for what type of C headers to use.
878dnl
879dnl --enable-cheaders= [does stuff].
880dnl --disable-cheaders [does not do anything, really].
881dnl + Usage: GLIBCXX_ENABLE_CHEADERS[(DEFAULT)]
882dnl Where DEFAULT is either `c' or `c_std'.
883dnl
884AC_DEFUN(GLIBCXX_ENABLE_CHEADERS, [
885 GLIBCXX_ENABLE(cheaders,$1,[=KIND],
886 [construct "C" headers for g++], [permit c|c_std])
887 AC_MSG_NOTICE("C" header strategy set to $enable_cheaders)
888
889 C_INCLUDE_DIR='${glibcxx_srcdir}/include/'$enable_cheaders
890
891 AC_SUBST(C_INCLUDE_DIR)
892 AM_CONDITIONAL(GLIBCXX_C_HEADERS_C, test $enable_cheaders = c)
893 AM_CONDITIONAL(GLIBCXX_C_HEADERS_C_STD, test $enable_cheaders = c_std)
894 AM_CONDITIONAL(GLIBCXX_C_HEADERS_COMPATIBILITY, test $c_compatibility = yes)
895])
896
897
0214010c 898dnl
ff66d28f
PE
899dnl Check for which locale library to use. The choice is mapped to
900dnl a subdirectory of config/locale.
37bc6ca2 901dnl
ff66d28f 902dnl Default is generic.
0214010c 903dnl
3d7c150e 904AC_DEFUN(GLIBCXX_ENABLE_CLOCALE, [
ff66d28f
PE
905 AC_MSG_CHECKING([for C locale to use])
906 GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
907 [use MODEL for target locale package],
908 [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
909
910 # If they didn't use this option switch, or if they specified --enable
911 # with no specific model, we'll have to look for one. If they
912 # specified --disable (???), do likewise.
913 if test $enable_clocale = no || test $enable_clocale = yes; then
914 enable_clocale=auto
915 fi
0214010c 916
ff66d28f 917 # Either a known package, or "auto"
0214010c
BK
918 enable_clocale_flag=$enable_clocale
919
ff66d28f
PE
920 # Probe for locale support if no specific model is specified.
921 # Default to "generic".
922 if test $enable_clocale_flag = auto; then
56deb74c
BK
923 case x${target_os} in
924 xlinux* | xgnu*)
ff66d28f 925 AC_EGREP_CPP([_GLIBCXX_ok], [
56deb74c 926 #include <features.h>
37bc6ca2 927 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
3d7c150e 928 _GLIBCXX_ok
56deb74c
BK
929 #endif
930 ], enable_clocale_flag=gnu, enable_clocale_flag=generic)
1451a492 931
ff66d28f
PE
932 # Test for bugs early in glibc-2.2.x series
933 if test x$enable_clocale_flag = xgnu; then
934 AC_TRY_RUN([
935 #define _GNU_SOURCE 1
936 #include <locale.h>
937 #include <string.h>
938 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
939 extern __typeof(newlocale) __newlocale;
940 extern __typeof(duplocale) __duplocale;
941 extern __typeof(strcoll_l) __strcoll_l;
942 #endif
943 int main()
944 {
945