]> sjero.net Git - iperf/blob - configure.ac
Timer Utilities
[iperf] / configure.ac
1 dnl ===================================================================
2 dnl configure.ac
3 dnl Process this file with autogen.sh to produce configure files
4 dnl ===================================================================
5
6
7 AC_PREREQ(2.59)
8 AC_INIT(Iperf,2.0.2)
9 AC_CONFIG_HEADER([config.h])
10 AM_INIT_AUTOMAKE()
11
12
13 AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--disable-ipv6],
14             [disable ipv6 support (default is autodetect)]), 
15         ac_cv_have_ipv6=$enable_ipv6,)
16
17 AC_ARG_ENABLE(multicast, AC_HELP_STRING([--disable-multicast],
18             [disable multicast support (default is autodetect)]),
19         ac_cv_multicast=$enable_multicast,)
20
21 AC_ARG_ENABLE(threads, AC_HELP_STRING([--disable-threads],
22             [disable thread support (default is autodetect)]))
23
24 AC_ARG_ENABLE(debuginfo, AC_HELP_STRING([--enable-debuginfo],
25             [enable debugging info for sockets (default is no)]),
26         enable_debuginfo=$enableval,
27         enable_debuginfo=no)
28
29 AC_ARG_ENABLE(web100, AC_HELP_STRING([--disable-web100],
30             [disable web100 support (default is autodetect)]))
31
32
33 dnl ===================================================================
34 dnl Checks for programs
35 dnl ===================================================================
36
37 AC_PROG_CXX
38 CXXFLAGS=`echo " $CXXFLAGS " | sed -e "s/ -g / /"` # do not want it implicitly
39 AC_PROG_CC
40 CFLAGS=`echo " $CFLAGS " | sed -e "s/ -g / /"` # do not want it implicitly
41 AC_ISC_POSIX
42 AC_PROG_INSTALL
43 AC_PROG_MAKE_SET
44 AC_PROG_RANLIB
45 AC_LANG(C)
46 AC_CANONICAL_HOST
47
48 dnl ===================================================================
49 dnl Checks for libraries.
50 dnl ===================================================================
51
52 dnl check for -lpthread
53  
54 if test "$enable_threads" != no; then
55   ACX_PTHREAD()
56     if test "$acx_pthread_ok" = yes; then
57       AC_DEFINE([HAVE_POSIX_THREAD], 1,)
58       AC_DEFINE([_REENTRANT], 1,)
59     fi
60 fi
61
62 dnl check for -lnsl, -lsocket
63 AC_CHECK_FUNC(gethostbyname,,AC_CHECK_LIB(nsl, gethostbyname))
64 AC_CHECK_FUNC(socket,,AC_CHECK_LIB(socket, socket))
65
66 dnl Checks for header files.
67 AC_HEADER_STDC
68 AC_CHECK_HEADERS([arpa/inet.h libintl.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h sys/time.h syslog.h unistd.h])
69
70 dnl ===================================================================
71 dnl Checks for typedefs, structures
72 dnl ===================================================================
73
74 AC_C_CONST
75 AC_TYPE_SIZE_T
76 AC_CHECK_TYPES(ssize_t,,AC_DEFINE_UNQUOTED(ssize_t, int))
77 AC_HEADER_TIME
78 AC_STRUCT_TM
79
80 dnl these intXX_t and u_intXX_t need to be defined to be the right size.
81 AX_CREATE_STDINT_H(include/iperf-int.h)
82
83 AC_CACHE_CHECK(3rd argument of accept, ac_cv_accept_arg, [
84   dnl Try socklen_t (POSIX)
85   DAST_ACCEPT_ARG(socklen_t)
86
87   dnl Try int (original BSD)
88   DAST_ACCEPT_ARG(int)
89
90   dnl Try size_t (older standard; AIX)
91   DAST_ACCEPT_ARG(size_t)
92
93   dnl Try short (shouldn't be)
94   DAST_ACCEPT_ARG(short)
95
96   dnl Try long (shouldn't be)
97   DAST_ACCEPT_ARG(long)
98 ])
99
100 if test -z "$ac_cv_accept_arg" ; then
101   ac_cv_accept_arg=int
102 fi
103
104 AC_DEFINE_UNQUOTED([Socklen_t], $ac_cv_accept_arg, [Define 3rd arg of accept])
105
106 dnl Checks for library functions.
107 AC_FUNC_FORK
108 AC_FUNC_MALLOC
109 AC_FUNC_MEMCMP
110 AC_FUNC_SELECT_ARGTYPES
111 AC_TYPE_SIGNAL
112 AC_FUNC_STRFTIME
113 AC_FUNC_VPRINTF
114 AC_CHECK_FUNCS([atexit gettimeofday memset pthread_cancel select strchr strerror strtol usleep])
115 AC_REPLACE_FUNCS(snprintf inet_pton inet_ntop gettimeofday)
116
117 dnl             Gotten from some NetBSD configure.in
118 dnl             We assume that if sprintf() supports %lld or %qd,
119 dnl             then all of *printf() does. If not, disable long long
120 dnl             support because we don't know how to display it.
121
122 AH_TEMPLATE(HAVE_QUAD_SUPPORT)
123 AH_TEMPLATE(HAVE_PRINTF_QD)
124
125 AC_MSG_CHECKING(*printf() support for %lld)
126 can_printf_longlong=no
127 AC_TRY_RUN([
128         #include <stdio.h>
129         int main() {
130                 char buf[100];
131                 sprintf(buf, "%lld", 21726587590LL);
132                 return (strcmp(buf, "21726587590"));
133         }
134         ], [
135         AC_MSG_RESULT(yes)
136         can_printf_longlong=yes
137         ], [
138         AC_MSG_RESULT(no)
139         ], [ : ])
140
141 if test $can_printf_longlong != yes; then
142         AC_MSG_CHECKING(*printf() support for %qd)
143         AC_TRY_RUN([
144                 #include <stdio.h>
145                 int main() {
146                         char buf[100];
147                         sprintf(buf, "%qd", 21726587590LL);
148                         return (strcmp(buf, "21726587590"));
149                 }
150                 ], [
151                 AC_MSG_RESULT(yes)
152                 can_printf_longlong=yes
153                 AC_DEFINE(HAVE_PRINTF_QD, 1)
154                 ], [
155                 AC_MSG_RESULT(no)
156                 ], [ : ])
157 fi
158
159 if test $can_printf_longlong = yes; then
160         AC_DEFINE(HAVE_QUAD_SUPPORT, 1)
161 fi
162
163 dnl ===================================================================
164 dnl Check for compiler characteristics
165
166 DAST_CHECK_BOOL
167
168 AC_C_BIGENDIAN
169
170 dnl ===================================================================
171 dnl Check for system services
172
173 dnl check for multicast
174 if test "$ac_cv_multicast" != no; then
175   AC_CHECK_TYPES(struct ip_mreq,,,[#include "compat/headers_slim.h"])
176   AC_CHECK_DECLS(IP_ADD_MEMBERSHIP,,,[#include "compat/headers_slim.h"])
177   AC_MSG_CHECKING(for multicast support)
178   ac_cv_multicast=no
179   if test "$ac_cv_have_decl_IP_ADD_MEMBERSHIP" = yes; then
180     if test "$ac_cv_type_struct_ip_mreq" = yes; then
181       ac_cv_multicast=yes
182     fi
183   fi
184   AC_MSG_RESULT($ac_cv_multicast)
185   if test "$ac_cv_multicast" = yes; then
186     AC_DEFINE([HAVE_MULTICAST], 1, [Define to enable multicast support])
187   fi
188 fi
189
190 dnl check for IPv6
191 if test "$ac_cv_have_ipv6" != no; then
192   AC_CHECK_TYPES(struct sockaddr_storage,,,[#include "compat/headers_slim.h"])
193   AC_CHECK_TYPES(struct sockaddr_in6,,,[#include "compat/headers_slim.h"])
194   AC_CHECK_DECLS(AF_INET6,,,[#include "compat/headers_slim.h"])
195   AC_MSG_CHECKING(for IPv6 headers and structures)
196   ac_cv_have_ipv6=no
197   if test "$ac_cv_type_struct_sockaddr_storage" = yes; then
198     if test "$ac_cv_type_struct_sockaddr_in6" = yes; then
199       if test "$ac_cv_have_decl_AF_INET6" = yes; then
200         AC_DEFINE([HAVE_IPV6], 1, [Define to enable IPv6 support])
201         ac_cv_have_ipv6=yes
202       fi
203     fi
204   fi
205   AC_MSG_RESULT($ac_cv_have_ipv6)
206 fi
207
208 if test "$ac_cv_have_ipv6" = yes; then
209   if test "$ac_cv_multicast" = yes; then
210     AC_CHECK_TYPES(struct ipv6_mreq,,,[#include "compat/headers_slim.h"])
211     AC_CHECK_DECLS(IPV6_ADD_MEMBERSHIP,,,[#include "compat/headers_slim.h"])
212     AC_CHECK_DECLS(IPV6_MULTICAST_HOPS,,,[#include "compat/headers_slim.h"])
213     AC_MSG_CHECKING(for IPv6 multicast support)
214     ac_cv_have_ipv6_multicast=no
215     if test "$ac_cv_type_struct_ipv6_mreq" = yes; then
216       if test "$ac_cv_have_decl_IPV6_ADD_MEMBERSHIP" = yes; then
217         if test "$ac_cv_have_decl_IPV6_MULTICAST_HOPS" = yes; then
218           AC_DEFINE([HAVE_IPV6_MULTICAST], 1, [Define to enable IPv6 multicast support])
219           ac_cv_have_ipv6_multicast=yes
220         fi
221       fi
222     fi
223     AC_MSG_RESULT($ac_cv_have_ipv6_multicast)
224   fi
225 fi
226
227 if test "$enable_debuginfo" = yes; then
228 AC_DEFINE([DBG_MJZ], 1, [Define if debugging info is desired])
229 fi
230
231 if test "$enable_web100" != no; then
232 if test -e "/proc/web100"; then
233 if test -d "/proc/web100"; then
234 if test -e "/proc/web100/header"; then
235 if test -f "/proc/web100/header"; then
236 if test -r "/proc/web100/header"; then
237 AM_PATH_WEB100()
238 if test "$web100_success" = yes; then 
239 AC_DEFINE([HAVE_WEB100], 1, [Define if Web100 is desired and available])
240 fi fi fi fi fi fi
241 fi
242
243 dnl GNU make allows us to use the $(strip ...) builtin which eliminates a
244 dnl large amount of extra whitespace in compile lines.
245 AC_MSG_CHECKING(whether make is GNU make)
246 STRIP_BEGIN=
247 STRIP_END=
248 if $ac_make --version 2> /dev/null | grep '^GNU Make ' > /dev/null ; then
249     STRIP_BEGIN='$(strip $(STRIP_DUMMY)'
250     STRIP_END=')'
251     AC_MSG_RESULT(yes)
252 else
253     AC_MSG_RESULT(no)
254 fi
255
256 dnl some Make 3.79 $(strip ) versions are broken and require an empty arg
257 STRIP_DUMMY=
258 AC_SUBST(STRIP_DUMMY)
259 AC_SUBST(STRIP_BEGIN)
260 AC_SUBST(STRIP_END)
261
262 AC_CONFIG_FILES([Makefile
263                 compat/Makefile
264                 doc/Makefile
265                 include/Makefile
266                 src/Makefile])
267 AC_OUTPUT