From: Tobias Brunner Date: Thu, 16 Jun 2016 15:57:37 +0000 (+0200) Subject: configure: Cache result of pthread_condattr_setclock() check X-Git-Tag: 5.5.0dr1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d79bfa8318ddd1b9b863241fe0e637be73af5f4;p=thirdparty%2Fstrongswan.git configure: Cache result of pthread_condattr_setclock() check Even if not using caching when running the configure script (-C) this allows pre-defining the result by setting the environment variable ss_cv_func_pthread_condattr_setclock_monotonic=yes|no|unknown before/while running the script. As the check requires running a test program this might be helpful when cross-compiling to disable using monotonic time if pthread_condattr_setclock() is defined but not actually usable with CLOCK_MONOTONIC. References #1502. --- diff --git a/configure.ac b/configure.ac index 3c6132e5f6..35f069a7ae 100644 --- a/configure.ac +++ b/configure.ac @@ -512,24 +512,28 @@ AC_COMPILE_IFELSE( # check if pthread_condattr_setclock(CLOCK_MONOTONIC) is supported saved_LIBS=$LIBS LIBS=$PTHREADLIB -AC_MSG_CHECKING([for pthread_condattr_setclock(CLOCK_MONOTONIC)]) -AC_RUN_IFELSE( - [AC_LANG_SOURCE( - [[#include - int main() { pthread_condattr_t attr; - pthread_condattr_init(&attr); - return pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);}]])], - [AC_MSG_RESULT([yes]); - AC_DEFINE([HAVE_CONDATTR_CLOCK_MONOTONIC], [], - [pthread_condattr_setclock supports CLOCK_MONOTONIC])], - [AC_MSG_RESULT([no])], - # Check existence of pthread_condattr_setclock if cross-compiling - [AC_MSG_RESULT([unknown]); - AC_CHECK_FUNCS(pthread_condattr_setclock, - [AC_DEFINE([HAVE_CONDATTR_CLOCK_MONOTONIC], [], - [have pthread_condattr_setclock()])] - )] -) +AC_CACHE_CHECK([for pthread_condattr_setclock(CLOCK_MONOTONIC)], + [ss_cv_func_pthread_condattr_setclock_monotonic], + [AC_RUN_IFELSE( + [AC_LANG_SOURCE( + [[#include + int main() { pthread_condattr_t attr; + pthread_condattr_init(&attr); + return pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);}]])], + [ss_cv_func_pthread_condattr_setclock_monotonic=yes], + [ss_cv_func_pthread_condattr_setclock_monotonic=no], + # Check existence of pthread_condattr_setclock if cross-compiling + [AC_CHECK_FUNCS(pthread_condattr_setclock, + ss_cv_func_pthread_condattr_setclock_monotonic=unknown)] + )]) +if test x$ss_cv_func_pthread_condattr_setclock_monotonic = xyes; then + AC_DEFINE([HAVE_CONDATTR_CLOCK_MONOTONIC], [], + [pthread_condattr_setclock supports CLOCK_MONOTONIC]) +elif test x$ss_cv_func_pthread_condattr_setclock_monotonic = xunknown; then + AC_DEFINE([HAVE_CONDATTR_CLOCK_MONOTONIC], [], + [have pthread_condattr_setclock()]) +fi + # check if we actually are able to configure attributes on cond vars AC_CHECK_FUNCS(pthread_condattr_init) # instead of pthread_condattr_setclock Android has this function