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.
This commit is contained in:
parent
cc7c045bae
commit
6c0cfe3d43
18
configure.ac
18
configure.ac
|
@ -705,6 +705,15 @@ if test "x$NEED_DBUS" = xyes; then
|
||||||
fi
|
fi
|
||||||
CONFIG_LIB='$(top_builddir)/config/libconfig.a'
|
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_FUNCS([clock_gettime], [have_clock_gettime=yes],
|
||||||
[AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
|
[AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
|
||||||
[have_clock_gettime=no])])
|
[have_clock_gettime=no])])
|
||||||
|
@ -720,11 +729,13 @@ if ! test "x$have_clock_gettime" = xno; then
|
||||||
|
|
||||||
LIBS_SAVE="$LIBS"
|
LIBS_SAVE="$LIBS"
|
||||||
LIBS="$CLOCK_LIBS"
|
LIBS="$CLOCK_LIBS"
|
||||||
|
CPPFLAGS_SAVE="$CPPFLAGS"
|
||||||
|
|
||||||
|
if test x"$glibc" = xyes; then
|
||||||
|
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=199309L"
|
||||||
|
fi
|
||||||
|
|
||||||
AC_RUN_IFELSE([
|
AC_RUN_IFELSE([
|
||||||
#ifdef __linux__
|
|
||||||
#define _POSIX_C_SOURCE 199309L
|
|
||||||
#endif
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[[]]) {
|
int main(int argc, char *argv[[]]) {
|
||||||
|
@ -739,6 +750,7 @@ int main(int argc, char *argv[[]]) {
|
||||||
[MONOTONIC_CLOCK="cross compiling"])
|
[MONOTONIC_CLOCK="cross compiling"])
|
||||||
|
|
||||||
LIBS="$LIBS_SAVE"
|
LIBS="$LIBS_SAVE"
|
||||||
|
CPPFLAGS="$CPPFLAGS_SAVE"
|
||||||
else
|
else
|
||||||
MONOTONIC_CLOCK=no
|
MONOTONIC_CLOCK=no
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue