Add a check to configure.in to detect if the target system has a  
function clock_gettime(). On my OS X and Linux systems, the check  
seems to work.

Signed-off-by: J. Tang <[email protected]>
---
  configure.in |   19 +++++++++++++++----
  1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/configure.in b/configure.in
index a0b1f40..4973a04 100644
--- a/configure.in
+++ b/configure.in
@@ -329,11 +329,22 @@ AC_SEARCH_LIBS(socket, socket, [SOCKLIB=$LIBS],
  )
  AC_SUBST(SOCKLIB)

+try_link_clock="yes";
+AC_MSG_CHECKING([for POSIX real-time clock])
+AC_TRY_COMPILE(
+       [#include <time.h>],
+       [clock_gettime(CLOCK_THREAD_CPUTIME_ID, 0);],
+       [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_CLOCK_GETTIME)],
+       [AC_MSG_RESULT([no]); try_link_clock="no";]
+)
+
  dnl FreeBSD has clock_gettime in libc, Linux needs librt
-LIBS=""
-AC_SEARCH_LIBS(clock_gettime, rt, [RTLIB=$LIBS])
-AC_CHECK_FUNCS(clock_gettime)
-AC_SUBST(RTLIB)
+if test $try_link_clock = yes; then
+       LIBS=""
+       AC_SEARCH_LIBS(clock_gettime, rt, [RTLIB=$LIBS])
+       AC_CHECK_FUNCS(clock_gettime)
+       AC_SUBST(RTLIB)
+fi

  dnl Android has pthread_* functions in bionic (libc), others need  
libpthread
  LIBS=""
-- 
1.7.3.2


_______________________________________________
Dev mailing list
[email protected]
https://lists.strongswan.org/mailman/listinfo/dev

Reply via email to