1# iperf, Copyright (c) 2014-2018, 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.6+, https://github.com/esnet/iperf, iperf, https://software.es.net/iperf/)
28m4_include([config/ax_check_openssl.m4])
29AC_LANG(C)
30
31# Specify where the auxiliary files created by configure should go. The config
32# directory is picked so that they don't clutter up more useful directories.
33AC_CONFIG_AUX_DIR(config)
34
35
36# Initialize the automake system
37AM_INIT_AUTOMAKE([foreign])
38AM_MAINTAINER_MODE
39AM_CONFIG_HEADER(src/iperf_config.h)
40
41AC_CANONICAL_HOST
42
43# Checks for tools: c compiler, ranlib (used for creating static libraries),
44# symlinks and libtool
45AC_PROG_CC
46AC_PROG_RANLIB
47AC_PROG_LN_S
48AC_PROG_LIBTOOL
49
50# Add -Wall if we are using GCC.
51if test "x$GCC" = "xyes"; then
52  CFLAGS="$CFLAGS -Wall"
53fi
54
55# Check if profiling must be disabled
56AC_ARG_ENABLE([profiling],
57    AS_HELP_STRING([--disable-profiling], [Disable iperf profiling binary]),
58    [:],
59    [enable_profiling=yes])
60AM_CONDITIONAL([ENABLE_PROFILING], [test x$enable_profiling = xyes])
61
62# Checks for header files.
63AC_HEADER_STDC
64
65# Check for systems which need -lsocket and -lnsl
66#AX_LIB_SOCKET_NSL
67
68# Check for the math library (needed by cjson on some platforms)
69AC_SEARCH_LIBS(floor, [m], [], [
70echo "floor()"
71exit 1
72])
73
74# On illumos we need -lsocket
75AC_SEARCH_LIBS(socket, [socket], [], [
76echo "socket()"
77exit 1
78])
79
80# On illumos inet_ntop in in -lnsl
81AC_SEARCH_LIBS(inet_ntop, [nsl], [], [
82echo "inet_ntop()"
83exit 1
84])
85
86# Checks for typedefs, structures, and compiler characteristics.
87AC_C_CONST
88
89# Check for poll.h (it's in POSIX so everyone should have it?)
90AC_CHECK_HEADERS([poll.h])
91
92# Check for SCTP support
93AC_CHECK_HEADERS([sys/socket.h])
94AC_CHECK_HEADERS([netinet/sctp.h],
95		 AC_DEFINE([HAVE_SCTP], [1], [Have SCTP support.])
96		 AC_SEARCH_LIBS(sctp_bindx, [sctp])
97		 AC_CHECK_TYPES([struct sctp_assoc_value], [], [],
98				[[#include <netinet/sctp.h>]]),
99		 [],
100		 [#ifdef HAVE_SYS_SOCKET_H
101#include <sys/socket.h>
102#endif
103])
104
105AC_CHECK_HEADER([endian.h],
106		AC_DEFINE([HAVE_ENDIAN_H], [1], [Define to 1 if you have the <endian.h> header file.]),
107		AC_CHECK_HEADER([sys/endian.h],
108				AC_DEFINE([HAVE_SYS_ENDIAN_H], [1], [Define to 1 if you have the <sys/endian.h> header file.]),
109				AC_MSG_WARN([Couldn't find endian.h or sys/endian.h files: doing compile-time tests.])
110				)
111		)
112
113if test "x$with_openssl" = "xno"; then
114    AC_MSG_WARN( [Building without OpenSSL; disabling iperf_auth functionality.] )
115else
116    # Check for OPENSSL support
117    AX_CHECK_OPENSSL(
118        [ AC_DEFINE([HAVE_SSL], [1], [OpenSSL Is Available]) ],
119	[ if test "x$with_openssl" != "x"; then
120	  AC_MSG_FAILURE([--with-openssl was given, but test for OpenSSL failed])
121	  fi ]
122    )
123    LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
124    LIBS="$OPENSSL_LIBS $LIBS"
125    CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
126fi
127
128# Check for TCP_CONGESTION sockopt (believed to be Linux and FreeBSD only)
129AC_CACHE_CHECK([TCP_CONGESTION socket option],
130[iperf3_cv_header_tcp_congestion],
131AC_EGREP_CPP(yes,
132[#include <netinet/tcp.h>
133#ifdef TCP_CONGESTION
134  yes
135#endif
136],iperf3_cv_header_tcp_congestion=yes,iperf3_cv_header_tcp_congestion=no))
137if test "x$iperf3_cv_header_tcp_congestion" = "xyes"; then
138    AC_DEFINE([HAVE_TCP_CONGESTION], [1], [Have TCP_CONGESTION sockopt.])
139fi
140
141# Check for IPv6 flowlabel support (believed to be Linux only)
142# We check for IPV6_FLOWLABEL_MGR in <linux/in6.h> even though we
143# don't use that file directly (we have our own stripped-down
144# copy, see src/flowlabel.h for more details).
145AC_CACHE_CHECK([IPv6 flowlabel support],
146[iperf3_cv_header_flowlabel],
147AC_EGREP_CPP(yes,
148[#include <sys/types.h>
149#include <linux/in6.h>
150#ifdef IPV6_FLOWLABEL_MGR
151  yes
152#endif
153],iperf3_cv_header_flowlabel=yes,iperf3_cv_header_flowlabel=no))
154if test "x$iperf3_cv_header_flowlabel" = "xyes"; then
155    AC_DEFINE([HAVE_FLOWLABEL], [1], [Have IPv6 flowlabel support.])
156fi
157
158# Check for CPU affinity support.  FreeBSD and Linux do this differently
159# unfortunately so we have to check separately for each of them.
160# FreeBSD uses cpuset_setaffinity while Linux uses sched_setaffinity.
161# Define HAVE_CPU_AFFINITY to indicate the CPU affinity setting as a
162# generic concept is available.
163AC_CHECK_FUNCS([cpuset_setaffinity sched_setaffinity SetProcessAffinityMask],
164	       AC_DEFINE([HAVE_CPU_AFFINITY], [1],
165	 	         [Have CPU affinity support.]))
166
167# Check for daemon().  Most systems have this but a few (IRIX) don't.
168AC_CHECK_FUNCS([daemon])
169
170# Check for sendfile support.  FreeBSD, Linux, and MacOS all support
171# this system call, but they're all different in terms of what headers
172# it needs and what arguments it expects.
173AC_CHECK_FUNCS([sendfile])
174
175# Check for getline support, used as a part of authenticated
176# connections.
177AC_CHECK_FUNCS([getline])
178
179# Check for packet pacing socket option (Linux only for now).
180AC_CACHE_CHECK([SO_MAX_PACING_RATE socket option],
181[iperf3_cv_header_so_max_pacing_rate],
182AC_EGREP_CPP(yes,
183[#include <sys/socket.h>
184#ifdef SO_MAX_PACING_RATE
185  yes
186#endif
187],iperf3_cv_header_so_max_pacing_rate=yes,iperf3_cv_header_so_max_pacing_rate=no))
188if test "x$iperf3_cv_header_so_max_pacing_rate" = "xyes"; then
189    AC_DEFINE([HAVE_SO_MAX_PACING_RATE], [1], [Have SO_MAX_PACING_RATE sockopt.])
190fi
191
192# Check if we need -lrt for clock_gettime
193AC_SEARCH_LIBS(clock_gettime, [rt posix4])
194# Check for clock_gettime support
195AC_CHECK_FUNCS([clock_gettime])
196
197AC_OUTPUT([Makefile src/Makefile src/version.h examples/Makefile iperf3.spec])
198