From bd2485ff0da2929fca2c2f24714306bfb7cd69d5 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 16 Dec 2014 18:35:55 +0100 Subject: [PATCH 1/6] Check whether libc provides rt for later linking of V8; if not we need to add -lrt to our LDFLAGS. See man clock_gettime for details. --- configure.ac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index 0ca1d5fb62..bc910682c4 100644 --- a/configure.ac +++ b/configure.ac @@ -182,6 +182,16 @@ dnl --SECTION-- EXTERNAL LIBRARIES dnl ============================================================================ +AC_MSG_CHECKING([for clock_gettime in libc]) +AC_TRY_LINK([ #include ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ + have_clock_gettime=yes + AC_MSG_RESULT([yes]) +], [ + LDFLAGS="${LDFLAGS} -lrt" + AC_MSG_RESULT([no]) +]) + + dnl ---------------------------------------------------------------------------- dnl MATH dnl ---------------------------------------------------------------------------- From ec4d6a33f477688aafd644d283cba240004b141a Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 16 Dec 2014 18:47:57 +0100 Subject: [PATCH 2/6] Add more complex macro checking for -lrt --- configure.ac | 14 ++++----- m4/clock_gettime | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 m4/clock_gettime diff --git a/configure.ac b/configure.ac index bc910682c4..e6d690ebc8 100644 --- a/configure.ac +++ b/configure.ac @@ -181,15 +181,11 @@ dnl ============================================================================ dnl --SECTION-- EXTERNAL LIBRARIES dnl ============================================================================ - -AC_MSG_CHECKING([for clock_gettime in libc]) -AC_TRY_LINK([ #include ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ - have_clock_gettime=yes - AC_MSG_RESULT([yes]) -], [ - LDFLAGS="${LDFLAGS} -lrt" - AC_MSG_RESULT([no]) -]) +dnl ---------------------------------------------------------------------------- +dnl -lrt +dnl ---------------------------------------------------------------------------- +m4_include([m4/clock_gettime]) +AC_CLOCK() dnl ---------------------------------------------------------------------------- diff --git a/m4/clock_gettime b/m4/clock_gettime new file mode 100644 index 0000000000..0f1b68ba49 --- /dev/null +++ b/m4/clock_gettime @@ -0,0 +1,77 @@ +dnl -*- mode: Autoconf; -*- +dnl borrowed from php-fpm configure + +AC_DEFUN([AC_CLOCK], +[ + have_clock_gettime=no + + AC_MSG_CHECKING([for clock_gettime oooooooooooooooooooooooooooooo]) + + AC_TRY_LINK([ #include ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ + have_clock_gettime=yes + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) + + if test "$have_clock_gettime" = "no"; then + AC_MSG_CHECKING([for clock_gettime in -lrt]) + + SAVED_LIBS="$LIBS" + LIBS="$LIBS -lrt" + + AC_TRY_LINK([ #include ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ + have_clock_gettime=yes + AC_MSG_RESULT([yes]) + ], [ + LIBS="$SAVED_LIBS" + AC_MSG_RESULT([no]) + ]) + fi + + if test "$have_clock_gettime" = "yes"; then + AC_DEFINE([HAVE_CLOCK_GETTIME], 1, [do we have clock_gettime?]) + fi + + have_clock_get_time=no + + if test "$have_clock_gettime" = "no"; then + AC_MSG_CHECKING([for clock_get_time]) + + AC_TRY_RUN([ #include + #include + #include + + int main() + { + kern_return_t ret; clock_serv_t aClock; mach_timespec_t aTime; + ret = host_get_clock_service(mach_host_self(), REALTIME_CLOCK, &aClock); + + if (ret != KERN_SUCCESS) { + return 1; + } + + ret = clock_get_time(aClock, &aTime); + if (ret != KERN_SUCCESS) { + return 2; + } + + return 0; + } + ], [ + have_clock_get_time=yes + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) + fi + + if test "$have_clock_get_time" = "yes"; then + AC_DEFINE([HAVE_CLOCK_GET_TIME], 1, [do we have clock_get_time?]) + fi +]) + +dnl Local Variables: +dnl mode: outline-minor +dnl outline-regexp: "^\\(dnl --SECTION--\\)" +dnl End: From 4e96da7b9e7ddfdc4511dc9aedd650f9fca91976 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 16 Dec 2014 18:56:18 +0100 Subject: [PATCH 3/6] Remove debug output - works now. --- m4/clock_gettime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/clock_gettime b/m4/clock_gettime index 0f1b68ba49..e1b90658f1 100644 --- a/m4/clock_gettime +++ b/m4/clock_gettime @@ -5,7 +5,7 @@ AC_DEFUN([AC_CLOCK], [ have_clock_gettime=no - AC_MSG_CHECKING([for clock_gettime oooooooooooooooooooooooooooooo]) + AC_MSG_CHECKING([for clock_gettime]) AC_TRY_LINK([ #include ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ have_clock_gettime=yes From 6850409229bf0edd4563d5893e6eb9273eed8789 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 16 Dec 2014 19:13:18 +0100 Subject: [PATCH 4/6] Properly include the -lrt into our automake scheme. --- Makefile.am | 1 + m4/clock_gettime | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 752239ebc1..e2cc43648e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -140,6 +140,7 @@ AM_LDFLAGS = \ ################################################################################ LIBS = \ + @RT_LIBS \ @LIBEV_LIBS@ \ @MATH_LIBS@ \ @OPENSSL_LIBS@ \ diff --git a/m4/clock_gettime b/m4/clock_gettime index e1b90658f1..aa9542c5ec 100644 --- a/m4/clock_gettime +++ b/m4/clock_gettime @@ -17,7 +17,6 @@ AC_DEFUN([AC_CLOCK], if test "$have_clock_gettime" = "no"; then AC_MSG_CHECKING([for clock_gettime in -lrt]) - SAVED_LIBS="$LIBS" LIBS="$LIBS -lrt" AC_TRY_LINK([ #include ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ @@ -69,6 +68,8 @@ AC_DEFUN([AC_CLOCK], if test "$have_clock_get_time" = "yes"; then AC_DEFINE([HAVE_CLOCK_GET_TIME], 1, [do we have clock_get_time?]) fi + RT_LIBS=LIBS + AC_SUBST(RT_LIBS) ]) dnl Local Variables: From aa5ba7db20cafd0105fc0ed1d85b176c4c0c59bd Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 16 Dec 2014 19:21:05 +0100 Subject: [PATCH 5/6] Fix typo in makefile. --- Installation/travisCI/script.sh | 1 - Makefile.am | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Installation/travisCI/script.sh b/Installation/travisCI/script.sh index 93a8ee5405..e74978c762 100755 --- a/Installation/travisCI/script.sh +++ b/Installation/travisCI/script.sh @@ -8,7 +8,6 @@ make setup || exit 1 echo echo "$0: configuring ArangoDB" # V8 needs lib realtime: -export LDFLAGS='-lrt -pthread' ./configure \ --enable-relative \ --enable-all-in-one-libev \ diff --git a/Makefile.am b/Makefile.am index e2cc43648e..f3b94799f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -140,7 +140,7 @@ AM_LDFLAGS = \ ################################################################################ LIBS = \ - @RT_LIBS \ + @RT_LIBS@ \ @LIBEV_LIBS@ \ @MATH_LIBS@ \ @OPENSSL_LIBS@ \ From 14baf7b3d65bec79b83d5b003114c7908ace095c Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 16 Dec 2014 19:37:56 +0100 Subject: [PATCH 6/6] fix typo. --- m4/clock_gettime | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/m4/clock_gettime b/m4/clock_gettime index aa9542c5ec..9f872a8f1c 100644 --- a/m4/clock_gettime +++ b/m4/clock_gettime @@ -17,6 +17,7 @@ AC_DEFUN([AC_CLOCK], if test "$have_clock_gettime" = "no"; then AC_MSG_CHECKING([for clock_gettime in -lrt]) + SAVED_LIBS=$LIBS LIBS="$LIBS -lrt" AC_TRY_LINK([ #include ], [struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);], [ @@ -68,8 +69,9 @@ AC_DEFUN([AC_CLOCK], if test "$have_clock_get_time" = "yes"; then AC_DEFINE([HAVE_CLOCK_GET_TIME], 1, [do we have clock_get_time?]) fi - RT_LIBS=LIBS + RT_LIBS=$LIBS AC_SUBST(RT_LIBS) + SAVED_LIBS=$LIBS ]) dnl Local Variables: