-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
176 lines (152 loc) · 5.89 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
AC_INIT([Haskell network package], [2.3.0.11], [[email protected]], [network])
ac_includes_default="$ac_includes_default
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
#endif
#ifdef HAVE_WS2TCPIP_H
# include <ws2tcpip.h>
// fix for MingW not defining IPV6_V6ONLY
# define IPV6_V6ONLY 27
#endif
#ifdef HAVE_WSPIAPI_H
# include <wspiapi.h>
#endif"
# Safety check: Ensure that we are in the correct source directory.
AC_CONFIG_SRCDIR([include/HsNet.h])
AC_CONFIG_HEADERS([include/HsNetworkConfig.h])
AC_CANONICAL_HOST
AC_ARG_WITH([cc],
[C compiler],
[CC=$withval])
AC_PROG_CC()
AC_C_CONST
dnl ** check for specific header (.h) files that we are interested in
AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h sys/types.h unistd.h winsock2.h ws2tcpip.h wspiapi.h])
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h netinet/tcp.h sys/socket.h sys/uio.h sys/un.h])
AC_CHECK_FUNCS([readlink symlink])
dnl ** check what fields struct msghdr contains
AC_CHECK_MEMBERS([struct msghdr.msg_control, struct msghdr.msg_accrights], [], [], [#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#if HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif])
dnl ** check if struct sockaddr contains sa_len
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif])
dnl --------------------------------------------------
dnl * test for in_addr_t
dnl --------------------------------------------------
AC_MSG_CHECKING(for in_addr_t in netinet/in.h)
AC_EGREP_HEADER(in_addr_t, netinet/in.h,
[ AC_DEFINE([HAVE_IN_ADDR_T], [1], [Define to 1 if in_addr_t is available.]) AC_MSG_RESULT(yes) ],
AC_MSG_RESULT(no))
dnl --------------------------------------------------
dnl * test for SO_PEERCRED and struct ucred
dnl --------------------------------------------------
AC_MSG_CHECKING(for SO_PEERCRED and struct ucred in sys/socket.h)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/socket.h>
#ifndef SO_PEERCRED
# error no SO_PEERCRED
#endif
struct ucred u;]])],ac_cv_ucred=yes,ac_cv_ucred=no)
if test "x$ac_cv_ucred" = xno; then
old_CFLAGS="$CFLAGS"
CFLAGS="-D_GNU_SOURCE $CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/socket.h>
#ifndef SO_PEERCRED
# error no SO_PEERCRED
#endif
struct ucred u;]])],ac_cv_ucred=yes,ac_cv_ucred=no)
if test "x$ac_cv_ucred" = xyes; then
EXTRA_CPPFLAGS=-D_GNU_SOURCE
fi
else
old_CFLAGS="$CFLAGS"
fi
if test "x$ac_cv_ucred" = xno; then
CFLAGS="$old_CFLAGS"
AC_MSG_RESULT(no)
else
AC_DEFINE([HAVE_STRUCT_UCRED], [1], [Define to 1 if you have both SO_PEERCRED and struct ucred.])
AC_MSG_RESULT(yes)
fi
dnl --------------------------------------------------
dnl * check for Windows networking libraries
dnl --------------------------------------------------
AC_CHECK_LIB(ws2_32, _head_libws2_32_a)
dnl --------------------------------------------------
dnl * test for getaddrinfo as proxy for IPv6 support
dnl --------------------------------------------------
AC_MSG_CHECKING(for getaddrinfo)
dnl Can't use AC_CHECK_FUNC here, because it doesn't do the right
dnl thing on Windows.
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default
int testme(){ getaddrinfo; }]])],[AC_DEFINE([HAVE_GETADDRINFO], [1], [Define to 1 if you have the `getaddrinfo' function.]) ac_have_getaddrinfo=yes; AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
dnl Under mingw, we may need to set WINVER to 0x0501 to expose getaddrinfo.
if test "x$ac_have_getaddrinfo" = x; then
old_CFLAGS="$CFLAGS"
if test "z$ac_cv_lib_ws2_32__head_libws2_32_a" = zyes; then
CFLAGS="-DWINVER=0x0501 $CFLAGS"
AC_MSG_CHECKING(for getaddrinfo if WINVER is 0x0501)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$ac_includes_default
int testme(){ getaddrinfo; }]])],[AC_DEFINE([HAVE_GETADDRINFO], [1], [Define to 1 if you have the `getaddrinfo' function.]) AC_DEFINE([NEED_WINVER_XP], [1], [Define to 1 if the `getaddrinfo' function needs WINVER set.]) EXTRA_CPPFLAGS="-DWINVER=0x0501 $EXTRA_CPPFLAGS"; AC_MSG_RESULT(yes)],[CFLAGS="$old_CFLAGS"; AC_MSG_RESULT(no)])
fi
fi
dnl Missing under mingw, sigh.
AC_CHECK_FUNCS(gai_strerror)
dnl -------------------------------------------------------
dnl * test for AI_* flags that not all implementations have
dnl -------------------------------------------------------
AC_CHECK_DECLS([AI_ADDRCONFIG, AI_ALL, AI_NUMERICSERV, AI_V4MAPPED])
dnl -------------------------------------------------------
dnl * test for IPV6_V6ONLY flags that not all implementations have
dnl -------------------------------------------------------
AC_CHECK_DECLS([IPV6_V6ONLY])
dnl --------------------------------------------------
dnl * test for Linux sendfile(2)
dnl --------------------------------------------------
AC_MSG_CHECKING(for sendfile in sys/sendfile.h)
AC_EGREP_HEADER(sendfile, sys/sendfile.h,
[ AC_DEFINE([HAVE_LINUX_SENDFILE], [1], [Define to 1 if you have a Linux sendfile(2) implementation.]) AC_MSG_RESULT(yes) ],
AC_MSG_RESULT(no))
dnl --------------------------------------------------
dnl * test for BSD sendfile(2)
dnl --------------------------------------------------
AC_MSG_CHECKING(for sendfile in sys/socket.h)
AC_EGREP_HEADER(sendfile, sys/socket.h,
[ AC_DEFINE([HAVE_BSD_SENDFILE], [1], [Define to 1 if you have a BSDish sendfile(2) implementation.]) AC_MSG_RESULT(yes) ],
AC_MSG_RESULT(no))
AC_CHECK_FUNCS(gethostent)
case "$host" in
*-mingw32)
EXTRA_SRCS="cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c"
EXTRA_LIBS=ws2_32
CALLCONV=stdcall ;;
*-solaris2*)
EXTRA_SRCS="cbits/ancilData.c"
EXTRA_LIBS="nsl, socket"
CALLCONV=ccall ;;
*)
EXTRA_SRCS="cbits/ancilData.c"
EXTRA_LIBS=
CALLCONV=ccall ;;
esac
AC_SUBST([CALLCONV])
AC_SUBST([EXTRA_CPPFLAGS])
AC_SUBST([EXTRA_LIBS])
AC_SUBST([EXTRA_SRCS])
AC_CONFIG_FILES([network.buildinfo])
AC_OUTPUT