From efffa5360ebb2b6919c5eb1998c5df4c8849a407 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 28 Jul 2022 22:39:54 +0100 Subject: patch 9.0.0103: if running configure with cached results -lrt may be missing Problem: If running configure with cached results -lrt may be missing. Solution: Use two cache variables, one without and one with -lrt. (closes #10799) Swap checks to avoid adding -lrt unnecessarily. --- src/configure.ac | 68 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 28 deletions(-) (limited to 'src/configure.ac') diff --git a/src/configure.ac b/src/configure.ac index b52aabcf95..d777b052fd 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -3807,9 +3807,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( dnl Check for timer_create. It probably requires the 'rt' library. dnl Run the program to find out if timer_create(CLOCK_MONOTONIC) actually dnl works, on Solaris timer_create() exists but fails at runtime. -AC_CACHE_CHECK([for timer_create], [vim_cv_timer_create], [ -save_LIBS="$LIBS" -LIBS="$LIBS -lrt" +AC_CACHE_CHECK([for timer_create without -lrt], [vim_cv_timer_create], [ AC_RUN_IFELSE([AC_LANG_PROGRAM([ #if STDC_HEADERS # include @@ -3828,36 +3826,50 @@ static void set_flag(union sigval sv) {} if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0) exit(1); // cannot create a monotonic timer ])], - AC_MSG_NOTICE(timer_create with -lrt); vim_cv_timer_create=yes, - LIBS="$save_LIBS" - AC_RUN_IFELSE([AC_LANG_PROGRAM([ -#if STDC_HEADERS -# include -# include -#endif -#include -#include -static void set_flag(union sigval sv) {} + vim_cv_timer_create=yes, + vim_cv_timer_create=no, + AC_MSG_ERROR(cross-compiling: please set 'vim_cv_timer_create') + )]) + +dnl If the previous failed, check for timer_create() and linking with -lrt. +if test "x$vim_cv_timer_create" = "xno" ; then + save_LIBS="$LIBS" + LIBS="$LIBS -lrt" + AC_CACHE_CHECK([for timer_create with -lrt], [vim_cv_timer_create_with_lrt], [ + AC_RUN_IFELSE([AC_LANG_PROGRAM([ + #if STDC_HEADERS + # include + # include + #endif + #include + #include + static void set_flag(union sigval sv) {} ], [ - struct timespec ts; - struct sigevent action = {0}; - timer_t timer_id; - - action.sigev_notify = SIGEV_THREAD; - action.sigev_notify_function = set_flag; - if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0) - exit(1); // cannot create a monotonic timer - ])], - vim_cv_timer_create=yes, - vim_cv_timer_create=no), - AC_MSG_ERROR(cross-compiling: please set 'vim_cv_timer_create') - )] -) + struct timespec ts; + struct sigevent action = {0}; + timer_t timer_id; + + action.sigev_notify = SIGEV_THREAD; + action.sigev_notify_function = set_flag; + if (timer_create(CLOCK_MONOTONIC, &action, &timer_id) < 0) + exit(1); // cannot create a monotonic timer + ])], + vim_cv_timer_create_with_lrt=yes, + vim_cv_timer_create_with_lrt=no, + AC_MSG_ERROR(cross-compiling: please set 'vim_cv_timer_create_with_lrt') + )]) + LIBS="$save_LIBS" +else + vim_cv_timer_create_with_lrt=no +fi if test "x$vim_cv_timer_create" = "xyes" ; then AC_DEFINE(HAVE_TIMER_CREATE) fi - +if test "x$vim_cv_timer_create_with_lrt" = "xyes" ; then + AC_DEFINE(HAVE_TIMER_CREATE) + LIBS="$LIBS -lrt" +fi AC_CACHE_CHECK([whether stat() ignores a trailing slash], [vim_cv_stat_ignores_slash], [ -- cgit v1.2.3