From edc746ea7b8725578e8533b094d40c2be5c04b8b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 22 Apr 2023 22:47:10 +0200 Subject: [PATCH] build: Conditionalize getprogname()/setprogname on macOS These functions are provided by the system libc, so there is no need for us to provide them. --- configure.ac | 3 +++ include/bsd/stdlib.h | 2 ++ man/Makefile.am | 9 +++++++-- test/Makefile.am | 5 ++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index f0762f6..624494e 100644 --- a/configure.ac +++ b/configure.ac @@ -320,6 +320,7 @@ AC_CHECK_FUNCS([\ need_arc4random=yes need_bsd_getopt=yes +need_progname=yes need_md5=yes need_nlist=yes need_strl=yes @@ -348,6 +349,7 @@ AS_CASE([$host_os], # there, so we can avoid providing these with no ABI breakage. need_arc4random=no need_bsd_getopt=no + need_progname=no need_transparent_libmd=no need_md5=no need_nlist=no @@ -364,6 +366,7 @@ 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_PROGNAME], [test "x$need_progname" = "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"]) diff --git a/include/bsd/stdlib.h b/include/bsd/stdlib.h index bba13af..51c58e8 100644 --- a/include/bsd/stdlib.h +++ b/include/bsd/stdlib.h @@ -65,8 +65,10 @@ void arc4random_addrandom(unsigned char *dat, int datlen); int dehumanize_number(const char *str, int64_t *size); +#if !defined(__APPLE__) const char *getprogname(void); void setprogname(const char *); +#endif int heapsort(void *, size_t, size_t, int (*)(const void *, const void *)); int mergesort(void *base, size_t nmemb, size_t size, diff --git a/man/Makefile.am b/man/Makefile.am index bc30c87..91499e1 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -180,7 +180,6 @@ dist_man_MANS = \ getbsize.3bsd \ getmode.3bsd \ getpeereid.3bsd \ - getprogname.3bsd \ heapsort.3bsd \ humanize_number.3bsd \ le16dec.3bsd \ @@ -205,7 +204,6 @@ dist_man_MANS = \ setmode.3bsd \ setproctitle.3bsd \ setproctitle_init.3bsd \ - setprogname.3bsd \ sl_add.3bsd \ sl_delete.3bsd \ sl_find.3bsd \ @@ -241,6 +239,13 @@ dist_man_MANS = \ wcslcpy.3bsd \ # EOL +if NEED_PROGNAME +dist_man_MANS += \ + getprogname.3bsd \ + setprogname.3bsd \ + # EOL +endif + if NEED_MD5 dist_man_MANS += \ md5.3bsd \ diff --git a/test/Makefile.am b/test/Makefile.am index 7d220f7..13c2ae1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -41,7 +41,6 @@ check_PROGRAMS = \ fgetln \ fparseln \ proctitle-init \ - progname \ setmode \ strnstr \ strtonum \ @@ -49,6 +48,10 @@ check_PROGRAMS = \ vis-openbsd \ # EOL +if NEED_PROGNAME +check_PROGRAMS += progname +endif + if NEED_NLIST check_PROGRAMS += nlist endif