]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
build: use libbsd overlay
authorVincent Bernat <vincent@bernat.im>
Sat, 12 Dec 2015 20:37:52 +0000 (21:37 +0100)
committerVincent Bernat <vincent@bernat.im>
Sat, 12 Dec 2015 20:37:52 +0000 (21:37 +0100)
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
src/compat/compat.h

index eaa576d0a9cf255548c7f92b20b156b0ffeef5c1..52dbc1b89d6f94b3a8a1b3e1d94ac7bca2f4e835 100644 (file)
@@ -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)], [
index 135661cc3caafcb08ef2b5f6a300a324ca232a91..5232c530e67ae5165eb7aba03c93ea29ac8345fd 100644 (file)
 #include <stdio.h>
 #include <stddef.h>
 #include <stdarg.h>
-#ifdef HAVE_LIBBSD
-# include <bsd/stdio.h>
-# include <bsd/string.h>
-# include <bsd/unistd.h>
-#endif
+#include <string.h>
+#include <unistd.h>
 
 #if !HAVE_ASPRINTF
 int vasprintf(char **, const char *, va_list) __attribute__ ((format (printf, 2, 0)));