1# iperf, Copyright (c) 2014-2021, 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 TTD@lbl.gov. 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_INIT([iperf],[3.10],[https://github.com/esnet/iperf],[iperf],[https://software.es.net/iperf/]) 28m4_include([config/ax_check_openssl.m4]) 29m4_include([config/iperf_config_static_bin.m4]) 30AC_LANG(C) 31 32# Specify where the auxiliary files created by configure should go. The config 33# directory is picked so that they don't clutter up more useful directories. 34AC_CONFIG_AUX_DIR(config) 35 36 37# Initialize the automake system 38AM_INIT_AUTOMAKE([foreign]) 39m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 40LT_INIT 41 42AM_MAINTAINER_MODE 43AM_CONFIG_HEADER(src/iperf_config.h) 44 45AC_CANONICAL_HOST 46 47# Checks for tools: c compiler, ranlib (used for creating static libraries), 48# symlinks and libtool 49AC_PROG_CC 50AC_PROG_RANLIB 51AC_PROG_LN_S 52LT_INIT 53 54# Add -Wall if we are using GCC. 55if test "x$GCC" = "xyes"; then 56 CFLAGS="$CFLAGS -Wall" 57fi 58 59# Check if enable profiling 60AC_ARG_ENABLE([profiling], 61 AS_HELP_STRING([--enable-profiling], [Enable iperf3 profiling binary])) 62AM_CONDITIONAL([ENABLE_PROFILING], [test x$enable_profiling = xyes]) 63 64# Checks for header files. 65m4_warn([obsolete], 66[The preprocessor macro `STDC_HEADERS' is obsolete. 67 Except in unusual embedded environments, you can safely include all 68 ISO C90 headers unconditionally.])dnl 69# Autoupdate added the next two lines to ensure that your configure 70# script's behavior did not change. They are probably safe to remove. 71AC_CHECK_INCLUDES_DEFAULT 72AC_PROG_EGREP 73 74 75# Check for systems which need -lsocket and -lnsl 76#AX_LIB_SOCKET_NSL 77 78# Check for the math library (needed by cjson on some platforms) 79AC_SEARCH_LIBS(floor, [m], [], [ 80echo "floor()" 81exit 1 82]) 83 84# On illumos we need -lsocket 85AC_SEARCH_LIBS(socket, [socket], [], [ 86echo "socket()" 87exit 1 88]) 89 90# On illumos inet_ntop in in -lnsl 91AC_SEARCH_LIBS(inet_ntop, [nsl], [], [ 92echo "inet_ntop()" 93exit 1 94]) 95 96# Checks for typedefs, structures, and compiler characteristics. 97AC_C_CONST 98 99# Check for poll.h (it's in POSIX so everyone should have it?) 100AC_CHECK_HEADERS([poll.h]) 101 102# SCTP. Allow user to disable SCTP support with --without-sctp. 103# Otherwise we try to find whatever support is required. 104try_sctp=true 105AC_ARG_WITH([sctp], 106 [AS_HELP_STRING([--without-sctp], 107 [disable SCTP])], 108 [ 109 case "$withval" in 110 y | ye | yes) 111 ;; 112 n | no) 113 try_sctp=false 114 ;; 115 *) 116 AC_MSG_ERROR([Invalid --with-sctp value]) 117 ;; 118 esac 119 ], [ 120 try_sctp=true 121 ] 122) 123 124AC_CHECK_HEADERS([linux/tcp.h]) 125 126# Check for SCTP support 127if $try_sctp; then 128AC_CHECK_HEADERS([sys/socket.h]) 129AC_CHECK_HEADERS([netinet/sctp.h], 130 AC_DEFINE([HAVE_SCTP_H], [1], [Have SCTP support.]) 131 AC_SEARCH_LIBS(sctp_bindx, [sctp]) 132 AC_CHECK_TYPES([struct sctp_assoc_value], [], [], 133 [[#include <netinet/sctp.h>]]), 134 [], 135 [#ifdef HAVE_SYS_SOCKET_H 136#include <sys/socket.h> 137#endif 138]) 139fi 140 141AC_CHECK_HEADER([endian.h], 142 AC_DEFINE([HAVE_ENDIAN_H], [1], [Define to 1 if you have the <endian.h> header file.]), 143 AC_CHECK_HEADER([sys/endian.h], 144 AC_DEFINE([HAVE_SYS_ENDIAN_H], [1], [Define to 1 if you have the <sys/endian.h> header file.]), 145 AC_MSG_WARN([Couldn't find endian.h or sys/endian.h files: doing compile-time tests.]) 146 ) 147 ) 148 149if test "x$with_openssl" = "xno"; then 150 AC_MSG_WARN( [Building without OpenSSL; disabling iperf_auth functionality.] ) 151else 152 # Check for OPENSSL support 153 havs_ssl=false 154 AX_CHECK_OPENSSL( 155 [ AC_DEFINE([HAVE_SSL], [1], [OpenSSL Is Available]) 156 have_ssl=true ], 157 [ if test "x$with_openssl" != "x"; then 158 AC_MSG_FAILURE([--with-openssl was given, but test for OpenSSL failed]) 159 fi ] 160 ) 161 if $have_ssl; then 162 case $host in 163 *-*-cygwin) 164 CFLAGS="$CFLAGS -DNOCRYPT" 165 ;; 166 esac 167 LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" 168 LIBS="$OPENSSL_LIBS $LIBS" 169 CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" 170 fi 171fi 172 173# Check for TCP_CONGESTION sockopt (believed to be Linux and FreeBSD only) 174AC_CACHE_CHECK([TCP_CONGESTION socket option], 175[iperf3_cv_header_tcp_congestion], 176AC_EGREP_CPP(yes, 177[#include <netinet/tcp.h> 178#ifdef TCP_CONGESTION 179 yes 180#endif 181],iperf3_cv_header_tcp_congestion=yes,iperf3_cv_header_tcp_congestion=no)) 182if test "x$iperf3_cv_header_tcp_congestion" = "xyes"; then 183 AC_DEFINE([HAVE_TCP_CONGESTION], [1], [Have TCP_CONGESTION sockopt.]) 184fi 185 186# Check for IPv6 flowlabel support (believed to be Linux only) 187# We check for IPV6_FLOWLABEL_MGR in <linux/in6.h> even though we 188# don't use that file directly (we have our own stripped-down 189# copy, see src/flowlabel.h for more details). 190AC_CACHE_CHECK([IPv6 flowlabel support], 191[iperf3_cv_header_flowlabel], 192AC_EGREP_CPP(yes, 193[#include <sys/types.h> 194#include <linux/in6.h> 195#ifdef IPV6_FLOWLABEL_MGR 196 yes 197#endif 198],iperf3_cv_header_flowlabel=yes,iperf3_cv_header_flowlabel=no)) 199if test "x$iperf3_cv_header_flowlabel" = "xyes"; then 200 AC_DEFINE([HAVE_FLOWLABEL], [1], [Have IPv6 flowlabel support.]) 201fi 202 203# Check for CPU affinity support. FreeBSD and Linux do this differently 204# unfortunately so we have to check separately for each of them. 205# FreeBSD uses cpuset_setaffinity while Linux uses sched_setaffinity. 206# Define HAVE_CPU_AFFINITY to indicate the CPU affinity setting as a 207# generic concept is available. 208AC_CHECK_FUNCS([cpuset_setaffinity sched_setaffinity SetProcessAffinityMask], 209 AC_DEFINE([HAVE_CPU_AFFINITY], [1], 210 [Have CPU affinity support.])) 211 212# Check for daemon(). Most systems have this but a few (IRIX) don't. 213AC_CHECK_FUNCS([daemon]) 214 215# Check for sendfile support. FreeBSD, Linux, and MacOS all support 216# this system call, but they're all different in terms of what headers 217# it needs and what arguments it expects. 218AC_CHECK_FUNCS([sendfile]) 219 220# Check for getline support, used as a part of authenticated 221# connections. 222AC_CHECK_FUNCS([getline]) 223 224# Check for packet pacing socket option (Linux only for now). 225AC_CACHE_CHECK([SO_MAX_PACING_RATE socket option], 226[iperf3_cv_header_so_max_pacing_rate], 227AC_EGREP_CPP(yes, 228[#include <sys/socket.h> 229#ifdef SO_MAX_PACING_RATE 230 yes 231#endif 232],iperf3_cv_header_so_max_pacing_rate=yes,iperf3_cv_header_so_max_pacing_rate=no)) 233if test "x$iperf3_cv_header_so_max_pacing_rate" = "xyes"; then 234 AC_DEFINE([HAVE_SO_MAX_PACING_RATE], [1], [Have SO_MAX_PACING_RATE sockopt.]) 235fi 236 237# Check for SO_BINDTODEVICE sockopt (believed to be Linux only) 238AC_CACHE_CHECK([SO_BINDTODEVICE socket option], 239[iperf3_cv_header_so_bindtodevice], 240AC_EGREP_CPP(yes, 241[#include <sys/socket.h> 242#ifdef SO_BINDTODEVICE 243 yes 244#endif 245],iperf3_cv_header_so_bindtodevice=yes,iperf3_cv_header_so_bindtodevice=no)) 246if test "x$iperf3_cv_header_so_bindtodevice" = "xyes"; then 247 AC_DEFINE([HAVE_SO_BINDTODEVICE], [1], [Have SO_BINDTODEVICE sockopt.]) 248fi 249 250# Check for IP DF support 251AC_CACHE_CHECK([IP_MTU_DISCOVER or IP_DONTFRAG socket option], 252[iperf3_cv_header_dontfragment], 253AC_EGREP_CPP(yes, 254[#include <sys/socket.h> 255#include <netinet/ip.h> 256#include <netinet/in.h> 257#ifdef IP_MTU_DISCOVER 258 yes 259#endif 260#ifdef IP_DONTFRAG 261 yes 262#endif 263#ifdef IP_DONTFRAGMENT 264 yes 265#endif 266],iperf3_cv_header_dontfragment=yes,iperf3_cv_header_dontfragment=no)) 267if test "x$iperf3_cv_header_dontfragment" = "xyes"; then 268 AC_DEFINE([HAVE_DONT_FRAGMENT], [1], [Have IP_MTU_DISCOVER/IP_DONTFRAG sockopt.]) 269fi 270 271AC_CHECK_MEMBER([struct tcp_info.tcpi_snd_wnd], 272[iperf3_cv_header_tcp_info_snd_wnd=yes], [iperf3_cv_header_tcp_info_snd_wnd=no], 273[#ifdef HAVE_LINUX_TCP_H 274#include <linux/tcp.h> 275#else 276#include <netinet/tcp.h> 277#endif 278]) 279 280if test "x$iperf3_cv_header_tcp_info_snd_wnd" = "xyes"; then 281 AC_DEFINE([HAVE_TCP_INFO_SND_WND], [1], [Have tcpi_snd_wnd field in tcp_info.]) 282fi 283 284# Check if we need -lrt for clock_gettime 285AC_SEARCH_LIBS(clock_gettime, [rt posix4]) 286# Check for clock_gettime support 287AC_CHECK_FUNCS([clock_gettime]) 288 289AC_CONFIG_FILES([Makefile src/Makefile src/version.h examples/Makefile iperf3.spec]) 290AC_OUTPUT 291