source: branches/samba-3.2.x/source/lib/replace/getifaddrs.m4

Last change on this file was 133, checked in by Paul Smedley, 17 years ago

Update trunk to 3.2.0pre3

File size: 4.2 KB
Line 
1AC_CHECK_HEADERS([ifaddrs.h])
2
3dnl Used when getifaddrs is not available
4AC_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
9dnl test for getifaddrs and freeifaddrs
10AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
11AC_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[
23struct ifaddrs *ifp = NULL;
24int ret = getifaddrs (&ifp);
25freeifaddrs(ifp);
26],
27libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)])
28if 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])
32fi
33
34##################
35# look for a method of finding the list of network interfaces
36#
37# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
38#
39old_LIBS=$LIBS
40LIBS="${LIBREPLACE_NETWORK_LIBS}"
41SAVE_CPPFLAGS="$CPPFLAGS"
42CPPFLAGS="$CPPFLAGS -I$libreplacedir"
43iface=no;
44##################
45# look for a method of finding the list of network interfaces
46iface=no;
47AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
48AC_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)])
60if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
61 iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
62else
63 LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o"
64fi
65
66
67if test $iface = no; then
68AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
69AC_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)])
82if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
83 iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
84fi
85fi
86
87
88if test $iface = no; then
89AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[
90AC_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)])
102if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
103 iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
104fi
105fi
106
107if test $iface = no; then
108AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[
109AC_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)])
121if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
122 iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
123fi
124fi
125
126LIBS=$old_LIBS
127CPPFLAGS="$SAVE_CPPFLAGS"
128
Note: See TracBrowser for help on using the repository browser.