build: Rework ABI selection logic Add a new LIBBSD_SELECT_ABI m4 macro, and use it to setup the ABI interfaces to expose and the various variables and conditionals to be used by the build system. Switch to set the initial values to unknown and then set every one of the selections explicitly by supported target. Update comments for rationale for things to DROP, or for why some selections are enabled.
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
diff --git a/configure.ac b/configure.ac
index c6163e7..ef79d0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,35 +35,56 @@ LT_INIT
LIBBSD_LINKER_VERSION_SCRIPT
## Select library ABI to expose.
+#
+# The systems have DROP comments for interfaces that could be dropped on
+# the next SOVERSION bump.
is_windows=no
-abi_arc4random=no
-abi_bsd_getopt=no
-abi_err=no
-abi_errc=no
-abi_fpurge=no
-abi_funopen=no
-abi_md5=no
-abi_name_from_id=no
-abi_nlist=no
-abi_progname=no
-abi_strl=no
-abi_strmode=no
-abi_wcsl=no
+abi_arc4random=unknown
+abi_bsd_getopt=unknown
+abi_err=unknown
+abi_errc=unknown
+abi_fpurge=unknown
+abi_funopen=unknown
+abi_md5=unknown
+abi_name_from_id=unknown
+abi_nlist=unknown
+abi_progname=unknown
+abi_strl=unknown
+abi_strmode=unknown
+abi_wcsl=unknown
AS_CASE([$host_os],
[*-gnu*], [
+ # DROP: On glibc >= 2.36, parts the arc4random() API got added.
+ #abi_arc4random=no
+ abi_arc4random=yes
+ abi_bsd_getopt=yes
+ abi_err=no
abi_errc=yes
- # On glibc >= 2.38, strlcpy() and strlcat() got added,
- # so these could then be dropped on the next SOVERSION bump.
+ abi_fpurge=yes
+ abi_funopen=yes
+ # DROP: On libmd.
+ #abi_md5=no
+ abi_md5=yes
+ abi_name_from_id=yes
+ abi_nlist=yes
+ abi_progname=yes
+ # DROP: On glibc >= 2.38.
#abi_strl=no
+ abi_strl=yes
+ abi_strmode=yes
+ abi_wcsl=yes
],
[*-musl*], [
- # On musl >= 0.9.7, optreset got implemented, so bsd_getopt() can then
- # be dropped on the next SOVERSION bump.
+ abi_arc4random=yes
+ # DROP: On musl >= 0.9.7, optreset got implemented.
#abi_bsd_getopt=no
+ abi_bsd_getopt=yes
abi_err=no
+ abi_errc=yes
+ abi_fpurge=yes
# On musl >= 1.1.19, fopencookie() got implemented, and because we were
# checking for its presence to decide whether to build funopen(), it got
# included in builds even when previously it had not been included, which
@@ -71,9 +92,17 @@ AS_CASE([$host_os],
# worse, we'll ignore this as this is only a problem with downgrades. And
# enable it explicitly
abi_funopen=yes
- # On musl >= 0.5.0, strlcpy() and strlcat() were already implemented,
- # so these can then be dropped on the next SOVERSION bump.
+ # DROP: On libmd.
+ #abi_md5=no
+ abi_md5=yes
+ abi_name_from_id=yes
+ abi_nlist=yes
+ abi_progname=yes
+ # DROP: On musl >= 0.5.0, strlcpy() and strlcat() were already implemented.
#abi_strl=no
+ abi_strl=yes
+ abi_strmode=yes
+ abi_wcsl=yes
],
[darwin*], [
# On macOS these are provided by the system, and libbsd has never built
@@ -83,7 +112,6 @@ AS_CASE([$host_os],
abi_err=no
abi_errc=no
abi_fpurge=no
- # On macOS we do not have fopencookie(), and cannot implement it.
abi_funopen=no
abi_md5=no
abi_name_from_id=no
@@ -280,20 +308,20 @@ AC_CHECK_FUNCS([\
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
# ABI selection
-AM_CONDITIONAL([ABI_ARC4RANDOM], [test "x$abi_arc4random" = "xyes"])
-AM_CONDITIONAL([ABI_BSD_GETOPT], [test "x$abi_bsd_getopt" = "xyes"])
-AM_CONDITIONAL([ABI_ERR], [test "x$abi_err" = "xyes"])
-AM_CONDITIONAL([ABI_ERRC], [test "x$abi_errc" = "xyes"])
-AM_CONDITIONAL([ABI_PROGNAME], [test "x$abi_progname" = "xyes"])
-AM_CONDITIONAL([ABI_TRANSPARENT_LIBMD], [test "x$abi_transparent_libmd" = "xyes"])
-AM_CONDITIONAL([ABI_MD5], [test "x$abi_md5" = "xyes"])
-AM_CONDITIONAL([ABI_NLIST], [test "x$abi_nlist" = "xyes"])
-AM_CONDITIONAL([ABI_STRL], [test "x$abi_strl" = "xyes"])
-AM_CONDITIONAL([ABI_WCSL], [test "x$abi_wcsl" = "xyes"])
-AM_CONDITIONAL([ABI_STRMODE], [test "x$abi_strmode" = "xyes"])
-AM_CONDITIONAL([ABI_NAME_FROM_ID], [test "x$abi_name_from_id" = "xyes"])
-AM_CONDITIONAL([ABI_FPURGE], [test "x$abi_fpurge" = "xyes"])
-AM_CONDITIONAL([ABI_FUNOPEN], [test "x$abi_funopen" = "xyes"])
+LIBBSD_SELECT_ABI([arc4random], [arc4random() API])
+LIBBSD_SELECT_ABI([bsd_getopt], [BSD getopt()])
+LIBBSD_SELECT_ABI([err], [err API])
+LIBBSD_SELECT_ABI([errc], [errc API])
+LIBBSD_SELECT_ABI([fpurge], [fpurge()])
+LIBBSD_SELECT_ABI([funopen], [funopen()])
+LIBBSD_SELECT_ABI([md5], [MD5 digest functions])
+LIBBSD_SELECT_ABI([name_from_id], [user_from_uid()/group_from_gid()])
+LIBBSD_SELECT_ABI([nlist], [nlist()])
+LIBBSD_SELECT_ABI([progname], [setprogname()/getprogname()])
+LIBBSD_SELECT_ABI([strl], [strlcpy()/strlcat()])
+LIBBSD_SELECT_ABI([strmode], [strmode()])
+LIBBSD_SELECT_ABI([transparent_libmd], [transparent libmd support])
+LIBBSD_SELECT_ABI([wcsl], [wcslcpy()/wcslcat()])
AS_IF([test "x$abi_funopen" = "xno" && \
test "x$ac_cv_func_funopen" != "xyes" && \
diff --git a/m4/libbsd-compiler.m4 b/m4/libbsd-compiler.m4
index 135f38c..0708f57 100644
--- a/m4/libbsd-compiler.m4
+++ b/m4/libbsd-compiler.m4
@@ -70,3 +70,19 @@ int main() { return rc; }
AM_CONDITIONAL([BUILD_LIBBSD_CTOR],
[test "$libbsd_cv_gnu_init_array_support" = yes])
])
+
+# LIBBSD_SELECT_ABI(name, desc)
+# -----------------
+AC_DEFUN([LIBBSD_SELECT_ABI], [
+ AS_IF([test -z "$AS_TR_SH([abi_$1])"], [
+ AC_MSG_ERROR([missing ABI selection for $1])
+ ], [test "$AS_TR_SH([abi_$1])" = "unknown"], [
+ AC_MSG_ERROR([unknown ABI selection for $1])
+ ], [test "$AS_TR_SH([abi_$1])" = "yes"], [
+ AC_DEFINE(AS_TR_CPP([LIBBSD_ABI_$1]), [1], [Provide ABI for $2])
+ ], [
+ AC_DEFINE(AS_TR_CPP([LIBBSD_ABI_$1]), [0])
+ ])
+ AM_CONDITIONAL(AS_TR_CPP([ABI_$1]),
+ [test "x$AS_TR_SH([abi_$1])" = "xyes"])
+])