summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2021-01-15 12:42:35 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2021-01-15 12:42:35 -0800
commit08e0029f105de993d798ea902827ae2efe7798a8 (patch)
tree6cbbd7c47658170b347c0684a6c1f5ac1bca9742
parente78cafbaa2692f5b6e8e8f0ff306f5826c5dd94d (diff)
downloadlibusb-08e0029f105de993d798ea902827ae2efe7798a8.tar.gz
configure.ac: Consider Mac OS X target version for clock_gettime()
The AC_CHECK_FUNCS() macro checks whether a program compiled on the host will link against the function, but it does not help when targeting older systems where that function is not available. Additionally, the way that autoconf compiles the program ignores any attributes or preprocessor guards that installed headers might have applied to that function. Resolve this by verifying that the OS X target version is 10.12 or newer before checking for clock_gettime(). Closes #836 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r--configure.ac28
-rw-r--r--libusb/version_nano.h2
2 files changed, 25 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 5b880f6..7c86598 100644
--- a/configure.ac
+++ b/configure.ac
@@ -199,17 +199,37 @@ dnl headers not available on all platforms but required on others
AC_CHECK_HEADERS([sys/time.h])
if test "x$platform" = xposix; then
- dnl the clock_gettime() function needs certain clock IDs defined
- AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [have_clock_gettime=])
+ dnl check availability of clock_gettime()
+ if test "x$backend" = xdarwin; then
+ dnl need to verify that OS X target is 10.12 or later for clock_gettime()
+ AC_MSG_CHECKING([whether OS X target version is 10.12 or later])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
+ #include <AvailabilityMacros.h>
+ #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
+ # error "Target OS X version is too old"
+ #endif
+ ], [])],
+ [AC_MSG_RESULT([yes])
+ osx_10_12_or_later=yes],
+ [AC_MSG_RESULT([no])
+ osx_10_12_or_later=])
+ if test "x$osx_10_12_or_later" = xyes; then
+ AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [have_clock_gettime=])
+ else
+ AC_MSG_NOTICE([clock_gettime() is not available on target OS X version])
+ fi
+ else
+ AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes], [AC_MSG_ERROR([clock_gettime() is required on this platform])])
+ fi
+
if test "x$have_clock_gettime" = xyes; then
+ dnl the clock_gettime() function needs certain clock IDs defined
AC_CHECK_DECL([CLOCK_MONOTONIC], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_MONOTONIC])], [[#include <time.h>]])
dnl use the monotonic clock for condition variable timed waits if possible
AC_CHECK_FUNCS([pthread_condattr_setclock], [need_clock_realtime=], [need_clock_realtime=yes])
if test "x$need_clock_realtime" = xyes; then
AC_CHECK_DECL([CLOCK_REALTIME], [], [AC_MSG_ERROR([C library headers missing definition for CLOCK_REALTIME])], [[#include <time.h>]])
fi
- elif test "x$backend" != xdarwin; then
- AC_MSG_ERROR([clock_gettime() is required on this platform])
fi
fi
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index e7da9f6..b8e72d6 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11597
+#define LIBUSB_NANO 11598