| 1 |
dnl acinclude.m4 |
| 2 |
dnl |
| 3 |
dnl This file was derived from libstdc++-v3/acinclude.m4 and heavily pruned. |
| 4 |
dnl Its purpose is to check for glibc time, gettimeofday and |
| 5 |
dnl float128 availability. |
| 6 |
dnl |
| 7 |
dnl GLIBCXX_CONDITIONAL (NAME, SHELL-TEST) |
| 8 |
dnl |
| 9 |
dnl Exactly like AM_CONDITIONAL, but delays evaluation of the test until the |
| 10 |
dnl end of configure. This lets tested variables be reassigned, and the |
| 11 |
dnl conditional will depend on the final state of the variable. For a simple |
| 12 |
dnl example of why this is needed, see GLIBCXX_ENABLE_HOSTED. |
| 13 |
dnl |
| 14 |
m4_define([_m4_divert(glibcxx_diversion)], 8000)dnl |
| 15 |
AC_DEFUN([GLIBCXX_CONDITIONAL], [dnl |
| 16 |
m4_divert_text([glibcxx_diversion],dnl |
| 17 |
AM_CONDITIONAL([$1],[$2]) |
| 18 |
)dnl |
| 19 |
])dnl |
| 20 |
AC_DEFUN([GLIBCXX_EVALUATE_CONDITIONALS], [m4_undivert([glibcxx_diversion])])dnl |
| 21 |
|
| 22 |
|
| 23 |
dnl |
| 24 |
dnl Check to see what architecture and operating system we are compiling |
| 25 |
dnl for. Also, if architecture- or OS-specific flags are required for |
| 26 |
dnl compilation, pick them up here. |
| 27 |
dnl |
| 28 |
AC_DEFUN([GLIBCXX_CHECK_HOST], [ |
| 29 |
. $glibcxx_srcdir/configure.host |
| 30 |
AC_MSG_NOTICE([CPU config directory is $cpu_include_dir]) |
| 31 |
AC_MSG_NOTICE([OS config directory is $os_include_dir]) |
| 32 |
]) |
| 33 |
|
| 34 |
|
| 35 |
dnl |
| 36 |
dnl Initialize the rest of the library configury. At this point we have |
| 37 |
dnl variables like $host. |
| 38 |
dnl |
| 39 |
dnl Sets: |
| 40 |
dnl SUBDIRS |
| 41 |
dnl Substs: |
| 42 |
dnl glibcxx_builddir (absolute path) |
| 43 |
dnl glibcxx_srcdir (absolute path) |
| 44 |
dnl toplevel_builddir (absolute path) |
| 45 |
dnl toplevel_srcdir (absolute path) |
| 46 |
dnl with_cross_host |
| 47 |
dnl with_newlib |
| 48 |
dnl with_target_subdir |
| 49 |
dnl plus |
| 50 |
dnl - the variables in GLIBCXX_CHECK_HOST / configure.host |
| 51 |
dnl - default settings for all AM_CONFITIONAL test variables |
| 52 |
dnl - lots of tools, like CC and CXX |
| 53 |
dnl |
| 54 |
AC_DEFUN([GLIBCXX_CONFIGURE], [ |
| 55 |
# Keep these sync'd with the list in Makefile.am. The first provides an |
| 56 |
# expandable list at autoconf time; the second provides an expandable list |
| 57 |
# (i.e., shell variable) at configure time. |
| 58 |
m4_define([glibcxx_SUBDIRS],[]) |
| 59 |
SUBDIRS='glibcxx_SUBDIRS' |
| 60 |
|
| 61 |
# These need to be absolute paths, yet at the same time need to |
| 62 |
# canonicalize only relative paths, because then amd will not unmount |
| 63 |
# drives. Thus the use of PWDCMD: set it to 'pawd' or 'amq -w' if using amd. |
| 64 |
glibcxx_builddir=`${PWDCMD-pwd}` |
| 65 |
case $srcdir in |
| 66 |
[\\/$]* | ?:[\\/]*) glibcxx_srcdir=${srcdir} ;; |
| 67 |
*) glibcxx_srcdir=`cd "$srcdir" && ${PWDCMD-pwd} || echo "$srcdir"` ;; |
| 68 |
esac |
| 69 |
toplevel_builddir=${glibcxx_builddir}/.. |
| 70 |
toplevel_srcdir=${glibcxx_srcdir}/.. |
| 71 |
AC_SUBST(glibcxx_builddir) |
| 72 |
AC_SUBST(glibcxx_srcdir) |
| 73 |
AC_SUBST(toplevel_builddir) |
| 74 |
AC_SUBST(toplevel_srcdir) |
| 75 |
|
| 76 |
# We use these options to decide which functions to include. They are |
| 77 |
# set from the top level. |
| 78 |
AC_ARG_WITH([target-subdir], |
| 79 |
AC_HELP_STRING([--with-target-subdir=SUBDIR], |
| 80 |
[configuring in a subdirectory])) |
| 81 |
|
| 82 |
AC_ARG_WITH([cross-host], |
| 83 |
AC_HELP_STRING([--with-cross-host=HOST], |
| 84 |
[configuring with a cross compiler])) |
| 85 |
|
| 86 |
AC_ARG_WITH([newlib], |
| 87 |
AC_HELP_STRING([--with-newlib], |
| 88 |
[assume newlib as a system C library])) |
| 89 |
|
| 90 |
# Will set LN_S to either 'ln -s', 'ln', or 'cp -p' (if linking isn't |
| 91 |
# available). Uncomment the next line to force a particular method. |
| 92 |
AC_PROG_LN_S |
| 93 |
#LN_S='cp -p' |
| 94 |
|
| 95 |
AC_CHECK_TOOL(AS, as) |
| 96 |
AC_CHECK_TOOL(AR, ar) |
| 97 |
AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error) |
| 98 |
|
| 99 |
AM_MAINTAINER_MODE |
| 100 |
|
| 101 |
# Set up safe default values for all subsequent AM_CONDITIONAL tests |
| 102 |
# which are themselves conditionally expanded. |
| 103 |
## (Right now, this only matters for enable_wchar_t, but nothing prevents |
| 104 |
## other macros from doing the same. This should be automated.) -pme |
| 105 |
|
| 106 |
# Check for C library flavor since GNU/Linux platforms use different |
| 107 |
# configuration directories depending on the C library in use. |
| 108 |
AC_EGREP_CPP([_using_uclibc], [ |
| 109 |
#include <stdio.h> |
| 110 |
#if __UCLIBC__ |
| 111 |
_using_uclibc |
| 112 |
#endif |
| 113 |
], uclibc=yes, uclibc=no) |
| 114 |
|
| 115 |
AC_EGREP_CPP([_using_bionic], [ |
| 116 |
#include <stdio.h> |
| 117 |
#if __BIONIC__ |
| 118 |
_using_bionic |
| 119 |
#endif |
| 120 |
], bionic=yes, bionic=no) |
| 121 |
|
| 122 |
# Find platform-specific directories containing configuration info. |
| 123 |
# Also possibly modify flags used elsewhere, as needed by the platform. |
| 124 |
GLIBCXX_CHECK_HOST |
| 125 |
]) |
| 126 |
|
| 127 |
|
| 128 |
dnl |
| 129 |
dnl GLIBCXX_ENABLE |
| 130 |
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING) |
| 131 |
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c) |
| 132 |
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER) |
| 133 |
dnl |
| 134 |
dnl See manual/appendix_porting.html#appendix.porting.build_hacking for |
| 135 |
dnl documentation. |
| 136 |
dnl |
| 137 |
m4_define([GLIBCXX_ENABLE],[dnl |
| 138 |
m4_define([_g_switch],[--enable-$1])dnl |
| 139 |
m4_define([_g_help],[AC_HELP_STRING([_g_switch$3],[$4 @<:@default=$2@:>@])])dnl |
| 140 |
AC_ARG_ENABLE([$1],m4_dquote(_g_help), |
| 141 |
m4_bmatch([$5], |
| 142 |
[^permit ], |
| 143 |
[[ |
| 144 |
case "$enableval" in |
| 145 |
m4_bpatsubst([$5],[permit ])) ;; |
| 146 |
*) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;; |
| 147 |
dnl Idea for future: generate a URL pointing to |
| 148 |
dnl "onlinedocs/configopts.html#whatever" |
| 149 |
esac |
| 150 |
]], |
| 151 |
[^$], |
| 152 |
[[ |
| 153 |
case "$enableval" in |
| 154 |
yes|no) ;; |
| 155 |
*) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;; |
| 156 |
esac |
| 157 |
]], |
| 158 |
[[$5]]), |
| 159 |
[enable_]m4_bpatsubst([$1],-,_)[=][$2]) |
| 160 |
m4_undefine([_g_switch])dnl |
| 161 |
m4_undefine([_g_help])dnl |
| 162 |
]) |
| 163 |
|
| 164 |
|
| 165 |
dnl |
| 166 |
dnl Check for clock_gettime, nanosleep and sched_yield, used in the |
| 167 |
dnl implementation of 20.11.7 [time.clock], and 30.3.2 [thread.thread.this] |
| 168 |
dnl in the C++11 standard. |
| 169 |
dnl |
| 170 |
dnl --enable-libstdcxx-time |
| 171 |
dnl --enable-libstdcxx-time=yes |
| 172 |
dnl checks for the availability of monotonic and realtime clocks, |
| 173 |
dnl nanosleep and sched_yield in libc. |
| 174 |
dnl --enable-libstdcxx-time=rt |
| 175 |
dnl also searches (and, if needed, links) librt. Note that this is |
| 176 |
dnl not always desirable because, in glibc 2.16 and earlier, for |
| 177 |
dnl example, in turn it triggers the linking of libpthread too, |
| 178 |
dnl which activates locking, |
| 179 |
dnl a large overhead for single-thread programs. |
| 180 |
dnl --enable-libstdcxx-time=no |
| 181 |
dnl --disable-libstdcxx-time |
| 182 |
dnl disables the checks completely |
| 183 |
dnl |
| 184 |
dnl N.B. Darwin provides nanosleep but doesn't support the whole POSIX |
| 185 |
dnl Timers option, so doesn't define _POSIX_TIMERS. Because the test |
| 186 |
dnl below fails Darwin unconditionally defines _GLIBCXX_USE_NANOSLEEP in |
| 187 |
dnl os_defines.h and also defines _GLIBCXX_USE_SCHED_YIELD. |
| 188 |
dnl |
| 189 |
dnl needed |
| 190 |
AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_TIME], [ |
| 191 |
|
| 192 |
GLIBCXX_ENABLE(libstdcxx-time,auto,[[[=KIND]]], |
| 193 |
[use KIND for check type], |
| 194 |
[permit yes|no|rt]) |
| 195 |
|
| 196 |
AC_LANG_SAVE |
| 197 |
AC_LANG_CPLUSPLUS |
| 198 |
ac_save_CXXFLAGS="$CXXFLAGS" |
| 199 |
CXXFLAGS="$CXXFLAGS -fno-exceptions" |
| 200 |
ac_save_LIBS="$LIBS" |
| 201 |
|
| 202 |
ac_has_clock_monotonic=no |
| 203 |
ac_has_clock_realtime=no |
| 204 |
ac_has_nanosleep=no |
| 205 |
ac_has_sched_yield=no |
| 206 |
|
| 207 |
if test x"$enable_libstdcxx_time" = x"auto"; then |
| 208 |
|
| 209 |
case "${target_os}" in |
| 210 |
cygwin*) |
| 211 |
ac_has_nanosleep=yes |
| 212 |
;; |
| 213 |
mingw*) |
| 214 |
ac_has_win32_sleep=yes |
| 215 |
ac_has_sched_yield=yes |
| 216 |
;; |
| 217 |
darwin*) |
| 218 |
ac_has_nanosleep=yes |
| 219 |
ac_has_sched_yield=yes |
| 220 |
;; |
| 221 |
# VxWorks has nanosleep as soon as the kernel is configured with |
| 222 |
# INCLUDE_POSIX_TIMERS, which is normally/most-often the case. |
| 223 |
vxworks*) |
| 224 |
ac_has_nanosleep=yes |
| 225 |
;; |
| 226 |
gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) |
| 227 |
# Don't use link test for freestanding library, in case gcc_no_link=yes |
| 228 |
if test x"$is_hosted" = xyes; then |
| 229 |
# Versions of glibc before 2.17 needed -lrt for clock_gettime. |
| 230 |
AC_SEARCH_LIBS(clock_gettime, [rt]) |
| 231 |
if test x"$ac_cv_search_clock_gettime" = x"none required"; then |
| 232 |
ac_has_clock_monotonic=yes |
| 233 |
ac_has_clock_realtime=yes |
| 234 |
fi |
| 235 |
fi |
| 236 |
ac_has_nanosleep=yes |
| 237 |
ac_has_sched_yield=yes |
| 238 |
;; |
| 239 |
freebsd*|netbsd*|dragonfly*|rtems*) |
| 240 |
ac_has_clock_monotonic=yes |
| 241 |
ac_has_clock_realtime=yes |
| 242 |
ac_has_nanosleep=yes |
| 243 |
ac_has_sched_yield=yes |
| 244 |
;; |
| 245 |
openbsd*) |
| 246 |
ac_has_clock_monotonic=yes |
| 247 |
ac_has_clock_realtime=yes |
| 248 |
ac_has_nanosleep=yes |
| 249 |
;; |
| 250 |
solaris*) |
| 251 |
ac_has_clock_monotonic=yes |
| 252 |
ac_has_clock_realtime=yes |
| 253 |
ac_has_nanosleep=yes |
| 254 |
ac_has_sched_yield=yes |
| 255 |
;; |
| 256 |
uclinux*) |
| 257 |
ac_has_nanosleep=yes |
| 258 |
ac_has_sched_yield=yes |
| 259 |
esac |
| 260 |
|
| 261 |
elif test x"$enable_libstdcxx_time" != x"no"; then |
| 262 |
|
| 263 |
if test x"$enable_libstdcxx_time" = x"rt"; then |
| 264 |
AC_SEARCH_LIBS(clock_gettime, [rt]) |
| 265 |
AC_SEARCH_LIBS(nanosleep, [rt]) |
| 266 |
else |
| 267 |
AC_CHECK_FUNC(clock_gettime) |
| 268 |
AC_CHECK_FUNC(nanosleep) |
| 269 |
fi |
| 270 |
|
| 271 |
case "$ac_cv_search_clock_gettime" in |
| 272 |
-l*) GLIBCXX_LIBS=$ac_cv_search_clock_gettime |
| 273 |
;; |
| 274 |
esac |
| 275 |
case "$ac_cv_search_nanosleep" in |
| 276 |
-l*) GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_nanosleep" |
| 277 |
;; |
| 278 |
esac |
| 279 |
|
| 280 |
AC_SEARCH_LIBS(sched_yield, [rt]) |
| 281 |
|
| 282 |
case "$ac_cv_search_sched_yield" in |
| 283 |
-lrt*) |
| 284 |
if test x"$enable_libstdcxx_time" = x"rt"; then |
| 285 |
GLIBCXX_LIBS="$GLIBCXX_LIBS $ac_cv_search_sched_yield" |
| 286 |
ac_has_sched_yield=yes |
| 287 |
fi |
| 288 |
;; |
| 289 |
*) |
| 290 |
ac_has_sched_yield=yes |
| 291 |
;; |
| 292 |
esac |
| 293 |
|
| 294 |
AC_CHECK_HEADERS(unistd.h, ac_has_unistd_h=yes, ac_has_unistd_h=no) |
| 295 |
|
| 296 |
if test x"$ac_has_unistd_h" = x"yes"; then |
| 297 |
AC_MSG_CHECKING([for monotonic clock]) |
| 298 |
AC_TRY_LINK( |
| 299 |
[#include <unistd.h> |
| 300 |
#include <time.h> |
| 301 |
], |
| 302 |
[#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) |
| 303 |
timespec tp; |
| 304 |
#endif |
| 305 |
clock_gettime(CLOCK_MONOTONIC, &tp); |
| 306 |
], [ac_has_clock_monotonic=yes], [ac_has_clock_monotonic=no]) |
| 307 |
|
| 308 |
AC_MSG_RESULT($ac_has_clock_monotonic) |
| 309 |
|
| 310 |
AC_MSG_CHECKING([for realtime clock]) |
| 311 |
AC_TRY_LINK( |
| 312 |
[#include <unistd.h> |
| 313 |
#include <time.h> |
| 314 |
], |
| 315 |
[#if _POSIX_TIMERS > 0 |
| 316 |
timespec tp; |
| 317 |
#endif |
| 318 |
clock_gettime(CLOCK_REALTIME, &tp); |
| 319 |
], [ac_has_clock_realtime=yes], [ac_has_clock_realtime=no]) |
| 320 |
|
| 321 |
AC_MSG_RESULT($ac_has_clock_realtime) |
| 322 |
|
| 323 |
AC_MSG_CHECKING([for nanosleep]) |
| 324 |
AC_TRY_LINK( |
| 325 |
[#include <unistd.h> |
| 326 |
#include <time.h> |
| 327 |
], |
| 328 |
[#if _POSIX_TIMERS > 0 |
| 329 |
timespec tp; |
| 330 |
#endif |
| 331 |
nanosleep(&tp, 0); |
| 332 |
], [ac_has_nanosleep=yes], [ac_has_nanosleep=no]) |
| 333 |
|
| 334 |
AC_MSG_RESULT($ac_has_nanosleep) |
| 335 |
fi |
| 336 |
fi |
| 337 |
|
| 338 |
if test x"$ac_has_clock_monotonic" != x"yes"; then |
| 339 |
case ${target_os} in |
| 340 |
linux* | uclinux*) |
| 341 |
AC_MSG_CHECKING([for clock_gettime syscall]) |
| 342 |
AC_TRY_COMPILE( |
| 343 |
[#include <unistd.h> |
| 344 |
#include <time.h> |
| 345 |
#include <sys/syscall.h> |
| 346 |
], |
| 347 |
[#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK) |
| 348 |
timespec tp; |
| 349 |
#endif |
| 350 |
syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &tp); |
| 351 |
syscall(SYS_clock_gettime, CLOCK_REALTIME, &tp); |
| 352 |
], [ac_has_clock_gettime_syscall=yes], [ac_has_clock_gettime_syscall=no]) |
| 353 |
AC_MSG_RESULT($ac_has_clock_gettime_syscall) |
| 354 |
if test x"$ac_has_clock_gettime_syscall" = x"yes"; then |
| 355 |
AC_DEFINE(_GLIBCXX_USE_CLOCK_GETTIME_SYSCALL, 1, |
| 356 |
[Defined if clock_gettime syscall has monotonic and realtime clock support. ]) |
| 357 |
ac_has_clock_monotonic=yes |
| 358 |
ac_has_clock_realtime=yes |
| 359 |
AC_MSG_CHECKING([for struct timespec that matches syscall]) |
| 360 |
AC_TRY_COMPILE( |
| 361 |
[#include <time.h> |
| 362 |
#include <sys/syscall.h> |
| 363 |
], |
| 364 |
[#ifdef SYS_clock_gettime64 |
| 365 |
#if SYS_clock_gettime64 != SYS_clock_gettime |
| 366 |
// We need to use SYS_clock_gettime and libc appears to |
| 367 |
// also know about the SYS_clock_gettime64 syscall. |
| 368 |
// Check that userspace doesn't use time64 version of timespec. |
| 369 |
static_assert(sizeof(timespec::tv_sec) == sizeof(long), |
| 370 |
"struct timespec must be compatible with SYS_clock_gettime"); |
| 371 |
#endif |
| 372 |
#endif |
| 373 |
], |
| 374 |
[ac_timespec_matches_syscall=yes], |
| 375 |
[ac_timespec_matches_syscall=no]) |
| 376 |
AC_MSG_RESULT($ac_timespec_matches_syscall) |
| 377 |
if test x"$ac_timespec_matches_syscall" = no; then |
| 378 |
AC_MSG_ERROR([struct timespec is not compatible with SYS_clock_gettime, please report a bug to http://gcc.gnu.org/bugzilla]) |
| 379 |
fi |
| 380 |
fi;; |
| 381 |
esac |
| 382 |
fi |
| 383 |
|
| 384 |
if test x"$ac_has_clock_monotonic" = x"yes"; then |
| 385 |
AC_DEFINE(_GLIBCXX_USE_CLOCK_MONOTONIC, 1, |
| 386 |
[ Defined if clock_gettime has monotonic clock support. ]) |
| 387 |
fi |
| 388 |
|
| 389 |
if test x"$ac_has_clock_realtime" = x"yes"; then |
| 390 |
AC_DEFINE(_GLIBCXX_USE_CLOCK_REALTIME, 1, |
| 391 |
[ Defined if clock_gettime has realtime clock support. ]) |
| 392 |
fi |
| 393 |
|
| 394 |
if test x"$ac_has_sched_yield" = x"yes"; then |
| 395 |
AC_DEFINE(_GLIBCXX_USE_SCHED_YIELD, 1, |
| 396 |
[ Defined if sched_yield is available. ]) |
| 397 |
fi |
| 398 |
|
| 399 |
if test x"$ac_has_nanosleep" = x"yes"; then |
| 400 |
AC_DEFINE(_GLIBCXX_USE_NANOSLEEP, 1, |
| 401 |
[ Defined if nanosleep is available. ]) |
| 402 |
elif test x"$ac_has_win32_sleep" = x"yes"; then |
| 403 |
AC_DEFINE(_GLIBCXX_USE_WIN32_SLEEP, 1, |
| 404 |
[Defined if Sleep exists.]) |
| 405 |
else |
| 406 |
AC_MSG_CHECKING([for sleep]) |
| 407 |
AC_TRY_COMPILE([#include <unistd.h>], |
| 408 |
[sleep(1)], |
| 409 |
[ac_has_sleep=yes],[ac_has_sleep=no]) |
| 410 |
if test x"$ac_has_sleep" = x"yes"; then |
| 411 |
AC_DEFINE(HAVE_SLEEP,1, [Defined if sleep exists.]) |
| 412 |
fi |
| 413 |
AC_MSG_RESULT($ac_has_sleep) |
| 414 |
AC_MSG_CHECKING([for usleep]) |
| 415 |
AC_TRY_COMPILE([#include <unistd.h>], |
| 416 |
[sleep(1); |
| 417 |
usleep(100);], |
| 418 |
[ac_has_usleep=yes],[ac_has_usleep=no]) |
| 419 |
if test x"$ac_has_usleep" = x"yes"; then |
| 420 |
AC_DEFINE(HAVE_USLEEP,1, [Defined if usleep exists.]) |
| 421 |
fi |
| 422 |
AC_MSG_RESULT($ac_has_usleep) |
| 423 |
fi |
| 424 |
|
| 425 |
if test x"$ac_has_nanosleep$ac_has_win32_sleep$ac_has_sleep" = x"nonono"; then |
| 426 |
AC_DEFINE(_GLIBCXX_NO_SLEEP,1, [Defined if no way to sleep is available.]) |
| 427 |
fi |
| 428 |
|
| 429 |
AC_SUBST(GLIBCXX_LIBS) |
| 430 |
|
| 431 |
CXXFLAGS="$ac_save_CXXFLAGS" |
| 432 |
LIBS="$ac_save_LIBS" |
| 433 |
AC_LANG_RESTORE |
| 434 |
]) |
| 435 |
|
| 436 |
dnl |
| 437 |
dnl Check for gettimeofday, used in the implementation of 20.11.7 |
| 438 |
dnl [time.clock] in the C++11 standard. |
| 439 |
dnl |
| 440 |
dnl needed |
| 441 |
AC_DEFUN([GLIBCXX_CHECK_GETTIMEOFDAY], [ |
| 442 |
|
| 443 |
AC_MSG_CHECKING([for gettimeofday]) |
| 444 |
|
| 445 |
AC_LANG_SAVE |
| 446 |
AC_LANG_CPLUSPLUS |
| 447 |
ac_save_CXXFLAGS="$CXXFLAGS" |
| 448 |
CXXFLAGS="$CXXFLAGS -fno-exceptions" |
| 449 |
|
| 450 |
ac_has_gettimeofday=no; |
| 451 |
AC_CHECK_HEADERS(sys/time.h, ac_has_sys_time_h=yes, ac_has_sys_time_h=no) |
| 452 |
if test x"$ac_has_sys_time_h" = x"yes"; then |
| 453 |
AC_MSG_CHECKING([for gettimeofday]) |
| 454 |
GCC_TRY_COMPILE_OR_LINK([#include <sys/time.h>], |
| 455 |
[timeval tv; gettimeofday(&tv, 0);], |
| 456 |
[ac_has_gettimeofday=yes], [ac_has_gettimeofday=no]) |
| 457 |
|
| 458 |
AC_MSG_RESULT($ac_has_gettimeofday) |
| 459 |
fi |
| 460 |
|
| 461 |
if test x"$ac_has_gettimeofday" = x"yes"; then |
| 462 |
AC_DEFINE(_GLIBCXX_USE_GETTIMEOFDAY, 1, |
| 463 |
[ Defined if gettimeofday is available. ]) |
| 464 |
fi |
| 465 |
|
| 466 |
CXXFLAGS="$ac_save_CXXFLAGS" |
| 467 |
AC_LANG_RESTORE |
| 468 |
]) |
| 469 |
|
| 470 |
dnl |
| 471 |
dnl Check for which locale library to use. The choice is mapped to |
| 472 |
dnl a subdirectory of config/locale. |
| 473 |
dnl |
| 474 |
dnl Default is generic. |
| 475 |
dnl |
| 476 |
AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [ |
| 477 |
GLIBCXX_ENABLE(clocale,auto,[[[=MODEL]]], |
| 478 |
[use MODEL for target locale package], |
| 479 |
[permit generic|gnu|ieee_1003.1-2001|newlib|yes|no|auto]) |
| 480 |
|
| 481 |
# Deal with gettext issues. Default to not using it (=no) until we detect |
| 482 |
# support for it later. Let the user turn it off via --e/d, but let that |
| 483 |
# default to on for easier handling. |
| 484 |
USE_NLS=no |
| 485 |
AC_ARG_ENABLE(nls, |
| 486 |
AC_HELP_STRING([--enable-nls],[use Native Language Support (default)]), |
| 487 |
[], |
| 488 |
[enable_nls=yes]) |
| 489 |
|
| 490 |
# Either a known package, or "auto" |
| 491 |
if test $enable_clocale = no || test $enable_clocale = yes; then |
| 492 |
enable_clocale=auto |
| 493 |
fi |
| 494 |
enable_clocale_flag=$enable_clocale |
| 495 |
|
| 496 |
# Probe for locale model to use if none specified. |
| 497 |
# Default to "generic". |
| 498 |
if test $enable_clocale_flag = auto; then |
| 499 |
case ${target_os} in |
| 500 |
linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu) |
| 501 |
enable_clocale_flag=gnu |
| 502 |
;; |
| 503 |
darwin*) |
| 504 |
enable_clocale_flag=darwin |
| 505 |
;; |
| 506 |
vxworks*) |
| 507 |
enable_clocale_flag=vxworks |
| 508 |
;; |
| 509 |
dragonfly* | freebsd*) |
| 510 |
enable_clocale_flag=dragonfly |
| 511 |
;; |
| 512 |
openbsd*) |
| 513 |
enable_clocale_flag=newlib |
| 514 |
;; |
| 515 |
*) |
| 516 |
if test x"$with_newlib" = x"yes"; then |
| 517 |
enable_clocale_flag=newlib |
| 518 |
else |
| 519 |
enable_clocale_flag=generic |
| 520 |
fi |
| 521 |
;; |
| 522 |
esac |
| 523 |
fi |
| 524 |
|
| 525 |
# Sanity check model, and test for special functionality. |
| 526 |
if test $enable_clocale_flag = gnu; then |
| 527 |
AC_EGREP_CPP([_GLIBCXX_ok], [ |
| 528 |
#include <features.h> |
| 529 |
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(__UCLIBC__) |
| 530 |
_GLIBCXX_ok |
| 531 |
#endif |
| 532 |
], enable_clocale_flag=gnu, enable_clocale_flag=generic) |
| 533 |
|
| 534 |
# Set it to scream when it hurts. |
| 535 |
ac_save_CFLAGS="$CFLAGS" |
| 536 |
CFLAGS="-Wimplicit-function-declaration -Werror" |
| 537 |
|
| 538 |
# Use strxfrm_l if available. |
| 539 |
AC_TRY_COMPILE([#define _GNU_SOURCE 1 |
| 540 |
#include <string.h> |
| 541 |
#include <locale.h>], |
| 542 |
[char s[128]; __locale_t loc; strxfrm_l(s, "C", 5, loc);], |
| 543 |
AC_DEFINE(HAVE_STRXFRM_L, 1, |
| 544 |
[Define if strxfrm_l is available in <string.h>.]),) |
| 545 |
|
| 546 |
# Use strerror_l if available. |
| 547 |
AC_TRY_COMPILE([#define _GNU_SOURCE 1 |
| 548 |
#include <string.h> |
| 549 |
#include <locale.h>], |
| 550 |
[__locale_t loc; strerror_l(5, loc);], |
| 551 |
AC_DEFINE(HAVE_STRERROR_L, 1, |
| 552 |
[Define if strerror_l is available in <string.h>.]),) |
| 553 |
|
| 554 |
CFLAGS="$ac_save_CFLAGS" |
| 555 |
fi |
| 556 |
|
| 557 |
# Perhaps use strerror_r if available, and strerror_l isn't. |
| 558 |
ac_save_CFLAGS="$CFLAGS" |
| 559 |
CFLAGS="-Wimplicit-function-declaration -Werror" |
| 560 |
AC_TRY_COMPILE([#define _GNU_SOURCE 1 |
| 561 |
#include <string.h> |
| 562 |
#include <locale.h>], |
| 563 |
[char s[128]; strerror_r(5, s, 128);], |
| 564 |
AC_DEFINE(HAVE_STRERROR_R, 1, |
| 565 |
[Define if strerror_r is available in <string.h>.]),) |
| 566 |
CFLAGS="$ac_save_CFLAGS" |
| 567 |
|
| 568 |
# Set configure bits for specified locale package |
| 569 |
AC_MSG_CHECKING([for C locale to use]) |
| 570 |
case ${enable_clocale_flag} in |
| 571 |
generic) |
| 572 |
AC_MSG_RESULT(generic) |
| 573 |
|
| 574 |
CLOCALE_H=config/locale/generic/c_locale.h |
| 575 |
CLOCALE_CC=config/locale/generic/c_locale.cc |
| 576 |
CCODECVT_CC=config/locale/generic/codecvt_members.cc |
| 577 |
CCOLLATE_CC=config/locale/generic/collate_members.cc |
| 578 |
CCTYPE_CC=config/locale/generic/ctype_members.cc |
| 579 |
CMESSAGES_H=config/locale/generic/messages_members.h |
| 580 |
CMESSAGES_CC=config/locale/generic/messages_members.cc |
| 581 |
CMONEY_CC=config/locale/generic/monetary_members.cc |
| 582 |
CNUMERIC_CC=config/locale/generic/numeric_members.cc |
| 583 |
CTIME_H=config/locale/generic/time_members.h |
| 584 |
CTIME_CC=config/locale/generic/time_members.cc |
| 585 |
CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h |
| 586 |
;; |
| 587 |
darwin) |
| 588 |
AC_MSG_RESULT(darwin) |
| 589 |
|
| 590 |
CLOCALE_H=config/locale/generic/c_locale.h |
| 591 |
CLOCALE_CC=config/locale/generic/c_locale.cc |
| 592 |
CCODECVT_CC=config/locale/generic/codecvt_members.cc |
| 593 |
CCOLLATE_CC=config/locale/generic/collate_members.cc |
| 594 |
CCTYPE_CC=config/locale/darwin/ctype_members.cc |
| 595 |
CMESSAGES_H=config/locale/generic/messages_members.h |
| 596 |
CMESSAGES_CC=config/locale/generic/messages_members.cc |
| 597 |
CMONEY_CC=config/locale/generic/monetary_members.cc |
| 598 |
CNUMERIC_CC=config/locale/generic/numeric_members.cc |
| 599 |
CTIME_H=config/locale/generic/time_members.h |
| 600 |
CTIME_CC=config/locale/generic/time_members.cc |
| 601 |
CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h |
| 602 |
;; |
| 603 |
vxworks) |
| 604 |
AC_MSG_RESULT(vxworks) |
| 605 |
|
| 606 |
CLOCALE_H=config/locale/generic/c_locale.h |
| 607 |
CLOCALE_CC=config/locale/generic/c_locale.cc |
| 608 |
CCODECVT_CC=config/locale/generic/codecvt_members.cc |
| 609 |
CCOLLATE_CC=config/locale/generic/collate_members.cc |
| 610 |
CCTYPE_CC=config/locale/vxworks/ctype_members.cc |
| 611 |
CMESSAGES_H=config/locale/generic/messages_members.h |
| 612 |
CMESSAGES_CC=config/locale/generic/messages_members.cc |
| 613 |
CMONEY_CC=config/locale/generic/monetary_members.cc |
| 614 |
CNUMERIC_CC=config/locale/generic/numeric_members.cc |
| 615 |
CTIME_H=config/locale/generic/time_members.h |
| 616 |
CTIME_CC=config/locale/generic/time_members.cc |
| 617 |
CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h |
| 618 |
;; |
| 619 |
dragonfly) |
| 620 |
AC_MSG_RESULT(dragonfly or freebsd) |
| 621 |
|
| 622 |
CLOCALE_H=config/locale/dragonfly/c_locale.h |
| 623 |
CLOCALE_CC=config/locale/dragonfly/c_locale.cc |
| 624 |
CCODECVT_CC=config/locale/dragonfly/codecvt_members.cc |
| 625 |
CCOLLATE_CC=config/locale/dragonfly/collate_members.cc |
| 626 |
CCTYPE_CC=config/locale/dragonfly/ctype_members.cc |
| 627 |
CMESSAGES_H=config/locale/generic/messages_members.h |
| 628 |
CMESSAGES_CC=config/locale/generic/messages_members.cc |
| 629 |
CMONEY_CC=config/locale/dragonfly/monetary_members.cc |
| 630 |
CNUMERIC_CC=config/locale/dragonfly/numeric_members.cc |
| 631 |
CTIME_H=config/locale/dragonfly/time_members.h |
| 632 |
CTIME_CC=config/locale/dragonfly/time_members.cc |
| 633 |
CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h |
| 634 |
;; |
| 635 |
|
| 636 |
gnu) |
| 637 |
AC_MSG_RESULT(gnu) |
| 638 |
|
| 639 |
# Declare intention to use gettext, and add support for specific |
| 640 |
# languages. |
| 641 |
# For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT |
| 642 |
ALL_LINGUAS="de fr" |
| 643 |
|
| 644 |
# Don't call AM-GNU-GETTEXT here. Instead, assume glibc. |
| 645 |
AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no) |
| 646 |
if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then |
| 647 |
USE_NLS=yes |
| 648 |
fi |
| 649 |
# Export the build objects. |
| 650 |
for ling in $ALL_LINGUAS; do \ |
| 651 |
glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \ |
| 652 |
glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \ |
| 653 |
done |
| 654 |
AC_SUBST(glibcxx_MOFILES) |
| 655 |
AC_SUBST(glibcxx_POFILES) |
| 656 |
|
| 657 |
CLOCALE_H=config/locale/gnu/c_locale.h |
| 658 |
CLOCALE_CC=config/locale/gnu/c_locale.cc |
| 659 |
CCODECVT_CC=config/locale/gnu/codecvt_members.cc |
| 660 |
CCOLLATE_CC=config/locale/gnu/collate_members.cc |
| 661 |
CCTYPE_CC=config/locale/gnu/ctype_members.cc |
| 662 |
CMESSAGES_H=config/locale/gnu/messages_members.h |
| 663 |
CMESSAGES_CC=config/locale/gnu/messages_members.cc |
| 664 |
CMONEY_CC=config/locale/gnu/monetary_members.cc |
| 665 |
CNUMERIC_CC=config/locale/gnu/numeric_members.cc |
| 666 |
CTIME_H=config/locale/gnu/time_members.h |
| 667 |
CTIME_CC=config/locale/gnu/time_members.cc |
| 668 |
CLOCALE_INTERNAL_H=config/locale/gnu/c++locale_internal.h |
| 669 |
;; |
| 670 |
ieee_1003.1-2001) |
| 671 |
AC_MSG_RESULT(IEEE 1003.1) |
| 672 |
|
| 673 |
CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h |
| 674 |
CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc |
| 675 |
CCODECVT_CC=config/locale/generic/codecvt_members.cc |
| 676 |
CCOLLATE_CC=config/locale/generic/collate_members.cc |
| 677 |
CCTYPE_CC=config/locale/generic/ctype_members.cc |
| 678 |
CMESSAGES_H=config/locale/ieee_1003.1-2001/messages_members.h |
| 679 |
CMESSAGES_CC=config/locale/ieee_1003.1-2001/messages_members.cc |
| 680 |
CMONEY_CC=config/locale/generic/monetary_members.cc |
| 681 |
CNUMERIC_CC=config/locale/generic/numeric_members.cc |
| 682 |
CTIME_H=config/locale/generic/time_members.h |
| 683 |
CTIME_CC=config/locale/generic/time_members.cc |
| 684 |
CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h |
| 685 |
;; |
| 686 |
newlib) |
| 687 |
AC_MSG_RESULT(newlib) |
| 688 |
|
| 689 |
CLOCALE_H=config/locale/generic/c_locale.h |
| 690 |
CLOCALE_CC=config/locale/generic/c_locale.cc |
| 691 |
CCODECVT_CC=config/locale/generic/codecvt_members.cc |
| 692 |
CCOLLATE_CC=config/locale/generic/collate_members.cc |
| 693 |
CCTYPE_CC=config/locale/newlib/ctype_members.cc |
| 694 |
CMESSAGES_H=config/locale/generic/messages_members.h |
| 695 |
CMESSAGES_CC=config/locale/generic/messages_members.cc |
| 696 |
CMONEY_CC=config/locale/generic/monetary_members.cc |
| 697 |
CNUMERIC_CC=config/locale/generic/numeric_members.cc |
| 698 |
CTIME_H=config/locale/generic/time_members.h |
| 699 |
CTIME_CC=config/locale/generic/time_members.cc |
| 700 |
CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h |
| 701 |
;; |
| 702 |
esac |
| 703 |
|
| 704 |
# This is where the testsuite looks for locale catalogs, using the |
| 705 |
# -DLOCALEDIR define during testsuite compilation. |
| 706 |
glibcxx_localedir=${glibcxx_builddir}/po/share/locale |
| 707 |
AC_SUBST(glibcxx_localedir) |
| 708 |
|
| 709 |
# A standalone libintl (e.g., GNU libintl) may be in use. |
| 710 |
if test $USE_NLS = yes; then |
| 711 |
AC_CHECK_HEADERS([libintl.h], [], USE_NLS=no) |
| 712 |
AC_SEARCH_LIBS(gettext, intl, [], USE_NLS=no) |
| 713 |
fi |
| 714 |
if test $USE_NLS = yes; then |
| 715 |
AC_DEFINE(_GLIBCXX_USE_NLS, 1, |
| 716 |
[Define if NLS translations are to be used.]) |
| 717 |
fi |
| 718 |
|
| 719 |
AC_SUBST(USE_NLS) |
| 720 |
AC_SUBST(CLOCALE_H) |
| 721 |
AC_SUBST(CMESSAGES_H) |
| 722 |
AC_SUBST(CCODECVT_CC) |
| 723 |
AC_SUBST(CCOLLATE_CC) |
| 724 |
AC_SUBST(CCTYPE_CC) |
| 725 |
AC_SUBST(CMESSAGES_CC) |
| 726 |
AC_SUBST(CMONEY_CC) |
| 727 |
AC_SUBST(CNUMERIC_CC) |
| 728 |
AC_SUBST(CTIME_H) |
| 729 |
AC_SUBST(CTIME_CC) |
| 730 |
AC_SUBST(CLOCALE_CC) |
| 731 |
AC_SUBST(CLOCALE_INTERNAL_H) |
| 732 |
]) |
| 733 |
|
| 734 |
|
| 735 |
dnl |
| 736 |
dnl Check for GNU 128-bit floating point type. |
| 737 |
dnl |
| 738 |
dnl Note: also checks that the type isn't a standard types. |
| 739 |
dnl |
| 740 |
dnl Defines: |
| 741 |
dnl ENABLE_FLOAT128 |
| 742 |
dnl |
| 743 |
AC_DEFUN([GLIBCXX_ENABLE_FLOAT128], [ |
| 744 |
|
| 745 |
AC_LANG_SAVE |
| 746 |
AC_LANG_CPLUSPLUS |
| 747 |
|
| 748 |
# Fake what AC_TRY_COMPILE does, without linking as this is |
| 749 |
# unnecessary for this test. |
| 750 |
|
| 751 |
cat > conftest.$ac_ext << EOF |
| 752 |
[#]line __oline__ "configure" |
| 753 |
template<typename T1, typename T2> |
| 754 |
struct same |
| 755 |
{ typedef T2 type; }; |
| 756 |
|
| 757 |
template<typename T> |
| 758 |
struct same<T, T>; |
| 759 |
|
| 760 |
int main() |
| 761 |
{ |
| 762 |
typename same<double, __float128>::type f1; |
| 763 |
typename same<long double, __float128>::type f2; |
| 764 |
} |
| 765 |
EOF |
| 766 |
|
| 767 |
AC_MSG_CHECKING([for __float128]) |
| 768 |
if AC_TRY_EVAL(ac_compile); then |
| 769 |
enable_float128=yes |
| 770 |
else |
| 771 |
enable_float128=no |
| 772 |
fi |
| 773 |
AC_MSG_RESULT($enable_float128) |
| 774 |
GLIBCXX_CONDITIONAL(ENABLE_FLOAT128, test $enable_float128 = yes) |
| 775 |
rm -f conftest* |
| 776 |
|
| 777 |
AC_LANG_RESTORE |
| 778 |
]) |
| 779 |
|
| 780 |
# Macros from the top-level gcc directory. |
| 781 |
m4_include([../config/gc++filt.m4]) |
| 782 |
m4_include([../config/tls.m4]) |
| 783 |
m4_include([../config/gthr.m4]) |
| 784 |
m4_include([../config/cet.m4]) |