build: avoid getifaddrs when unavailable

This commit is contained in:
Cory Fields 2018-07-19 14:21:05 -04:00 committed by Lawrence Nahum
parent 2070a545e2
commit 9256f7d13f
No known key found for this signature in database
GPG Key ID: 17AB8BC320B151D8
2 changed files with 5 additions and 1 deletions

View File

@ -727,6 +727,10 @@ fi
AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h]) AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
AC_CHECK_DECLS([getifaddrs, freeifaddrs],,,
[#include <sys/types.h>
#include <ifaddrs.h>]
)
AC_CHECK_DECLS([strnlen]) AC_CHECK_DECLS([strnlen])
# Check for daemon(3), unrelated to --with-daemon (although used by it) # Check for daemon(3), unrelated to --with-daemon (although used by it)

View File

@ -2167,7 +2167,7 @@ void Discover()
} }
} }
} }
#else #elif (HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS)
// Get local host ip // Get local host ip
struct ifaddrs* myaddrs; struct ifaddrs* myaddrs;
if (getifaddrs(&myaddrs) == 0) if (getifaddrs(&myaddrs) == 0)