blob: 3ac0d69c01e0879f20057e31a66a70bc821ff477 [file] [log] [blame]
Cullen Jennings235513a2005-09-21 22:51:36 +00001dnl Process this file with autoconf to produce a configure script.
Pascal Bühler34acba62017-01-19 10:57:30 +01002AC_INIT([libsrtp2], [2.1.0-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
Idar Tollefsen27d857c2017-01-19 15:28:18 +01005if test "x$CFLAGS" = "x"; then
David McGrewb67061f2005-09-28 14:23:06 +00006 dnl Default value for CFLAGS if not specified.
Alexander Traud12658582016-10-15 21:53:20 +02007 CFLAGS="-Wall -pedantic -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.
Alexander Traud52c30db2016-06-16 17:24:18 +020011m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
Cullen Jennings235513a2005-09-21 22:51:36 +000012AC_PROG_RANLIB
13AC_PROG_CC
David McGrewb67061f2005-09-28 14:23:06 +000014AC_PROG_INSTALL
Cullen Jennings235513a2005-09-21 22:51:36 +000015
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000016dnl Check the byte order
17AC_C_BIGENDIAN
18
19AC_CANONICAL_HOST
20
21dnl check host_cpu type, set defines appropriately
22case $host_cpu in
Idar Tollefsen5fd11872017-01-19 15:25:12 +010023 i*86 | x86_64 )
Idar Tollefsen5e67d392017-01-20 13:03:52 +010024 AC_DEFINE([CPU_CISC], [1], [Define if building for a CISC machine (e.g. Intel).])
25 AC_DEFINE([HAVE_X86], [1], [Define to use X86 inlined assembly code])
Idar Tollefsen5fd11872017-01-19 15:25:12 +010026 ;;
27 * )
Idar Tollefsen5e67d392017-01-20 13:03:52 +010028 AC_DEFINE([CPU_RISC], [1], [Define if building for a RISC machine (assume slow byte access).])
Idar Tollefsen5fd11872017-01-19 15:25:12 +010029 ;;
30esac
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000031
32dnl Check if we are on a Windows platform.
33case $host_os in
Idar Tollefsen5fd11872017-01-19 15:25:12 +010034 *cygwin*|*mingw* )
35 EXE=.exe
Idar Tollefsen5fd11872017-01-19 15:25:12 +010036 ;;
37 * )
38 EXE=""
39 ;;
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000040esac
Idar Tollefsen5e67d392017-01-20 13:03:52 +010041AC_SUBST([EXE]) # define executable suffix; this is needed for `make clean'
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000042
Cullen Jennings235513a2005-09-21 22:51:36 +000043
44dnl Checks for header files.
45AC_HEADER_STDC
Idar Tollefsen5e67d392017-01-20 13:03:52 +010046AC_CHECK_HEADERS(
47 [unistd.h byteswap.h stdint.h sys/uio.h inttypes.h sys/types.h machine/types.h sys/int_types.h],
48 [], [], [AC_INCLUDES_DEFAULT])
Cullen Jennings235513a2005-09-21 22:51:36 +000049
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000050dnl socket() and friends
Idar Tollefsen5e67d392017-01-20 13:03:52 +010051AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h], [], [], [AC_INCLUDES_DEFAULT])
52AC_CHECK_HEADERS(
53 [windows.h],
54 [AC_CHECK_HEADERS([winsock2.h], [], [], [AC_INCLUDES_DEFAULT])],
55 [], [AC_INCLUDES_DEFAULT])
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000056
Idar Tollefsen5e67d392017-01-20 13:03:52 +010057AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, uint64_t])
58AC_CHECK_SIZEOF([unsigned long])
59AC_CHECK_SIZEOF([unsigned long long])
Cullen Jennings235513a2005-09-21 22:51:36 +000060
61dnl Checks for typedefs, structures, and compiler characteristics.
62AC_C_CONST
63AC_C_INLINE
64AC_TYPE_SIZE_T
65
66dnl Checks for library functions.
Idar Tollefsen5e67d392017-01-20 13:03:52 +010067AC_CHECK_FUNCS([socket inet_aton usleep sigaction])
David McGrewb67061f2005-09-28 14:23:06 +000068
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000069dnl Find socket function if not found yet.
70if test "x$ac_cv_func_socket" = "xno"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +010071 AC_CHECK_LIB([socket], [socket])
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000072 AC_MSG_CHECKING([for socket in -lwsock32])
73 SAVELIBS="$LIBS"
74 LIBS="$LIBS -lwsock32"
Alexander Traudd80ef6c2016-06-16 17:31:35 +020075 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000076#include <winsock2.h>
Alexander Traudd80ef6c2016-06-16 17:31:35 +020077]], [[
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000078socket(0, 0, 0);
Alexander Traudd80ef6c2016-06-16 17:31:35 +020079]])],[ac_cv_func_socket=yes
Idar Tollefsen5e67d392017-01-20 13:03:52 +010080 AC_MSG_RESULT([yes])],[LIBS="$SAVELIBS"
81 AC_MSG_RESULT([no])])
Marcus Sundberg8046c3a2005-10-02 20:02:05 +000082fi
Cullen Jennings235513a2005-09-21 22:51:36 +000083
Idar Tollefsen5e67d392017-01-20 13:03:52 +010084AC_MSG_CHECKING([whether to compile in debugging])
85AC_ARG_ENABLE([debug],
86 [AS_HELP_STRING([--disable-debug], [do not compile in dynamic debugging system])],
87 [], [enable_debug=yes])
David McGrewb67061f2005-09-28 14:23:06 +000088if test "$enable_debug" = "yes"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +010089 AC_DEFINE([ENABLE_DEBUGGING], [1], [Define to compile in dynamic debugging system.])
Cullen Jennings235513a2005-09-21 22:51:36 +000090fi
Idar Tollefsen5e67d392017-01-20 13:03:52 +010091AC_MSG_RESULT([$enable_debug])
Cullen Jennings235513a2005-09-21 22:51:36 +000092
Idar Tollefsen5e67d392017-01-20 13:03:52 +010093AC_MSG_CHECKING([whether to use ISMAcryp code])
94AC_ARG_ENABLE([generic-aesicm],
95 [AS_HELP_STRING([--enable-generic-aesicm], [compile in changes for ISMAcryp])],
96 [], [enable_generic_aesicm=no])
David McGrewb67061f2005-09-28 14:23:06 +000097if test "$enable_generic_aesicm" = "yes"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +010098 AC_DEFINE([GENERIC_AESICM], [1], [Define this to use ISMAcryp code.])
Cullen Jennings235513a2005-09-21 22:51:36 +000099fi
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100100AC_MSG_RESULT([$enable_generic_aesicm])
Cullen Jennings235513a2005-09-21 22:51:36 +0000101
Michael Thomas (malinka)1d4460d2016-06-04 19:59:31 -0400102PKG_PROG_PKG_CONFIG
103
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100104AC_MSG_CHECKING([whether to leverage OpenSSL crypto])
105AC_ARG_ENABLE([openssl],
106 [AS_HELP_STRING([--enable-openssl], [compile in OpenSSL crypto engine])],
107 [], [enable_openssl=no])
108AC_MSG_RESULT([$enable_openssl])
jfigusa14b5a02013-03-29 12:24:12 -0400109if test "$enable_openssl" = "yes"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100110 AC_MSG_CHECKING([for user specified OpenSSL directory])
111 AC_ARG_WITH([openssl-dir],
jfigus038d2cf2015-05-11 14:10:11 -0400112 [AS_HELP_STRING([--with-openssl-dir], [Location of OpenSSL installation])],
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100113 [openssl_dir="$withval"
114 AC_MSG_RESULT([openssl_dir])],
115 [openssl_dir=""
116 AC_MSG_RESULT([no])])
jfigus038d2cf2015-05-11 14:10:11 -0400117
Michael Thomas (malinka)df9fe1a2016-06-04 20:00:00 -0400118 LDFLAGS="$LDFLAGS -L$openssl_dir/lib $($PKG_CONFIG --libs openssl)";
119 CFLAGS="$CFLAGS -I$openssl_dir/include $($PKG_CONFIG --cflags openssl)";
Cullen Jenningse1de50f2013-05-22 12:27:28 -0600120
jfigusb5fad5f2015-02-26 12:25:08 -0500121 AC_CHECK_LIB([dl], [dlopen], [],
jfigus13fd6942015-03-02 09:09:13 -0500122 [AC_MSG_WARN([can't find libdl])])
jfigusb5fad5f2015-02-26 12:25:08 -0500123 AC_CHECK_LIB([z], [inflate], [],
jfigus13fd6942015-03-02 09:09:13 -0500124 [AC_MSG_WARN([can't find libz])])
jfigusa14b5a02013-03-29 12:24:12 -0400125 AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
jfigus5b22e372013-05-09 09:23:26 -0400126 [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
127 AC_CHECK_LIB([crypto], [EVP_aes_128_ctr], [],
128 [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
jfigus7882dd92013-08-02 16:08:23 -0400129 AC_CHECK_LIB([crypto], [EVP_aes_128_gcm], [],
130 [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100131 AC_DEFINE([OPENSSL], [1], [Define this to use OpenSSL crypto.])
jfigus7882dd92013-08-02 16:08:23 -0400132 AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o"
jfigus0d3a2682013-04-02 15:42:37 -0400133 HMAC_OBJS=crypto/hash/hmac_ossl.o
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100134 AC_SUBST([USE_OPENSSL], [1])
jfigus038d2cf2015-05-11 14:10:11 -0400135
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100136 AC_MSG_CHECKING([whether to leverage OpenSSL KDF algorithm])
137 AC_ARG_ENABLE([openssl-kdf],
jfigus038d2cf2015-05-11 14:10:11 -0400138 [AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])],
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100139 [], [enable_openssl_kdf=no])
140 AC_MSG_RESULT([$enable_openssl_kdf])
jfigus038d2cf2015-05-11 14:10:11 -0400141 if test "$enable_openssl_kdf" = "yes"; then
142 AC_CHECK_LIB([crypto], [kdf_srtp], [],
143 [AC_MSG_FAILURE([can't find openssl KDF lib])])
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100144 AC_DEFINE([OPENSSL_KDF], [1], [Define this to use OpenSSL KDF for SRTP.])
jfigus038d2cf2015-05-11 14:10:11 -0400145 fi
jfigusa14b5a02013-03-29 12:24:12 -0400146else
jfigusa3127b82014-11-19 14:46:52 -0500147 AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o"
jfigus0d3a2682013-04-02 15:42:37 -0400148 HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"
jfigusa14b5a02013-03-29 12:24:12 -0400149fi
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100150AC_SUBST([AES_ICM_OBJS])
151AC_SUBST([HMAC_OBJS])
jfigusa14b5a02013-03-29 12:24:12 -0400152
Bernardo Torres79e38ae2014-10-10 05:29:36 -0300153dnl Checking for PCAP
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100154AC_CHECK_LIB([pcap], [pcap_create],
155 [LIBS="-lpcap $LIBS"
156 AC_DEFINE([HAVE_PCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap)])
157 AC_SUBST([HAVE_PCAP], [1])])
Bernardo Torres79e38ae2014-10-10 05:29:36 -0300158
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100159AC_MSG_CHECKING([whether to use stdout for error reporting])
160AC_ARG_ENABLE([stdout],
jfigus97a80f42014-11-04 14:15:40 -0500161 [AS_HELP_STRING([--enable-stdout], [use stdout for debug/error reporting])],
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100162 [], [enable_stdout=no])
David McGrewb67061f2005-09-28 14:23:06 +0000163if test "$enable_stdout" = "yes"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100164 AC_DEFINE([ERR_REPORTING_STDOUT], [1], [Define to use logging to stdout.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000165fi
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100166AC_MSG_RESULT([$enable_stdout])
Cullen Jennings235513a2005-09-21 22:51:36 +0000167
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100168AC_MSG_CHECKING([whether to use /dev/console for error reporting])
169AC_ARG_ENABLE([console],
David McGrewb67061f2005-09-28 14:23:06 +0000170 [AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])],
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100171 [], [enable_console=no])
David McGrewb67061f2005-09-28 14:23:06 +0000172if test "$enable_console" = "yes"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100173 AC_DEFINE([USE_ERR_REPORTING_FILE], [1], [Write errors to this file])
174 AC_DEFINE([ERR_REPORTING_FILE], ["/dev/console"], [Report errors to this file.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000175fi
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100176AC_MSG_RESULT([$enable_console])
Cullen Jennings235513a2005-09-21 22:51:36 +0000177
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100178AC_CONFIG_HEADER([crypto/include/config.h:config_in.h])
Cullen Jennings235513a2005-09-21 22:51:36 +0000179
Idar Tollefsen3edfcef2017-01-20 16:14:51 +0100180AC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile libsrtp2.pc])
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200181AC_OUTPUT
Marcus Sundberg4ce29b22005-09-29 14:29:53 +0000182
183# This is needed when building outside the source dir.
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100184AS_MKDIR_P([crypto/cipher])
185AS_MKDIR_P([crypto/hash])
186AS_MKDIR_P([crypto/kernel])
187AS_MKDIR_P([crypto/math])
188AS_MKDIR_P([crypto/replay])
189AS_MKDIR_P([crypto/test])
190AS_MKDIR_P([doc])
191AS_MKDIR_P([srtp])
192AS_MKDIR_P([test])