summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-04 19:29:35 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-04 19:30:08 -0700
commitc01da8ebd0969efd15388ce999e121127cc46f67 (patch)
treebd63329720ef74fba8f47c9bafc83e8c89367666
parente5ace1c5fe009e5c66fa16f886b13cce2558684a (diff)
Only link with libbsd if needed for arc4random_buf()
Avoid unnecessary library dependency when using a libc with this function included Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--configure.ac16
1 files changed, 11 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 3d8d76f..a73a418 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,11 +56,6 @@ AC_PROG_LN_S
AC_CHECK_HEADERS([sys/random.h])
# Checks for libraries.
-PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay], [
- CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
- LIBS="$LIBS $LIBBSD_LIBS"
-], [:])
-
AC_SEARCH_LIBS([recvfrom],[socket])
case $host_os in
@@ -71,6 +66,17 @@ case $host_os in
;;
esac
+# Checks for non-standard functions and fallback to libbsd if we can
+# We only check for arc4random_buf, because if we have that, we don't
+# need/use getentropy.
+AC_LINK_IFELSE([AC_LANG_CALL([], [arc4random_buf])],
+ [TRY_LIBBSD="no"], [TRY_LIBBSD="yes"])
+AS_IF([test "x$TRY_LIBBSD" = "xyes"],
+ [PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay], [
+ CFLAGS="$CFLAGS $LIBBSD_CFLAGS"
+ LIBS="$LIBS $LIBBSD_LIBS"
+], [:])])
+
# Checks for library functions.
AC_CHECK_FUNCS([srand48 lrand48 arc4random_buf getentropy])