diff options
author | Julien Cristau <jcristau@debian.org> | 2008-04-04 19:01:40 +0200 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2008-04-07 10:32:13 -0400 |
commit | fe87d921da97f498e860270e2eeb73a860f19989 (patch) | |
tree | 9d030f232594b64c79d4b5d7a2d742c84b0941d5 | |
parent | 9a908769e62fe56930ad3a2d3375e29119a2fe09 (diff) |
Fix the clock_gettime check for glibc-based non-Linux systems
We need to define _POSIX_C_SOURCE on glibc, not just Linux, so add a new
test for the __GLIBC__ macro.
(cherry picked from commit 6c0cfe3d43b177c4cfaf7e228f32c655f9a98459)
-rw-r--r-- | configure.ac | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac index c151c20a0..1e48b0774 100644 --- a/configure.ac +++ b/configure.ac @@ -707,6 +707,15 @@ if test "x$NEED_DBUS" = xyes; then fi CONFIG_LIB='$(top_builddir)/config/libconfig.a' +AC_MSG_CHECKING([for glibc...]) +AC_PREPROC_IFELSE([ +#include <features.h> +#ifndef __GLIBC__ +#error +#endif +], glibc=yes, glibc=no) +AC_MSG_RESULT([$glibc]) + AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt], [have_clock_gettime=no])]) @@ -722,11 +731,13 @@ if ! test "x$have_clock_gettime" = xno; then LIBS_SAVE="$LIBS" LIBS="$CLOCK_LIBS" + CPPFLAGS_SAVE="$CPPFLAGS" + + if test x"$glibc" = xyes; then + CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=199309L" + fi AC_RUN_IFELSE([ -#ifdef __linux__ -#define _POSIX_C_SOURCE 199309L -#endif #include <time.h> int main(int argc, char *argv[[]]) { @@ -741,6 +752,7 @@ int main(int argc, char *argv[[]]) { [MONOTONIC_CLOCK="cross compiling"]) LIBS="$LIBS_SAVE" + CPPFLAGS="$CPPFLAGS_SAVE" else MONOTONIC_CLOCK=no fi |