xref: /iperf/configure.ac (revision 9eef1603)
1# iperf, Copyright (c) 2014-2022, The Regents of the University of
2# California, through Lawrence Berkeley National Laboratory (subject
3# to receipt of any required approvals from the U.S. Dept. of
4# Energy).  All rights reserved.
5#
6# If you have questions about your rights to use or distribute this
7# software, please contact Berkeley Lab's Technology Transfer
8# Department at [email protected].
9#
10# NOTICE.  This software is owned by the U.S. Department of Energy.
11# As such, the U.S. Government has been granted for itself and others
12# acting on its behalf a paid-up, nonexclusive, irrevocable,
13# worldwide license in the Software to reproduce, prepare derivative
14# works, and perform publicly and display publicly.  Beginning five
15# (5) years after the date permission to assert copyright is obtained
16# from the U.S. Department of Energy, and subject to any subsequent
17# five (5) year renewals, the U.S. Government is granted for itself
18# and others acting on its behalf a paid-up, nonexclusive,
19# irrevocable, worldwide license in the Software to reproduce,
20# prepare derivative works, distribute copies to the public, perform
21# publicly and display publicly, and to permit others to do so.
22#
23# This code is distributed under a BSD style license, see the LICENSE
24# file for complete information.
25
26# Initialize the autoconf system for the specified tool, version and mailing list
27AC_PREREQ([2.71])
28AC_INIT([iperf],[3.11],[https://github.com/esnet/iperf],[iperf],[https://software.es.net/iperf/])
29m4_include([config/ax_check_openssl.m4])
30m4_include([config/iperf_config_static_bin.m4])
31AC_LANG(C)
32
33# Specify where the auxiliary files created by configure should go. The config
34# directory is picked so that they don't clutter up more useful directories.
35AC_CONFIG_AUX_DIR(config)
36
37
38# Initialize the automake system
39AM_INIT_AUTOMAKE([foreign])
40m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
41LT_INIT
42
43AM_MAINTAINER_MODE
44AC_CONFIG_HEADERS(src/iperf_config.h)
45
46AC_CANONICAL_HOST
47
48# Checks for tools: c compiler, ranlib (used for creating static libraries),
49# symlinks and libtool
50AC_PROG_CC
51AC_PROG_RANLIB
52AC_PROG_LN_S
53LT_INIT
54
55# Add -Wall if we are using GCC.
56if test "x$GCC" = "xyes"; then
57  CFLAGS="$CFLAGS -Wall"
58fi
59
60# Check if enable profiling
61AC_ARG_ENABLE([profiling],
62    AS_HELP_STRING([--enable-profiling], [Enable iperf3 profiling binary]))
63AM_CONDITIONAL([ENABLE_PROFILING], [test x$enable_profiling = xyes])
64
65# Check for the math library (needed by cjson on some platforms)
66AC_SEARCH_LIBS(floor, [m], [], [
67echo "floor()"
68exit 1
69])
70
71# On illumos we need -lsocket
72AC_SEARCH_LIBS(socket, [socket], [], [
73echo "socket()"
74exit 1
75])
76
77# On illumos inet_ntop in in -lnsl
78AC_SEARCH_LIBS(inet_ntop, [nsl], [], [
79echo "inet_ntop()"
80exit 1
81])
82
83# Checks for typedefs, structures, and compiler characteristics.
84AC_C_CONST
85
86# Check for poll.h (it's in POSIX so everyone should have it?)
87AC_CHECK_HEADERS([poll.h])
88
89# SCTP.  Allow user to disable SCTP support with --without-sctp.
90# Otherwise we try to find whatever support is required.
91try_sctp=true
92AC_ARG_WITH([sctp],
93    [AS_HELP_STRING([--without-sctp],
94        [disable SCTP])],
95    [
96        case "$withval" in
97	y | ye | yes)
98	  ;;
99	n | no)
100	try_sctp=false
101	  ;;
102	*)
103	AC_MSG_ERROR([Invalid --with-sctp value])
104	  ;;
105	esac
106    ], [
107        try_sctp=true
108    ]
109)
110
111AC_CHECK_HEADERS([linux/tcp.h])
112
113# Check for SCTP support
114if $try_sctp; then
115AC_CHECK_HEADERS([sys/socket.h])
116AC_CHECK_HEADERS([netinet/sctp.h],
117		 AC_DEFINE([HAVE_SCTP_H], [1], [Have SCTP support.])
118		 AC_SEARCH_LIBS(sctp_bindx, [sctp])
119		 AC_CHECK_TYPES([struct sctp_assoc_value], [], [],
120				[[#include <netinet/sctp.h>]]),
121		 [],
122		 [#ifdef HAVE_SYS_SOCKET_H
123#include <sys/socket.h>
124#endif
125])
126fi
127
128AC_CHECK_HEADER([endian.h],
129		AC_DEFINE([HAVE_ENDIAN_H], [1], [Define to 1 if you have the <endian.h> header file.]),
130		AC_CHECK_HEADER([sys/endian.h],
131				AC_DEFINE([HAVE_SYS_ENDIAN_H], [1], [Define to 1 if you have the <sys/endian.h> header file.]),
132				AC_MSG_WARN([Couldn't find endian.h or sys/endian.h files: doing compile-time tests.])
133				)
134		)
135
136if test "x$with_openssl" = "xno"; then
137    AC_MSG_WARN( [Building without OpenSSL; disabling iperf_auth functionality.] )
138else
139    # Check for OPENSSL support
140    havs_ssl=false
141    AX_CHECK_OPENSSL(
142        [ AC_DEFINE([HAVE_SSL], [1], [OpenSSL Is Available])
143          have_ssl=true ],
144	[ if test "x$with_openssl" != "x"; then
145	  AC_MSG_FAILURE([--with-openssl was given, but test for OpenSSL failed])
146	  fi ]
147    )
148    if $have_ssl; then
149        case $host in
150           *-*-cygwin)
151             CFLAGS="$CFLAGS -DNOCRYPT"
152             ;;
153        esac
154        LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
155        LIBS="$OPENSSL_LIBS $LIBS"
156        CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
157    fi
158fi
159
160# Check for TCP_CONGESTION sockopt (believed to be Linux and FreeBSD only)
161AC_CACHE_CHECK([TCP_CONGESTION socket option],
162[iperf3_cv_header_tcp_congestion],
163AC_COMPILE_IFELSE(
164  [AC_LANG_PROGRAM([[#include <netinet/tcp.h>]],
165                   [[int foo = TCP_CONGESTION;]])],
166  iperf3_cv_header_tcp_congestion=yes,
167  iperf3_cv_header_tcp_congestion=no))
168if test "x$iperf3_cv_header_tcp_congestion" = "xyes"; then
169    AC_DEFINE([HAVE_TCP_CONGESTION], [1], [Have TCP_CONGESTION sockopt.])
170fi
171
172# Check for TCP_USER_TIMEOUT sockopt (believed to be Linux 2.6.37+ only)
173AC_CACHE_CHECK([TCP_USER_TIMEOUT socket option],
174[iperf3_cv_header_tcp_user_timeout],
175AC_COMPILE_IFELSE(
176  [AC_LANG_PROGRAM([[#include <netinet/tcp.h>]],
177                   [[int foo = TCP_USER_TIMEOUT;]])],
178  iperf3_cv_header_tcp_user_timeout=yes,
179  iperf3_cv_header_tcp_user_timeout=no))
180if test "x$iperf3_cv_header_tcp_user_timeout" = "xyes"; then
181    AC_DEFINE([HAVE_TCP_USER_TIMEOUT], [1], [Have TCP_USER_TIMEOUT sockopt.])
182fi
183
184# Check for IPv6 flowlabel support (believed to be Linux only)
185# We check for IPV6_FLOWLABEL_MGR in <linux/in6.h> even though we
186# don't use that file directly (we have our own stripped-down
187# copy, see src/flowlabel.h for more details).
188AC_CACHE_CHECK([IPv6 flowlabel support],
189[iperf3_cv_header_flowlabel],
190AC_COMPILE_IFELSE(
191  [AC_LANG_PROGRAM([[#include <sys/types.h>
192                     #include <linux/in6.h>]],
193                   [[int foo = IPV6_FLOWLABEL_MGR;]])],
194  iperf3_cv_header_flowlabel=yes,
195  iperf3_cv_header_flowlabel=no))
196if test "x$iperf3_cv_header_flowlabel" = "xyes"; then
197    AC_DEFINE([HAVE_FLOWLABEL], [1], [Have IPv6 flowlabel support.])
198fi
199
200# Check for CPU affinity support.  FreeBSD and Linux do this differently
201# unfortunately so we have to check separately for each of them.
202# FreeBSD uses cpuset_setaffinity while Linux uses sched_setaffinity.
203# Define HAVE_CPU_AFFINITY to indicate the CPU affinity setting as a
204# generic concept is available.
205AC_CHECK_FUNCS([cpuset_setaffinity sched_setaffinity SetProcessAffinityMask],
206	       AC_DEFINE([HAVE_CPU_AFFINITY], [1],
207	 	         [Have CPU affinity support.]))
208
209# Check for daemon().  Most systems have this but a few (IRIX) don't.
210AC_CHECK_FUNCS([daemon])
211
212# Check for sendfile support.  FreeBSD, Linux, and MacOS all support
213# this system call, but they're all different in terms of what headers
214# it needs and what arguments it expects.
215AC_CHECK_FUNCS([sendfile])
216
217# Check for getline support, used as a part of authenticated
218# connections.
219AC_CHECK_FUNCS([getline])
220
221# Check for packet pacing socket option (Linux only for now).
222AC_CACHE_CHECK([SO_MAX_PACING_RATE socket option],
223[iperf3_cv_header_so_max_pacing_rate],
224AC_COMPILE_IFELSE(
225  [AC_LANG_PROGRAM([[#include <sys/socket.h>]],
226                   [[int foo = SO_MAX_PACING_RATE;]])],
227  iperf3_cv_header_so_max_pacing_rate=yes,
228  iperf3_cv_header_so_max_pacing_rate=no))
229if test "x$iperf3_cv_header_so_max_pacing_rate" = "xyes"; then
230    AC_DEFINE([HAVE_SO_MAX_PACING_RATE], [1], [Have SO_MAX_PACING_RATE sockopt.])
231fi
232
233# Check for SO_BINDTODEVICE sockopt (believed to be Linux only)
234AC_CACHE_CHECK([SO_BINDTODEVICE socket option],
235[iperf3_cv_header_so_bindtodevice],
236AC_COMPILE_IFELSE(
237  [AC_LANG_PROGRAM([[#include <sys/socket.h>]],
238                   [[int foo = SO_BINDTODEVICE;]])],
239  iperf3_cv_header_so_bindtodevice=yes,
240  iperf3_cv_header_so_bindtodevice=no))
241if test "x$iperf3_cv_header_so_bindtodevice" = "xyes"; then
242    AC_DEFINE([HAVE_SO_BINDTODEVICE], [1], [Have SO_BINDTODEVICE sockopt.])
243fi
244
245# Check for IP_MTU_DISCOVER (mostly on Linux)
246AC_CACHE_CHECK([IP_MTU_DISCOVER socket option],
247[iperf3_cv_header_ip_mtu_discover],
248AC_COMPILE_IFELSE(
249  [AC_LANG_PROGRAM([[#include <sys/types.h>
250                     #include <sys/socket.h>
251                     #include <netinet/in.h>]],
252                   [[int foo = IP_MTU_DISCOVER;]])],
253  iperf3_cv_header_ip_mtu_discover=yes,
254  iperf3_cv_header_ip_mtu_discover=no))
255if test "x$iperf3_cv_header_ip_mtu_discover" = "xyes"; then
256    AC_DEFINE([HAVE_IP_MTU_DISCOVER], [1], [Have IP_MTU_DISCOVER sockopt.])
257fi
258
259# Check for IP_DONTFRAG (BSD?)
260AC_CACHE_CHECK([IP_DONTFRAG socket option],
261[iperf3_cv_header_ip_dontfrag],
262AC_COMPILE_IFELSE(
263  [AC_LANG_PROGRAM([[#include <sys/types.h>
264                     #include <sys/socket.h>
265                     #include <netinet/in.h>]],
266                   [[int foo = IP_DONTFRAG;]])],
267  iperf3_cv_header_ip_dontfrag=yes,
268  iperf3_cv_header_ip_dontfrag=no))
269if test "x$iperf3_cv_header_ip_dontfrag" = "xyes"; then
270    AC_DEFINE([HAVE_IP_DONTFRAG], [1], [Have IP_DONTFRAG sockopt.])
271fi
272
273# Check for IP_DONTFRAGMENT (Windows?)
274AC_CACHE_CHECK([IP_DONTFRAGMENT socket option],
275[iperf3_cv_header_ip_dontfragment],
276AC_COMPILE_IFELSE(
277  [AC_LANG_PROGRAM([[#include <sys/types.h>
278                     #include <sys/socket.h>
279                     #include <netinet/in.h>]],
280                   [[int foo = IP_DONTFRAGMENT;]])],
281  iperf3_cv_header_ip_dontfragment=yes,
282  iperf3_cv_header_ip_dontfragment=no))
283if test "x$iperf3_cv_header_ip_dontfragment" = "xyes"; then
284    AC_DEFINE([HAVE_IP_DONTFRAGMENT], [1], [Have IP_DONTFRAGMENT sockopt.])
285fi
286
287# Check for IP DF support
288AC_CACHE_CHECK([any kind of DF socket option],
289[iperf3_cv_header_dontfragment],
290[if test "x$iperf3_cv_header_ip_mtu_discover" = "xyes" -o "x$iperf3_cv_header_ip_dontfrag" = "xyes" -o "x$iperf3_cv_header_ip_dontfragment" = "xyes"; then
291  iperf3_cv_header_dontfragment=yes
292else
293  iperf3_cv_header_dontfragment=no
294fi])
295
296if test "x$iperf3_cv_header_dontfragment" = "xyes"; then
297    AC_DEFINE([HAVE_DONT_FRAGMENT], [1], [Have IP_MTU_DISCOVER/IP_DONTFRAG/IP_DONTFRAGMENT sockopt.])
298fi
299
300#
301# Check for tcpi_snd_wnd in struct tcp_info
302#
303AC_CHECK_MEMBER([struct tcp_info.tcpi_snd_wnd],
304[iperf3_cv_header_tcp_info_snd_wnd=yes], [iperf3_cv_header_tcp_info_snd_wnd=no],
305[#ifdef HAVE_LINUX_TCP_H
306#include <linux/tcp.h>
307#else
308#include <netinet/tcp.h>
309#endif
310])
311
312if test "x$iperf3_cv_header_tcp_info_snd_wnd" = "xyes"; then
313  AC_DEFINE([HAVE_TCP_INFO_SND_WND], [1], [Have tcpi_snd_wnd field in tcp_info.])
314fi
315
316# Check if we need -lrt for clock_gettime
317AC_SEARCH_LIBS(clock_gettime, [rt posix4])
318# Check for clock_gettime support
319AC_CHECK_FUNCS([clock_gettime])
320
321AC_CONFIG_FILES([Makefile src/Makefile src/version.h examples/Makefile iperf3.spec])
322AC_OUTPUT
323