[PATCH] Fix for clock_gettime() detection without librt

Brad Smith <[email protected]> Fri, 29 Oct 2021 17:03:33 -0400
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <[email protected]>
Fix clock_gettime() detection on OS's that do not have librt such as OpenBSD.


Index: configure
===================================================================
--- configure	(revision 38325)
+++ configure	(working copy)
@@ -4563,8 +4563,12 @@
 echocheck "clock_gettime()"
 clock_gettime=no
 def_clock_gettime='#undef HAVE_CLOCK_GETTIME'
-statement_check_broken stddef.h time.h 'struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp)' -lrt &&
-    { clock_gettime=yes ; def_clock_gettime='#define HAVE_CLOCK_GETTIME 1' ; extra_ldflags="$extra_ldflags -lrt" ; }
+statement_check_broken stddef.h time.h 'struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp)' &&
+    { clock_gettime=yes ; def_clock_gettime='#define HAVE_CLOCK_GETTIME 1' ; }
+if test "$clock_gettime" = no ; then
+  statement_check_broken stddef.h time.h 'struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp)' -lrt &&
+      { clock_gettime=yes ; def_clock_gettime='#define HAVE_CLOCK_GETTIME 1' ; extra_ldflags="$extra_ldflags -lrt" ; }
+fi
 echores "$clock_gettime"