summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@hadrons.org>2024-02-14 04:59:44 +0100
committerGuillem Jover <guillem@hadrons.org>2024-02-25 03:49:15 +0100
commit27503a1066fe28ebc84d080f24a475c99f82b48e (patch)
tree18c4209af007afd84ad7dee6da705f1d65e4e150
parent99739877be6e3eaa28681201019ec16788c789fe (diff)
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.
-rw-r--r--configure.ac96
-rw-r--r--m4/libbsd-compiler.m416
2 files changed, 78 insertions, 34 deletions
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"])
+])