]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
build: Conditionalize bsd_getopt() on macOS
authorGuillem Jover <guillem@hadrons.org>
Tue, 18 Apr 2023 01:58:24 +0000 (03:58 +0200)
committerGuillem Jover <guillem@hadrons.org>
Sat, 22 Apr 2023 17:30:05 +0000 (19:30 +0200)
The system library provides a getopt() with BSD semantics.

configure.ac
include/bsd/unistd.h
src/Makefile.am

index d6446a06347983d34ef17dae09e7e6ddcef770c7..c759d4e0502aa546f73573c3b075e587fad194af 100644 (file)
@@ -309,6 +309,7 @@ AC_CHECK_FUNCS([\
 ])
 
 need_arc4random=yes
+need_bsd_getopt=yes
 need_md5=yes
 need_nlist=yes
 need_strl=yes
@@ -330,6 +331,7 @@ AS_CASE([$host_os],
     # On macOS these are provided by the system, and libbsd has never built
     # there, so we can avoid providing these with no ABI breakage.
     need_arc4random=no
+    need_bsd_getopt=no
     need_transparent_libmd=no
     need_md5=no
     need_nlist=no
@@ -345,6 +347,7 @@ AS_CASE([$host_os],
 AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
 
 AM_CONDITIONAL([NEED_ARC4RANDOM], [test "x$need_arc4random" = "xyes"])
+AM_CONDITIONAL([NEED_BSD_GETOPT], [test "x$need_bsd_getopt" = "xyes"])
 AM_CONDITIONAL([NEED_TRANSPARENT_LIBMD], [test "x$need_transparent_libmd" = "xyes"])
 AM_CONDITIONAL([NEED_MD5], [test "x$need_md5" = "xyes"])
 AM_CONDITIONAL([NEED_NLIST], [test "x$need_nlist" = "xyes"])
index 20b09931633604f261c942e1e1b031a75e8cc9f9..f246ac5d93fd4eda87c8ce6e02710b1627946622 100644 (file)
@@ -47,6 +47,7 @@
 #endif
 
 __BEGIN_DECLS
+#if !defined(__APPLE__)
 extern int optreset;
 
 #ifdef LIBBSD_OVERLAY
@@ -55,6 +56,7 @@ extern int optreset;
 #endif
 
 int bsd_getopt(int argc, char * const argv[], const char *shortopts);
+#endif
 
 mode_t getmode(const void *set, mode_t mode);
 void *setmode(const char *mode_str);
index c02561eb271a2a113437afb1a7c83f1a5b3f1cce..3e26159a527c89f1fcb8e9462e890e1b5071ae1d 100644 (file)
@@ -75,7 +75,6 @@ EXTRA_libbsd_la_DEPENDENCIES += \
        # EOL
 endif
 libbsd_la_SOURCES = \
-       bsd_getopt.c \
        closefrom.c \
        dehumanize_number.c \
        err.c \
@@ -116,6 +115,12 @@ libbsd_la_SOURCES = \
        wcslcpy.c \
        # EOL
 
+if NEED_BSD_GETOPT
+libbsd_la_SOURCES += \
+       bsd_getopt.c \
+       # EOL
+endif
+
 if NEED_ARC4RANDOM
 if !HAVE_GETENTROPY
 libbsd_la_SOURCES += \