ptp: Check for the actual API we use instead of just looking for __APPLE__

Should fix the build on FreeBSD, DragonFly and other BSDs.

https://bugzilla.gnome.org/show_bug.cgi?id=750530
This commit is contained in:
Sebastian Dröge 2015-06-09 10:59:42 +02:00
parent 59d916a071
commit 1ae38f7ba7
2 changed files with 47 additions and 5 deletions

View file

@ -325,6 +325,44 @@ AC_PATH_PROG([SETCAP], [setcap], [no], [$PATH:/usr/bin:/bin:/usr/sbin:/sbin])
if test "x$HAVE_PTP" = "xyes"; then if test "x$HAVE_PTP" = "xyes"; then
AC_DEFINE(HAVE_PTP, 1, [PTP support available]) AC_DEFINE(HAVE_PTP, 1, [PTP support available])
AC_MSG_CHECKING([for SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <sys/ioctl.h>
#include <net/if.h>
]],
[[
struct ifreq ifr;
struct ifconf ifc;
ioctl(0, SIOCGIFCONF, &ifc);
ioctl(0, SIOCGIFFLAGS, &ifr);
ioctl(0, SIOCGIFHWADDR, &ifr);
int dummy = ifr.ifr_hwaddr.sa_data[0];
]])], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR, 1, [SIOCGIFCONF, SIOCGIFFLAGS and SIOCGIFHWADDR is available])
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING([for getifaddrs() and AF_LINK])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <ifaddrs.h>
#include <net/if.h>
#include <net/if_dl.h>
]],
[[
struct ifaddrs *ifaddr;
getifaddrs(&ifaddr);
int dummy = (ifaddr->ifa_flags & IFF_LOOPBACK) && ifaddr->ifa_addr->sa_family != AF_LINK;
]])], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETIFADDRS_AF_LINK, 1, [getifaddrs() and AF_LINK is available])
], [
AC_MSG_RESULT(no)
])
AC_MSG_CHECKING([how to install gst-ptp-helper]) AC_MSG_CHECKING([how to install gst-ptp-helper])
if test "x$with_ptp_helper_permissions" = "xauto"; then if test "x$with_ptp_helper_permissions" = "xauto"; then
if test "x$gst_ptp_have_cap" = "xyes" -a "x$SETCAP" != "xno"; then if test "x$gst_ptp_have_cap" = "xyes" -a "x$SETCAP" != "xno"; then

View file

@ -41,7 +41,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <string.h> #include <string.h>
#ifdef __APPLE__ #ifdef HAVE_GETIFADDRS_AF_LINK
#include <ifaddrs.h> #include <ifaddrs.h>
#include <net/if_dl.h> #include <net/if_dl.h>
#endif #endif
@ -240,7 +240,7 @@ setup_sockets (void)
/* Probe all non-loopback interfaces */ /* Probe all non-loopback interfaces */
if (!ifaces) { if (!ifaces) {
#ifndef __APPLE__ #if defined(HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR)
struct ifreq ifr; struct ifreq ifr;
struct ifconf ifc; struct ifconf ifc;
gchar buf[8192]; gchar buf[8192];
@ -269,7 +269,7 @@ setup_sockets (void)
ifaces = probed_ifaces; ifaces = probed_ifaces;
} }
} }
#else #elif defined(HAVE_GETIFADDRS_AF_LINK)
struct ifaddrs *ifaddr, *ifa; struct ifaddrs *ifaddr, *ifa;
if (getifaddrs (&ifaddr) != -1) { if (getifaddrs (&ifaddr) != -1) {
@ -291,6 +291,8 @@ setup_sockets (void)
g_ptr_array_add (arr, NULL); g_ptr_array_add (arr, NULL);
ifaces = probed_ifaces = (gchar **) g_ptr_array_free (arr, FALSE); ifaces = probed_ifaces = (gchar **) g_ptr_array_free (arr, FALSE);
} }
#else
#warning "Implement something to list all network interfaces"
#endif #endif
} }
@ -298,7 +300,7 @@ setup_sockets (void)
if (clock_id == (guint64) - 1) { if (clock_id == (guint64) - 1) {
gboolean success = FALSE; gboolean success = FALSE;
#ifndef __APPLE__ #if defined(HAVE_SIOCGIFCONF_SIOCGIFFLAGS_SIOCGIFHWADDR)
struct ifreq ifr; struct ifreq ifr;
if (ifaces) { if (ifaces) {
@ -356,7 +358,7 @@ setup_sockets (void)
} }
} }
} }
#else #elif defined(HAVE_GETIFADDRS_AF_LINK)
struct ifaddrs *ifaddr, *ifa; struct ifaddrs *ifaddr, *ifa;
if (getifaddrs (&ifaddr) != -1) { if (getifaddrs (&ifaddr) != -1) {
@ -405,6 +407,8 @@ setup_sockets (void)
freeifaddrs (ifaddr); freeifaddrs (ifaddr);
} }
#else
#warning "Implement something to get MAC addresses of network interfaces"
#endif #endif
if (!success) { if (!success) {