blob: b57ead2c87e2b2a1dcb5b4d7e52879bc2b65bcfb [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001# dnet.m4 serial 1 (libdnet-1.11)
2
3dnl
4dnl Check for 4.4 BSD sa_len member in sockaddr struct
5dnl
6dnl usage: AC_DNET_SOCKADDR_SA_LEN
7dnl results: HAVE_SOCKADDR_SA_LEN (defined)
8dnl
9AC_DEFUN([AC_DNET_SOCKADDR_SA_LEN],
10 [AC_MSG_CHECKING(for sa_len in sockaddr struct)
11 AC_CACHE_VAL(ac_cv_dnet_sockaddr_has_sa_len,
12 AC_TRY_COMPILE([
13# ifndef _SOCKADDR_LEN
14# define _SOCKADDR_LEN 1
15# endif
16# include <sys/types.h>
17# include <sys/socket.h>],
18 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
19 ac_cv_dnet_sockaddr_has_sa_len=yes,
20 ac_cv_dnet_sockaddr_has_sa_len=no))
21 AC_MSG_RESULT($ac_cv_dnet_sockaddr_has_sa_len)
22 if test $ac_cv_dnet_sockaddr_has_sa_len = yes ; then
23 AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1,
24 [Define if sockaddr struct has sa_len.])
25 fi])
26
27dnl
28dnl Check for sockaddr_in6 struct in <netinet/in.h>
29dnl
30dnl usage: AC_DNET_SOCKADDR_IN6
31dnl results: HAVE_SOCKADDR_IN6
32dnl
33AC_DEFUN([AC_DNET_SOCKADDR_IN6],
34 [AC_MSG_CHECKING(for sockaddr_in6 struct in <netinet/in.h>)
35 AC_CACHE_VAL(ac_cv_dnet_netinet_in_h_has_sockaddr_in6,
36 AC_TRY_COMPILE([
37# include <sys/types.h>
38# include <sys/socket.h>
39# include <netinet/in.h>],
40 [struct sockaddr_in6 sin6; sin6.sin6_family = AF_INET6;],
41 ac_cv_dnet_netinet_in_h_has_sockaddr_in6=yes,
42 ac_cv_dnet_netinet_in_h_has_sockaddr_in6=no))
43 AC_MSG_RESULT($ac_cv_dnet_netinet_in_h_has_sockaddr_in6)
44 if test $ac_cv_dnet_netinet_in_h_has_sockaddr_in6 = yes ; then
45 AC_DEFINE(HAVE_SOCKADDR_IN6, 1,
46 [Define if <netinet/in.h> has sockaddr_in6 struct.])
47 fi])
48
49dnl
50dnl Check for arp_dev member in arpreq struct
51dnl
52dnl usage: AC_DNET_ARPREQ_ARP_DEV
53dnl results: HAVE_ARPREQ_ARP_DEV (defined)
54dnl
55AC_DEFUN([AC_DNET_ARPREQ_ARP_DEV],
56 [AC_MSG_CHECKING(for arp_dev in arpreq struct)
57 AC_CACHE_VAL(ac_cv_dnet_arpreq_has_arp_dev,
58 AC_TRY_COMPILE([
59# include <sys/types.h>
60# include <sys/socket.h>
61# include <net/if_arp.h>],
62 [void *p = ((struct arpreq *)0)->arp_dev],
63 ac_cv_dnet_arpreq_has_arp_dev=yes,
64 ac_cv_dnet_arpreq_has_arp_dev=no))
65 AC_MSG_RESULT($ac_cv_dnet_arpreq_has_arp_dev)
66 if test $ac_cv_dnet_arpreq_has_arp_dev = yes ; then
67 AC_DEFINE(HAVE_ARPREQ_ARP_DEV, 1,
68 [Define if arpreq struct has arp_dev.])
69 fi])
70
71dnl
72dnl Check for rt_msghdr struct in <net/route.h>
73dnl
74dnl usage: AC_DNET_ROUTE_RT_MSGHDR
75dnl results: HAVE_ROUTE_RT_MSGHDR
76dnl
77AC_DEFUN([AC_DNET_ROUTE_RT_MSGHDR],
78 [AC_MSG_CHECKING(for rt_msghdr struct in <net/route.h>)
79 AC_CACHE_VAL(ac_cv_dnet_route_h_has_rt_msghdr,
80 AC_TRY_COMPILE([
81# include <sys/types.h>
82# include <sys/socket.h>
83# include <net/if.h>
84# include <net/route.h>],
85 [struct rt_msghdr rtm; rtm.rtm_msglen = 0;],
86 ac_cv_dnet_route_h_has_rt_msghdr=yes,
87 ac_cv_dnet_route_h_has_rt_msghdr=no))
88 AC_MSG_RESULT($ac_cv_dnet_route_h_has_rt_msghdr)
89 if test $ac_cv_dnet_route_h_has_rt_msghdr = yes ; then
90 AC_DEFINE(HAVE_ROUTE_RT_MSGHDR, 1,
91 [Define if <net/route.h> has rt_msghdr struct.])
92 fi])
93
94dnl
95dnl Check for the Berkeley Packet Filter
96dnl
97dnl usage: AC_DNET_BSD_BPF
98dnl results: HAVE_BSD_BPF
99dnl
100AC_DEFUN([AC_DNET_BSD_BPF],
101 [AC_MSG_CHECKING(for Berkeley Packet Filter)
102 AC_CACHE_VAL(ac_cv_dnet_bsd_bpf,
103 if test -c /dev/bpf0 ; then
104 ac_cv_dnet_bsd_bpf=yes
105 else
106 ac_cv_dnet_bsd_bpf=no
107 fi)
108 AC_MSG_RESULT($ac_cv_dnet_bsd_bpf)
109 if test $ac_cv_dnet_bsd_bpf = yes ; then
110 AC_DEFINE(HAVE_BSD_BPF, 1,
111 [Define if you have the Berkeley Packet Filter.])
112 fi])
113
114dnl
115dnl Check for the Linux /proc filesystem
116dnl
117dnl usage: AC_DNET_LINUX_PROCFS
118dnl results: HAVE_LINUX_PROCFS
119dnl
120AC_DEFUN([AC_DNET_LINUX_PROCFS],
121 [AC_MSG_CHECKING(for Linux proc filesystem)
122 AC_CACHE_VAL(ac_cv_dnet_linux_procfs,
123 if test "x`cat /proc/sys/kernel/ostype 2>&-`" = "xLinux" ; then
124 ac_cv_dnet_linux_procfs=yes
125 else
126 ac_cv_dnet_linux_procfs=no
127 fi)
128 AC_MSG_RESULT($ac_cv_dnet_linux_procfs)
129 if test $ac_cv_dnet_linux_procfs = yes ; then
130 AC_DEFINE(HAVE_LINUX_PROCFS, 1,
131 [Define if you have the Linux /proc filesystem.])
132 fi])
133
134dnl
135dnl Check for Linux PF_PACKET sockets
136dnl
137dnl usage: AC_DNET_LINUX_PF_PACKET
138dnl results: HAVE_LINUX_PF_PACKET
139dnl
140AC_DEFUN([AC_DNET_LINUX_PF_PACKET],
141 [AC_MSG_CHECKING(for Linux PF_PACKET sockets)
142 AC_CACHE_VAL(ac_cv_dnet_linux_pf_packet,
143 if test -f /usr/include/netpacket/packet.h ; then
144 ac_cv_dnet_linux_pf_packet=yes
145 else
146 ac_cv_dnet_linux_pf_packet=no
147 fi)
148 AC_MSG_RESULT($ac_cv_dnet_linux_pf_packet)
149 if test $ac_cv_dnet_linux_pf_packet = yes ; then
150 AC_DEFINE(HAVE_LINUX_PF_PACKET, 1,
151 [Define if you have Linux PF_PACKET sockets.])
152 fi])
153
154dnl
155dnl Check for SNMP MIB2 STREAMS (Solaris only?)
156dnl
157dnl usage: AC_DNET_STREAMS_MIB2
158dnl results: HAVE_STREAMS_MIB2
159dnl
160AC_DEFUN([AC_DNET_STREAMS_MIB2],
161 [AC_MSG_CHECKING(for SNMP MIB2 STREAMS)
162 AC_CACHE_VAL(ac_cv_dnet_streams_mib2,
163 if test -f /usr/include/inet/mib2.h -a -c /dev/ip ; then
164 ac_cv_dnet_streams_mib2=yes
165 else
166 ac_cv_dnet_streams_mib2=no
167 fi)
168 AC_MSG_RESULT($ac_cv_dnet_streams_mib2)
169 if test $ac_cv_dnet_streams_mib2 = yes ; then
170 AC_DEFINE(HAVE_STREAMS_MIB2, 1,
171 [Define if you have SNMP MIB2 STREAMS.])
172 fi])
173
174dnl
175dnl Check for route(7) STREAMS (UnixWare only?)
176dnl
177dnl usage: AC_DNET_STREAMS_ROUTE
178dnl results: HAVE_STREAMS_ROUTE
179dnl
180AC_DEFUN([AC_DNET_STREAMS_ROUTE],
181 [AC_MSG_CHECKING(for route(7) STREAMS)
182 AC_CACHE_VAL(ac_cv_dnet_streams_route,
183 if grep RTSTR_SEND /usr/include/net/route.h >/dev/null 2>&1 ; then
184 ac_cv_dnet_streams_route=yes
185 else
186 ac_cv_dnet_streams_route=no
187 fi)
188 AC_MSG_RESULT($ac_cv_dnet_streams_route)
189 if test $ac_cv_dnet_streams_route = yes ; then
190 AC_DEFINE(HAVE_STREAMS_ROUTE, 1,
191 [Define if you have route(7) STREAMS.])
192 fi])
193
194dnl
195dnl Check for arp(7) ioctls
196dnl
197dnl usage: AC_DNET_IOCTL_ARP
198dnl results: HAVE_IOCTL_ARP
199dnl
200AC_DEFUN([AC_DNET_IOCTL_ARP],
201 [AC_MSG_CHECKING(for arp(7) ioctls)
202 AC_CACHE_VAL(ac_cv_dnet_ioctl_arp,
203 AC_EGREP_CPP(werd, [
204# include <sys/types.h>
205# define BSD_COMP
206# include <sys/ioctl.h>
207# ifdef SIOCGARP
208 werd
209# endif],
210 ac_cv_dnet_ioctl_arp=yes,
211 ac_cv_dnet_ioctl_arp=no))
212 case "$host_os" in
213 irix*)
214 ac_cv_dnet_ioctl_arp=no ;;
215 esac
216 AC_MSG_RESULT($ac_cv_dnet_ioctl_arp)
217 if test $ac_cv_dnet_ioctl_arp = yes ; then
218 AC_DEFINE(HAVE_IOCTL_ARP, 1,
219 [Define if you have arp(7) ioctls.])
220 fi])
221
222dnl
223dnl Check for raw IP sockets ip_{len,off} host byte ordering
224dnl
225dnl usage: AC_DNET_RAWIP_HOST_OFFLEN
226dnl results: HAVE_RAWIP_HOST_OFFLEN
227dnl
228AC_DEFUN([AC_DNET_RAWIP_HOST_OFFLEN],
229 [AC_MSG_CHECKING([for raw IP sockets ip_{len,off} host byte ordering])
230 AC_CACHE_VAL(ac_cv_dnet_rawip_host_offlen, [
231 case "$host_os" in
232 *openbsd*)
233 ac_cv_dnet_rawip_host_offlen=no ;;
234 *bsd*|*osf*|*unixware*)
235 ac_cv_dnet_rawip_host_offlen=yes ;;
236 *)
237 ac_cv_dnet_rawip_host_offlen=no ;;
238 esac])
239 AC_MSG_RESULT($ac_cv_dnet_rawip_host_offlen)
240 if test $ac_cv_dnet_rawip_host_offlen = yes ; then
241 AC_DEFINE(HAVE_RAWIP_HOST_OFFLEN, 1,
242 [Define if raw IP sockets require host byte ordering for ip_off, ip_len.])
243 fi])
244
245dnl
246dnl Check for cooked raw IP sockets
247dnl
248dnl usage: AC_DNET_RAWIP_COOKED
249dnl results: HAVE_RAWIP_COOKED
250dnl
251AC_DEFUN([AC_DNET_RAWIP_COOKED],
252 [AC_MSG_CHECKING(for cooked raw IP sockets)
253 AC_CACHE_VAL(ac_cv_dnet_rawip_cooked, [
254 case "$host_os" in
255 solaris*|irix*)
256 ac_cv_dnet_rawip_cooked=yes ;;
257 *)
258 ac_cv_dnet_rawip_cooked=no ;;
259 esac])
260 AC_MSG_RESULT($ac_cv_dnet_rawip_cooked)
261 if test $ac_cv_dnet_rawip_cooked = yes ; then
262 AC_DEFINE(HAVE_RAWIP_COOKED, 1,
263 [Define if you have cooked raw IP sockets.])
264 fi])
265
266dnl
267dnl AC_LBL_LIBRARY_NET
268dnl
269dnl This test is for network applications that need socket() and
270dnl gethostbyname() -ish functions. Under Solaris, those applications
271dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
272dnl with "-lnsl" but should *not* link with "-lsocket" because
273dnl libsocket.a breaks a number of things (for instance:
274dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
275dnl versions of IRIX).
276dnl
277dnl Unfortunately, many application developers are not aware of this,
278dnl and mistakenly write tests that cause -lsocket to be used under
279dnl IRIX. It is also easy to write tests that cause -lnsl to be used
280dnl under operating systems where neither are necessary (or useful),
281dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
282dnl
283dnl This test exists so that every application developer does not test
284dnl this in a different, and subtly broken fashion.
285
286dnl It has been argued that this test should be broken up into two
287dnl seperate tests, one for the resolver libraries, and one for the
288dnl libraries necessary for using Sockets API. Unfortunately, the two
289dnl are carefully intertwined and allowing the autoconf user to use
290dnl them independantly potentially results in unfortunate ordering
291dnl dependancies -- as such, such component macros would have to
292dnl carefully use indirection and be aware if the other components were
293dnl executed. Since other autoconf macros do not go to this trouble,
294dnl and almost no applications use sockets without the resolver, this
295dnl complexity has not been implemented.
296dnl
297dnl The check for libresolv is in case you are attempting to link
298dnl statically and happen to have a libresolv.a lying around (and no
299dnl libnsl.a).
300dnl
301AC_DEFUN([AC_LBL_LIBRARY_NET], [
302 # Most operating systems have gethostbyname() in the default searched
303 # libraries (i.e. libc):
304 AC_CHECK_FUNC(gethostbyname, ,
305 # Some OSes (eg. Solaris) place it in libnsl:
306 AC_CHECK_LIB(nsl, gethostbyname, ,
307 # Some strange OSes (SINIX) have it in libsocket:
308 AC_CHECK_LIB(socket, gethostbyname, ,
309 # Unfortunately libsocket sometimes depends on libnsl.
310 # AC_CHECK_LIB's API is essentially broken so the
311 # following ugliness is necessary:
312 AC_CHECK_LIB(socket, gethostbyname,
313 LIBS="-lsocket -lnsl $LIBS",
314 AC_CHECK_LIB(resolv, gethostbyname),
315 -lnsl))))
316 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
317 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
318 -lnsl)))
319 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
320 AC_CHECK_LIB(str, putmsg)
321 ])
322