Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1 | dnl Process this file with autoconf to produce a configure script. |
Pascal Bühler | 34acba6 | 2017-01-19 10:57:30 +0100 | [diff] [blame] | 2 | AC_INIT([libsrtp2], [2.1.0-pre], [https://github.com/cisco/libsrtp/issues]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 3 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 4 | dnl Must come before AC_PROG_CC |
Idar Tollefsen | 27d857c | 2017-01-19 15:28:18 +0100 | [diff] [blame] | 5 | if test "x$CFLAGS" = "x"; then |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 6 | dnl Default value for CFLAGS if not specified. |
Alexander Traud | 1265858 | 2016-10-15 21:53:20 +0200 | [diff] [blame] | 7 | CFLAGS="-Wall -pedantic -O4 -fexpensive-optimizations -funroll-loops" |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 8 | fi |
| 9 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 10 | dnl Checks for programs. |
Alexander Traud | 52c30db | 2016-06-16 17:24:18 +0200 | [diff] [blame] | 11 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 12 | AC_PROG_RANLIB |
| 13 | AC_PROG_CC |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 14 | AC_PROG_INSTALL |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 15 | |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 16 | dnl Check the byte order |
| 17 | AC_C_BIGENDIAN |
| 18 | |
| 19 | AC_CANONICAL_HOST |
| 20 | |
| 21 | dnl check host_cpu type, set defines appropriately |
| 22 | case $host_cpu in |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 23 | i*86 | x86_64 ) |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 24 | 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 Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 26 | ;; |
| 27 | * ) |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 28 | AC_DEFINE([CPU_RISC], [1], [Define if building for a RISC machine (assume slow byte access).]) |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 29 | ;; |
| 30 | esac |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 31 | |
| 32 | dnl Check if we are on a Windows platform. |
| 33 | case $host_os in |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 34 | *cygwin*|*mingw* ) |
| 35 | EXE=.exe |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 36 | ;; |
| 37 | * ) |
| 38 | EXE="" |
| 39 | ;; |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 40 | esac |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 41 | AC_SUBST([EXE]) # define executable suffix; this is needed for `make clean' |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 42 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 43 | |
| 44 | dnl Checks for header files. |
| 45 | AC_HEADER_STDC |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 46 | AC_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 Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 49 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 50 | dnl socket() and friends |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 51 | AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h], [], [], [AC_INCLUDES_DEFAULT]) |
| 52 | AC_CHECK_HEADERS( |
| 53 | [windows.h], |
| 54 | [AC_CHECK_HEADERS([winsock2.h], [], [], [AC_INCLUDES_DEFAULT])], |
| 55 | [], [AC_INCLUDES_DEFAULT]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 56 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 57 | AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, uint64_t]) |
| 58 | AC_CHECK_SIZEOF([unsigned long]) |
| 59 | AC_CHECK_SIZEOF([unsigned long long]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 60 | |
| 61 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 62 | AC_C_CONST |
| 63 | AC_C_INLINE |
| 64 | AC_TYPE_SIZE_T |
| 65 | |
| 66 | dnl Checks for library functions. |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 67 | AC_CHECK_FUNCS([socket inet_aton usleep sigaction]) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 68 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 69 | dnl Find socket function if not found yet. |
| 70 | if test "x$ac_cv_func_socket" = "xno"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 71 | AC_CHECK_LIB([socket], [socket]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 72 | AC_MSG_CHECKING([for socket in -lwsock32]) |
| 73 | SAVELIBS="$LIBS" |
| 74 | LIBS="$LIBS -lwsock32" |
Alexander Traud | d80ef6c | 2016-06-16 17:31:35 +0200 | [diff] [blame] | 75 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 76 | #include <winsock2.h> |
Alexander Traud | d80ef6c | 2016-06-16 17:31:35 +0200 | [diff] [blame] | 77 | ]], [[ |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 78 | socket(0, 0, 0); |
Alexander Traud | d80ef6c | 2016-06-16 17:31:35 +0200 | [diff] [blame] | 79 | ]])],[ac_cv_func_socket=yes |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 80 | AC_MSG_RESULT([yes])],[LIBS="$SAVELIBS" |
| 81 | AC_MSG_RESULT([no])]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 82 | fi |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 83 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 84 | AC_MSG_CHECKING([whether to compile in debugging]) |
| 85 | AC_ARG_ENABLE([debug], |
| 86 | [AS_HELP_STRING([--disable-debug], [do not compile in dynamic debugging system])], |
| 87 | [], [enable_debug=yes]) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 88 | if test "$enable_debug" = "yes"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 89 | AC_DEFINE([ENABLE_DEBUGGING], [1], [Define to compile in dynamic debugging system.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 90 | fi |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 91 | AC_MSG_RESULT([$enable_debug]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 92 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 93 | AC_MSG_CHECKING([whether to use ISMAcryp code]) |
| 94 | AC_ARG_ENABLE([generic-aesicm], |
| 95 | [AS_HELP_STRING([--enable-generic-aesicm], [compile in changes for ISMAcryp])], |
| 96 | [], [enable_generic_aesicm=no]) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 97 | if test "$enable_generic_aesicm" = "yes"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 98 | AC_DEFINE([GENERIC_AESICM], [1], [Define this to use ISMAcryp code.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 99 | fi |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 100 | AC_MSG_RESULT([$enable_generic_aesicm]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 101 | |
Michael Thomas (malinka) | 1d4460d | 2016-06-04 19:59:31 -0400 | [diff] [blame] | 102 | PKG_PROG_PKG_CONFIG |
| 103 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 104 | AC_MSG_CHECKING([whether to leverage OpenSSL crypto]) |
| 105 | AC_ARG_ENABLE([openssl], |
| 106 | [AS_HELP_STRING([--enable-openssl], [compile in OpenSSL crypto engine])], |
| 107 | [], [enable_openssl=no]) |
| 108 | AC_MSG_RESULT([$enable_openssl]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 109 | if test "$enable_openssl" = "yes"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 110 | AC_MSG_CHECKING([for user specified OpenSSL directory]) |
| 111 | AC_ARG_WITH([openssl-dir], |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 112 | [AS_HELP_STRING([--with-openssl-dir], [Location of OpenSSL installation])], |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 113 | [openssl_dir="$withval" |
| 114 | AC_MSG_RESULT([openssl_dir])], |
| 115 | [openssl_dir="" |
| 116 | AC_MSG_RESULT([no])]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 117 | |
Michael Thomas (malinka) | df9fe1a | 2016-06-04 20:00:00 -0400 | [diff] [blame] | 118 | LDFLAGS="$LDFLAGS -L$openssl_dir/lib $($PKG_CONFIG --libs openssl)"; |
| 119 | CFLAGS="$CFLAGS -I$openssl_dir/include $($PKG_CONFIG --cflags openssl)"; |
Cullen Jennings | e1de50f | 2013-05-22 12:27:28 -0600 | [diff] [blame] | 120 | |
jfigus | b5fad5f | 2015-02-26 12:25:08 -0500 | [diff] [blame] | 121 | AC_CHECK_LIB([dl], [dlopen], [], |
jfigus | 13fd694 | 2015-03-02 09:09:13 -0500 | [diff] [blame] | 122 | [AC_MSG_WARN([can't find libdl])]) |
jfigus | b5fad5f | 2015-02-26 12:25:08 -0500 | [diff] [blame] | 123 | AC_CHECK_LIB([z], [inflate], [], |
jfigus | 13fd694 | 2015-03-02 09:09:13 -0500 | [diff] [blame] | 124 | [AC_MSG_WARN([can't find libz])]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 125 | AC_CHECK_LIB([crypto], [EVP_EncryptInit], [], |
jfigus | 5b22e37 | 2013-05-09 09:23:26 -0400 | [diff] [blame] | 126 | [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])]) |
jfigus | 7882dd9 | 2013-08-02 16:08:23 -0400 | [diff] [blame] | 129 | AC_CHECK_LIB([crypto], [EVP_aes_128_gcm], [], |
| 130 | [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 131 | AC_DEFINE([OPENSSL], [1], [Define this to use OpenSSL crypto.]) |
jfigus | 7882dd9 | 2013-08-02 16:08:23 -0400 | [diff] [blame] | 132 | AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o" |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 133 | HMAC_OBJS=crypto/hash/hmac_ossl.o |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 134 | AC_SUBST([USE_OPENSSL], [1]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 135 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 136 | AC_MSG_CHECKING([whether to leverage OpenSSL KDF algorithm]) |
| 137 | AC_ARG_ENABLE([openssl-kdf], |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 138 | [AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])], |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 139 | [], [enable_openssl_kdf=no]) |
| 140 | AC_MSG_RESULT([$enable_openssl_kdf]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 141 | 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 Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 144 | AC_DEFINE([OPENSSL_KDF], [1], [Define this to use OpenSSL KDF for SRTP.]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 145 | fi |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 146 | else |
jfigus | a3127b8 | 2014-11-19 14:46:52 -0500 | [diff] [blame] | 147 | AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o" |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 148 | HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o" |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 149 | fi |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 150 | AC_SUBST([AES_ICM_OBJS]) |
| 151 | AC_SUBST([HMAC_OBJS]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 152 | |
Bernardo Torres | 79e38ae | 2014-10-10 05:29:36 -0300 | [diff] [blame] | 153 | dnl Checking for PCAP |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 154 | AC_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 Torres | 79e38ae | 2014-10-10 05:29:36 -0300 | [diff] [blame] | 158 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 159 | AC_MSG_CHECKING([whether to use stdout for error reporting]) |
| 160 | AC_ARG_ENABLE([stdout], |
jfigus | 97a80f4 | 2014-11-04 14:15:40 -0500 | [diff] [blame] | 161 | [AS_HELP_STRING([--enable-stdout], [use stdout for debug/error reporting])], |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 162 | [], [enable_stdout=no]) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 163 | if test "$enable_stdout" = "yes"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 164 | AC_DEFINE([ERR_REPORTING_STDOUT], [1], [Define to use logging to stdout.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 165 | fi |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 166 | AC_MSG_RESULT([$enable_stdout]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 167 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 168 | AC_MSG_CHECKING([whether to use /dev/console for error reporting]) |
| 169 | AC_ARG_ENABLE([console], |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 170 | [AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])], |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 171 | [], [enable_console=no]) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 172 | if test "$enable_console" = "yes"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 173 | 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 Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 175 | fi |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 176 | AC_MSG_RESULT([$enable_console]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 177 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 178 | AC_CONFIG_HEADER([crypto/include/config.h:config_in.h]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 179 | |
Idar Tollefsen | 3edfcef | 2017-01-20 16:14:51 +0100 | [diff] [blame^] | 180 | AC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile libsrtp2.pc]) |
Saúl Ibarra Corretgé | b86063c | 2014-10-01 11:23:24 +0200 | [diff] [blame] | 181 | AC_OUTPUT |
Marcus Sundberg | 4ce29b2 | 2005-09-29 14:29:53 +0000 | [diff] [blame] | 182 | |
| 183 | # This is needed when building outside the source dir. |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 184 | AS_MKDIR_P([crypto/cipher]) |
| 185 | AS_MKDIR_P([crypto/hash]) |
| 186 | AS_MKDIR_P([crypto/kernel]) |
| 187 | AS_MKDIR_P([crypto/math]) |
| 188 | AS_MKDIR_P([crypto/replay]) |
| 189 | AS_MKDIR_P([crypto/test]) |
| 190 | AS_MKDIR_P([doc]) |
| 191 | AS_MKDIR_P([srtp]) |
| 192 | AS_MKDIR_P([test]) |