summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-10-27 18:42:47 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-10-27 18:45:32 -0700
commit246cbc402aabe5e971c43d1a21b66ab4c602f1cf (patch)
treeadc85cd9fb08f76e9376919a4065ae69f7e77f45
parent81da58f39d274ab7f822fb22e56b5b2027597a51 (diff)
Only link with libbsd if needed for arc4random_buf() or getentropy()
Avoid unnecessary library dependency when using a libc with these functions included Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--configure.ac11
1 files changed, 9 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 1c9bcf8..328f95f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,10 +31,17 @@ XORG_CHECK_SGML_DOCTOOLS(1.8)
# Obtain compiler/linker options for dependencies
PKG_CHECK_MODULES(ICE, [xproto >= 7.0.25 xtrans])
-PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay], [
+
+# 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([asprintf arc4random_buf getentropy])