Bug 728968 - Detect clock_gettime when it's not in -lrt. r=khuey

This commit is contained in:
Mike Hommey 2012-02-23 11:00:46 +01:00
parent 90431b093f
commit b81ee70b4a

View File

@ -3728,20 +3728,23 @@ AC_CHECK_FUNCS(random strerror lchown fchmod snprintf statvfs memmove rint stat6
AC_CHECK_FUNCS(flockfile getpagesize) AC_CHECK_FUNCS(flockfile getpagesize)
AC_CHECK_FUNCS(localtime_r strtok_r) AC_CHECK_FUNCS(localtime_r strtok_r)
dnl check for clock_gettime(), the CLOCK_MONOTONIC clock, and -lrt dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
_SAVE_LDFLAGS=$LDFLAGS AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
LDFLAGS="$LDFLAGS -lrt" ac_cv_clock_monotonic,
AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC) and -lrt, [for libs in "" -lrt; do
ac_cv_have_clock_monotonic, _SAVE_LDFLAGS="$LDFLAGS"
[AC_TRY_LINK([#include <time.h>], LDFLAGS="$LDFLAGS $libs"
[ struct timespec ts; AC_TRY_LINK([#include <time.h>],
clock_gettime(CLOCK_MONOTONIC, &ts); ], [ struct timespec ts;
ac_cv_have_clock_monotonic=yes, clock_gettime(CLOCK_MONOTONIC, &ts); ],
ac_cv_have_clock_monotonic=no)]) ac_cv_clock_monotonic=$libs
LDFLAGS=$_SAVE_LDFLAGS break,
if test "$ac_cv_have_clock_monotonic" = "yes"; then ac_cv_clock_monotonic=no)
LDFLAGS="$_SAVE_LDFLAGS"
done])
if test "$ac_cv_clock_monotonic" != "no"; then
HAVE_CLOCK_MONOTONIC=1 HAVE_CLOCK_MONOTONIC=1
REALTIME_LIBS=-lrt REALTIME_LIBS=$ac_cv_clock_monotonic
AC_DEFINE(HAVE_CLOCK_MONOTONIC) AC_DEFINE(HAVE_CLOCK_MONOTONIC)
AC_SUBST(HAVE_CLOCK_MONOTONIC) AC_SUBST(HAVE_CLOCK_MONOTONIC)
AC_SUBST(REALTIME_LIBS) AC_SUBST(REALTIME_LIBS)