1 dnl source: configure.ac
2 dnl Copyright Gerhard Rieger and contributors (see file CHANGES)
3 dnl Published under the GNU General Public License V.2, see file COPYING
5 dnl Process this file with autoconf to produce a configure script.
8 AC_CONFIG_HEADER(config.h)
10 if test -f /usr/xpg4/bin/fgrep; then
11 FGREP=/usr/xpg4/bin/fgrep # Solaris
16 # find out which defines gcc passes to cpp, so makedepend does not run into
17 # (harmless) "error architecture not supported"
18 AC_MSG_CHECKING(which defines needed for makedepend)
19 __cpp_defs=`$CC -v -E - </dev/null 2>&1 |$FGREP -e '/cpp ' -e '/cc1 '`
20 SYSDEFS=`aa=; for a in $__cpp_defs
21 do case "$a" in -D*) aa="$aa $a";; esac; done; echo "$aa"`
23 AC_MSG_RESULT($SYSDEFS)
26 # this must come before AC_PROG_CC
27 if test -z "$CFLAGS"; then
28 # if CFLAGS is not set, we preset it to -O
29 # with this setting, we prevent autoconf from defaulting to "-g -O2"
35 dnl Checks for programs.
36 AC_PROG_INSTALL(install)
40 AC_CHECK_PROG(AR, ar, ar, gar)
42 # we need to explicitely call this here; otherwise, with --disable-libwrap we
44 AC_LANG_COMPILER_REQUIRE()
46 if test "$GCC" = yes; then
47 CFLAGS="$CFLAGS -D_GNU_SOURCE -Wall -Wno-parentheses"
48 ERRONWARN="-Werror -O0"
49 elif test "$CC" = "clang"; then
50 CFLAGS="$CFLAGS -D_GNU_SOURCE -Wall -Wno-parentheses"
51 ERRONWARN="-Werror -O0"
53 # ERRONWARN="-errwarn"
60 dnl Checks for header files.
62 AC_CHECK_HEADERS(stdbool.h)
63 AC_CHECK_HEADERS(inttypes.h)
65 AC_CHECK_HEADERS(fcntl.h limits.h strings.h sys/param.h sys/ioctl.h sys/time.h syslog.h unistd.h)
66 AC_CHECK_HEADERS(pwd.h grp.h stdint.h sys/types.h poll.h sys/poll.h sys/socket.h sys/uio.h sys/stat.h netdb.h sys/un.h)
67 AC_CHECK_HEADERS(pty.h)
68 AC_CHECK_HEADERS(netinet/in.h netinet/in_systm.h)
69 AC_CHECK_HEADERS(netinet/ip.h, [], [], [AC_INCLUDES_DEFAULT
70 #if HAVE_NETINET_IN_H && HAVE_NETINET_IN_SYSTM_H
71 #include <netinet/in.h>
72 #include <netinet/in_systm.h>
73 #endif]) # Solaris prerequisites for netinet/ip.h
74 AC_CHECK_HEADERS(netinet/tcp.h)
75 AC_CHECK_HEADER(net/if.h, AC_DEFINE(HAVE_NET_IF_H), [], [AC_INCLUDES_DEFAULT
77 #include <sys/socket.h>
78 #endif]) # Mac OS X requires including sys/socket.h
79 AC_CHECK_HEADERS(arpa/nameser.h)
83 AC_CHECK_HEADERS(termios.h linux/if_tun.h)
84 AC_CHECK_HEADERS(net/if_dl.h)
85 AC_CHECK_HEADERS(linux/types.h)
86 AC_CHECK_HEADER(linux/errqueue.h, AC_DEFINE(HAVE_LINUX_ERRQUEUE_H), [], [#include <sys/time.h>
87 #include <linux/types.h>])
88 AC_CHECK_HEADERS(sys/utsname.h sys/select.h sys/file.h)
89 AC_CHECK_HEADERS(util.h bsd/libutil.h libutil.h stropts.h regex.h)
90 AC_CHECK_HEADERS(linux/fs.h linux/ext2_fs.h)
92 dnl Checks for setgrent, getgrent and endgrent.
93 AC_CHECK_FUNCS(setgrent getgrent endgrent)
94 dnl Checks for getgrouplist() /* BSD */
95 AC_CHECK_FUNCS(getgrouplist)
96 AC_CHECK_FUNCS(cfmakeraw)
98 dnl Link libresolv if necessary (for Mac OS X)
99 AC_SEARCH_LIBS([res_9_init], [resolv])
102 dnl Check for extra socket library (for Solaris)
103 AC_CHECK_FUNC(hstrerror, , AC_CHECK_LIB(resolv, hstrerror, [LIBS="$LIBS -lresolv"; AC_DEFINE(HAVE_HSTRERROR)]))
104 AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent))
105 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
107 dnl Check for function prototype and in lib
108 dnl arg1: function name
109 dnl arg2: required include files beyond sysincludes.h
110 define(AC_CHECK_PROTOTYPE_LIB,[
111 AC_MSG_CHECKING(for $1 prototype)
112 AC_CACHE_VAL(sc_cv_have_prototype_lib_$1,
113 [CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
114 AC_TRY_LINK([#include "sysincludes.h"
115 $2],[return(&$1==(void *)&$1);],
116 [sc_cv_have_prototype_lib_$1=yes],
117 [sc_cv_have_prototype_lib_$1=no]);
119 if test $sc_cv_have_prototype_lib_$1 = yes; then
120 AC_DEFINE(HAVE_PROTOTYPE_LIB_$1)
122 AC_MSG_RESULT($sc_cv_have_prototype_lib_$1)
126 dnl Check for hstrerror prototype
127 AC_MSG_CHECKING(for hstrerror prototype)
128 AC_CACHE_VAL(sc_cv_have_prototype_hstrerror,
129 [CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN $(echo "$CFLAGS1" | sed -e 's@-Wall@@g')";
130 AC_TRY_COMPILE([#include <netdb.h>],[hstrerror();],
131 [sc_cv_have_prototype_hstrerror=no],
132 [sc_cv_have_prototype_hstrerror=yes]);
134 if test $sc_cv_have_prototype_hstrerror = yes; then
135 AC_DEFINE(HAVE_PROTOTYPE_HSTRERROR)
137 AC_MSG_RESULT($sc_cv_have_prototype_hstrerror)
139 # getprotobynumber_r() is not standardized
140 AC_MSG_CHECKING(for getprotobynumber_r() variant)
141 AC_CACHE_VAL(sc_cv_getprotobynumber_r,
142 [AC_TRY_LINK([#include <stddef.h>
143 #include <netdb.h>],[getprotobynumber_r(1,NULL,NULL,1024,NULL);],
144 [sc_cv_getprotobynumber_r=1; tmp_bynum_variant=Linux],
145 [AC_TRY_LINK([#include <stddef.h>
146 #include <netdb.h>],[getprotobynumber_r(1,NULL,NULL,1024);],
147 [sc_cv_getprotobynumber_r=2; tmp_bynum_variant=Solaris],
148 [AC_TRY_LINK([#include <stddef.h>
149 #include <netdb.h>],[getprotobynumber_r(1,NULL,NULL);],
150 [sc_cv_getprotobynumber_r=3; tmp_bynum_variant=AIX],
152 [sc_cv_getprotobynumber_r=]
154 if test "$sc_cv_getprotobynumber_r"; then
155 AC_DEFINE_UNQUOTED(HAVE_GETPROTOBYNUMBER_R, $sc_cv_getprotobynumber_r)
157 AC_MSG_RESULT($sc_cv_getprotobynumber_r /* $tmp_bynum_variant */)
160 AC_MSG_CHECKING(whether to include help)
161 AC_ARG_ENABLE(help, [ --disable-help disable help],
162 [case "$enableval" in
163 no) AC_MSG_RESULT(no);;
164 *) AC_DEFINE(WITH_HELP) AC_MSG_RESULT(yes);;
166 [AC_DEFINE(WITH_HELP) AC_MSG_RESULT(yes)])
168 AC_MSG_CHECKING(whether to include transfer statistics)
169 AC_ARG_ENABLE(stats, [ --disable-stats disable stats],
170 [case "$enableval" in
171 no) AC_MSG_RESULT(no);;
172 *) AC_DEFINE(WITH_STATS) AC_MSG_RESULT(yes);;
174 [AC_DEFINE(WITH_STATS) AC_MSG_RESULT(yes)])
176 AC_MSG_CHECKING(whether to include STDIO support)
177 AC_ARG_ENABLE(stdio, [ --disable-stdio disable STDIO support],
178 [case "$enableval" in
179 no) AC_MSG_RESULT(no);;
180 *) AC_DEFINE(WITH_STDIO) AC_MSG_RESULT(yes);;
182 [AC_DEFINE(WITH_STDIO) AC_MSG_RESULT(yes)])
184 AC_MSG_CHECKING(whether to include FD-number support)
185 AC_ARG_ENABLE(fdnum, [ --disable-fdnum disable FD-number support],
186 [case "$enableval" in
187 no) AC_MSG_RESULT(no);;
188 *) AC_DEFINE(WITH_FDNUM) AC_MSG_RESULT(yes);;
190 [AC_DEFINE(WITH_FDNUM) AC_MSG_RESULT(yes)])
192 AC_MSG_CHECKING(whether to include direct file support)
193 AC_ARG_ENABLE(file, [ --disable-file disable direct file support],
194 [case "$enableval" in
195 no) AC_MSG_RESULT(no);;
196 *) AC_DEFINE(WITH_FILE) AC_MSG_RESULT(yes);;
198 [AC_DEFINE(WITH_FILE) AC_MSG_RESULT(yes)])
200 AC_MSG_CHECKING(whether to include direct create support)
201 AC_ARG_ENABLE(creat, [ --disable-creat disable direct create support],
202 [case "$enableval" in
203 no) AC_MSG_RESULT(no);;
204 *) AC_DEFINE(WITH_CREAT) AC_MSG_RESULT(yes);;
206 [AC_DEFINE(WITH_CREAT) AC_MSG_RESULT(yes)])
208 AC_MSG_CHECKING(whether to include gopen support)
209 AC_ARG_ENABLE(gopen, [ --disable-gopen disable open for UNIX socket support],
210 [case "$enableval" in
211 no) AC_MSG_RESULT(no);;
212 *) AC_DEFINE(WITH_GOPEN) AC_MSG_RESULT(yes);;
214 [AC_DEFINE(WITH_GOPEN) AC_MSG_RESULT(yes)])
216 AC_MSG_CHECKING(whether to include explicit pipe support)
217 AC_ARG_ENABLE(pipe, [ --disable-pipe disable pipe support],
218 [case "$enableval" in
219 no) AC_MSG_RESULT(no);;
220 *) AC_DEFINE(WITH_PIPE) AC_MSG_RESULT(yes);;
222 [AC_DEFINE(WITH_PIPE) AC_MSG_RESULT(yes)])
224 AC_MSG_CHECKING(whether to include explicit socketpair support)
225 AC_ARG_ENABLE(socketpair, [ --disable-socketpair disable socketpair support],
226 [case "$enableval" in
227 no) AC_MSG_RESULT(no);;
228 *) AC_DEFINE(WITH_SOCKETPAIR) AC_MSG_RESULT(yes);;
230 [AC_DEFINE(WITH_SOCKETPAIR) AC_MSG_RESULT(yes)])
232 AC_MSG_CHECKING(whether to include explicit termios support)
233 AC_ARG_ENABLE(termios, [ --disable-termios disable termios support],
234 [case "$enableval" in
235 no) AC_MSG_RESULT(no);;
236 *) AC_DEFINE(WITH_TERMIOS) AC_MSG_RESULT(yes);;
238 [AC_DEFINE(WITH_TERMIOS) AC_MSG_RESULT(yes)])
240 AC_MSG_CHECKING(whether to include UNIX socket support)
241 AC_ARG_ENABLE(unix, [ --disable-unix disable UNIX domain socket support],
242 [case "$enableval" in
243 no) AC_MSG_RESULT(no);;
244 *) AC_DEFINE(WITH_UNIX) AC_MSG_RESULT(yes);;
246 [AC_DEFINE(WITH_UNIX) AC_MSG_RESULT(yes)])
248 AC_MSG_CHECKING(whether to include abstract UNIX socket support)
249 AC_ARG_ENABLE(abstract_unixsocket, [ --disable-abstract-unixsocket disable abstract UNIX domain socket support],
250 [case "$enableval" in
251 no) AC_MSG_RESULT(no);;
252 *) AC_DEFINE(WITH_ABSTRACT_UNIXSOCKET) AC_MSG_RESULT(yes);;
256 AC_DEFINE(WITH_ABSTRACT_UNIXSOCKET) AC_MSG_RESULT(yes);;
261 AC_MSG_CHECKING(whether to include IPv4 support)
262 AC_ARG_ENABLE(ip4, [ --disable-ip4 disable IPv4 support],
263 [case "$enableval" in
264 no) AC_MSG_RESULT(no);;
265 *) AC_DEFINE(WITH_IP4) AC_MSG_RESULT(yes);;
267 [AC_DEFINE(WITH_IP4) AC_MSG_RESULT(yes)])
269 AC_MSG_CHECKING(whether to include IPv6 support)
270 AC_ARG_ENABLE(ip6, [ --disable-ip6 disable IPv6 support],
271 [case "$enableval" in
272 no) AC_MSG_RESULT(no); WITH_IP6= ;;
273 *) AC_MSG_RESULT(yes); WITH_IP6=1 ;;
275 [ AC_MSG_RESULT(yes); WITH_IP6=1 ])
276 if test "$WITH_IP6"; then
277 AC_CHECK_HEADERS([netinet/ip6.h],
278 [AC_DEFINE(HAVE_NETINET_IP6_H) AC_DEFINE(WITH_IP6)],
279 [AC_MSG_WARN([include file netinet/ip6.h not found, disabling IP6])],
281 #ifdef HAVE_NETINET_IN_H
282 # include <netinet/in.h>
284 #ifdef HAVE_NETINET_IP_H
285 # include <netinet/ip.h>
287 AC_CHECK_HEADERS(netinet6/in6.h) # found on OpenBSD and Lion, used for IPV6_*
289 AC_MSG_CHECKING(if __APPLE_USE_RFC_2292 is helpful)
290 AC_CACHE_VAL(ac_cv_apple_use_rfc_2292,
291 [AC_TRY_COMPILE(,[#ifndef IPV6_HOPOPTS
294 [ac_cv_apple_use_rfc_2292=no],
295 [AC_TRY_COMPILE([#define __APPLE_USE_RFC_2292],
296 [#ifndef IPV6_HOPOPTS
299 [ac_cv_apple_use_rfc_2292=yes],
300 [ac_cv_apple_use_rfc_2292=no]
303 if test "$ac_cv_apple_use_rfc_2292" = yes; then
304 AC_DEFINE(__APPLE_USE_RFC_2292)
306 AC_MSG_RESULT($ac_cv_apple_use_rfc_2292)
308 AC_MSG_CHECKING(if including netinet/in.h suffices)
309 AC_TRY_COMPILE([#include <sys/types.h>
310 #include <netinet/in.h>],
311 [struct sockaddr_in6 s;],
312 [ AC_MSG_RESULT(yes); WITH_IP6=1],
313 [ AC_MSG_RESULT(no); WITH_IP6=])
314 if test "$WITH_IP6"; then
320 AC_MSG_CHECKING(whether to include raw IP support)
321 AC_ARG_ENABLE(rawip, [ --disable-rawip disable raw IP support],
322 [case "$enableval" in
323 no) AC_MSG_RESULT(no);;
324 *) AC_DEFINE(WITH_RAWIP) AC_MSG_RESULT(yes);;
326 [AC_DEFINE(WITH_RAWIP) AC_MSG_RESULT(yes)])
328 AC_MSG_CHECKING(whether to include generic socket support)
329 AC_ARG_ENABLE(genericsocket, [ --disable-genericsocket disable generic socket support],
330 [case "$enableval" in
331 no) AC_MSG_RESULT(no);;
332 *) AC_DEFINE(WITH_GENERICSOCKET) AC_MSG_RESULT(yes);;
334 [AC_DEFINE(WITH_GENERICSOCKET) AC_MSG_RESULT(yes)])
336 AC_MSG_CHECKING(whether to include generic network interface support)
337 AC_ARG_ENABLE(interface, [ --disable-interface disable network interface support],
338 [case "$enableval" in
339 no) AC_MSG_RESULT(no); WITH_INTERFACE= ;;
340 *) AC_MSG_RESULT(yes); WITH_INTERFACE=1 ;;
342 [AC_MSG_RESULT(yes); WITH_INTERFACE=1 ])
344 AC_MSG_CHECKING(whether to include TCP support)
345 AC_ARG_ENABLE(tcp, [ --disable-tcp disable TCP support],
346 [case "$enableval" in
347 no) AC_MSG_RESULT(no);;
348 *) AC_DEFINE(WITH_TCP) AC_MSG_RESULT(yes);;
350 [AC_DEFINE(WITH_TCP) AC_MSG_RESULT(yes)])
352 AC_MSG_CHECKING(whether to include UDP support)
353 AC_ARG_ENABLE(udp, [ --disable-udp disable UDP support],
354 [case "$enableval" in
355 no) AC_MSG_RESULT(no);;
356 *) AC_DEFINE(WITH_UDP) AC_MSG_RESULT(yes);;
358 [AC_DEFINE(WITH_UDP) AC_MSG_RESULT(yes)])
360 AC_MSG_CHECKING(whether to include UDP-Lite support)
361 AC_ARG_ENABLE(udplite, [ --disable-udplite disable UDP-Lite support],
362 [case "$enableval" in
363 no) AC_MSG_RESULT(no); WITH_UDPLITE= ;;
364 *) AC_MSG_RESULT(yes); WITH_UDPLITE=1 ;;
366 [AC_MSG_RESULT(yes); WITH_UDPLITE=1 ])
367 if test -n "$WITH_UDPLITE"; then
368 AC_MSG_CHECKING(for IPPROTO_UDPLITE)
369 AC_TRY_COMPILE([#include <sys/types.h>
370 #include <netinet/in.h>],
372 [ AC_MSG_RESULT(yes); WITH_UDPLITE=1],
373 [ AC_MSG_RESULT(no); WITH_UDPLITE=])
374 if test "$WITH_UDPLITE"; then
375 AC_DEFINE(WITH_UDPLITE)
379 AC_MSG_CHECKING(whether to include SCTP support)
380 AC_ARG_ENABLE(sctp, [ --disable-sctp disable SCTP support],
381 [case "$enableval" in
382 no) AC_MSG_RESULT(no); WITH_SCTP= ;;
383 *) AC_MSG_RESULT(yes); WITH_SCTP=1 ;;
385 [AC_MSG_RESULT(yes); WITH_SCTP=1 ])
387 if test -n "$WITH_SCTP"; then
388 AC_MSG_CHECKING(for IPPROTO_SCTP)
389 AC_CACHE_VAL(sc_cv_define_ipproto_sctp,
390 [AC_TRY_COMPILE([#include <sys/types.h>
391 #include <netinet/in.h>],
393 [sc_cv_define_ipproto_sctp=yes],
394 [sc_cv_define_ipproto_sctp=no])])
395 AC_MSG_RESULT($sc_cv_define_ipproto_sctp)
396 if test $sc_cv_define_ipproto_sctp = yes; then
399 AC_MSG_WARN([IPPROTO_SCTP undefined, disabling SCTP support])
403 AC_MSG_CHECKING(whether to include DCCP support)
404 AC_ARG_ENABLE(dccp, [ --disable-dccp disable DCCP support],
405 [case "$enableval" in
406 no) AC_MSG_RESULT(no); WITH_DCCP= ;;
407 *) AC_MSG_RESULT(yes); WITH_DCCP=1 ;;
409 [AC_MSG_RESULT(yes); WITH_DCCP=1 ])
411 if test -n "$WITH_DCCP"; then
412 AC_MSG_CHECKING(for IPPROTO_DCCP)
413 AC_CACHE_VAL(sc_cv_define_ipproto_dccp,
414 [AC_TRY_COMPILE([#include <sys/types.h>
415 #include <netinet/in.h>],
417 [sc_cv_define_ipproto_dccp=yes],
418 [sc_cv_define_ipproto_dccp=no])])
419 AC_MSG_RESULT($sc_cv_define_ipproto_dccp)
420 if test $sc_cv_define_ipproto_dccp = yes; then
422 AC_CHECK_HEADER(linux/dccp.h,
423 AC_DEFINE(HAVE_LINUX_DCCP_H))
425 AC_MSG_WARN([IPPROTO_DCCP undefined, disabling DCCP support])
429 AC_MSG_CHECKING(whether to include vsock support)
430 AC_ARG_ENABLE(vsock, [ --disable-vsock disable vsock support],
431 [case "$enableval" in
432 no) AC_MSG_RESULT(no); WITH_VSOCK= ;;
433 *) AC_MSG_RESULT(yes); WITH_VSOCK=1 ;;
435 [AC_MSG_RESULT(yes); WITH_VSOCK=1 ])
436 if test "$WITH_VSOCK"; then
437 AC_CHECK_HEADER(linux/vm_sockets.h,
438 AC_DEFINE(HAVE_LINUX_VM_SOCKETS_H),
440 AC_MSG_WARN([include file linux/vm_sockets.h not found, disabling vsock])],
442 #if HAVE_SYS_SOCKET_H
443 #include <sys/socket.h>
448 if test "$WITH_VSOCK"; then
449 AC_DEFINE(WITH_VSOCK)
452 AC_ARG_ENABLE(namespaces, [ --disable-namespaces disable Linux namespaces support],
453 [case "$enableval" in
454 no) TRY_NAMESPACES= ;;
455 *) TRY_NAMESPACES=1 ;;
458 if test "TRY_NAMESPACES"; then
459 AC_TRY_LINK([#include <sched.h>],
462 [TRY_NAMESPACES=failed])
464 AC_MSG_CHECKING(whether to include Linux namespaces support)
465 if test "$TRY_NAMESPACES" = 1; then
467 AC_DEFINE(WITH_NAMESPACES)
468 AC_DEFINE(HAVE_SCHED_H)
469 AC_DEFINE(HAVE_SETNS)
470 elif test "$TRY_NAMESPACES" = yes; then
471 AC_MSG_RESULT(NO (failed))
476 AC_MSG_CHECKING(whether to include listen support)
477 AC_ARG_ENABLE(listen, [ --disable-listen disable listen support],
478 [case "$enableval" in
479 no) AC_MSG_RESULT(no);;
480 *) AC_DEFINE(WITH_LISTEN) AC_MSG_RESULT(yes);;
482 [AC_DEFINE(WITH_LISTEN) AC_MSG_RESULT(yes)])
484 AC_MSG_CHECKING(whether to include POSIX MQ support)
485 AC_ARG_ENABLE(posixmq, [ --disable-posixmq disable POSIX MQ support],
486 [case "$enableval" in
487 no) AC_MSG_RESULT(no)
489 *) WITH_POSIXMQ=1; AC_MSG_RESULT(yes);;
491 [WITH_POSIXMQ=1; AC_MSG_RESULT(yes)])
492 if test "$WITH_POSIXMQ"; then
494 Linux) AC_DEFINE(WITH_POSIXMQ)
496 *) AC_MSG_WARN([POSIX MQ currently implemented for Linux only])
501 AC_MSG_CHECKING(whether to include socks4 support)
502 AC_ARG_ENABLE(socks4, [ --disable-socks4 disable socks4 support],
503 [case "$enableval" in
504 no) AC_MSG_RESULT(no);;
505 *) AC_DEFINE(WITH_SOCKS4) AC_MSG_RESULT(yes);;
507 [AC_DEFINE(WITH_SOCKS4) AC_MSG_RESULT(yes)])
509 AC_MSG_CHECKING(whether to include socks4a support)
510 AC_ARG_ENABLE(socks4a, [ --disable-socks4a disable socks4a support],
511 [case "$enableval" in
512 no) AC_MSG_RESULT(no);;
513 *) AC_DEFINE(WITH_SOCKS4A) AC_MSG_RESULT(yes);;
515 [AC_DEFINE(WITH_SOCKS4A) AC_MSG_RESULT(yes)])
517 AC_MSG_CHECKING(whether to include socks5 support)
518 AC_ARG_ENABLE(socks5, [ --disable-socks5 disable socks5 support],
519 [case "$enableval" in
520 no) AC_MSG_RESULT(no);;
521 *) AC_DEFINE(WITH_SOCKS5) AC_MSG_RESULT(yes);;
523 [AC_DEFINE(WITH_SOCKS5) AC_MSG_RESULT(yes)])
525 AC_MSG_CHECKING(whether to include proxy connect support)
526 AC_ARG_ENABLE(proxy, [ --disable-proxy disable proxy connect support],
527 [case "$enableval" in
528 no) AC_MSG_RESULT(no);;
529 *) AC_DEFINE(WITH_PROXY) AC_MSG_RESULT(yes);;
531 [AC_DEFINE(WITH_PROXY) AC_MSG_RESULT(yes)])
533 AC_MSG_CHECKING(whether to include exec support)
534 AC_ARG_ENABLE(exec, [ --disable-exec disable exec support],
535 [case "$enableval" in
536 no) AC_MSG_RESULT(no);;
537 *) AC_DEFINE(WITH_EXEC) AC_MSG_RESULT(yes);;
539 [AC_DEFINE(WITH_EXEC) AC_MSG_RESULT(yes)])
541 AC_MSG_CHECKING([whether to include system (shell) support])
542 AC_ARG_ENABLE(system, [ --disable-system disable system (shell) support],
543 [case "$enableval" in
544 no) AC_MSG_RESULT(no);;
545 *) AC_DEFINE(WITH_SYSTEM) AC_MSG_RESULT(yes);;
547 [AC_DEFINE(WITH_SYSTEM) AC_MSG_RESULT(yes)])
549 AC_MSG_CHECKING([whether to include shell invocation support])
550 AC_ARG_ENABLE(shell, [ --disable-shell disable shell invocation support],
551 [case "$enableval" in
552 no) AC_MSG_RESULT(no);;
553 *) AC_DEFINE(WITH_SHELL) AC_MSG_RESULT(yes);;
555 [AC_DEFINE(WITH_SHELL) AC_MSG_RESULT(yes)])
557 AC_MSG_CHECKING(whether to include pty address support)
558 AC_ARG_ENABLE(pty, [ --disable-pty disable pty support],
559 [case "$enableval" in
560 no) AC_MSG_RESULT(no);;
561 *) AC_DEFINE(WITH_PTY) AC_MSG_RESULT(yes);;
563 [AC_DEFINE(WITH_PTY) AC_MSG_RESULT(yes)])
565 AC_MSG_CHECKING(whether to include fs attributes support)
566 AC_ARG_ENABLE(fs, [ --disable-fs disable fs attributes support],
567 [case "$enableval" in
568 no) AC_MSG_RESULT(no);;
569 *) AC_DEFINE(WITH_FS) AC_MSG_RESULT(yes);;
571 [AC_DEFINE(WITH_FS) AC_MSG_RESULT(yes)])
573 AC_MSG_CHECKING(whether to include readline support)
574 AC_ARG_ENABLE(readline, [ --disable-readline disable readline support],
575 [case "$enableval" in
576 no) AC_MSG_RESULT(no); WITH_READLINE= ;;
577 *) AC_MSG_RESULT(yes); WITH_READLINE=1 ;;
579 [AC_MSG_RESULT(yes); WITH_READLINE=1 ])
581 if test -n "$WITH_READLINE"; then
582 CPPFLAGS_ORIG=$CPPFLAGS
585 sc_usable_readline_found=
587 for D in "" "/usr/local" "/opt/local" "/sw" "/opt/freeware" "/usr/sfw"; do
588 if test -n "$D" ; then
589 CPPFLAGS="$CPPFLAGS -I$D/include"
590 CFLAGS="$CFLAGS -L$D/lib"
591 DLOC="in location $D"
593 DLOC="in default location"
595 AC_MSG_CHECKING(for usable readline $DLOC)
597 # Some systems require -lcurses, some require -lncurses.
598 # Mac OS X 10.4 (and others) ships with libedit masquerading as readline,
599 # but it doesn't work well with socat. It can be recognized by the absence
602 for L in "" "-lcurses" "-lncurses"; do
603 LIBS="$LIBS_ORIG -lreadline $L"
606 #include <readline/readline.h>
607 #include <readline/history.h>],
609 append_history(0, NULL); ],
610 [ sc_usable_readline_found=1
614 if test -n "$sc_usable_readline_found"; then
616 AC_DEFINE(HAVE_READLINE_READLINE_H,1)
617 AC_DEFINE(HAVE_READLINE_HISTORY_H,1)
618 AC_DEFINE(HAVE_LIBREADLINE,1)
619 AC_DEFINE(WITH_READLINE,1)
623 CPPFLAGS=$CPPFLAGS_ORIG
629 if test -z "$sc_usable_readline_found"; then
630 AC_MSG_WARN([no suitable version of readline found; perhaps you need to install a newer version])
634 AC_MSG_CHECKING(whether to include openssl support)
635 AC_ARG_ENABLE(openssl, [ --disable-openssl disable OpenSSL support],
636 [ case "$enableval" in
637 no) AC_MSG_RESULT(no); WITH_OPENSSL= ;;
638 *) AC_MSG_RESULT(yes); WITH_OPENSSL=1 ;;
640 [ AC_MSG_RESULT(yes); WITH_OPENSSL=1 ])
641 AC_ARG_ENABLE(openssl_base, [ --enable-openssl-base specify directory with include/ and lib/],
642 [ OPENSSL_BASE="$enableval" ],
643 [ unset OPENSSL_BASE ])
645 if test -n "$WITH_OPENSSL"; then
646 if test -n "$OPENSSL_BASE"; then
647 sc_cv_have_openssl_ssl_h=yes;
648 CPPFLAGS="-I$OPENSSL_BASE/include $CPPFLAGS"
650 AC_MSG_NOTICE(checking for components of OpenSSL)
651 # first, we need to find the include file <openssl/ssl.h>
652 AC_CACHE_VAL(sc_cv_have_openssl_ssl_h,
653 [AC_TRY_COMPILE([#include <openssl/ssl.h>],[;],
654 [sc_cv_have_openssl_ssl_h=yes; OPENSSL_BASE=""; ],
655 [sc_cv_have_openssl_ssl_h=no
656 if test "$OPENSSL_BASE"; then
659 Ds="/sw /usr/local /opt/freeware /usr/sfw /usr/local/ssl"
664 if test -r "$i"; then
665 #V_INCL="$V_INCL -I$I"
666 CPPFLAGS="$CPPFLAGS -I$I"
667 AC_MSG_NOTICE(found $i)
668 sc_cv_have_openssl_ssl_h=yes; OPENSSL_BASE="$D"
673 if test "$sc_cv_have_openssl_ssl_h" = "yes"; then
674 AC_DEFINE(HAVE_OPENSSL_SSL_H)
676 AC_MSG_NOTICE(checked for openssl/ssl.h... $sc_cv_have_openssl_ssl_h)
678 fi # end checking for openssl/ssl.h
681 #if test -n "$WITH_OPENSSL"; then
682 # AC_CHECK_FUNCS(OPENSSL_init_ssl, SSL_library_init)
685 if test -n "$WITH_OPENSSL" -a "$sc_cv_have_openssl_ssl_h" = 'yes'; then
686 # next, we search for the openssl library (libssl.*)
687 # interesting: Linux only requires -lssl, FreeBSD requires -lssl -lcrypto
688 # Note, version OpenSSL 0.9.7j and higher requires -lcrypto even on Linux.
689 AC_MSG_CHECKING(for libssl)
690 AC_CACHE_VAL(sc_cv_have_libssl,
692 if test -n "$OPENSSL_BASE"; then
693 L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lssl -lcrypto"
695 LIBS="$LIBS -lssl -lcrypto"
697 AC_TRY_LINK([#include <openssl/ssl.h>
698 #include <openssl/err.h>
700 [SSL_library_init();ERR_error_string()],
701 [sc_cv_have_libssl='yes'],
702 [ LIBS="$LIBS -lcrypto"
703 AC_TRY_LINK([#include <openssl/ssl.h>],
704 [SSL_library_init()],
705 [sc_cv_have_libssl='yes'],
706 [sc_cv_have_libssl='no'])
708 if test "$sc_cv_have_libssl" != 'yes'; then
713 if test "$sc_cv_have_libssl" = 'yes'; then
714 AC_DEFINE(HAVE_LIBSSL)
716 AC_MSG_RESULT($sc_cv_have_libssl)
719 # # a possible location for openssl (on Sourceforge/Solaris)
720 # AC_CHECK_FILE(/usr/local/ssl/lib, LIBS="$LIBS -L/usr/local/ssl/lib/")
721 # # sometimes on Solaris:
722 # AC_CHECK_FILE(/pkgs/lib, LIBS="$LIBS -L/pkgs/lib/")
723 # # for AIX 5.1 with Linux toolbox:
724 # AC_CHECK_FILE(/opt/freeware/lib, LIBS="$LIBS -L/opt/freeware/lib/")
726 # AC_CHECK_LIB(crypto, main)
727 # AC_CHECK_LIB(ssl, main)
729 # # MacOSX has openssl includes in another directory
730 # if test -d /sw/include/; then
731 # V_INCL="$V_INCL -I/sw/include"
732 # # and Solaris at sourceforge here:
733 # elif test -d /usr/local/ssl/include/; then
734 # V_INCL="$V_INCL -I/usr/local/ssl/include"
735 # # and AIX 5.1 with Linux toolbox:
736 # elif test -d /opt/freeware/include; then
737 # V_INCL="$V_INCL -I/opt/freeware/include"
740 if test -n "$WITH_OPENSSL"; then
741 if test "$sc_cv_have_openssl_ssl_h" = "yes" -a "$sc_cv_have_libssl" = "yes"; then
742 AC_DEFINE(WITH_OPENSSL)
744 AC_MSG_WARN([not all components of OpenSSL found, disabling it]);
748 # Guarded for OpenBSD
749 AC_CHECK_FUNCS(OPENSSL_init_ssl SSL_library_init OPENSSL_INIT_new)
750 AC_CHECK_TYPE(OPENSSL_INIT_SETTINGS, AC_DEFINE(HAVE_TYPE_OPENSSL_INIT_SETTINGS),,[#include "openssl.h"])
752 #; sc_cv_have_SSL_library_init='yes'; AC_DEFINE(HAVE_SSL_library_init)
753 #if test -n "$WITH_OPENSSL"; then
754 # AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
756 # AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
757 # AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
758 # AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL; WITH_OPENSSL=])])
759 # AS_IF([test "x$FOUND_SSL_LIB" = xyes], [LIBS="$LIBS -L$L -lssl -lcrypto"])
762 if test -n "$WITH_OPENSSL"; then
763 AC_MSG_CHECKING(whether to include OpenSSL method option)
764 AC_ARG_ENABLE(openssl-method, [ --enable-openssl-method enable OpenSSL method option],
765 [case "$enableval" in
766 no) AC_MSG_RESULT(no);;
767 *) AC_DEFINE(WITH_OPENSSL_METHOD) WITH_OPENSSL_METHOD=1; AC_MSG_RESULT(yes);;
772 AC_MSG_CHECKING(whether to include undocumented resolver related options)
773 AC_ARG_ENABLE(resolve, [ --enable-resolve enable undocumented resolver options],
774 [case "$enableval" in
775 no) AC_MSG_RESULT(no);;
776 *) AC_DEFINE(WITH_RESOLVE) AC_MSG_RESULT(yes);;
778 [AC_DEFINE(WITH_RESOLVE) AC_MSG_RESULT(yes)])
780 AC_MSG_CHECKING(whether to include deprecated resolver option)
781 AC_ARG_ENABLE(res-deprecated, [ --enable-res-deprecated enable deprecated resolver options],
782 [case "$enableval" in
783 no) AC_MSG_RESULT(no);;
784 *) AC_DEFINE(WITH_RES_DEPRECATED) WITH_RES_DEPRECATED=1; AC_MSG_RESULT(yes);;
788 # check for fips support
789 AC_MSG_CHECKING(whether to include openssl fips support)
790 AC_ARG_ENABLE(fips, [ --enable-fips enable OpenSSL FIPS support],
791 [ case "$enableval" in
792 yes) AC_MSG_RESULT(yes); WITH_FIPS=1 ;;
793 *) AC_MSG_RESULT(no); WITH_FIPS= ;;
795 [ AC_MSG_RESULT(no); WITH_FIPS= ])
797 if test -n "$WITH_FIPS"; then
798 if test -n "$WITH_OPENSSL"; then
799 AC_CHECK_PROG(HAVE_FIPSLD, fipsld, 1)
800 if test "$sc_cv_have_openssl_ssl_h" != "yes" -o "$sc_cv_have_libssl" != "yes" -o ! "$HAVE_FIPSLD";
802 AC_MSG_WARN([not all components of OpenSSL found, disabling FIPS]);
806 AC_MSG_WARN([must enable OpenSSL to enable FIPS; use --enable-openssl]);
810 if test -n "$WITH_FIPS"; then
811 AC_MSG_CHECKING(for components of OpenSSL FIPS)
812 # first, we need to find the include file <openssl/fips.h>
813 AC_CACHE_VAL(sc_cv_have_openssl_fips_h,
814 [AC_TRY_COMPILE([#define OPENSSL_FIPS
816 #include <openssl/fips.h>],[;],
817 [sc_cv_have_openssl_fips_h=yes; ],
818 [sv_cv_have_openssl_fips_h=no
819 if test -n "$OPENSSL_BASE"; then
820 I="$OPENSSL_BASE/include"
821 i="$I/openssl/fips.h"
822 if test -r "$i"; then
823 AC_MSG_NOTICE(found $i)
824 sc_cv_have_openssl_fips_h=yes;
830 if test "$sv_cv_have_openssl_fips_h" = "yes"; then
831 AC_DEFINE(HAVE_OPENSSL_FIPS_H)
833 AC_MSG_NOTICE(checked for openssl/fips.h... $sc_cv_have_openssl_ssl_h)
836 if test -n "$WITH_FIPS" -a "$sc_cv_have_openssl_fips_h" = 'yes'; then
837 # check for the libcrypto library with fips support
838 AC_MSG_CHECKING(for libcrypto with FIPS support)
839 AC_CACHE_VAL(sc_cv_have_libcrypto,
841 echo $LIBS | grep -q "\-lcrypto"
842 if test $? -ne 0; then
843 if test -n "$OPENSSL_BASE"; then
844 L="$OPENSSL_BASE/lib"; LIBS="$LIBS -L$L -lcrypto"
846 LIBS="$LIBS -lcrypto"
849 AC_TRY_LINK([#define OPENSSL_FIPS
850 #include <openssl/ssl.h>
851 #include <openssl/fips.h>],
852 [int res = FIPS_mode_set(1);],
853 [sc_cv_have_libcrypto='yes'],
854 [sc_cv_have_libcrypto='no']
856 if test "$sc_cv_have_libcrypto" != 'yes'; then
861 if test "$sc_cv_have_libcrypto" = 'yes'; then
862 AC_DEFINE(HAVE_LIBCRYPTO)
864 AC_MSG_RESULT($sc_cv_have_libcrypto)
867 if test -n "$WITH_FIPS"; then
868 if test "$sc_cv_have_openssl_fips_h" = 'yes' -a "$sc_cv_have_libcrypto" = 'yes'; then
870 AC_DEFINE(OPENSSL_FIPS)
872 AC_MSG_WARN([not all components of OpenSSL FIPS found, disabling it]);
876 AC_MSG_CHECKING(whether to include tun/tap address support)
877 AC_ARG_ENABLE(tun, [ --disable-tun disable TUN/TAP support],
878 [case "$enableval" in
879 no) AC_MSG_RESULT(no); WITH_TUN= ;;
880 *) AC_MSG_RESULT(yes); WITH_TUN=1 ;;
882 [AC_MSG_RESULT(yes); WITH_TUN=1 ])
885 if ! test "$ac_cv_header_linux_if_tun_h" = 'yes'; then
886 AC_MSG_WARN(include file linux/if_tun.h not found, disabling TUN)
890 if test -n "$WITH_TUN"; then
894 if test "$WITH_INTERFACE"; then
895 AC_CHECK_HEADER(netinet/if_ether.h,
896 AC_DEFINE(HAVE_NETINET_IF_ETHER_H),
898 AC_MSG_WARN([include file netinet/if_ether.h not found, disabling interface])],
900 #if HAVE_NET_IF_H && HAVE_NETINET_IN_H
902 #include <netinet/in.h>
906 if test "$WITH_INTERFACE" || test "$WITH_TUN"; then
907 AC_CHECK_HEADER(linux/if_packet.h,
908 AC_DEFINE(HAVE_LINUX_IF_PACKET_H),
910 AC_MSG_WARN([include file linux/if_packet.h not found, disabling interface])])
912 if test "$WITH_INTERFACE"; then
913 AC_DEFINE(WITH_INTERFACE)
916 AC_MSG_CHECKING(whether to include system call tracing)
917 AC_ARG_ENABLE(sycls, [ --disable-sycls disable system call tracing],
918 [case "$enableval" in
919 no) SYCLS=""; SSLCLS=""; AC_MSG_RESULT(no);;
920 *) AC_DEFINE(WITH_SYCLS)
921 SYCLS="sycls.c"; SSLCLS="sslcls.c"; AC_MSG_RESULT(yes);;
923 [AC_DEFINE(WITH_SYCLS)
924 SYCLS="sycls.c"; SSLCLS="sslcls.c"; AC_MSG_RESULT(yes)])
928 AC_MSG_CHECKING(whether to include file descriptor analyzer)
929 AC_ARG_ENABLE(filan, [ --disable-filan disable file descriptor analyzer],
930 [case "$enableval" in
931 no) FILAN=""; AC_MSG_RESULT(no);;
932 *) AC_DEFINE(WITH_FILAN) FILAN="filan.c"; AC_MSG_RESULT(yes);;
934 [AC_DEFINE(WITH_FILAN) FILAN="filan.c"; AC_MSG_RESULT(yes)])
937 AC_MSG_CHECKING(whether to include retry support)
938 AC_ARG_ENABLE(retry, [ --disable-retry disable retry support],
939 [case "$enableval" in
940 no) AC_MSG_RESULT(no);;
941 *) AC_DEFINE(WITH_RETRY) AC_MSG_RESULT(yes);;
943 [AC_DEFINE(WITH_RETRY) AC_MSG_RESULT(yes)])
945 AC_MSG_CHECKING(whether to include devtests support)
946 AC_ARG_ENABLE(devtests, [ --enable-devtests enable devtests support],
947 [case "$enableval" in
948 yes) AC_DEFINE(WITH_DEVTESTS) AC_MSG_RESULT(yes);;
949 *) AC_MSG_RESULT(no) ;;
954 AC_MSG_CHECKING(included message level)
955 AC_ARG_ENABLE(msglevel, [ --enable-msglevel=N set max verbosity to debug,info,notice,warn,error,fatal],
956 [case "$enableval" in
957 0|DEBUG|Debug|debug) AC_DEFINE(WITH_MSGLEVEL,0) AC_MSG_RESULT(debug);;
958 1|INFO|Info|info) AC_DEFINE(WITH_MSGLEVEL,1) AC_MSG_RESULT(info);;
959 2|NOTICE|Notice|notice) AC_DEFINE(WITH_MSGLEVEL,2) AC_MSG_RESULT(notice);;
960 3|WARN|Warn|warn) AC_DEFINE(WITH_MSGLEVEL,3) AC_MSG_RESULT(warn);;
961 4|ERROR|Error|error) AC_DEFINE(WITH_MSGLEVEL,4) AC_MSG_RESULT(error);;
962 5|FATAL|Fatal|fatal) AC_DEFINE(WITH_MSGLEVEL,5) AC_MSG_RESULT(fatal);;
963 *) AC_DEFINE(WITH_MSGLEVEL,0) AC_MSG_RESULT(debug);;
965 [AC_DEFINE(WITH_MSGLEVEL,0) AC_MSG_RESULT(debug)])
967 AC_MSG_CHECKING(default IP version)
968 AC_ARG_ENABLE(default-ipv, [ --enable-default-ipv=N set default/preferred IP version to "0" (none), "4", "6"],
969 [case "$enableval" in
970 "") AC_DEFINE(WITH_DEFAULT_IPV, '4') AC_MSG_RESULT("0");;
971 0) AC_DEFINE(WITH_DEFAULT_IPV, '0') AC_MSG_RESULT("4");;
972 4) AC_DEFINE(WITH_DEFAULT_IPV, '4') AC_MSG_RESULT("4");;
973 6) AC_DEFINE(WITH_DEFAULT_IPV, '6') AC_MSG_RESULT("6");;
974 *) AC_DEFINE(WITH_DEFAULT_IPV, '4') AC_MSG_RESULT("0");;
976 [AC_DEFINE(WITH_DEFAULT_IPV, '4') AC_MSG_RESULT("0")])
981 dnl Checks for typedefs, structures, and compiler characteristics.
993 dnl Check for extra realtime library (for Solaris)
994 AC_CHECK_FUNC(nanosleep, AC_DEFINE(HAVE_NANOSLEEP), AC_CHECK_LIB(rt, nanosleep, [LIBS="-lrt $LIBS"; AC_DEFINE(HAVE_NANOSLEEP)]))
995 #AC_CHECK_FUNC(nanosleep, , AC_CHECK_LIB(rt, nanosleep))
997 dnl Checks for library functions.
998 AC_PROG_GCC_TRADITIONAL
1002 AC_CHECK_FUNCS(putenv select pselect poll socket strtod strtol)
1003 AC_CHECK_FUNCS(strtoul uname getpgid getsid gethostbyname getaddrinfo)
1004 AC_CHECK_FUNCS(getprotobynumber)
1005 AC_CHECK_FUNCS(setgroups inet_aton)
1007 AC_CHECK_FUNCS(grantpt unlockpt)
1009 # GR AC_CHECK_FUNCS only checks linking, not prototype. This may lead to implicit
1010 # function declarations and to SIGSEGV on systems with 32bit int and 64bit pointer
1012 dnl Search for cfsetispeed(),cfgetispeed(),cfsetspeed(),cfgetospeed() functions
1013 AC_CHECK_FUNCS(cfsetispeed cfgetispeed cfsetospeed cfgetospeed)
1015 ###################################
1016 # check for prototype and existence of functions that return a pointer
1017 # defines in config.h: HAVE_PROTOTYPE_LIB_$1
1018 AC_CHECK_PROTOTYPE_LIB(posix_memalign)
1019 AC_CHECK_PROTOTYPE_LIB(strdup)
1020 AC_CHECK_PROTOTYPE_LIB(strerror)
1021 AC_CHECK_PROTOTYPE_LIB(strstr)
1022 AC_CHECK_PROTOTYPE_LIB(getipnodebyname)
1023 AC_CHECK_PROTOTYPE_LIB(strndup)
1024 AC_CHECK_PROTOTYPE_LIB(memrchr)
1025 AC_CHECK_PROTOTYPE_LIB(if_indextoname)
1026 AC_CHECK_PROTOTYPE_LIB(ptsname)
1028 AC_MSG_CHECKING(for long long)
1029 AC_CACHE_VAL(sc_cv_type_longlong,
1030 [AC_TRY_COMPILE([],[long long s;],
1031 [sc_cv_type_longlong=yes],
1032 [sc_cv_type_longlong=no])])
1033 if test $sc_cv_type_longlong = yes; then
1034 AC_DEFINE(HAVE_TYPE_LONGLONG)
1036 AC_MSG_RESULT($sc_cv_type_longlong)
1038 AC_CHECK_TYPE(sig_atomic_t,AC_DEFINE(HAVE_TYPE_SIG_ATOMIC_T),,[#include "sysincludes.h"])
1040 AC_MSG_CHECKING(for bool)
1041 AC_CACHE_VAL(sc_cv_type_bool,
1042 [AC_TRY_COMPILE([#ifdef HAVE_STDBOOL_H
1043 #include <stdbool.h>
1046 [sc_cv_type_bool=yes],
1047 [sc_cv_type_bool=no])])
1048 if test $sc_cv_type_bool = yes; then
1049 AC_DEFINE(HAVE_TYPE_BOOL)
1051 AC_MSG_RESULT($sc_cv_type_bool)
1053 # following builtin macro does not check unistd.h and sys/socket.h where
1054 # socklen_t might be defined
1055 #AC_CHECK_TYPE(socklen_t, int)
1057 AC_MSG_CHECKING(for socklen_t)
1058 AC_CACHE_VAL(sc_cv_type_socklen,
1059 [AC_TRY_COMPILE([#include <sys/types.h>
1060 #include <sys/socket.h>
1061 #include <unistd.h>],[socklen_t s;],
1062 [sc_cv_type_socklen=yes],
1063 [sc_cv_type_socklen=no])])
1064 if test $sc_cv_type_socklen = yes; then
1065 AC_DEFINE(HAVE_TYPE_SOCKLEN)
1067 AC_MSG_RESULT($sc_cv_type_socklen)
1069 AC_MSG_CHECKING(for struct stat64)
1070 AC_CACHE_VAL(sc_cv_type_stat64,
1071 [AC_TRY_COMPILE([#include <sys/stat.h>],[struct stat64 s;],
1072 [sc_cv_type_stat64=yes],
1073 [sc_cv_type_stat64=no])])
1074 if test $sc_cv_type_stat64 = yes; then
1075 AC_DEFINE(HAVE_TYPE_STAT64)
1077 AC_MSG_RESULT($sc_cv_type_stat64)
1079 AC_MSG_CHECKING(for off64_t)
1080 AC_CACHE_VAL(sc_cv_type_off64,
1081 [AC_TRY_COMPILE([#include <unistd.h>],[off64_t s;],
1082 [sc_cv_type_off64=yes],
1083 [sc_cv_type_off64=no])])
1084 if test $sc_cv_type_off64 = yes; then
1085 AC_DEFINE(HAVE_TYPE_OFF64)
1087 AC_MSG_RESULT($sc_cv_type_off64)
1089 AC_MSG_CHECKING(for sighandler_t)
1090 AC_CACHE_VAL(sc_cv_type_sighandler,
1091 [AC_TRY_COMPILE([#include <signal.h>],[sighandler_t s;],
1092 [sc_cv_type_sighandler=yes],
1093 [sc_cv_type_sighandler=no])])
1094 if test $sc_cv_type_sighandler = yes; then
1095 AC_DEFINE(HAVE_TYPE_SIGHANDLER)
1097 AC_MSG_RESULT($sc_cv_type_socklen)
1099 AC_MSG_CHECKING(for uint8_t)
1100 AC_CACHE_VAL(sc_cv_type_uint8,
1101 [AC_TRY_COMPILE([#include <sys/types.h>
1105 /* Tru64 has uint8_t etc from netdb.h */
1109 #include <unistd.h>],[uint8_t s;],
1110 [sc_cv_type_uint8=yes],
1111 [sc_cv_type_uint8=no])])
1112 if test $sc_cv_type_uint8 = yes; then
1113 AC_DEFINE(HAVE_TYPE_UINT8)
1115 AC_MSG_RESULT($sc_cv_type_uint8)
1117 AC_MSG_CHECKING(for uint16_t)
1118 AC_CACHE_VAL(sc_cv_type_uint16,
1119 [AC_TRY_COMPILE([#include <sys/types.h>
1123 /* Tru64 has uint16_t etc from netdb.h */
1127 #include <unistd.h>],[uint16_t s;],
1128 [sc_cv_type_uint16=yes],
1129 [sc_cv_type_uint16=no])])
1130 if test $sc_cv_type_uint16 = yes; then
1131 AC_DEFINE(HAVE_TYPE_UINT16)
1133 AC_MSG_RESULT($sc_cv_type_uint16)
1135 AC_MSG_CHECKING(for uint32_t)
1136 AC_CACHE_VAL(sc_cv_type_uint32,
1137 [AC_TRY_COMPILE([#include <sys/types.h>
1141 /* Tru64 has uint32_t etc from netdb.h */
1145 #include <unistd.h>],[uint32_t s;],
1146 [sc_cv_type_uint32=yes],
1147 [sc_cv_type_uint32=no])])
1148 if test $sc_cv_type_uint32 = yes; then
1149 AC_DEFINE(HAVE_TYPE_UINT32)
1151 AC_MSG_RESULT($sc_cv_type_uint32)
1153 AC_MSG_CHECKING(for uint64_t)
1154 AC_CACHE_VAL(sc_cv_type_uint64,
1155 [AC_TRY_COMPILE([#include <sys/types.h>
1159 /* Tru64 has uint32_t etc from netdb.h */
1163 #include <unistd.h>],[uint64_t s;],
1164 [sc_cv_type_uint64=yes],
1165 [sc_cv_type_uint64=no])])
1166 if test $sc_cv_type_uint64 = yes; then
1167 AC_DEFINE(HAVE_TYPE_UINT64)
1169 AC_MSG_RESULT($sc_cv_type_uint64)
1171 ### AIX 4.1 needs _XOPEN_EXTENDED_SOURCE for syslog headers,
1172 # but then gets problems with 3rd arg of getsockaddr...
1173 #AC_MSG_CHECKING(for _XOPEN_EXTENDED_SOURCE requirement)
1174 #CFLAGS="-Werror -Wall"
1175 #AC_TRY_COMPILE([#include <sys/syslog.h>],
1177 #[AC_MSG_RESULT(no)],
1178 #[AC_MSG_RESULT(required); AC_DEFINE(_XOPEN_EXTENDED_SOURCE)])
1182 AC_MSG_CHECKING(for fdset->fds_bits)
1183 AC_TRY_COMPILE([#include <sys/types.h>
1184 #if HAVE_SYS_SELECT_H
1185 #include <sys/select.h>
1187 [fd_set s; s.fds_bits[0]=0;],
1188 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FDS_BITS)],
1189 [AC_MSG_RESULT(no);])
1191 AC_MSG_CHECKING(for struct termios . c_ispeed)
1192 AC_TRY_COMPILE([#include <unistd.h>
1194 #include <termios.h>
1196 [struct termios s; s.c_ispeed=0;],
1197 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_TERMIOS_C_ISPEED)],
1198 [AC_MSG_RESULT(no);])
1200 AC_MSG_CHECKING(for struct termios . c_ospeed)
1201 AC_TRY_COMPILE([#include <unistd.h>
1203 #include <termios.h>
1205 [struct termios s; s.c_ospeed=0;],
1206 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_TERMIOS_C_OSPEED)],
1207 [AC_MSG_RESULT(no);])
1209 AC_MSG_CHECKING(for sa_family_t)
1210 AC_CACHE_VAL(sc_cv_type_sa_family_t,
1211 [AC_TRY_COMPILE([#include <sys/types.h>
1212 #include <sys/socket.h>
1213 #include <netinet/in.h>],[sa_family_t s;],
1214 [sc_cv_type_sa_family_t=yes],
1215 [sc_cv_type_sa_family_t=no])])
1216 if test $sc_cv_type_sa_family_t = yes; then
1217 AC_DEFINE(HAVE_TYPE_SA_FAMILY_T)
1219 AC_MSG_RESULT($sc_cv_type_sa_family_t)
1221 AC_MSG_CHECKING(for struct sock_extended_err)
1222 AC_CACHE_VAL(sc_cv_struct_sock_extended_err,
1223 [AC_TRY_COMPILE([#include <linux/types.h>
1224 #if TIME_WITH_SYS_TIME
1225 #include <sys/time.h>
1227 #if HAVE_LINUX_ERRQUEUE_H
1228 #include <linux/errqueue.h>
1229 #endif],[struct sock_extended_err s;],
1230 [sc_cv_struct_sock_extended_err=yes],
1231 [sc_cv_struct_sock_extended_err=no])])
1232 if test $sc_cv_struct_sock_extended_err = yes; then
1233 AC_DEFINE(HAVE_STRUCT_SOCK_EXTENDED_ERR)
1235 AC_MSG_RESULT($sc_cv_struct_sock_extended_err)
1237 AC_MSG_CHECKING(for struct sigaction.sa_sigaction)
1238 AC_CACHE_VAL(sc_cv_struct_sigaction_sa_sigaction,
1239 [AC_TRY_COMPILE([#include <signal.h>],[struct sigaction s;s.sa_sigaction=0;],
1240 [sc_cv_struct_sigaction_sa_sigaction=yes],
1241 [sc_cv_struct_sigaction_sa_sigaction=no])])
1242 if test $sc_cv_struct_sigaction_sa_sigaction = yes; then
1243 AC_DEFINE(HAVE_STRUCT_SIGACTION_SA_SIGACTION)
1245 AC_MSG_RESULT($sc_cv_struct_sigaction_sa_sigaction)
1247 # there is another issue with termios: OSR requires "#define _SVID3 ..."
1248 # for reasonable termios support. We check this situation using IMAXBEL
1249 AC_MSG_CHECKING(if _SVID3 is helpful)
1250 AC_CACHE_VAL(ac_cv_svid3,
1251 [AC_TRY_COMPILE([#include <termios.h>],
1254 [AC_TRY_COMPILE([#define _SVID3 1
1255 #include <termios.h>],
1261 if test $ac_cv_svid3 = yes; then
1264 AC_MSG_RESULT($ac_cv_svid3)
1267 # Openindiana needs _XPG4_2 for CMSG stuff
1268 AC_MSG_CHECKING(if _XPG4_2 is helpful)
1269 AC_CACHE_VAL(ac_cv_xpg4_2,
1270 [AC_TRY_LINK([#include <sys/socket.h>],
1271 [int i=CMSG_DATA(0)],
1273 [AC_TRY_LINK([#define _XPG4_2 1
1274 #include <sys/socket.h>],
1275 [int i=CMSG_DATA(0)],
1280 if test $ac_cv_xpg4_2 = yes; then
1283 AC_MSG_RESULT($ac_cv_xpg4_2)
1285 # When on Openindiana _XPG4_2 is defined (see above)
1286 # we also need to define __EXTENSIONS__ for basic stuff.
1287 # Note that <sys/procset.h> is important on Openindiana
1288 # but does not exist on Linux
1289 if test "$ac_cv_xpg4_2" = yes; then
1290 AC_MSG_CHECKING(if __EXTENSIONS__ is helpful)
1291 AC_CACHE_VAL(ac_cv___extensions__,
1292 [AC_TRY_COMPILE([#include <sys/procset.h>],
1294 [ac_cv___extensions__=no],
1295 [AC_TRY_COMPILE([#define __EXTENSIONS__ 1
1296 #include <sys/procset.h>],
1298 [ac_cv___extensions__=yes],
1299 [ac_cv___extensions__=no]
1302 if test $ac_cv___extensions__ = yes; then
1303 AC_DEFINE(__EXTENSIONS__)
1305 AC_MSG_RESULT($ac_cv___extensions__)
1308 # When on Openindiana __EXTENSIONS__ is defined (see above)
1309 # _POSIX_PTHREAD_SEMANTICS must be defined for standard ctime_r()
1310 if test "$ac_cv___extensions__" = yes; then
1311 AC_MSG_CHECKING(if _POSIX_PTHREAD_SEMANTICS is helpful)
1312 AC_CACHE_VAL(ac_cv__posix_pthread_semantics,
1313 [AC_TRY_COMPILE([#include <time.h>],
1314 [char *s = ctime_r(0,0);],
1315 [ac_cv__posix_pthread_semantics=no],
1316 [AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS 1
1318 [char *s = ctime_r(0,0);],
1319 [ac_cv__posix_pthread_semantics=yes],
1320 [ac_cv__posix_pthread_semantics=no]
1323 if test $ac_cv__posix_pthread_semantics = yes; then
1324 AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1326 AC_MSG_RESULT($ac_cv__posix_pthread_semantics)
1331 AC_MSG_CHECKING(for struct timespec)
1332 AC_CACHE_VAL(sc_cv_struct_timespec,
1333 [AC_TRY_COMPILE([#include <time.h>
1335 #include <sys/time.h>
1336 #endif],[struct timespec s;],
1337 [sc_cv_struct_timespec=yes],
1338 [sc_cv_struct_timespec=no])])
1339 if test $sc_cv_struct_timespec = yes; then
1340 AC_DEFINE(HAVE_STRUCT_TIMESPEC)
1342 AC_MSG_RESULT($sc_cv_struct_timespec)
1345 # struct linger; FreeBSD requires sys/types.h for sys/socket.h
1346 AC_MSG_CHECKING(for struct linger)
1347 AC_CACHE_VAL(sc_cv_struct_linger,
1348 [AC_TRY_COMPILE([#include <sys/types.h>
1349 #include <sys/socket.h>],[struct linger s;],
1350 [sc_cv_struct_linger=yes],
1351 [sc_cv_struct_linger=no])])
1352 if test $sc_cv_struct_linger = yes; then
1353 AC_DEFINE(HAVE_STRUCT_LINGER)
1355 AC_MSG_RESULT($sc_cv_struct_linger)
1358 # struct ip (for IPv4 header info)
1359 AC_MSG_CHECKING(for struct ip)
1360 AC_CACHE_VAL(sc_cv_struct_ip,
1361 [AC_TRY_COMPILE([#include <netinet/in.h>
1362 #include <netinet/ip.h>],[struct ip s;],
1363 [sc_cv_struct_ip=yes],
1364 [sc_cv_struct_ip=no])])
1365 if test $sc_cv_struct_ip = yes; then
1366 AC_DEFINE(HAVE_STRUCT_IP)
1368 AC_MSG_RESULT($sc_cv_struct_ip)
1370 # struct ip_mreq (for multicasting options)
1371 AC_MSG_CHECKING(for struct ip_mreq)
1372 AC_CACHE_VAL(sc_cv_struct_ip_mreq,
1373 [AC_TRY_COMPILE([#include <sys/types.h>
1374 #include <sys/socket.h>
1375 #include <netinet/in.h>],[struct ip_mreq s;],
1376 [sc_cv_struct_ip_mreq=yes],
1377 [sc_cv_struct_ip_mreq=no])])
1378 if test $sc_cv_struct_ip_mreq = yes; then
1379 AC_DEFINE(HAVE_STRUCT_IP_MREQ)
1381 AC_MSG_RESULT($sc_cv_struct_ip_mreq)
1383 # struct ip_mreqn (for multicasting options)
1384 AC_MSG_CHECKING(for struct ip_mreqn)
1385 AC_CACHE_VAL(sc_cv_struct_ip_mreqn,
1386 [AC_TRY_COMPILE([#include <sys/types.h>
1387 #include <sys/socket.h>
1388 #include <netinet/in.h>
1389 #include <netinet/ip.h>],[struct ip_mreqn s;],
1390 [sc_cv_struct_ip_mreqn=yes],
1391 [sc_cv_struct_ip_mreqn=no])])
1392 if test $sc_cv_struct_ip_mreqn = yes; then
1393 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
1395 AC_MSG_RESULT($sc_cv_struct_ip_mreqn)
1397 # struct ipv6_mreq (for multicasting options)
1398 AC_MSG_CHECKING(for struct ipv6_mreq)
1399 AC_CACHE_VAL(sc_cv_struct_ipv6_mreq,
1400 [AC_TRY_COMPILE([#include <sys/types.h>
1401 #include <sys/socket.h>
1402 #include <netinet/in.h>],[struct ipv6_mreq s;],
1403 [sc_cv_struct_ipv6_mreq=yes],
1404 [sc_cv_struct_ipv6_mreq=no])])
1405 if test $sc_cv_struct_ipv6_mreq = yes; then
1406 AC_DEFINE(HAVE_STRUCT_IPV6_MREQ)
1408 AC_MSG_RESULT($sc_cv_struct_ipv6_mreq)
1410 # struct ip_mreq_source (for multicasting options)
1411 AC_MSG_CHECKING(for struct ip_mreq_source)
1412 AC_CACHE_VAL(sc_cv_struct_ip_mreq_source,
1413 [AC_TRY_COMPILE([#include <sys/types.h>
1414 #include <sys/socket.h>
1415 #include <netinet/in.h>
1416 #include <netinet/ip.h>],[struct ip_mreq_source s;],
1417 [sc_cv_struct_ip_mreq_source=yes],
1418 [sc_cv_struct_ip_mreq_source=no])])
1419 if test $sc_cv_struct_ip_mreq_source = yes; then
1420 AC_DEFINE(HAVE_STRUCT_IP_MREQ_SOURCE)
1422 AC_MSG_RESULT($sc_cv_struct_ip_mreqn)
1424 # struct group_source_req (for multicasting options)
1425 AC_MSG_CHECKING(for struct group_source_req)
1426 AC_CACHE_VAL(sc_cv_struct_group_source_req,
1427 [AC_TRY_COMPILE([#include <sys/types.h>
1428 #include <sys/socket.h>
1429 #include <netinet/in.h>
1430 #include <netinet/ip.h>],[struct group_source_req s;],
1431 [sc_cv_struct_group_source_req=yes],
1432 [sc_cv_struct_group_source_req=no])])
1433 if test $sc_cv_struct_group_source_req = yes; then
1434 AC_DEFINE(HAVE_STRUCT_GROUP_SOURCE_REQ)
1436 AC_MSG_RESULT($sc_cv_struct_group_source_req)
1439 # struct ifreq (for network interfaces)
1440 AC_MSG_CHECKING(for struct ifreq)
1441 AC_CACHE_VAL(sc_cv_struct_ifreq,
1442 [AC_TRY_COMPILE([#include <sys/types.h>
1443 #include <sys/socket.h>
1444 #include <net/if.h>],[struct ifreq s;],
1445 [sc_cv_struct_ifreq=yes],
1446 [sc_cv_struct_ifreq=no])])
1447 if test $sc_cv_struct_ifreq = yes; then
1448 AC_DEFINE(HAVE_STRUCT_IFREQ)
1450 AC_MSG_RESULT($sc_cv_struct_ifreq)
1452 # struct ifreq.ifr_index
1453 # on most systems that have struct ifreq
1454 AC_MSG_CHECKING(for struct ifreq.ifr_index)
1455 AC_CACHE_VAL(sc_cv_struct_ifreq_ifr_index,
1456 [AC_TRY_COMPILE([#include <sys/types.h>
1457 #include <sys/socket.h>
1458 #include <net/if.h>],
1459 [struct ifreq ir;ir.ifr_index=0;],
1460 [sc_cv_struct_ifreq_ifr_index=yes],
1461 [sc_cv_struct_ifreq_ifr_index=no])])
1462 if test $sc_cv_struct_ifreq_ifr_index = yes; then
1463 AC_DEFINE(HAVE_STRUCT_IFREQ_IFR_INDEX)
1465 AC_MSG_RESULT($sc_cv_struct_ifreq_ifr_index)
1467 # struct ifreq.ifr_ifindex
1468 # Linux has ifr_ifindex instead of ifr_index
1469 AC_MSG_CHECKING(for struct ifreq.ifr_ifindex)
1470 AC_CACHE_VAL(sc_cv_struct_ifreq_ifr_ifindex,
1471 [AC_TRY_COMPILE([#include <sys/types.h>
1472 #include <sys/socket.h>
1473 #include <net/if.h>],
1474 [struct ifreq ir;ir.ifr_ifindex=0;],
1475 [sc_cv_struct_ifreq_ifr_ifindex=yes],
1476 [sc_cv_struct_ifreq_ifr_ifindex=no])])
1477 if test $sc_cv_struct_ifreq_ifr_ifindex = yes; then
1478 AC_DEFINE(HAVE_STRUCT_IFREQ_IFR_IFINDEX)
1480 AC_MSG_RESULT($sc_cv_struct_ifreq_ifr_ifindex)
1483 # some systems have a sa_len field in struct sockaddr and we need to support it
1484 # so we can compare sockaddrs simply with memcmp
1485 AC_MSG_CHECKING(for struct sockaddr.sa_len)
1486 AC_CACHE_VAL(sc_cv_struct_sockaddr_salen,
1487 [AC_TRY_COMPILE([#include <sys/types.h>
1488 #include <sys/socket.h>],
1489 [struct sockaddr sa;sa.sa_len=0;],
1490 [sc_cv_struct_sockaddr_salen=yes],
1491 [sc_cv_struct_sockaddr_salen=no])])
1492 if test $sc_cv_struct_sockaddr_salen = yes; then
1493 AC_DEFINE(HAVE_STRUCT_SOCKADDR_SALEN)
1495 AC_MSG_RESULT($sc_cv_struct_sockaddr_salen)
1497 ### IP6 sockaddr_in6
1499 AC_MSG_CHECKING(for component names of sockaddr_in6)
1500 AC_TRY_COMPILE([#include <sys/types.h>
1501 #include <netinet/in.h>],
1502 [struct sockaddr_in6 sa6;sa6.sin6_addr.s6_addr[0]=0;],
1503 [AC_MSG_RESULT(s6_addr);
1504 AC_DEFINE(HAVE_IP6_SOCKADDR, 0)],
1505 [AC_TRY_COMPILE([#include <sys/types.h>
1506 #include <netinet/in.h>],
1507 [struct sockaddr_in6 sa6;sa6.sin6_addr.u6_addr.u6_addr16[0]=0;],
1508 [AC_MSG_RESULT(u6_addr.u6_addr16);
1509 AC_DEFINE(HAVE_IP6_SOCKADDR, 1)],
1510 [AC_TRY_COMPILE([#include <sys/types.h>
1511 #include <netinet/in.h>],
1512 [struct sockaddr_in6 sa6;sa6.sin6_addr.u6_addr16[0]=0;],
1513 [AC_MSG_RESULT(u6_addr16); AC_DEFINE(HAVE_IP6_SOCKADDR, 2)],
1514 [AC_TRY_COMPILE([#include <sys/types.h>
1515 #include <netinet/in.h>],
1516 [struct sockaddr_in6 sa6;sa6.sin6_addr.in6_u.u6_addr16[0]=0;],
1517 [AC_MSG_RESULT(in6_u.u6_addr16);
1518 AC_DEFINE(HAVE_IP6_SOCKADDR, 3)],
1519 [AC_TRY_COMPILE([#include <sys/types.h>
1520 #include <netinet/in.h>],
1521 [struct sockaddr_in6 sa6;sa6.sin6_addr._S6_un._S6_u32[0]=0;],
1522 [AC_MSG_RESULT(_S6_un._S6_u32);
1523 AC_DEFINE(HAVE_IP6_SOCKADDR, 4)],
1524 [AC_TRY_COMPILE([#include <sys/types.h>
1525 #include <netinet/in.h>],
1526 [struct sockaddr_in6 sa6;sa6.sin6_addr.__u6_addr.__u6_addr32[0]=0;],
1527 [AC_MSG_RESULT(__u6_addr.__u6_addr32);
1528 AC_DEFINE(HAVE_IP6_SOCKADDR, 5)],
1530 [AC_MSG_RESULT([none or unknown])]
1533 dnl Check for struct iovec
1534 AC_MSG_CHECKING(for struct iovec)
1535 AC_CACHE_VAL(sc_cv_struct_iovec,
1536 [AC_TRY_COMPILE([#include <sys/uio.h>],[struct iovec s;],
1537 [sc_cv_struct_iovec=yes],
1538 [sc_cv_struct_iovec=no])])
1539 if test $sc_cv_struct_iovec = yes; then
1540 AC_DEFINE(HAVE_STRUCT_IOVEC)
1542 AC_MSG_RESULT($sc_cv_struct_iovec)
1544 dnl check for msg_control in struct msghdr
1545 AC_MSG_CHECKING(for struct msghdr.msg_control)
1546 AC_CACHE_VAL(sc_cv_struct_msghdr_msgcontrol,
1547 [AC_TRY_COMPILE([#include <sys/types.h>
1548 #include <sys/socket.h>],
1549 [struct msghdr s;s.msg_control=0;],
1550 [sc_cv_struct_msghdr_msgcontrol=yes],
1551 [sc_cv_struct_msghdr_msgcontrol=no])])
1552 if test $sc_cv_struct_msghdr_msgcontrol = yes; then
1553 AC_DEFINE(HAVE_STRUCT_MSGHDR_MSGCONTROL)
1555 AC_MSG_RESULT($sc_cv_struct_msghdr_msgcontrol)
1557 dnl check for msg_controllen in struct msghdr
1558 AC_MSG_CHECKING(for struct msghdr.msg_controllen)
1559 AC_CACHE_VAL(sc_cv_struct_msghdr_msgcontrollen,
1560 [AC_TRY_COMPILE([#include <sys/types.h>
1561 #include <sys/socket.h>],
1562 [struct msghdr s;s.msg_controllen=0;],
1563 [sc_cv_struct_msghdr_msgcontrollen=yes],
1564 [sc_cv_struct_msghdr_msgcontrollen=no])])
1565 if test $sc_cv_struct_msghdr_msgcontrollen = yes; then
1566 AC_DEFINE(HAVE_STRUCT_MSGHDR_MSGCONTROLLEN)
1568 AC_MSG_RESULT($sc_cv_struct_msghdr_msgcontrollen)
1570 dnl check for msg_flags in struct msghdr
1571 AC_MSG_CHECKING(for struct msghdr.msgflags)
1572 AC_CACHE_VAL(sc_cv_struct_msghdr_msgflags,
1573 [AC_TRY_COMPILE([#include <sys/types.h>
1574 #include <sys/socket.h>],
1575 [struct msghdr s;s.msg_flags=0;],
1576 [sc_cv_struct_msghdr_msgflags=yes],
1577 [sc_cv_struct_msghdr_msgflags=no])])
1578 if test $sc_cv_struct_msghdr_msgflags = yes; then
1579 AC_DEFINE(HAVE_STRUCT_MSGHDR_MSGFLAGS)
1581 AC_MSG_RESULT($sc_cv_struct_msghdr_msgflags)
1583 dnl check for struct cmsghdr
1584 AC_MSG_CHECKING(for struct cmsghdr)
1585 AC_CACHE_VAL(sc_cv_struct_cmsghdr,
1586 [AC_TRY_COMPILE([#include <sys/types.h>
1587 #include <sys/socket.h>
1588 #include <net/if.h>],[struct cmsghdr s;],
1589 [sc_cv_struct_cmsghdr=yes],
1590 [sc_cv_struct_cmsghdr=no])])
1591 if test $sc_cv_struct_cmsghdr = yes; then
1592 AC_DEFINE(HAVE_STRUCT_CMSGHDR)
1594 AC_MSG_RESULT($sc_cv_struct_cmsghdr)
1596 dnl check for struct in_pktinfo
1597 AC_MSG_CHECKING(for struct in_pktinfo)
1598 AC_CACHE_VAL(sc_cv_struct_in_pktinfo,
1599 [AC_TRY_COMPILE([#include <sys/types.h>
1600 #include <sys/socket.h>
1601 #include <netinet/in.h>],[struct in_pktinfo s;],
1602 [sc_cv_struct_in_pktinfo=yes],
1603 [sc_cv_struct_in_pktinfo=no])])
1604 if test $sc_cv_struct_in_pktinfo = yes; then
1605 AC_DEFINE(HAVE_STRUCT_IN_PKTINFO)
1607 AC_MSG_RESULT($sc_cv_struct_in_pktinfo)
1609 if test $sc_cv_struct_in_pktinfo = 'yes'; then
1610 dnl check for component ipi_spec_dst in struct in_pktinfo
1611 AC_MSG_CHECKING(for ipi_spec_dst in struct in_pktinfo)
1612 AC_CACHE_VAL(sc_cv_pktinfo_ipi_spec_dst,
1613 [AC_TRY_COMPILE([#include <sys/types.h>
1614 #include <sys/socket.h>
1615 #include <netinet/in.h>],[struct in_pktinfo s; s.ipi_spec_dst],
1616 [sc_cv_pktinfo_ipi_spec_dst=yes],
1617 [sc_cv_pktinfo_ipi_spec_dst=no])])
1618 if test $sc_cv_pktinfo_ipi_spec_dst = yes; then
1619 AC_DEFINE(HAVE_PKTINFO_IPI_SPEC_DST)
1621 AC_MSG_RESULT($sc_cv_pktinfo_ipi_spec_dst)
1624 dnl check for struct in6_pktinfo
1625 AC_MSG_CHECKING(for struct in6_pktinfo)
1626 AC_CACHE_VAL(sc_cv_struct_in6_pktinfo,
1627 [AC_TRY_COMPILE([#include "sysincludes.h"],
1628 [struct in6_pktinfo s;],
1629 [sc_cv_struct_in6_pktinfo=yes],
1630 [sc_cv_struct_in6_pktinfo=no])])
1631 if test $sc_cv_struct_in6_pktinfo = yes; then
1632 AC_DEFINE(HAVE_STRUCT_IN6_PKTINFO)
1634 AC_MSG_RESULT($sc_cv_struct_in6_pktinfo)
1636 dnl check for struct tpacket_auxdata
1637 AC_MSG_CHECKING(for struct tpacket_auxdata)
1638 AC_CACHE_VAL(sc_cv_struct_tpacket_auxdata,
1639 [AC_TRY_COMPILE([#include "sysincludes.h"],
1640 [struct tpacket_auxdata s;],
1641 [sc_cv_struct_tpacket_auxdata=yes],
1642 [sc_cv_struct_tpacket_auxdata=no])])
1643 if test $sc_cv_struct_tpacket_auxdata = yes; then
1644 AC_DEFINE(HAVE_STRUCT_TPACKET_AUXDATA)
1646 AC_MSG_RESULT($sc_cv_struct_tpacket_auxdata)
1648 AC_MSG_CHECKING(for tp_vlan_tpid in struct tpacket_auxdata)
1649 AC_CACHE_VAL(sc_cv_struct_tpacket_auxdata_tp_vlan_tpid,
1650 [AC_TRY_COMPILE([#include "sysincludes.h"],
1651 [struct tpacket_auxdata s; s.tp_vlan_tpid=0],
1652 [sc_cv_struct_tpacket_auxdata_tp_vlan_tpid=yes],
1653 [sc_cv_struct_tpacket_auxdata_tp_vlan_tpid=no])])
1654 if test $sc_cv_struct_tpacket_auxdata_tp_vlan_tpid = yes; then
1655 AC_DEFINE(HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TPID)
1657 AC_MSG_RESULT($sc_cv_struct_tpacket_auxdata)
1659 dnl check for ip_hl in struct ip
1660 AC_MSG_CHECKING(for struct ip.ip_hl)
1661 AC_CACHE_VAL(sc_cv_struct_ip_ip_hl,
1662 [AC_TRY_COMPILE([#include <sys/types.h>
1663 #include <netinet/in_systm.h>
1664 #include <netinet/in.h>
1665 #include <netinet/ip.h>],
1666 [struct ip s;s.ip_hl=0;],
1667 [sc_cv_struct_ip_ip_hl=yes],
1668 [sc_cv_struct_ip_ip_hl=no])])
1669 if test $sc_cv_struct_ip_ip_hl = yes; then
1670 AC_DEFINE(HAVE_STRUCT_IP_IP_HL)
1672 AC_MSG_RESULT($sc_cv_struct_ip_ip_hl)
1675 dnl Library function checks
1677 dnl Check sigaction()
1678 AC_CHECK_FUNC(sigaction, AC_DEFINE(HAVE_SIGACTION))
1680 dnl Check for 64bit versions of system calls
1681 AC_CHECK_FUNC(stat64, AC_DEFINE(HAVE_STAT64))
1682 AC_CHECK_FUNC(fstat64, AC_DEFINE(HAVE_FSTAT64))
1683 AC_CHECK_FUNC(lstat64, AC_DEFINE(HAVE_LSTAT64))
1684 AC_CHECK_FUNC(lseek64, AC_DEFINE(HAVE_LSEEK64))
1685 AC_CHECK_FUNC(truncate64, AC_DEFINE(HAVE_TRUNCATE64))
1686 AC_CHECK_FUNC(ftruncate64, AC_DEFINE(HAVE_FTRUNCATE64))
1688 AC_CHECK_FUNC(strtoll, AC_DEFINE(HAVE_STRTOLL))
1689 AC_CHECK_FUNC(hstrerror, AC_DEFINE(HAVE_HSTRERROR))
1690 AC_CHECK_FUNC(inet_ntop, AC_DEFINE(HAVE_INET_NTOP))
1692 #if test "$ac_cv_func_hstrerror" = "yes"; then
1693 # AC_MSG_CHECKING(if _XOPEN_SOURCE_EXTENDED is helpful)
1694 # AC_CACHE_VAL(ac_cv_xopen_source_extended,
1695 # [AC_TRY_COMPILE([#include <netdb.h>],
1697 # [ac_cv_xopen_source_extended=no],
1698 # [AC_TRY_COMPILE([#define _XOPEN_SOURCE_EXTENDED 1
1699 ## include <netdb.h>],
1701 # [ac_cv_xopen_source_extended=yes],
1702 # [ac_cv_xopen_source_extended=no]
1705 # if test $ac_cv_xopen_source_extended = yes; then
1706 # AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
1708 # AC_MSG_RESULT($ac_cv_xopen_source_extended)
1711 dnl Search for openpty()
1713 AC_CHECK_FUNC(openpty, AC_DEFINE(HAVE_OPENPTY))
1715 AC_CHECK_LIB(bsd, openpty,
1716 [LIBS="-lbsd $LIBS"; AC_DEFINE(HAVE_OPENPTY)])
1718 AC_CHECK_LIB(util, openpty,
1719 [LIBS="-lutil $LIBS"; AC_DEFINE(HAVE_OPENPTY)])
1721 AC_CHECK_PROTOTYPE_LIB(gettimeofday)
1723 AC_CHECK_FUNC(clock_gettime, AC_DEFINE(HAVE_CLOCK_GETTIME), AC_CHECK_LIB(rt, clock_gettime, [LIBS="-lrt $LIBS"; AC_DEFINE(HAVE_CLOCK_GETTIME)]))
1725 dnl Search for flock()
1726 # with Linux it's in libc, with AIX in libbsd
1727 AC_CHECK_FUNC(flock, AC_DEFINE(HAVE_FLOCK),
1728 AC_CHECK_LIB(bsd, flock, [LIBS="-lbsd $LIBS"]))
1730 dnl Search for setenv()
1731 AC_CHECK_FUNC(setenv, AC_DEFINE(HAVE_SETENV),
1732 AC_CHECK_LIB(isode, setenv, [LIBS="-lisode $LIBS"]))
1734 dnl Search for unsetenv()
1735 AC_CHECK_FUNC(unsetenv, AC_DEFINE(HAVE_UNSETENV))
1737 AC_CHECK_FUNC(TLS_client_method, AC_DEFINE(HAVE_TLS_client_method) ac_cv_have_tls_client_method=yes, AC_CHECK_LIB(crypt, TLS_client_method, [LIBS=-lcrypt $LIBS]))
1738 AC_CHECK_FUNC(TLS_server_method, AC_DEFINE(HAVE_TLS_server_method) ac_cv_have_tls_server_method=yes, AC_CHECK_LIB(crypt, TLS_server_method, [LIBS=-lcrypt $LIBS]))
1739 AC_CHECK_FUNC(DTLS_client_method, AC_DEFINE(HAVE_DTLS_client_method), AC_CHECK_LIB(crypt, DTLS_client_method, [LIBS=-lcrypt $LIBS]))
1740 AC_CHECK_FUNC(DTLS_server_method, AC_DEFINE(HAVE_DTLS_server_method), AC_CHECK_LIB(crypt, DTLS_server_method, [LIBS=-lcrypt $LIBS]))
1741 if test -n "$WITH_OPENSSL_METHOD" -o -z "$ac_cv_have_tls_client_method" -o -z "$ac_cv_have_tls_server_method" ; then
1742 dnl Search for SSLv2_client_method, SSLv2_server_method
1743 AC_CHECK_FUNC(SSLv2_client_method, AC_DEFINE(HAVE_SSLv2_client_method), AC_CHECK_LIB(crypt, SSLv2_client_method, [LIBS=-lcrypt $LIBS]))
1744 AC_CHECK_FUNC(SSLv2_server_method, AC_DEFINE(HAVE_SSLv2_server_method), AC_CHECK_LIB(crypt, SSLv2_server_method, [LIBS=-lcrypt $LIBS]))
1746 AC_CHECK_FUNC(SSLv3_client_method, AC_DEFINE(HAVE_SSLv3_client_method), AC_CHECK_LIB(crypt, SSLv3_client_method, [LIBS=-lcrypt $LIBS]))
1747 AC_CHECK_FUNC(SSLv3_server_method, AC_DEFINE(HAVE_SSLv3_server_method), AC_CHECK_LIB(crypt, SSLv3_server_method, [LIBS=-lcrypt $LIBS]))
1748 AC_CHECK_FUNC(SSLv23_client_method, AC_DEFINE(HAVE_SSLv23_client_method), AC_CHECK_LIB(crypt, SSLv23_client_method, [LIBS=-lcrypt $LIBS]))
1749 AC_CHECK_FUNC(SSLv23_server_method, AC_DEFINE(HAVE_SSLv23_server_method), AC_CHECK_LIB(crypt, SSLv23_server_method, [LIBS=-lcrypt $LIBS]))
1750 AC_CHECK_FUNC(TLSv1_client_method, AC_DEFINE(HAVE_TLSv1_client_method), AC_CHECK_LIB(crypt, TLSv1_client_method, [LIBS=-lcrypt $LIBS]))
1751 AC_CHECK_FUNC(TLSv1_server_method, AC_DEFINE(HAVE_TLSv1_server_method), AC_CHECK_LIB(crypt, TLSv1_server_method, [LIBS=-lcrypt $LIBS]))
1752 AC_CHECK_FUNC(TLSv1_1_client_method, AC_DEFINE(HAVE_TLSv1_1_client_method), AC_CHECK_LIB(crypt, TLSv1_1_client_method, [LIBS=-lcrypt $LIBS]))
1753 AC_CHECK_FUNC(TLSv1_1_server_method, AC_DEFINE(HAVE_TLSv1_1_server_method), AC_CHECK_LIB(crypt, TLSv1_1_server_method, [LIBS=-lcrypt $LIBS]))
1754 AC_CHECK_FUNC(TLSv1_2_client_method, AC_DEFINE(HAVE_TLSv1_2_client_method), AC_CHECK_LIB(crypt, TLSv1_2_client_method, [LIBS=-lcrypt $LIBS]))
1755 AC_CHECK_FUNC(TLSv1_2_server_method, AC_DEFINE(HAVE_TLSv1_2_server_method), AC_CHECK_LIB(crypt, TLSv1_2_server_method, [LIBS=-lcrypt $LIBS]))
1756 AC_CHECK_FUNC(DTLSv1_client_method, AC_DEFINE(HAVE_DTLSv1_client_method), AC_CHECK_LIB(crypt, DTLSv1_client_method, [LIBS=-lcrypt $LIBS]))
1757 AC_CHECK_FUNC(DTLSv1_server_method, AC_DEFINE(HAVE_DTLSv1_server_method), AC_CHECK_LIB(crypt, DTLSv1_server_method, [LIBS=-lcrypt $LIBS]))
1758 AC_CHECK_FUNC(DTLSv1_2_client_method, AC_DEFINE(HAVE_DTLSv1_2_client_method), AC_CHECK_LIB(crypt, DTLSv1_2_client_method, [LIBS=-lcrypt $LIBS]))
1759 AC_CHECK_FUNC(DTLSv1_2_server_method, AC_DEFINE(HAVE_DTLSv1_2_server_method), AC_CHECK_LIB(crypt, DTLSv1_2_server_method, [LIBS=-lcrypt $LIBS]))
1760 fi # $WITH_OPENSSL_METHOD
1762 AC_CHECK_FUNC(SSL_CTX_set_default_verify_paths, AC_DEFINE(HAVE_SSL_CTX_set_default_verify_paths))
1763 AC_CHECK_FUNC(RAND_egd, AC_DEFINE(HAVE_RAND_egd), AC_CHECK_LIB(crypt, RAND_egd, [LIBS=-lcrypt $LIBS]))
1764 AC_CHECK_FUNC(DH_set0_pqg, AC_DEFINE(HAVE_DH_set0_pqg), AC_CHECK_LIB(crypt, DH_set0_pqg, [LIBS=-lcrypt $LIBS]))
1765 AC_CHECK_FUNC(ASN1_STRING_get0_data, AC_DEFINE(HAVE_ASN1_STRING_get0_data), AC_CHECK_LIB(crypt, ASN1_STRING_get0_data, [LIBS=-lcrypt $LIBS]))
1766 AC_CHECK_FUNC(RAND_status, AC_DEFINE(HAVE_RAND_status))
1767 AC_CHECK_FUNC(SSL_CTX_clear_mode, AC_DEFINE(HAVE_SSL_CTX_clear_mode))
1768 AC_CHECK_FUNC(SSL_set_tlsext_host_name, AC_DEFINE(HAVE_SSL_set_tlsext_host_name))
1769 AC_CHECK_FUNC(SSL_CTX_set_tlsext_max_fragment_length, AC_DEFINE(HAVE_SSL_CTX_set_tlsext_max_fragment_length))
1771 AC_MSG_CHECKING(if SSL_CTX_set_max_send_fragment exists)
1772 AC_CACHE_VAL(ac_cv_have_SSL_CTX_set_max_send_fragment,
1773 [AC_TRY_COMPILE([#include <openssl/ssl.h>],[
1774 #ifndef SSL_CTX_set_max_send_fragment
1775 #error "SSL_CTX_set_max_send_fragment not found"
1778 [ac_cv_have_SSL_CTX_set_max_send_fragment=yes],
1779 [ac_cv_have_SSL_CTX_set_max_send_fragment=no])]
1781 if test $ac_cv_have_SSL_CTX_set_max_send_fragment = yes; then
1782 AC_DEFINE(HAVE_SSL_CTX_set_max_send_fragment)
1784 AC_MSG_RESULT($ac_cv_have_SSL_CTX_set_max_send_fragment)
1786 AC_CHECK_FUNC(SSL_library_init, AC_DEFINE(HAVE_SSL_library_init))
1787 AC_CHECK_FUNC(ERR_error_string, AC_DEFINE(HAVE_ERR_error_string))
1789 AC_MSG_CHECKING(for type EC_KEY)
1790 AC_CACHE_VAL(sc_cv_type_EC_TYPE,
1791 [AC_TRY_COMPILE([#include <openssl/ec.h>
1793 [sc_cv_type_EC_KEY=yes],
1794 [sc_cv_type_EC_KEY=no])])
1795 if test $sc_cv_type_EC_KEY = yes; then
1796 AC_DEFINE(HAVE_TYPE_EC_KEY)
1798 AC_MSG_RESULT($sc_cv_type_EC_KEY)
1804 AC_MSG_CHECKING(if snprintf conforms to C99)
1805 AC_CACHE_VAL(ac_cv_have_c99_snprintf,
1811 exit(snprintf(s,2,"ab")!=2);
1813 [ac_cv_have_c99_snprintf=yes],
1814 [ac_cv_have_c99_snprintf=no],
1815 [ac_cv_have_c99_snprintf=no])])
1816 if test $ac_cv_have_c99_snprintf = yes; then
1817 AC_DEFINE(HAVE_C99_SNPRINTF)
1819 AC_MSG_RESULT($ac_cv_have_c99_snprintf)
1822 AC_MSG_CHECKING(if printf has Z modifier)
1823 AC_CACHE_VAL(ac_cv_have_z_modifier,
1824 if test "$cc" = gcc; then
1831 exit(strcmp(s,"1"));
1833 [ac_cv_have_z_modifier=yes],
1834 [ac_cv_have_z_modifier=no],
1835 [ac_cv_have_z_modifier=no])]
1836 else ac_cv_have_z_modifier=no
1839 if test $ac_cv_have_z_modifier = yes; then
1840 AC_DEFINE(HAVE_FORMAT_Z)
1842 AC_MSG_RESULT($ac_cv_have_z_modifier)
1845 dnl find the number of bits we must shift a value to match the given mask
1846 dnl (e.g., mask 0x00f0 requires shifting with 4)
1847 ## NOTE: some platforms only need one '\' to escape '"' in string constant
1848 define(AC_SHIFT_OFFSET,[
1849 AC_CACHE_CHECK(shift offset of $1, $2,
1850 [LIBS1="$LIBS"; LIBS="" # avoid libwrap allow_severity undefined
1851 conftestoffset="conftestoffset.out"
1856 #include <termios.h>
1859 unsigned int i,n=$1;
1861 if ((f=fopen("$conftestoffset","w"))==NULL){
1862 fprintf(stderr,"\\"$conftestoffset\\": %s\n",strerror(errno)); exit(-1);
1864 if (n==0) {fprintf(stderr,"$1 is 0 (impossible!)\n"); exit(1);}
1865 i=0; while (!(n&1)) {
1868 fprintf(f, "%u", i);
1870 fprintf(f, "-1"); /* anticipate result of xioinitialize assert */
1875 [$2=`cat $conftestoffset`],
1880 AC_DEFINE_UNQUOTED($1_SHIFT, ${$2})
1881 if test "$2" = -1; then
1882 AC_MSG_WARN(please determine $1_SHIFT manually)
1886 AC_SHIFT_OFFSET(CRDLY, sc_cv_sys_crdly_shift)
1887 AC_SHIFT_OFFSET(TABDLY, sc_cv_sys_tabdly_shift)
1888 AC_SHIFT_OFFSET(CSIZE, sc_cv_sys_csize_shift)
1891 dnl Find what physical type (basic C type) is equivalent to the given type.
1892 dnl If possible we try to compile simple test code and get no warning only with
1893 dnl the matching type.
1894 dnl If this method does not seem to work we run test programs that print the
1895 dnl length and signedness of the type.
1897 dnl do we have a -Werror option?
1898 dnl Does the test code compile with -Werror when types fit?
1899 CHANCE_TO_TYPECHECK=1
1900 CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN $(echo "$CFLAGS1" | sed -e 's@-Wall@@g')"
1901 AC_TRY_COMPILE([#include <stdlib.h>],[int u; int v; exit(&u==&v);],,CHANCE_TO_TYPECHECK=0)
1904 dnl Does the test code compile without -Werror when types do not fit?
1905 if test "$CHANCE_TO_TYPECHECK" -ne 0; then
1906 AC_TRY_COMPILE([#include <stdlib.h>],[int u; unsigned int v; exit(&u==&v);],,CHANCE_TO_TYPECHECK=0)
1909 dnl Does the test code fail to compile with -Werror when types do not fit?
1910 if test "$CHANCE_TO_TYPECHECK" -ne 0; then
1911 CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN $(echo "$CFLAGS1" | sed -e 's@-Wall@@g')"
1912 AC_TRY_COMPILE([#include <stdlib.h>],[int u; unsigned int v; exit(&u==&v);],CHANCE_TO_TYPECHECK=0,)
1916 if test "$CHANCE_TO_TYPECHECK" -ne 0; then
1917 AC_MSG_NOTICE(using compile -Werror method to find basic types)
1919 AC_MSG_NOTICE(using code run method to find basic types)
1923 dnl see AC_BASIC_TYPE
1924 define(AC_BASIC_TYPE_GCC,[
1925 AC_CACHE_CHECK(for equivalent simple type of $2, $4,
1926 [CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN $(echo "$CFLAGS1" | sed -e 's@-Wall@@g')"
1927 dnl echo "echo: trying short for $2" >&2
1928 AC_TRY_COMPILE([$1],[$2 u; short v; return(&u==&v);],
1929 [$4="1 /* short */"],
1930 [AC_TRY_COMPILE([$1],[$2 u; unsigned short v; return(&u==&v);],
1931 [$4="2 /* unsigned short */"],
1932 [AC_TRY_COMPILE([$1],[$2 u; int v; return(&u==&v);],
1934 [AC_TRY_COMPILE([$1],[$2 u; unsigned int v; return(&u==&v);],
1935 [$4="4 /* unsigned int */"],
1936 [AC_TRY_COMPILE([$1],[$2 u; long v; return(&u==&v);],
1937 [$4="5 /* long */"],
1938 [AC_TRY_COMPILE([$1],[$2 u; unsigned long v; return(&u==&v);],
1939 [$4="6 /* unsigned long */"],
1940 [AC_TRY_COMPILE([$1],[$2 u; long long v; return(&u==&v);],
1941 [$4="7 /* long long */"],
1942 [AC_TRY_COMPILE([$1],[$2 u; unsigned long long v; return(&u==&v);],
1943 [$4="8 /* unsigned long long */"],
1944 [$4="0 /* unknown, taking default */"
1945 ]) ]) ]) ]) ]) ]) ]) ])
1946 CFLAGS="$CFLAGS1" ])
1947 AC_DEFINE_UNQUOTED($3, ${$4})
1950 dnl see AC_BASIC_TYPE
1951 define(AC_BASIC_TYPE_OTHER,[
1952 AC_CACHE_CHECK(for equivalent simple type of $2, $4,
1955 int main() { return!(sizeof($2)==sizeof(short));}],
1956 # same length as short
1959 int main() { $2 x=-1; return !(x<0);}],
1960 [$4="1 /* short */"],
1961 [$4="2 /* unsigned short */"]),
1962 # length differs from short, try others
1965 int main() { return!(sizeof($2)==sizeof(int));}],
1966 # same length as int
1969 int main() { $2 x=-1; return !(x<0);}],
1971 [$4="4 /* unsigned int */"]),
1972 # length differs from int, try others
1975 int main() { return !(sizeof($2)==sizeof(long));}],
1976 # same length as long
1979 int main() { $2 x=-1; return !(x<0);}],
1980 [$4="5 /* long */"],
1981 [$4="6 /* unsigned long */"] ),
1982 # length differs from long, try others
1985 int main() { return !(sizeof($2)==sizeof(long long));}],
1986 # same length as long long
1989 int main() { $2 x=-1; return !(x<0);}],
1990 [$4="7 /* long long */"],
1991 [$4="8 /* unsigned long long */"] ),
1992 [$4="0 /* unknown */"]
1998 AC_DEFINE_UNQUOTED($3, ${$4})
2001 dnl find what physical type (basic C type) is equivalent to the given type.
2002 dnl arg1: include file(s)
2004 dnl arg3: output variable
2005 dnl arg4: cache variable (might be constructed automatically)
2006 dnl output values: 1..short, 2..unsigned short, 3..int, 4..u-int,
2007 dnl 5..long, 6..u-long; others not yet supported
2008 define(AC_BASIC_TYPE,[
2009 if test "$CHANCE_TO_TYPECHECK" -ne 0; then
2010 AC_BASIC_TYPE_GCC([$1],[$2],[$3],[$4])
2012 AC_BASIC_TYPE_OTHER([$1],[$2],[$3],[$4])
2017 dnl See AC_TYPEOF_COMPONENT
2018 dnl This version is for compilers with -Werror or so: gcc, clang, Sun Studio?
2019 define(AC_TYPEOF_COMPONENT_GCC,[
2020 AC_CACHE_CHECK(for basic type of $2.$3, $5,
2021 [CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN $(echo "$CFLAGS1" | sed -e 's@-Wall@@g')"
2022 AC_TRY_COMPILE([$1],[$2 u;short v; return(&u.$3==&v);],
2023 [$5="1 /* short */"],
2024 [AC_TRY_COMPILE([$1],[$2 u; unsigned short v; return(&u.$3==&v);],
2025 [$5="2 /* unsigned short */"],
2026 [AC_TRY_COMPILE([$1],[$2 u; int v; return(&u.$3==&v);],
2028 [AC_TRY_COMPILE([$1],[$2 u; unsigned int v; return(&u.$3==&v);],
2029 [$5="4 /* unsigned int */"],
2030 [AC_TRY_COMPILE([$1],[$2 u; long v; return(&u.$3==&v);],
2031 [$5="5 /* long */"],
2032 [AC_TRY_COMPILE([$1],[$2 u; unsigned long v; return(&u.$3==&v);],
2033 [$5="6 /* unsigned long */"],
2034 [AC_TRY_COMPILE([$1],[$2 u; long long v; return(&u.$3==&v);],
2035 [$5="7 /* long long */"],
2036 [AC_TRY_COMPILE([$1],[$2 u; unsigned long long v; return(&u.$3==&v);],
2037 [$5="8 /* unsigned long long */"],
2038 [$5="0 /* unknown, taking default */"
2039 ]) ]) ]) ]) ]) ]) ]) ])
2040 CFLAGS="$CFLAGS1" ])
2041 AC_DEFINE_UNQUOTED($4, ${$5})
2044 dnl See AC_TYPEOF_COMPONENT
2045 dnl This version is for compilers with no -Werror or so
2046 define(AC_TYPEOF_COMPONENT_OTHER,[
2047 AC_CACHE_CHECK(for basic type of $2.$3, $5,
2050 int main() { $2 x; return!(sizeof(x.$3)==sizeof(short));}],
2051 # same length as short
2054 int main() { $2 x; x.$3=-1; return !(x.$3<0);}],
2055 [$5="1 /* short */"],
2056 [$5="2 /* unsigned short */"]),
2057 # length differs from short, try others
2060 int main() { $2 x; return!(sizeof(x.$3)==sizeof(int));}],
2061 # same length as int
2064 int main() { $2 x; x.$3=-1; return !(x.$3<0);}],
2066 [$5="4 /* unsigned int */"]),
2067 # length differs from int, try others
2070 int main() { $2 x; return !(sizeof(x.$3)==sizeof(long));}],
2071 # same length as long
2074 int main() { $2 x; x.$3=-1; return !(x.$3<0);}],
2075 [$5="5 /* long */"],
2076 [$5="6 /* unsigned long */"] ),
2077 # length differs from long, try others
2080 int main() { $2 x; return !(sizeof(x.$3)==sizeof(long long));}],
2081 # same length as long long
2084 int main() { x $2; x.$3=-1; return !(x.$3<0);}],
2085 [$5="7 /* long long */"],
2086 [$5="8 /* unsigned long long */"] ),
2087 [$5="0 /* unknown */"]
2093 AC_DEFINE_UNQUOTED($4, ${$5})
2096 dnl find what physical type (basic C type) describes the given struct or union
2098 dnl arg1: include file(s); must declare the structure type
2099 dnl arg2: struct name (e.g., "struct stat")
2100 dnl arg3: variable or component (e.g., "st_ino")
2101 dnl arg4: output variable, values see AC_BASIC_TYPE
2102 dnl arg5: cache variable (might be constructed automatically)
2103 define(AC_TYPEOF_COMPONENT,[
2104 if test "$CHANCE_TO_TYPECHECK" -ne 0; then
2105 AC_TYPEOF_COMPONENT_GCC([$1],[$2],[$3],[$4],[$5])
2107 AC_TYPEOF_COMPONENT_OTHER([$1],[$2],[$3],[$4],[$5])
2111 AC_BASIC_TYPE([#include <stdint.h>], uint16_t, HAVE_BASIC_UINT16_T, sc_cv_type_uint16_basic)
2112 AC_BASIC_TYPE([#include <stdint.h>], uint32_t, HAVE_BASIC_UINT32_T, sc_cv_type_uint32_basic)
2113 AC_BASIC_TYPE([#include <stdint.h>], uint64_t, HAVE_BASIC_UINT64_T, sc_cv_type_uint64_basic)
2114 AC_BASIC_TYPE([#include <stdint.h>], int16_t, HAVE_BASIC_INT16_T, sc_cv_type_int16_basic)
2115 AC_BASIC_TYPE([#include <stdint.h>], int32_t, HAVE_BASIC_INT32_T, sc_cv_type_int32_basic)
2116 AC_BASIC_TYPE([#include <stdint.h>], int64_t, HAVE_BASIC_INT64_T, sc_cv_type_int64_basic)
2117 AC_BASIC_TYPE([#include <stdlib.h>], size_t, HAVE_BASIC_SIZE_T, sc_cv_type_sizet_basic)
2118 AC_BASIC_TYPE([#include <sys/types.h>
2119 #include <sys/stat.h>
2120 #include <unistd.h>], mode_t, HAVE_BASIC_MODE_T, sc_cv_type_modet_basic)
2121 AC_BASIC_TYPE([#include <sys/types.h>
2122 #include <unistd.h>], pid_t, HAVE_BASIC_PID_T, sc_cv_type_pidt_basic)
2123 AC_BASIC_TYPE([#include <sys/types.h>
2124 #include <unistd.h>], uid_t, HAVE_BASIC_UID_T, sc_cv_type_uidt_basic)
2125 AC_BASIC_TYPE([#include <sys/types.h>
2126 #include <unistd.h>], gid_t, HAVE_BASIC_GID_T, sc_cv_type_gidt_basic)
2128 AC_BASIC_TYPE([#include <time.h>], time_t, HAVE_BASIC_TIME_T,
2129 sc_cv_type_timet_basic)
2131 # this is questionable, might fail on some systems
2132 AC_BASIC_TYPE([#include <sys/types.h>
2133 #include <sys/socket.h>
2134 #include <unistd.h>], socklen_t, HAVE_BASIC_SOCKLEN_T,
2135 sc_cv_type_socklent_basic)
2137 AC_BASIC_TYPE([#include <sys/types.h>
2138 #include <unistd.h>], off_t, HAVE_BASIC_OFF_T, sc_cv_type_off_basic)
2140 AC_BASIC_TYPE([#include <sys/types.h>
2141 #include <unistd.h>], off64_t, HAVE_BASIC_OFF64_T, sc_cv_type_off64_basic)
2143 # oh god, __dev_t in Linux 2.4 is struct{int[2];}, not handled here yet.
2144 AC_BASIC_TYPE([#include <sys/stat.h>], dev_t, HAVE_BASIC_DEV_T, sc_cv_type_dev_basic)
2146 AC_BASIC_TYPE([#include <unistd.h>
2147 #include <termios.h>], speed_t, HAVE_BASIC_SPEED_T, sc_cv_type_spee_t)
2149 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_ino, HAVE_TYPEOF_ST_INO, sc_cv_type_stat_stino_basic)
2150 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_nlink, HAVE_TYPEOF_ST_NLINK, sc_cv_type_stat_stnlink_basic)
2151 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_size, HAVE_TYPEOF_ST_SIZE, sc_cv_type_stat_stsize_basic)
2152 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_blksize, HAVE_TYPEOF_ST_BLKSIZE, sc_cv_type_stat_stblksize_basic)
2153 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat, st_blocks, HAVE_TYPEOF_ST_BLOCKS, sc_cv_type_stat_stblocks_basic)
2155 if test "$ac_cv_func_stat64" = yes; then
2156 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat64, st_dev, HAVE_TYPEOF_ST64_DEV, sc_cv_type_stat64_stdev_basic)
2157 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat64, st_ino, HAVE_TYPEOF_ST64_INO, sc_cv_type_stat64_stino_basic)
2158 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat64, st_nlink, HAVE_TYPEOF_ST64_NLINK, sc_cv_type_stat64_stnlink_basic)
2159 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat64, st_size, HAVE_TYPEOF_ST64_SIZE, sc_cv_type_stat64_stsize_basic)
2160 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat64, st_blksize, HAVE_TYPEOF_ST64_BLKSIZE, sc_cv_type_stat64_stblksize_basic)
2161 AC_TYPEOF_COMPONENT([#include <sys/stat.h>], struct stat64, st_blocks, HAVE_TYPEOF_ST64_BLOCKS, sc_cv_type_stat64_stblocks_basic)
2164 AC_TYPEOF_COMPONENT([#include <sys/time.h>], struct timeval, tv_usec, HAVE_TYPEOF_STRUCT_TIMEVAL_TV_USEC, sc_cv_type_struct_timeval_tv_usec)
2166 AC_TYPEOF_COMPONENT([#include <sys/time.h>], struct timespec, tv_nsec, HAVE_TYPEOF_STRUCT_TIMESPEC_TV_NSEC, sc_cv_type_struct_timespec_tv_nsec)
2168 AC_TYPEOF_COMPONENT([#include <sys/types.h>
2169 #include <sys/time.h>
2170 #include <sys/resource.h>],
2171 struct rlimit, rlim_max, HAVE_TYPEOF_RLIM_MAX, sc_cv_type_rlimit_rlimmax_basic)
2173 # Fedora-19 doc says it is socklen_t which is equivalent to unsigned int, but it is equivalent to size_t (x86_64)
2174 AC_TYPEOF_COMPONENT([#include "sysincludes.h"], struct cmsghdr, cmsg_len, HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN, sc_cv_typeof_struct_cmsghdr_cmsg_len)
2175 ### snprintf, vsnprintf
2177 AC_MSG_CHECKING(for /dev/ptmx)
2178 if test -c /dev/ptmx; then
2179 AC_DEFINE(HAVE_DEV_PTMX, 1)
2183 AC_MSG_CHECKING(for /dev/ptc)
2184 if test -c /dev/ptc; then
2185 AC_DEFINE(HAVE_DEV_PTC)
2192 AC_MSG_CHECKING(for /proc)
2193 if test -d /proc; then
2194 AC_DEFINE(HAVE_PROC_DIR, 1)
2200 AC_MSG_CHECKING(for /proc/*/fd)
2201 if test -d /proc/$$/fd; then
2202 AC_DEFINE(HAVE_PROC_DIR_FD, 1)
2208 # On Solaris family, we have to use /proc/$$/path/N
2209 AC_MSG_CHECKING(for /proc/*/path)
2210 if test -d /proc/$$/path; then
2211 AC_DEFINE(HAVE_PROC_DIR_PATH, 1)
2217 # On Solaris family there is not dirent.d_type
2218 AC_MSG_CHECKING(for d_type in struct dirent)
2219 AC_CACHE_VAL(sc_cv_dirent_d_type,
2220 [AC_TRY_COMPILE([#include <dirent.h>],[struct dirent d; d.d_type],
2221 [sc_cv_dirent_d_type=yes],
2222 [sc_cv_dirent_d_type=no])])
2223 if test $sc_cv_dirent_d_type = yes; then
2224 AC_DEFINE(HAVE_DIRENT_D_TYPE)
2226 AC_MSG_RESULT($sc_cv_dirent_d_type)
2228 # Some OSes have undocumented _res.retrans, _res.retry components
2229 AC_MSG_CHECKING(for _res.retrans)
2230 AC_TRY_COMPILE([#include <resolv.h>],
2231 [_res.retrans == 0],
2232 [AC_MSG_RESULT(yes);
2233 AC_DEFINE(HAVE_RES_RETRANS, 1)],
2234 [AC_MSG_RESULT(no)])
2235 AC_MSG_CHECKING(for _res.retry)
2236 AC_TRY_COMPILE([#include <resolv.h>],
2238 [AC_MSG_RESULT(yes);
2239 AC_DEFINE(HAVE_RES_RETRY, 1)],
2240 [AC_MSG_RESULT(no)])
2241 AC_MSG_CHECKING(for _res.nsaddr_list)
2242 AC_TRY_COMPILE([#include <resolv.h>],
2243 [_res.nsaddr_list[0].sin_family == 0],
2244 [AC_MSG_RESULT(yes);
2245 AC_DEFINE(HAVE_RES_NSADDR_LIST, 1)],
2246 [AC_MSG_RESULT(no)])
2249 dnl "tcpd" "tcpwrappers"
2250 # on some platforms, raw linking with libwrap fails because allow_severity and
2251 # deny_severity are not explicitely defined. Thus we put the libwrap part to
2253 AC_MSG_CHECKING(whether to include libwrap support)
2254 AC_ARG_ENABLE(libwrap, [ --disable-libwrap disable libwrap support],
2255 [ case "$enableval" in
2256 no) AC_MSG_RESULT(no); WITH_LIBWRAP= ;;
2257 *) AC_MSG_RESULT(yes); WITH_LIBWRAP=1 ;;
2259 [ AC_MSG_RESULT(yes); WITH_LIBWRAP=1 ])
2261 # check if we find the components of libwrap ("tcpd" "tcpwrappers")
2262 if test -n "$WITH_LIBWRAP"; then
2263 AC_MSG_CHECKING(for components of libwrap)
2264 # first, we need to find the include file <tcpd.h>
2265 AC_CACHE_VAL(sc_cv_have_tcpd_h,
2266 [AC_TRY_COMPILE([#include <sys/types.h>
2267 #include <tcpd.h>],[;],
2268 [sc_cv_have_tcpd_h=yes; LIBWRAP_ROOT=""],
2269 [sc_cv_have_tcpd_h=no
2270 for D in "/sw" "/usr/local" "/opt/freeware" "/usr/sfw"; do
2273 if test -r "$i"; then
2274 #V_INCL="$V_INCL -I$I"
2275 CPPFLAGS="$CPPFLAGS -I$I"
2276 AC_MSG_NOTICE(found $i)
2277 sc_cv_have_tcpd_h=yes; LIBWRAP_ROOT="$D"
2282 if test "$sc_cv_have_tcpd_h" = "yes"; then
2283 AC_DEFINE(HAVE_TCPD_H)
2285 AC_MSG_NOTICE(checked for tcpd.h... $sc_cv_have_tcpd_h)
2286 fi # end checking for tcpd.h
2287 if test -n "$WITH_LIBWRAP" -a "$sc_cv_have_tcpd_h" = yes; then
2288 # next, we search for the wrap library (libwrap.*)
2289 AC_MSG_CHECKING(for libwrap)
2290 AC_CACHE_VAL(sc_cv_have_libwrap,
2292 if test -n "$LIBWRAP_ROOT"; then
2293 L="$LIBWRAP_ROOT/lib"; LIBS="-L$L -lwrap $LIBS"
2297 AC_TRY_LINK([#include <sys/types.h>
2299 int allow_severity,deny_severity;],[hosts_access(0)],
2300 [sc_cv_have_libwrap='yes'],
2301 [sc_cv_have_libwrap='no'
2302 LIBS="$LIBS -lnsl" # RedHat73
2303 AC_TRY_LINK([#include <sys/types.h>
2305 int allow_severity,deny_severity;],[hosts_access(0)],
2306 [sc_cv_have_libwrap='yes'],
2307 [sc_cv_have_libwrap='no'])
2310 if test "$sc_cv_have_libwrap" != 'yes'; then
2315 if test "$sc_cv_have_libwrap" = 'yes'; then
2316 AC_DEFINE(HAVE_LIBWRAP)
2318 AC_MSG_RESULT($sc_cv_have_libwrap)
2321 if test -n "$WITH_LIBWRAP"; then
2322 if test "$sc_cv_have_tcpd_h" = "yes" -a "$sc_cv_have_libwrap" = "yes"; then
2323 AC_DEFINE(WITH_LIBWRAP)
2325 AC_MSG_WARN([not all components of tcp wrappers found, disabling it]);
2329 # check of hosts_allow_table
2330 if test -n "$WITH_LIBWRAP"; then
2331 AC_MSG_CHECKING(for hosts_allow_table)
2332 AC_CACHE_VAL(sc_cv_have_hosts_allow_table,
2333 [AC_TRY_COMPILE([#include <sys/types.h>
2334 #include <tcpd.h>],[hosts_allow_table="";],
2335 [sc_cv_have_hosts_allow_table=yes],
2336 [sc_cv_have_hosts_allow_table=no])])
2337 if test $sc_cv_have_hosts_allow_table = yes; then
2338 AC_DEFINE(HAVE_HOSTS_ALLOW_TABLE)
2340 AC_MSG_RESULT($sc_cv_have_hosts_allow_table)
2341 fi # test -n "$WITH_LIBWRAP"
2344 if test "$GCC" = yes; then
2348 # FIPS support requires compiling with fipsld.
2349 # fipsld requires the FIPSLD_CC variable to be set to the original CC.
2350 # This check must be done after all other checks that require compiling
2351 # so that fipsld is not used by the configure script itself.
2352 if test -n "$WITH_FIPS"; then
2353 if test "$sc_cv_have_openssl_fips_h" = 'yes' -a "$sc_cv_have_libcrypto" = 'yes'; then
2355 if test "${FIPSLD+set}" != set ; then
2358 CC="FIPSLD_CC=$CC $FIPSLD"
2363 # autoconf does not seem to provide AC_CHECK_VAR or so
2364 # thus we have to check by foot
2365 AC_MSG_CHECKING(for declaration of environ)
2366 AC_CACHE_VAL(sc_cv_decl_environ,
2367 [AC_TRY_COMPILE([#include <unistd.h>],[char **s = environ;],
2368 [sc_cv_decl_environ=yes],
2369 [sc_cv_decl_environ=no])])
2370 if test $sc_cv_decl_environ = yes; then
2371 AC_DEFINE(HAVE_DECL_ENVIRON)
2373 AC_MSG_RESULT($sc_cv_decl_environ)
2375 # on some systems environ exists but not the declaration
2376 AC_MSG_CHECKING(for var environ)
2377 AC_CACHE_VAL(sc_cv_var_environ,
2378 [AC_TRY_COMPILE([],[extern char **environ; char **s = environ;],
2379 [sc_cv_var_environ=yes],
2380 [sc_cv_var_environ=no])])
2381 if test $sc_cv_var_environ = yes; then
2382 AC_DEFINE(HAVE_VAR_ENVIRON)
2384 AC_MSG_RESULT($sc_cv_var_environ)
2386 # allow BUILD_DATE to be externally set for build reproducibility
2387 if test "$SOURCE_DATE_EPOCH"; then
2388 DATE_FMT="%d %b %Y %H:%M:%S"
2389 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT")
2390 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
2391 elif test "$BUILD_DATE"; then
2392 AC_DEFINE_UNQUOTED(BUILD_DATE, ["$BUILD_DATE"])
2394 AC_DEFINE(BUILD_DATE, [__DATE__" "__TIME__])