From 47bbc5f3743cacb7a38a62ebcd64c117bd556eb6 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sat, 12 Dec 2015 21:37:52 +0100 Subject: [PATCH] build: use libbsd overlay This enables more portable code. We check for the presence of libbsd and use it if it is here. All the remaining should work with/without libbsd on Linux or on other OSes. --- configure.ac | 15 +++++++-------- src/compat/compat.h | 7 ++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index eaa576d0..52dbc1b8 100644 --- a/configure.ac +++ b/configure.ac @@ -129,8 +129,13 @@ AC_CONFIG_LIBOBJ_DIR([src/compat]) AC_FUNC_MALLOC AC_FUNC_REALLOC AC_FUNC_FORK -# setproctitle (maybe through libbsd [until 0.5, it is only a stub function]) -AC_SEARCH_LIBS([setproctitle], [util bsd]) + +# Some functions can be in libbsd +PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [ + CFLAGS="$CFLAGS $libbsd_CFLAGS" + LIBS="$LIBS $libbsd_LIBS" +], []) +# setproctitle may have an _init function AC_REPLACE_FUNCS([setproctitle]) AC_CHECK_FUNCS([setproctitle_init]) # Other functions @@ -144,12 +149,6 @@ AC_REPLACE_FUNCS([strlcpy # Optional functions AC_CHECK_FUNCS([setresuid setresgid]) -case " $LIBS " in - *\ -lbsd\ *) - AC_DEFINE(HAVE_LIBBSD, 1, [Define if libbsd is used]) - ;; -esac - # Check for res_init. On OSX, res_init is a symbol in libsystem_info # and a macro in resolv.h. We need to ensure we test with resolv.h. m4_pushdef([AC_LANG_CALL(C)], [ diff --git a/src/compat/compat.h b/src/compat/compat.h index 135661cc..5232c530 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -40,11 +40,8 @@ #include #include #include -#ifdef HAVE_LIBBSD -# include -# include -# include -#endif +#include +#include #if !HAVE_ASPRINTF int vasprintf(char **, const char *, va_list) __attribute__ ((format (printf, 2, 0))); -- 2.39.5