build: Use a single variable to track libraries to link against Using various variables means we have to keep these in sync in various places. Just use a single variable that we can use anywhere where this is needed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
diff --git a/configure.ac b/configure.ac
index 7afc7af..3281efb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,7 @@ saved_LIBS="$LIBS"
AC_SEARCH_LIBS([MD5Update], [md], [
AS_IF([test "x$ac_cv_search_MD5Update" != "xnone required"], [
MD_LIBS="$ac_cv_search_MD5Update"
+ LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_MD5Update"
])
], [
AC_MSG_ERROR([cannot find required MD5 functions in libc or libmd])
@@ -74,6 +75,7 @@ AC_SEARCH_LIBS([MD5Update], [md], [
AC_SEARCH_LIBS([SHA512Update], [md], [
AS_IF([test "x$ac_cv_search_SHA512Update" != "xnone required"], [
MD_LIBS="$ac_cv_search_SHA512Update"
+ LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_SHA512Update"
])
], [
AC_MSG_ERROR([cannot find required SHA-2 functions in libc or libmd])
@@ -88,10 +90,9 @@ AS_CASE([$host_os],
saved_LIBS="$LIBS"
AC_SEARCH_LIBS([clock_gettime], [rt], [
AS_IF([test "x$ac_cv_search_clock_gettime" != "xnone required"], [
- CLOCK_GETTIME_LIBS="$ac_cv_search_clock_gettime"
+ LIBBSD_LIBS="$LIBBSD_LIBS $ac_cv_search_clock_gettime"
])
])
- AC_SUBST([CLOCK_GETTIME_LIBS])
LIBS="$saved_LIBS"
],
[*-musl*], [
@@ -199,8 +200,7 @@ AC_LINK_IFELSE(
[AC_DEFINE([HAVE___REGISTER_ATFORK], [1],
[Define to 1 if you have __register_atfork])
AC_MSG_RESULT([yes])],
- [ARC4RANDOM_ATFORK_LIBS="-pthread"
- AC_SUBST([ARC4RANDOM_ATFORK_LIBS])
+ [LIBBSD_LIBS="$LIBBSD_LIBS -pthread"
AC_MSG_RESULT([no])
])
@@ -209,6 +209,8 @@ AC_CHECK_FUNCS([clearenv dirfd fopencookie __fpurge \
pstat_getproc sysconf])
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xtrue"])
+AC_SUBST([LIBBSD_LIBS])
+
AC_CONFIG_FILES([
Makefile
include/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 48fb1fa..7ef2013 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -52,9 +52,7 @@ libbsd_la_DEPENDENCIES = \
$(libbsd_la_included_sources) \
libbsd.map
libbsd_la_LIBADD = \
- $(MD_LIBS) \
- $(CLOCK_GETTIME_LIBS) \
- $(ARC4RANDOM_ATFORK_LIBS) \
+ $(LIBBSD_LIBS) \
$(nil)
libbsd_la_LDFLAGS = \
-version-number $(LIBBSD_ABI)