blob: ce22b2048c9c387565a756dee88f1ce69f0b963d [file] [log] [blame]
Cullen Jennings235513a2005-09-21 22:51:36 +00001dnl Process this file with autoconf to produce a configure script.
jfigus7b8383f2014-10-13 12:38:58 -04002AC_INIT([libsrtp], [1.5.1-pre], [https://github.com/cisco/libsrtp/issues])
Cullen Jennings235513a2005-09-21 22:51:36 +00003
David McGrewb67061f2005-09-28 14:23:06 +00004dnl Must come before AC_PROG_CC
5if test -z "$CFLAGS"; then
6 dnl Default value for CFLAGS if not specified.
Kristian Kielhofnerb90f1ba2013-11-07 13:35:46 -08007 CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops"
David McGrewb67061f2005-09-28 14:23:06 +00008fi
9
Cullen Jennings235513a2005-09-21 22:51:36 +000010dnl Checks for programs.
11AC_PROG_RANLIB
12AC_PROG_CC
David McGrewb67061f2005-09-28 14:23:06 +000013AC_PROG_INSTALL
Cullen Jennings235513a2005-09-21 22:51:36 +000014
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000015dnl Check the byte order
16AC_C_BIGENDIAN
17
18AC_CANONICAL_HOST
19
20dnl check host_cpu type, set defines appropriately
21case $host_cpu in
Jonathan Lennoxc7528162012-04-26 23:17:21 +000022 i*86 | x86_64 )
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000023 AC_DEFINE(CPU_CISC, 1,
24 [Define if building for a CISC machine (e.g. Intel).])
25 AC_DEFINE(HAVE_X86, 1,
26 [Define to use X86 inlined assembly code]);;
27 * )
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000028 AC_DEFINE(CPU_RISC, 1,
29 [Define if building for a RISC machine (assume slow byte access).])
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000030 ;;
31esac
32
33dnl Check if we are on a Windows platform.
34case $host_os in
35 *cygwin*|*mingw* )
36 EXE=.exe
37 HOST_IS_WINDOWS=yes
38 ;;
39 * )
40 EXE=""
41 ;;
42esac
43AC_SUBST(EXE) # define executable suffix; this is needed for `make clean'
44
Cullen Jennings235513a2005-09-21 22:51:36 +000045
Marcus Sundberg7b81b062005-10-03 15:15:08 +000046AC_ARG_ENABLE(kernel-linux,
47 [AS_HELP_STRING([--enable-kernel-linux],
48 [build library to run in Linux kernel context])],
49 [], enable_kernel_linux=no)
50AC_MSG_CHECKING(whether to build for Linux kernel context)
51if test "$enable_kernel_linux" = "yes"; then
52 AC_DEFINE(SRTP_KERNEL, 1,
53 [Define to compile for kernel contexts.])
54 AC_DEFINE(SRTP_KERNEL_LINUX, 1,
55 [Define to compile for Linux kernel context.])
56fi
57AC_MSG_RESULT($enable_kernel_linux)
58
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000059if test "$cross_compiling" != yes -a "$HOST_IS_WINDOWS" != yes; then
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000060 dnl Check for /dev/urandom
61 AC_CHECK_FILE(/dev/urandom, DEV_URANDOM=/dev/urandom,
62 [AC_CHECK_FILE(/dev/random, DEV_URANDOM=/dev/random)])
63fi
David McGrewb67061f2005-09-28 14:23:06 +000064
Cullen Jennings235513a2005-09-21 22:51:36 +000065
66
67dnl Checks for header files.
68AC_HEADER_STDC
69AC_CHECK_HEADERS(stdlib.h)
70AC_CHECK_HEADERS(unistd.h)
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000071AC_CHECK_HEADERS(byteswap.h)
Cullen Jennings235513a2005-09-21 22:51:36 +000072AC_CHECK_HEADERS(stdint.h)
73AC_CHECK_HEADERS(sys/uio.h)
Randell Jesupaa851352005-09-28 22:36:05 +000074AC_CHECK_HEADERS(inttypes.h)
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000075AC_CHECK_HEADERS(sys/types.h)
Cullen Jennings235513a2005-09-21 22:51:36 +000076AC_CHECK_HEADERS(machine/types.h)
77AC_CHECK_HEADERS(sys/int_types.h)
78
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000079dnl socket() and friends
80AC_CHECK_HEADERS(sys/socket.h netinet/in.h arpa/inet.h)
81AC_CHECK_HEADERS(windows.h, [AC_CHECK_HEADERS(winsock2.h)])
82
Cullen Jennings235513a2005-09-21 22:51:36 +000083AC_CHECK_HEADERS(syslog.h)
84
Randell Jesupaa851352005-09-28 22:36:05 +000085AC_CHECK_TYPES([int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,uint64_t])
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000086AC_CHECK_SIZEOF(unsigned long)
87AC_CHECK_SIZEOF(unsigned long long)
Cullen Jennings235513a2005-09-21 22:51:36 +000088
89dnl Checks for typedefs, structures, and compiler characteristics.
90AC_C_CONST
91AC_C_INLINE
92AC_TYPE_SIZE_T
93
94dnl Checks for library functions.
Jonathan Lennox3f7fc222010-05-17 19:32:02 +000095AC_CHECK_FUNCS(socket inet_aton usleep sigaction)
David McGrewb67061f2005-09-28 14:23:06 +000096
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000097dnl Find socket function if not found yet.
98if test "x$ac_cv_func_socket" = "xno"; then
99 AC_CHECK_LIB(socket, socket)
100 AC_MSG_CHECKING([for socket in -lwsock32])
101 SAVELIBS="$LIBS"
102 LIBS="$LIBS -lwsock32"
103 AC_TRY_LINK([
104#include <winsock2.h>
105],[
106socket(0, 0, 0);
107],
108 ac_cv_func_socket=yes
109 AC_MSG_RESULT(yes),
110 LIBS="$SAVELIBS"
111 AC_MSG_RESULT(no))
112fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000113
David McGrewb67061f2005-09-28 14:23:06 +0000114AC_MSG_CHECKING(whether to compile in debugging)
115AC_ARG_ENABLE(debug,
116 [AS_HELP_STRING([--disable-debug],
117 [do not compile in dynamic debugging system])],
118 [], enable_debug=yes)
119if test "$enable_debug" = "yes"; then
120 AC_DEFINE(ENABLE_DEBUGGING, 1,
121 [Define to compile in dynamic debugging system.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000122fi
David McGrewb67061f2005-09-28 14:23:06 +0000123AC_MSG_RESULT($enable_debug)
Cullen Jennings235513a2005-09-21 22:51:36 +0000124
David McGrewb67061f2005-09-28 14:23:06 +0000125AC_MSG_CHECKING(whether to use ISMAcryp code)
126AC_ARG_ENABLE(generic-aesicm,
127 [AS_HELP_STRING([--enable-generic-aesicm],
128 [compile in changes for ISMAcryp])],
129 [], enable_generic_aesicm=no)
130if test "$enable_generic_aesicm" = "yes"; then
131 AC_DEFINE(GENERIC_AESICM, 1, [Define this to use ISMAcryp code.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000132fi
David McGrewb67061f2005-09-28 14:23:06 +0000133AC_MSG_RESULT($enable_generic_aesicm)
Cullen Jennings235513a2005-09-21 22:51:36 +0000134
jfigusa14b5a02013-03-29 12:24:12 -0400135AC_MSG_CHECKING(whether to leverage OpenSSL crypto)
136AC_ARG_ENABLE(openssl,
137 [AS_HELP_STRING([--enable-openssl],
138 [compile in OpenSSL crypto engine])],
139 [], enable_openssl=no)
jfigus2b486652014-07-24 15:01:41 -0400140AC_MSG_RESULT($enable_openssl)
jfigusa14b5a02013-03-29 12:24:12 -0400141if test "$enable_openssl" = "yes"; then
Kristian Kielhofnerb90f1ba2013-11-07 13:35:46 -0800142 LDFLAGS="$LDFLAGS $(pkg-config --libs openssl)";
143 CFLAGS="$CFLAGS $(pkg-config --cflags openssl)";
Cullen Jenningse1de50f2013-05-22 12:27:28 -0600144
jfigusa14b5a02013-03-29 12:24:12 -0400145 AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
jfigus5b22e372013-05-09 09:23:26 -0400146 [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
147 AC_CHECK_LIB([crypto], [EVP_aes_128_ctr], [],
148 [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
jfigus7882dd92013-08-02 16:08:23 -0400149 AC_CHECK_LIB([crypto], [EVP_aes_128_gcm], [],
150 [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
jfigusa14b5a02013-03-29 12:24:12 -0400151 AC_DEFINE(OPENSSL, 1, [Define this to use OpenSSL crypto.])
jfigus7882dd92013-08-02 16:08:23 -0400152 AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o"
jfigusa14b5a02013-03-29 12:24:12 -0400153 RNG_OBJS=rand_source_ossl.o
jfigus0d3a2682013-04-02 15:42:37 -0400154 HMAC_OBJS=crypto/hash/hmac_ossl.o
155 USE_OPENSSL=1
156 AC_SUBST(USE_OPENSSL)
jfigusa14b5a02013-03-29 12:24:12 -0400157else
jfigus0d3a2682013-04-02 15:42:37 -0400158 AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o crypto/cipher/aes_cbc.o"
jfigusa14b5a02013-03-29 12:24:12 -0400159 AC_MSG_CHECKING(which random device to use)
160 if test "$enable_kernel_linux" = "yes"; then
161 RNG_OBJS=rand_linux_kernel.o
162 AC_MSG_RESULT([Linux kernel builtin])
163 else
164 RNG_OBJS=rand_source.o
165 if test -n "$DEV_URANDOM"; then
166 AC_DEFINE_UNQUOTED(DEV_URANDOM, "$DEV_URANDOM",[Path to random device])
167 AC_MSG_RESULT([$DEV_URANDOM])
168 else
169 AC_MSG_RESULT([standard rand() function...])
170 fi
171 fi
172 RNG_EXTRA_OBJS="crypto/rng/prng.o crypto/rng/ctr_prng.o"
jfigus0d3a2682013-04-02 15:42:37 -0400173 HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"
jfigusa14b5a02013-03-29 12:24:12 -0400174fi
jfigus0d3a2682013-04-02 15:42:37 -0400175AC_SUBST(AES_ICM_OBJS)
jfigusa14b5a02013-03-29 12:24:12 -0400176AC_SUBST(RNG_OBJS)
177AC_SUBST(RNG_EXTRA_OBJS)
jfigus0d3a2682013-04-02 15:42:37 -0400178AC_SUBST(HMAC_OBJS)
jfigusa14b5a02013-03-29 12:24:12 -0400179
Bernardo Torres79e38ae2014-10-10 05:29:36 -0300180dnl Checking for PCAP
Bernardo Torresb3c51422014-10-14 12:40:09 -0300181AC_CHECK_LIB([pcap],[pcap_create],
182 [PCAP=1
183 LIBS="-lpcap $LIBS"
184 HAVE_PCAP=1
185 AC_DEFINE(HAVE_PCAP, 1, [Define to 1 if you have the `pcap' library (-lpcap)])
186 AC_SUBST(HAVE_PCAP)
187])
Bernardo Torres79e38ae2014-10-10 05:29:36 -0300188
David McGrewb67061f2005-09-28 14:23:06 +0000189AC_MSG_CHECKING(whether to use syslog for error reporting)
190AC_ARG_ENABLE(syslog,
191 [AS_HELP_STRING([--enable-syslog], [use syslog for error reporting])],
192 [], enable_syslog=no)
193if test "$enable_syslog" = "yes"; then
194 AC_DEFINE(USE_SYSLOG, 1, [Define to use syslog logging.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000195fi
David McGrewb67061f2005-09-28 14:23:06 +0000196AC_MSG_RESULT($enable_syslog)
Cullen Jennings235513a2005-09-21 22:51:36 +0000197
David McGrewb67061f2005-09-28 14:23:06 +0000198AC_MSG_CHECKING(whether to use stdout for error reporting)
199AC_ARG_ENABLE(stdout,
200 [AS_HELP_STRING([--disable-stdout], [don't use stdout for error reporting])],
201 [], enable_stdout=yes)
202if test "$enable_stdout" = "yes"; then
203 AC_DEFINE(ERR_REPORTING_STDOUT, 1, [Define to use logging to stdout.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000204fi
David McGrewb67061f2005-09-28 14:23:06 +0000205AC_MSG_RESULT($enable_stdout)
Cullen Jennings235513a2005-09-21 22:51:36 +0000206
David McGrewb67061f2005-09-28 14:23:06 +0000207AC_MSG_CHECKING(whether to use /dev/console for error reporting)
208AC_ARG_ENABLE(console,
209 [AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])],
210 [], enable_console=no)
211if test "$enable_console" = "yes"; then
212 AC_DEFINE(USE_ERR_REPORTING_FILE, 1, [Write errors to this file])
213 AC_DEFINE(ERR_REPORTING_FILE, "/dev/console", [Report errors to this file.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000214fi
David McGrewb67061f2005-09-28 14:23:06 +0000215AC_MSG_RESULT($enable_console)
Cullen Jennings235513a2005-09-21 22:51:36 +0000216
David McGrewb67061f2005-09-28 14:23:06 +0000217AC_MSG_CHECKING(whether to use GDOI key management)
218AC_ARG_ENABLE(gdoi,
219 [AS_HELP_STRING([--enable-gdoi], [enable GDOI key management])],
220 [], enable_gdoi=no)
221if test "$enable_gdoi" = "yes"; then
222 AC_DEFINE(SRTP_GDOI, 1, [Define to use GDOI.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000223 GDOI_OBJS=gdoi/srtp+gdoi.o
224 AC_SUBST(GDOI_OBJS)
225fi
David McGrewb67061f2005-09-28 14:23:06 +0000226AC_MSG_RESULT($enable_gdoi)
Cullen Jennings235513a2005-09-21 22:51:36 +0000227
David McGrewfec49dd2005-09-23 19:34:11 +0000228AC_CONFIG_HEADER(crypto/include/config.h:config_in.h)
Cullen Jennings235513a2005-09-21 22:51:36 +0000229
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200230AC_CHECK_PROG(PKG_CONFIG, pkg-config, yes)
231if test "x$PKG_CONFIG" != "x"; then
232 HAVE_PKG_CONFIG=1
233 AC_CONFIG_FILES([libsrtp.pc])
234else
235 HAVE_PKG_CONFIG=0
236fi
237AC_SUBST(HAVE_PKG_CONFIG)
238AC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile])
239AC_OUTPUT
Marcus Sundberg4ce29b22005-09-29 14:29:53 +0000240
241# This is needed when building outside the source dir.
242AS_MKDIR_P(crypto/ae_xfm)
243AS_MKDIR_P(crypto/cipher)
244AS_MKDIR_P(crypto/hash)
245AS_MKDIR_P(crypto/kernel)
246AS_MKDIR_P(crypto/math)
247AS_MKDIR_P(crypto/replay)
248AS_MKDIR_P(crypto/rng)
249AS_MKDIR_P(crypto/test)
250AS_MKDIR_P(doc)
251AS_MKDIR_P(srtp)
252AS_MKDIR_P(tables)
253AS_MKDIR_P(test)