dnl AUTOCONF configuration for Rawsock
dnl Sam Steingold 2004-2011

AC_PREREQ([2.64])
AC_INIT(rawsock, 1.0, clisp-list)
AC_CONFIG_SRCDIR(sock.lisp)
AC_CONFIG_HEADERS(config.h)

RSE_BOLD
BOLD_MSG([Rawsock (Common)])
CL_MODULE_COMMON_CHECKS()

BOLD_MSG([Rawsock (Headers)])
CL_TCPCONN
AC_CHECK_HEADERS([linux/if_packet.h netdb.h \
asm/types.h sys/ioctl.h stropts.h poll.h sys/un.h ifaddrs.h])
AC_CHECK_HEADERS([net/if.h],[],[],[
#include <sys/types.h> /* for u_long on *BSD */
#include <sys/socket.h>
])
AC_CHECK_HEADERS([netinet/if_ether.h],[],[],[
#include <sys/types.h> /* for u_long on *BSD */
#include <sys/socket.h>
#if HAVE_NET_IF_H
# include <net/if.h>
#endif
])
AC_CHECK_HEADERS([linux/netlink.h],[],[],[
#if defined(HAVE_ASM_TYPES_H)
# include <asm/types.h>
#endif
])
dnl gnulib sys/socket.h defines msghdr with msg_flags but WITHOUT msg_control
AC_CHECK_MEMBERS([struct msghdr.msg_flags, struct msghdr.msg_control],,,
[#include <sys/socket.h>])
AC_CHECK_TYPES(struct if_nameindex,,,[
#if HAVE_NET_IF_H
# include <net/if.h>
#endif
])

BOLD_MSG([Rawsock (Functions)])
cl_save_LIBS=$LIBS
LIBS="$LIBS $LIBSOCKET"
AC_CHECK_FUNCS(socketpair sockatmark recvmsg sendmsg htonl htons ntohl ntohs dnl
readv writev getnameinfo getaddrinfo freeaddrinfo gai_strerror dnl
endprotoent getprotobyname getprotobynumber getprotoent setprotoent dnl
if_nametoindex if_indextoname if_nameindex if_freenameindex dnl
endnetent getnetbyaddr getnetbyname getnetent setnetent getifaddrs freeifaddrs)
LIBS=$cl_save_LIBS

BOLD_MSG([Rawsock (Output)])
AC_CONFIG_FILES(Makefile link.sh)
AC_OUTPUT

BOLD_MSG([Rawsock (Done)])
