r26469: Fix paths, only include IPv4 addresses for now.
[Samba.git] / source / lib / replace / getifaddrs.m4
blob7e6016ed8f053b9c8254505f7f912b4ee1c70ad2
1 AC_CHECK_HEADERS([ifaddrs.h])
3 dnl test for getifaddrs and freeifaddrs
4 AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[
5 AC_TRY_COMPILE([
6 #include <sys/socket.h>
7 #include <sys/types.h>
8 #include <netinet/in.h>
9 #include <arpa/inet.h>
10 #include <ifaddrs.h>
11 #include <netdb.h>],
13 struct ifaddrs *ifp = NULL;
14 int ret = getifaddrs (&ifp);
15 freeifaddrs(ifp);
17 samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)])
18 if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then
19     AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs])
20     AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs])
21         AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available])
24 ##################
25 # look for a method of finding the list of network interfaces
27 # This tests need LIBS="$NSL_LIBS $SOCKET_LIBS"
29 old_LIBS=$LIBS
30 LIBS="$NSL_LIBS $SOCKET_LIBS"
31 iface=no;
32 ##################
33 # look for a method of finding the list of network interfaces
34 iface=no;
35 AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[
36 SAVE_CPPFLAGS="$CPPFLAGS"
37 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
38 AC_TRY_RUN([
39 #define NO_CONFIG_H 1
40 #define HAVE_IFACE_GETIFADDRS 1
41 #define AUTOCONF_TEST 1
42 #include "$libreplacedir/replace.c"
43 #include "$libreplacedir/getifaddrs.c"],
44            samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)])
45 CPPFLAGS="$SAVE_CPPFLAGS"
46 if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
47     iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
48 else
49         LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o"
53 if test $iface = no; then
54 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
55 AC_TRY_RUN([
56 #define HAVE_IFACE_AIX 1
57 #define AUTOCONF_TEST 1
58 #undef _XOPEN_SOURCE_EXTENDED
59 #include "$libreplacedir/getifaddrs.c"],
60            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
61 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
62     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
67 if test $iface = no; then
68 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
69 AC_TRY_RUN([
70 #define HAVE_IFACE_IFCONF 1
71 #define AUTOCONF_TEST 1
72 #include "$libreplacedir/getifaddrs.c"],
73            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
74 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
75     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
79 if test $iface = no; then
80 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
81 AC_TRY_RUN([
82 #define HAVE_IFACE_IFREQ 1
83 #define AUTOCONF_TEST 1
84 #include "$libreplacedir/getifaddrs.c"],
85            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
86 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
87     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
91 LIBS=$old_LIBS