From 246cbc402aabe5e971c43d1a21b66ab4c602f1cf Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 27 Oct 2022 18:42:47 -0700 Subject: 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 --- configure.ac | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'configure.ac') 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]) -- cgit v1.2.3