]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
build: Select whether to include funopen() in the build system
authorGuillem Jover <guillem@hadrons.org>
Thu, 6 Apr 2023 21:05:27 +0000 (23:05 +0200)
committerGuillem Jover <guillem@hadrons.org>
Mon, 17 Apr 2023 02:12:42 +0000 (04:12 +0200)
This makes sure we include it when expected, alongside the man pages,
and the test cases, and do not accidentally break the ABI if the system
starts providing such interface.

configure.ac
man/Makefile.am
src/Makefile.am
src/funopen.c
test/Makefile.am

index 44717c2be7936c05dc4c450a03d2ccda8fcdd1cd..c2bd521e8e94e6cdbb4ba5c1477d667d4434d46e 100644 (file)
@@ -297,6 +297,7 @@ AC_CHECK_FUNCS([\
   flock \
   fopencookie \
   __fpurge \
+  funopen \
   getauxval \
   getentropy \
   getexecname \
@@ -305,8 +306,31 @@ AC_CHECK_FUNCS([\
   pstat_getproc \
   sysconf \
 ])
+
+need_funopen=yes
+AS_CASE([$host_os],
+  [*-musl*], [
+    # 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
+    # is partially an ABI issue, but given that disabling it now would be
+    # worse, we'll ignore this as this is only a problem with downgrades. And
+    # enable it explicitly
+    need_funopen=yes
+  ],
+  [darwin*], [
+    # On macOS we do not have fopencookie(), and cannot implement it.
+    need_funopen=no
+  ],
+)
+
 AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
-AM_CONDITIONAL([HAVE_FOPENCOOKIE], [test "x$ac_cv_func_fopencookie" = "xyes"])
+AM_CONDITIONAL([NEED_FUNOPEN], [test "x$need_funopen" = "xyes"])
+AS_IF([test "x$need_funopen" = "xno" && \
+       test "x$ac_cv_func_funopen" != "xyes" && \
+       test "x$ac_cv_func_fopencookie" = "xyes"], [
+  AC_MSG_WARN([[can implement funopen() now based on newly added fopencooke(), report upstream]])
+])
 
 AC_SUBST([MD5_LIBS])
 AC_SUBST([LIBBSD_LIBS])
index 961d2f5e5e44b556b4ff2d3ba89aba1b136d8a3e..6d1c86a89933120fa54271dc23197fa3949c0007 100644 (file)
@@ -178,7 +178,6 @@ dist_man_MANS = \
        fmtcheck.3bsd \
        fparseln.3bsd \
        fpurge.3bsd \
-       funopen.3bsd \
        getbsize.3bsd \
        getmode.3bsd \
        getpeereid.3bsd \
@@ -252,3 +251,9 @@ dist_man_MANS = \
        wcslcat.3bsd \
        wcslcpy.3bsd \
        # EOL
+
+if NEED_FUNOPEN
+dist_man_MANS += \
+       funopen.3bsd \
+       # EOL
+endif
index bc1add60a4b8943cf3678f3903249ddf48374b87..4781bdb1d6c0fef60f87223731b3bd762af31049 100644 (file)
@@ -95,7 +95,6 @@ libbsd_la_SOURCES = \
        fmtcheck.c \
        fparseln.c \
        fpurge.c \
-       funopen.c \
        getbsize.c \
        getpeereid.c \
        heapsort.c \
@@ -137,6 +136,12 @@ libbsd_la_SOURCES += \
        # EOL
 endif
 
+if NEED_FUNOPEN
+libbsd_la_SOURCES += \
+       funopen.c \
+       # EOL
+endif
+
 if NEED_TRANSPARENT_LIBMD
 CLEANFILES += \
        format.ld \
index 0513e38dabb23f3917e022bdafa498f71e245cfb..fdcdcba687e1ed9398410478f41fe3a213060989 100644 (file)
@@ -138,5 +138,5 @@ funopen(const void *cookie,
        return fopencookie(cookiewrap, mode, funcswrap);
 }
 #else
-#warning "Function funopen() is not provided on this platform."
+#error "Function funopen() needs to be ported."
 #endif
index 458a4e94da611dbe3cdbf2ece736c454739d6fc1..985e3e133175f256e929d7074fe7f98f311ef245 100644 (file)
@@ -55,7 +55,7 @@ check_PROGRAMS = \
        vis-openbsd \
        # EOL
 
-if HAVE_FOPENCOOKIE
+if NEED_FUNOPEN
 check_PROGRAMS += funopen
 endif