1 | AC_CHECK_HEADERS([ifaddrs.h])
|
---|
2 |
|
---|
3 | dnl Used when getifaddrs is not available
|
---|
4 | AC_CHECK_MEMBERS([struct sockaddr.sa_len],
|
---|
5 | [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])],
|
---|
6 | [],
|
---|
7 | [#include <sys/socket.h>])
|
---|
8 |
|
---|
9 | dnl test for getifaddrs and freeifaddrs
|
---|
10 | AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
|
---|
11 | AC_TRY_COMPILE([
|
---|
12 | #include <sys/types.h>
|
---|
13 | #if STDC_HEADERS
|
---|
14 | #include <stdlib.h>
|
---|
15 | #include <stddef.h>
|
---|
16 | #endif
|
---|
17 | #include <sys/socket.h>
|
---|
18 | #include <netinet/in.h>
|
---|
19 | #include <arpa/inet.h>
|
---|
20 | #include <ifaddrs.h>
|
---|
21 | #include <netdb.h>],
|
---|
22 | [
|
---|
23 | struct ifaddrs *ifp = NULL;
|
---|
24 | int ret = getifaddrs (&ifp);
|
---|
25 | freeifaddrs(ifp);
|
---|
26 | ],
|
---|
27 | libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)])
|
---|
28 | if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then
|
---|
29 | AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs])
|
---|
30 | AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs])
|
---|
31 | AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available])
|
---|
32 | fi
|
---|
33 |
|
---|
34 | ##################
|
---|
35 | # look for a method of finding the list of network interfaces
|
---|
36 | #
|
---|
37 | # This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
|
---|
38 | #
|
---|
39 | old_LIBS=$LIBS
|
---|
40 | LIBS="${LIBREPLACE_NETWORK_LIBS}"
|
---|
41 | SAVE_CPPFLAGS="$CPPFLAGS"
|
---|
42 | CPPFLAGS="$CPPFLAGS -I$libreplacedir"
|
---|
43 | iface=no;
|
---|
44 | ##################
|
---|
45 | # look for a method of finding the list of network interfaces
|
---|
46 | iface=no;
|
---|
47 | AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
|
---|
48 | AC_TRY_RUN([
|
---|
49 | #define HAVE_IFACE_GETIFADDRS 1
|
---|
50 | #define NO_CONFIG_H 1
|
---|
51 | #define AUTOCONF_TEST 1
|
---|
52 | #define SOCKET_WRAPPER_NOT_REPLACE
|
---|
53 | #include "$libreplacedir/replace.c"
|
---|
54 | #include "$libreplacedir/inet_ntop.c"
|
---|
55 | #include "$libreplacedir/snprintf.c"
|
---|
56 | #include "$libreplacedir/getifaddrs.c"
|
---|
57 | #define getifaddrs_test main
|
---|
58 | #include "$libreplacedir/test/getifaddrs.c"],
|
---|
59 | libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)])
|
---|
60 | if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
|
---|
61 | iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
|
---|
62 | else
|
---|
63 | LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o"
|
---|
64 | fi
|
---|
65 |
|
---|
66 |
|
---|
67 | if test $iface = no; then
|
---|
68 | AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
|
---|
69 | AC_TRY_RUN([
|
---|
70 | #define HAVE_IFACE_AIX 1
|
---|
71 | #define NO_CONFIG_H 1
|
---|
72 | #define AUTOCONF_TEST 1
|
---|
73 | #undef _XOPEN_SOURCE_EXTENDED
|
---|
74 | #define SOCKET_WRAPPER_NOT_REPLACE
|
---|
75 | #include "$libreplacedir/replace.c"
|
---|
76 | #include "$libreplacedir/inet_ntop.c"
|
---|
77 | #include "$libreplacedir/snprintf.c"
|
---|
78 | #include "$libreplacedir/getifaddrs.c"
|
---|
79 | #define getifaddrs_test main
|
---|
80 | #include "$libreplacedir/test/getifaddrs.c"],
|
---|
81 | libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)])
|
---|
82 | if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
|
---|
83 | iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
|
---|
84 | fi
|
---|
85 | fi
|
---|
86 |
|
---|
87 |
|
---|
88 | if test $iface = no; then
|
---|
89 | AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[
|
---|
90 | AC_TRY_RUN([
|
---|
91 | #define HAVE_IFACE_IFCONF 1
|
---|
92 | #define NO_CONFIG_H 1
|
---|
93 | #define AUTOCONF_TEST 1
|
---|
94 | #define SOCKET_WRAPPER_NOT_REPLACE
|
---|
95 | #include "$libreplacedir/replace.c"
|
---|
96 | #include "$libreplacedir/inet_ntop.c"
|
---|
97 | #include "$libreplacedir/snprintf.c"
|
---|
98 | #include "$libreplacedir/getifaddrs.c"
|
---|
99 | #define getifaddrs_test main
|
---|
100 | #include "$libreplacedir/test/getifaddrs.c"],
|
---|
101 | libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)])
|
---|
102 | if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
|
---|
103 | iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
|
---|
104 | fi
|
---|
105 | fi
|
---|
106 |
|
---|
107 | if test $iface = no; then
|
---|
108 | AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[
|
---|
109 | AC_TRY_RUN([
|
---|
110 | #define HAVE_IFACE_IFREQ 1
|
---|
111 | #define NO_CONFIG_H 1
|
---|
112 | #define AUTOCONF_TEST 1
|
---|
113 | #define SOCKET_WRAPPER_NOT_REPLACE
|
---|
114 | #include "$libreplacedir/replace.c"
|
---|
115 | #include "$libreplacedir/inet_ntop.c"
|
---|
116 | #include "$libreplacedir/snprintf.c"
|
---|
117 | #include "$libreplacedir/getifaddrs.c"
|
---|
118 | #define getifaddrs_test main
|
---|
119 | #include "$libreplacedir/test/getifaddrs.c"],
|
---|
120 | libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)])
|
---|
121 | if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
|
---|
122 | iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
|
---|
123 | fi
|
---|
124 | fi
|
---|
125 |
|
---|
126 | LIBS=$old_LIBS
|
---|
127 | CPPFLAGS="$SAVE_CPPFLAGS"
|
---|
128 |
|
---|