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 |
| 5 | if test -z "$CFLAGS"; then |
| 6 | dnl Default value for CFLAGS if not specified. |
Alexander Traud | 536bd51 | 2016-06-16 17:43:58 +0200 | [diff] [blame] | 7 | CFLAGS="-Wall -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 |
Jonathan Lennox | c752816 | 2012-04-26 23:17:21 +0000 | [diff] [blame] | 23 | i*86 | x86_64 ) |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 24 | AC_DEFINE(CPU_CISC, 1, |
| 25 | [Define if building for a CISC machine (e.g. Intel).]) |
| 26 | AC_DEFINE(HAVE_X86, 1, |
| 27 | [Define to use X86 inlined assembly code]);; |
| 28 | * ) |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 29 | AC_DEFINE(CPU_RISC, 1, |
| 30 | [Define if building for a RISC machine (assume slow byte access).]) |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 31 | ;; |
| 32 | esac |
| 33 | |
| 34 | dnl Check if we are on a Windows platform. |
| 35 | case $host_os in |
| 36 | *cygwin*|*mingw* ) |
| 37 | EXE=.exe |
| 38 | HOST_IS_WINDOWS=yes |
| 39 | ;; |
| 40 | * ) |
| 41 | EXE="" |
| 42 | ;; |
| 43 | esac |
| 44 | AC_SUBST(EXE) # define executable suffix; this is needed for `make clean' |
| 45 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 46 | |
| 47 | dnl Checks for header files. |
| 48 | AC_HEADER_STDC |
| 49 | AC_CHECK_HEADERS(stdlib.h) |
| 50 | AC_CHECK_HEADERS(unistd.h) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 51 | AC_CHECK_HEADERS(byteswap.h) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 52 | AC_CHECK_HEADERS(stdint.h) |
| 53 | AC_CHECK_HEADERS(sys/uio.h) |
Randell Jesup | aa85135 | 2005-09-28 22:36:05 +0000 | [diff] [blame] | 54 | AC_CHECK_HEADERS(inttypes.h) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 55 | AC_CHECK_HEADERS(sys/types.h) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 56 | AC_CHECK_HEADERS(machine/types.h) |
| 57 | AC_CHECK_HEADERS(sys/int_types.h) |
| 58 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 59 | dnl socket() and friends |
| 60 | AC_CHECK_HEADERS(sys/socket.h netinet/in.h arpa/inet.h) |
| 61 | AC_CHECK_HEADERS(windows.h, [AC_CHECK_HEADERS(winsock2.h)]) |
| 62 | |
Randell Jesup | aa85135 | 2005-09-28 22:36:05 +0000 | [diff] [blame] | 63 | AC_CHECK_TYPES([int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,uint64_t]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 64 | AC_CHECK_SIZEOF(unsigned long) |
| 65 | AC_CHECK_SIZEOF(unsigned long long) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 66 | |
| 67 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 68 | AC_C_CONST |
| 69 | AC_C_INLINE |
| 70 | AC_TYPE_SIZE_T |
| 71 | |
| 72 | dnl Checks for library functions. |
Jonathan Lennox | 3f7fc22 | 2010-05-17 19:32:02 +0000 | [diff] [blame] | 73 | AC_CHECK_FUNCS(socket inet_aton usleep sigaction) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 74 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 75 | dnl Find socket function if not found yet. |
| 76 | if test "x$ac_cv_func_socket" = "xno"; then |
| 77 | AC_CHECK_LIB(socket, socket) |
| 78 | AC_MSG_CHECKING([for socket in -lwsock32]) |
| 79 | SAVELIBS="$LIBS" |
| 80 | LIBS="$LIBS -lwsock32" |
Alexander Traud | d80ef6c | 2016-06-16 17:31:35 +0200 | [diff] [blame] | 81 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 82 | #include <winsock2.h> |
Alexander Traud | d80ef6c | 2016-06-16 17:31:35 +0200 | [diff] [blame] | 83 | ]], [[ |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 84 | socket(0, 0, 0); |
Alexander Traud | d80ef6c | 2016-06-16 17:31:35 +0200 | [diff] [blame] | 85 | ]])],[ac_cv_func_socket=yes |
| 86 | AC_MSG_RESULT(yes)],[LIBS="$SAVELIBS" |
| 87 | AC_MSG_RESULT(no)]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 88 | fi |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 89 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 90 | AC_MSG_CHECKING(whether to compile in debugging) |
| 91 | AC_ARG_ENABLE(debug, |
| 92 | [AS_HELP_STRING([--disable-debug], |
| 93 | [do not compile in dynamic debugging system])], |
| 94 | [], enable_debug=yes) |
| 95 | if test "$enable_debug" = "yes"; then |
| 96 | AC_DEFINE(ENABLE_DEBUGGING, 1, |
| 97 | [Define to compile in dynamic debugging system.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 98 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 99 | AC_MSG_RESULT($enable_debug) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 100 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 101 | AC_MSG_CHECKING(whether to use ISMAcryp code) |
| 102 | AC_ARG_ENABLE(generic-aesicm, |
| 103 | [AS_HELP_STRING([--enable-generic-aesicm], |
| 104 | [compile in changes for ISMAcryp])], |
| 105 | [], enable_generic_aesicm=no) |
| 106 | if test "$enable_generic_aesicm" = "yes"; then |
| 107 | AC_DEFINE(GENERIC_AESICM, 1, [Define this to use ISMAcryp code.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 108 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 109 | AC_MSG_RESULT($enable_generic_aesicm) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 110 | |
Michael Thomas (malinka) | 1d4460d | 2016-06-04 19:59:31 -0400 | [diff] [blame] | 111 | PKG_PROG_PKG_CONFIG |
| 112 | |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 113 | AC_MSG_CHECKING(whether to leverage OpenSSL crypto) |
| 114 | AC_ARG_ENABLE(openssl, |
| 115 | [AS_HELP_STRING([--enable-openssl], |
| 116 | [compile in OpenSSL crypto engine])], |
| 117 | [], enable_openssl=no) |
jfigus | 2b48665 | 2014-07-24 15:01:41 -0400 | [diff] [blame] | 118 | AC_MSG_RESULT($enable_openssl) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 119 | if test "$enable_openssl" = "yes"; then |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 120 | AC_MSG_CHECKING(for user specified OpenSSL directory) |
| 121 | AC_ARG_WITH(openssl-dir, |
| 122 | [AS_HELP_STRING([--with-openssl-dir], [Location of OpenSSL installation])], |
| 123 | [openssl_dir="$withval"], openssl_dir="") |
| 124 | |
Michael Thomas (malinka) | df9fe1a | 2016-06-04 20:00:00 -0400 | [diff] [blame] | 125 | LDFLAGS="$LDFLAGS -L$openssl_dir/lib $($PKG_CONFIG --libs openssl)"; |
| 126 | CFLAGS="$CFLAGS -I$openssl_dir/include $($PKG_CONFIG --cflags openssl)"; |
Cullen Jennings | e1de50f | 2013-05-22 12:27:28 -0600 | [diff] [blame] | 127 | |
jfigus | b5fad5f | 2015-02-26 12:25:08 -0500 | [diff] [blame] | 128 | AC_CHECK_LIB([dl], [dlopen], [], |
jfigus | 13fd694 | 2015-03-02 09:09:13 -0500 | [diff] [blame] | 129 | [AC_MSG_WARN([can't find libdl])]) |
jfigus | b5fad5f | 2015-02-26 12:25:08 -0500 | [diff] [blame] | 130 | AC_CHECK_LIB([z], [inflate], [], |
jfigus | 13fd694 | 2015-03-02 09:09:13 -0500 | [diff] [blame] | 131 | [AC_MSG_WARN([can't find libz])]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 132 | AC_CHECK_LIB([crypto], [EVP_EncryptInit], [], |
jfigus | 5b22e37 | 2013-05-09 09:23:26 -0400 | [diff] [blame] | 133 | [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) |
| 134 | AC_CHECK_LIB([crypto], [EVP_aes_128_ctr], [], |
| 135 | [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) |
jfigus | 7882dd9 | 2013-08-02 16:08:23 -0400 | [diff] [blame] | 136 | AC_CHECK_LIB([crypto], [EVP_aes_128_gcm], [], |
| 137 | [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 138 | AC_DEFINE(OPENSSL, 1, [Define this to use OpenSSL crypto.]) |
jfigus | 7882dd9 | 2013-08-02 16:08:23 -0400 | [diff] [blame] | 139 | 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] | 140 | HMAC_OBJS=crypto/hash/hmac_ossl.o |
| 141 | USE_OPENSSL=1 |
| 142 | AC_SUBST(USE_OPENSSL) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 143 | |
| 144 | AC_MSG_CHECKING(whether to leverage OpenSSL KDF algorithm) |
| 145 | AC_ARG_ENABLE(openssl-kdf, |
| 146 | [AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])], |
| 147 | [], enable_openssl_kdf=no) |
| 148 | AC_MSG_RESULT($enable_openssl_kdf) |
| 149 | if test "$enable_openssl_kdf" = "yes"; then |
| 150 | AC_CHECK_LIB([crypto], [kdf_srtp], [], |
| 151 | [AC_MSG_FAILURE([can't find openssl KDF lib])]) |
| 152 | AC_DEFINE(OPENSSL_KDF, 1, [Define this to use OpenSSL KDF for SRTP.]) |
| 153 | fi |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 154 | else |
jfigus | a3127b8 | 2014-11-19 14:46:52 -0500 | [diff] [blame] | 155 | AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o" |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 156 | HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o" |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 157 | fi |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 158 | AC_SUBST(AES_ICM_OBJS) |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 159 | AC_SUBST(HMAC_OBJS) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 160 | |
Bernardo Torres | 79e38ae | 2014-10-10 05:29:36 -0300 | [diff] [blame] | 161 | dnl Checking for PCAP |
Bernardo Torres | b3c5142 | 2014-10-14 12:40:09 -0300 | [diff] [blame] | 162 | AC_CHECK_LIB([pcap],[pcap_create], |
| 163 | [PCAP=1 |
| 164 | LIBS="-lpcap $LIBS" |
| 165 | HAVE_PCAP=1 |
| 166 | AC_DEFINE(HAVE_PCAP, 1, [Define to 1 if you have the `pcap' library (-lpcap)]) |
| 167 | AC_SUBST(HAVE_PCAP) |
| 168 | ]) |
Bernardo Torres | 79e38ae | 2014-10-10 05:29:36 -0300 | [diff] [blame] | 169 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 170 | AC_MSG_CHECKING(whether to use stdout for error reporting) |
| 171 | AC_ARG_ENABLE(stdout, |
jfigus | 97a80f4 | 2014-11-04 14:15:40 -0500 | [diff] [blame] | 172 | [AS_HELP_STRING([--enable-stdout], [use stdout for debug/error reporting])], |
| 173 | [], enable_stdout=no) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 174 | if test "$enable_stdout" = "yes"; then |
| 175 | AC_DEFINE(ERR_REPORTING_STDOUT, 1, [Define to use logging to stdout.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 176 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 177 | AC_MSG_RESULT($enable_stdout) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 178 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 179 | AC_MSG_CHECKING(whether to use /dev/console for error reporting) |
| 180 | AC_ARG_ENABLE(console, |
| 181 | [AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])], |
| 182 | [], enable_console=no) |
| 183 | if test "$enable_console" = "yes"; then |
| 184 | AC_DEFINE(USE_ERR_REPORTING_FILE, 1, [Write errors to this file]) |
| 185 | AC_DEFINE(ERR_REPORTING_FILE, "/dev/console", [Report errors to this file.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 186 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 187 | AC_MSG_RESULT($enable_console) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 188 | |
David McGrew | fec49dd | 2005-09-23 19:34:11 +0000 | [diff] [blame] | 189 | AC_CONFIG_HEADER(crypto/include/config.h:config_in.h) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 190 | |
Saúl Ibarra Corretgé | b86063c | 2014-10-01 11:23:24 +0200 | [diff] [blame] | 191 | if test "x$PKG_CONFIG" != "x"; then |
| 192 | HAVE_PKG_CONFIG=1 |
jfigus | d196e02 | 2014-11-20 16:43:44 -0500 | [diff] [blame] | 193 | AC_CONFIG_FILES([libsrtp2.pc]) |
Saúl Ibarra Corretgé | b86063c | 2014-10-01 11:23:24 +0200 | [diff] [blame] | 194 | else |
| 195 | HAVE_PKG_CONFIG=0 |
| 196 | fi |
| 197 | AC_SUBST(HAVE_PKG_CONFIG) |
| 198 | AC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile]) |
| 199 | AC_OUTPUT |
Marcus Sundberg | 4ce29b2 | 2005-09-29 14:29:53 +0000 | [diff] [blame] | 200 | |
| 201 | # This is needed when building outside the source dir. |
Marcus Sundberg | 4ce29b2 | 2005-09-29 14:29:53 +0000 | [diff] [blame] | 202 | AS_MKDIR_P(crypto/cipher) |
| 203 | AS_MKDIR_P(crypto/hash) |
| 204 | AS_MKDIR_P(crypto/kernel) |
| 205 | AS_MKDIR_P(crypto/math) |
| 206 | AS_MKDIR_P(crypto/replay) |
Marcus Sundberg | 4ce29b2 | 2005-09-29 14:29:53 +0000 | [diff] [blame] | 207 | AS_MKDIR_P(crypto/test) |
| 208 | AS_MKDIR_P(doc) |
| 209 | AS_MKDIR_P(srtp) |
Marcus Sundberg | 4ce29b2 | 2005-09-29 14:29:53 +0000 | [diff] [blame] | 210 | AS_MKDIR_P(test) |