diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 701af2f0bf0..d3f65aa18c6 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -256,6 +256,14 @@ if_indextoname(index) -- returns the corresponding interface name\n\ #include #endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_NET_IF_H +#include +#endif + /* Generic socket object definitions and includes */ #define PySocket_BUILDING_SOCKET #include "socketmodule.h" diff --git a/configure b/configure index d5506efd942..e1ab99b81e9 100755 --- a/configure +++ b/configure @@ -6037,7 +6037,7 @@ sys/lock.h sys/mkdev.h sys/modem.h \ sys/param.h sys/poll.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \ sys/stat.h sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ -libutil.h sys/resource.h net/if.h netpacket/packet.h sysexits.h bluetooth.h \ +libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ bluetooth/bluetooth.h linux/tipc.h spawn.h util.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -6260,6 +6260,34 @@ fi fi +# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first. +for ac_header in net/if.h +do : + ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +" +if test "x$ac_cv_header_net_if_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_NET_IF_H 1 +_ACEOF + +fi + +done + + + # On Solaris, term.h requires curses.h for ac_header in term.h do : diff --git a/configure.in b/configure.in index 3ae9a34ffe1..3bf46b0ed8d 100644 --- a/configure.in +++ b/configure.in @@ -1293,11 +1293,28 @@ sys/lock.h sys/mkdev.h sys/modem.h \ sys/param.h sys/poll.h sys/select.h sys/sendfile.h sys/socket.h sys/statvfs.h \ sys/stat.h sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ -libutil.h sys/resource.h net/if.h netpacket/packet.h sysexits.h bluetooth.h \ +libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ bluetooth/bluetooth.h linux/tipc.h spawn.h util.h) AC_HEADER_DIRENT AC_HEADER_MAJOR +# On Darwin (OS X) net/if.h requires sys/socket.h to be imported first. +AC_CHECK_HEADERS([net/if.h], [], [], +[#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +]) + + # On Solaris, term.h requires curses.h AC_CHECK_HEADERS(term.h,,,[ #ifdef HAVE_CURSES_H