Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly link against functions introduced in macOS 10.12 #350

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
first pass
  • Loading branch information
maxbelanger committed Feb 27, 2017
commit 4f0a8574c778b28b66eb8c8ff04ace2ca91ad9f4
71 changes: 60 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -11256,7 +11256,7 @@ fi
for ac_func in alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
clock confstr ctermid dup3 execv faccessat fchmod fchmodat fchown fchownat \
fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
futimens futimes gai_strerror getentropy \
futimens futimes gai_strerror \
getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
initgroups kill killpg lchmod lchown linkat lstat lutimes mmap \
Expand Down Expand Up @@ -12488,7 +12488,55 @@ fi
done


for ac_func in clock_gettime
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for macOS SDK pre-Sierra" >&5
$as_echo_n "checking for macOS SDK pre-Sierra... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#ifdef __APPLE__
# include <AvailabilityMacros.h>
# ifndef MAC_OS_X_VERSION_10_12
# define MAC_OS_X_VERSION_10_12 101200
# endif
# if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
# error "pre-Sierra"
# endif
# endif
#endif

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
on_macos_pre_sierra=no ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
else
on_macos_pre_sierra=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext


if test "$on_macos_pre_sierra" = "no"; then
for ac_func in getentropy
do :
ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy"
if test "x$ac_cv_func_getentropy" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_GETENTROPY 1
_ACEOF

fi
done


for ac_func in clock_gettime
do :
ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
if test "x$ac_cv_func_clock_gettime" = xyes; then :
Expand All @@ -12498,7 +12546,7 @@ _ACEOF

else

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
$as_echo_n "checking for clock_gettime in -lrt... " >&6; }
if ${ac_cv_lib_rt_clock_gettime+:} false; then :
$as_echo_n "(cached) " >&6
Expand Down Expand Up @@ -12536,8 +12584,8 @@ fi
$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
if test "x$ac_cv_lib_rt_clock_gettime" = xyes; then :

LIBS="$LIBS -lrt"
$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
LIBS="$LIBS -lrt"
$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h


$as_echo "#define TIMEMODULE_LIB rt" >>confdefs.h
Expand All @@ -12550,7 +12598,7 @@ fi
done


for ac_func in clock_getres
for ac_func in clock_getres
do :
ac_fn_c_check_func "$LINENO" "clock_getres" "ac_cv_func_clock_getres"
if test "x$ac_cv_func_clock_getres" = xyes; then :
Expand All @@ -12560,7 +12608,7 @@ _ACEOF

else

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_getres in -lrt" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_getres in -lrt" >&5
$as_echo_n "checking for clock_getres in -lrt... " >&6; }
if ${ac_cv_lib_rt_clock_getres+:} false; then :
$as_echo_n "(cached) " >&6
Expand Down Expand Up @@ -12598,7 +12646,7 @@ fi
$as_echo "$ac_cv_lib_rt_clock_getres" >&6; }
if test "x$ac_cv_lib_rt_clock_getres" = xyes; then :

$as_echo "#define HAVE_CLOCK_GETRES 1" >>confdefs.h
$as_echo "#define HAVE_CLOCK_GETRES 1" >>confdefs.h


fi
Expand All @@ -12608,7 +12656,7 @@ fi
done


for ac_func in clock_settime
for ac_func in clock_settime
do :
ac_fn_c_check_func "$LINENO" "clock_settime" "ac_cv_func_clock_settime"
if test "x$ac_cv_func_clock_settime" = xyes; then :
Expand All @@ -12618,7 +12666,7 @@ _ACEOF

else

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_settime in -lrt" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_settime in -lrt" >&5
$as_echo_n "checking for clock_settime in -lrt... " >&6; }
if ${ac_cv_lib_rt_clock_settime+:} false; then :
$as_echo_n "(cached) " >&6
Expand Down Expand Up @@ -12656,7 +12704,7 @@ fi
$as_echo "$ac_cv_lib_rt_clock_settime" >&6; }
if test "x$ac_cv_lib_rt_clock_settime" = xyes; then :

$as_echo "#define HAVE_CLOCK_SETTIME 1" >>confdefs.h
$as_echo "#define HAVE_CLOCK_SETTIME 1" >>confdefs.h


fi
Expand All @@ -12665,6 +12713,7 @@ fi
fi
done

fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for major" >&5
$as_echo_n "checking for major... " >&6; }
Expand Down
54 changes: 38 additions & 16 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3417,7 +3417,7 @@ fi
AC_CHECK_FUNCS(alarm accept4 setitimer getitimer bind_textdomain_codeset chown \
clock confstr ctermid dup3 execv faccessat fchmod fchmodat fchown fchownat \
fexecve fdopendir fork fpathconf fstatat ftime ftruncate futimesat \
futimens futimes gai_strerror getentropy \
futimens futimes gai_strerror \
getgrouplist getgroups getlogin getloadavg getpeername getpgid getpid \
getpriority getresuid getresgid getpwent getspnam getspent getsid getwd \
initgroups kill killpg lchmod lchown linkat lstat lutimes mmap \
Expand Down Expand Up @@ -3732,26 +3732,48 @@ AC_CHECK_FUNCS(gettimeofday,
])
)

AC_CHECK_FUNCS(clock_gettime, [], [
AC_CHECK_LIB(rt, clock_gettime, [
LIBS="$LIBS -lrt"
AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
AC_DEFINE(TIMEMODULE_LIB, [rt],
[Library needed by timemodule.c: librt may be needed for clock_gettime()])
AC_MSG_CHECKING([for macOS SDK pre-Sierra])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef __APPLE__
# include <AvailabilityMacros.h>
# ifndef MAC_OS_X_VERSION_10_12
# define MAC_OS_X_VERSION_10_12 101200
# endif
# if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
# error "pre-Sierra"
# endif
# endif
#endif
]], [[]])],
[on_macos_pre_sierra=no ; AC_MSG_RESULT([no])],
[on_macos_pre_sierra=yes; AC_MSG_RESULT([yes])])


if test "$on_macos_pre_sierra" = "no"; then
AC_CHECK_FUNCS(getentropy)

AC_CHECK_FUNCS(clock_gettime, [], [
AC_CHECK_LIB(rt, clock_gettime, [
LIBS="$LIBS -lrt"
AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
AC_DEFINE(TIMEMODULE_LIB, [rt],
[Library needed by timemodule.c: librt may be needed for clock_gettime()])
])
])
])

AC_CHECK_FUNCS(clock_getres, [], [
AC_CHECK_LIB(rt, clock_getres, [
AC_DEFINE(HAVE_CLOCK_GETRES, 1)
AC_CHECK_FUNCS(clock_getres, [], [
AC_CHECK_LIB(rt, clock_getres, [
AC_DEFINE(HAVE_CLOCK_GETRES, 1)
])
])
])

AC_CHECK_FUNCS(clock_settime, [], [
AC_CHECK_LIB(rt, clock_settime, [
AC_DEFINE(HAVE_CLOCK_SETTIME, 1)
AC_CHECK_FUNCS(clock_settime, [], [
AC_CHECK_LIB(rt, clock_settime, [
AC_DEFINE(HAVE_CLOCK_SETTIME, 1)
])
])
])
fi

AC_MSG_CHECKING(for major, minor, and makedev)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Expand Down