Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 1 | dnl Process this file with autoconf to produce a configure script. |
| 2 | AC_INIT(srtp) |
| 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. |
| 7 | CFLAGS="-Wall -O4 -fexpensive-optimizations -funroll-loops" |
| 8 | fi |
| 9 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 10 | dnl Checks for programs. |
| 11 | AC_PROG_RANLIB |
| 12 | AC_PROG_CC |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 13 | AC_PROG_INSTALL |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 14 | |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 15 | dnl Check the byte order |
| 16 | AC_C_BIGENDIAN |
| 17 | |
| 18 | AC_CANONICAL_HOST |
| 19 | |
| 20 | dnl check host_cpu type, set defines appropriately |
| 21 | case $host_cpu in |
Jonathan Lennox | c752816 | 2012-04-26 23:17:21 +0000 | [diff] [blame] | 22 | i*86 | x86_64 ) |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 23 | 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 | * ) |
| 28 | # CPU_RISC is only supported for big endian machines. |
| 29 | if test "$ac_cv_c_bigendian" = "yes"; then |
| 30 | AC_DEFINE(CPU_RISC, 1, |
| 31 | [Define if building for a RISC machine (assume slow byte access).]) |
| 32 | else |
| 33 | AC_DEFINE(CPU_CISC, 1) |
| 34 | fi |
| 35 | ;; |
| 36 | esac |
| 37 | |
| 38 | dnl Check if we are on a Windows platform. |
| 39 | case $host_os in |
| 40 | *cygwin*|*mingw* ) |
| 41 | EXE=.exe |
| 42 | HOST_IS_WINDOWS=yes |
| 43 | ;; |
| 44 | * ) |
| 45 | EXE="" |
| 46 | ;; |
| 47 | esac |
| 48 | AC_SUBST(EXE) # define executable suffix; this is needed for `make clean' |
| 49 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 50 | |
Marcus Sundberg | 7b81b06 | 2005-10-03 15:15:08 +0000 | [diff] [blame] | 51 | AC_ARG_ENABLE(kernel-linux, |
| 52 | [AS_HELP_STRING([--enable-kernel-linux], |
| 53 | [build library to run in Linux kernel context])], |
| 54 | [], enable_kernel_linux=no) |
| 55 | AC_MSG_CHECKING(whether to build for Linux kernel context) |
| 56 | if test "$enable_kernel_linux" = "yes"; then |
| 57 | AC_DEFINE(SRTP_KERNEL, 1, |
| 58 | [Define to compile for kernel contexts.]) |
| 59 | AC_DEFINE(SRTP_KERNEL_LINUX, 1, |
| 60 | [Define to compile for Linux kernel context.]) |
| 61 | fi |
| 62 | AC_MSG_RESULT($enable_kernel_linux) |
| 63 | |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 64 | if test "$cross_compiling" != yes -a "$HOST_IS_WINDOWS" != yes; then |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 65 | dnl Check for /dev/urandom |
| 66 | AC_CHECK_FILE(/dev/urandom, DEV_URANDOM=/dev/urandom, |
| 67 | [AC_CHECK_FILE(/dev/random, DEV_URANDOM=/dev/random)]) |
| 68 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 69 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 70 | |
| 71 | |
| 72 | dnl Checks for header files. |
| 73 | AC_HEADER_STDC |
| 74 | AC_CHECK_HEADERS(stdlib.h) |
| 75 | AC_CHECK_HEADERS(unistd.h) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 76 | AC_CHECK_HEADERS(byteswap.h) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 77 | AC_CHECK_HEADERS(stdint.h) |
| 78 | AC_CHECK_HEADERS(sys/uio.h) |
Randell Jesup | aa85135 | 2005-09-28 22:36:05 +0000 | [diff] [blame] | 79 | AC_CHECK_HEADERS(inttypes.h) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 80 | AC_CHECK_HEADERS(sys/types.h) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 81 | AC_CHECK_HEADERS(machine/types.h) |
| 82 | AC_CHECK_HEADERS(sys/int_types.h) |
| 83 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 84 | dnl socket() and friends |
| 85 | AC_CHECK_HEADERS(sys/socket.h netinet/in.h arpa/inet.h) |
| 86 | AC_CHECK_HEADERS(windows.h, [AC_CHECK_HEADERS(winsock2.h)]) |
| 87 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 88 | AC_CHECK_HEADERS(syslog.h) |
| 89 | |
Randell Jesup | aa85135 | 2005-09-28 22:36:05 +0000 | [diff] [blame] | 90 | 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] | 91 | AC_CHECK_SIZEOF(unsigned long) |
| 92 | AC_CHECK_SIZEOF(unsigned long long) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 93 | |
| 94 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 95 | AC_C_CONST |
| 96 | AC_C_INLINE |
| 97 | AC_TYPE_SIZE_T |
| 98 | |
| 99 | dnl Checks for library functions. |
Jonathan Lennox | 3f7fc22 | 2010-05-17 19:32:02 +0000 | [diff] [blame] | 100 | AC_CHECK_FUNCS(socket inet_aton usleep sigaction) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 101 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 102 | dnl Find socket function if not found yet. |
| 103 | if test "x$ac_cv_func_socket" = "xno"; then |
| 104 | AC_CHECK_LIB(socket, socket) |
| 105 | AC_MSG_CHECKING([for socket in -lwsock32]) |
| 106 | SAVELIBS="$LIBS" |
| 107 | LIBS="$LIBS -lwsock32" |
| 108 | AC_TRY_LINK([ |
| 109 | #include <winsock2.h> |
| 110 | ],[ |
| 111 | socket(0, 0, 0); |
| 112 | ], |
| 113 | ac_cv_func_socket=yes |
| 114 | AC_MSG_RESULT(yes), |
| 115 | LIBS="$SAVELIBS" |
| 116 | AC_MSG_RESULT(no)) |
| 117 | fi |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 118 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 119 | AC_MSG_CHECKING(whether to compile in debugging) |
| 120 | AC_ARG_ENABLE(debug, |
| 121 | [AS_HELP_STRING([--disable-debug], |
| 122 | [do not compile in dynamic debugging system])], |
| 123 | [], enable_debug=yes) |
| 124 | if test "$enable_debug" = "yes"; then |
| 125 | AC_DEFINE(ENABLE_DEBUGGING, 1, |
| 126 | [Define to compile in dynamic debugging system.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 127 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 128 | AC_MSG_RESULT($enable_debug) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 129 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 130 | AC_MSG_CHECKING(whether to use ISMAcryp code) |
| 131 | AC_ARG_ENABLE(generic-aesicm, |
| 132 | [AS_HELP_STRING([--enable-generic-aesicm], |
| 133 | [compile in changes for ISMAcryp])], |
| 134 | [], enable_generic_aesicm=no) |
| 135 | if test "$enable_generic_aesicm" = "yes"; then |
| 136 | AC_DEFINE(GENERIC_AESICM, 1, [Define this to use ISMAcryp code.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 137 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 138 | AC_MSG_RESULT($enable_generic_aesicm) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 139 | |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 140 | AC_MSG_CHECKING(whether to leverage OpenSSL crypto) |
| 141 | AC_ARG_ENABLE(openssl, |
| 142 | [AS_HELP_STRING([--enable-openssl], |
| 143 | [compile in OpenSSL crypto engine])], |
| 144 | [], enable_openssl=no) |
| 145 | if test "$enable_openssl" = "yes"; then |
| 146 | AC_CHECK_LIB([crypto], [EVP_EncryptInit], [], |
jfigus | 5b22e37 | 2013-05-09 09:23:26 -0400 | [diff] [blame^] | 147 | [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) |
| 148 | AC_CHECK_LIB([crypto], [EVP_aes_128_ctr], [], |
| 149 | [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 150 | AC_DEFINE(OPENSSL, 1, [Define this to use OpenSSL crypto.]) |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 151 | AES_ICM_OBJS=crypto/cipher/aes_icm_ossl.o |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 152 | RNG_OBJS=rand_source_ossl.o |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 153 | HMAC_OBJS=crypto/hash/hmac_ossl.o |
| 154 | USE_OPENSSL=1 |
| 155 | AC_SUBST(USE_OPENSSL) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 156 | else |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 157 | AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o crypto/cipher/aes_cbc.o" |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 158 | AC_MSG_CHECKING(which random device to use) |
| 159 | if test "$enable_kernel_linux" = "yes"; then |
| 160 | RNG_OBJS=rand_linux_kernel.o |
| 161 | AC_MSG_RESULT([Linux kernel builtin]) |
| 162 | else |
| 163 | RNG_OBJS=rand_source.o |
| 164 | if test -n "$DEV_URANDOM"; then |
| 165 | AC_DEFINE_UNQUOTED(DEV_URANDOM, "$DEV_URANDOM",[Path to random device]) |
| 166 | AC_MSG_RESULT([$DEV_URANDOM]) |
| 167 | else |
| 168 | AC_MSG_RESULT([standard rand() function...]) |
| 169 | fi |
| 170 | fi |
| 171 | RNG_EXTRA_OBJS="crypto/rng/prng.o crypto/rng/ctr_prng.o" |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 172 | HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o" |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 173 | fi |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 174 | AC_SUBST(AES_ICM_OBJS) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 175 | AC_SUBST(RNG_OBJS) |
| 176 | AC_SUBST(RNG_EXTRA_OBJS) |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 177 | AC_SUBST(HMAC_OBJS) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 178 | AC_MSG_RESULT($enable_openssl) |
| 179 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 180 | AC_MSG_CHECKING(whether to use syslog for error reporting) |
| 181 | AC_ARG_ENABLE(syslog, |
| 182 | [AS_HELP_STRING([--enable-syslog], [use syslog for error reporting])], |
| 183 | [], enable_syslog=no) |
| 184 | if test "$enable_syslog" = "yes"; then |
| 185 | AC_DEFINE(USE_SYSLOG, 1, [Define to use syslog logging.]) |
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_syslog) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 188 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 189 | AC_MSG_CHECKING(whether to use stdout for error reporting) |
| 190 | AC_ARG_ENABLE(stdout, |
| 191 | [AS_HELP_STRING([--disable-stdout], [don't use stdout for error reporting])], |
| 192 | [], enable_stdout=yes) |
| 193 | if test "$enable_stdout" = "yes"; then |
| 194 | AC_DEFINE(ERR_REPORTING_STDOUT, 1, [Define to use logging to stdout.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 195 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 196 | AC_MSG_RESULT($enable_stdout) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 197 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 198 | AC_MSG_CHECKING(whether to use /dev/console for error reporting) |
| 199 | AC_ARG_ENABLE(console, |
| 200 | [AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])], |
| 201 | [], enable_console=no) |
| 202 | if test "$enable_console" = "yes"; then |
| 203 | AC_DEFINE(USE_ERR_REPORTING_FILE, 1, [Write errors to this file]) |
| 204 | AC_DEFINE(ERR_REPORTING_FILE, "/dev/console", [Report errors to this file.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 205 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 206 | AC_MSG_RESULT($enable_console) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 207 | |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 208 | AC_MSG_CHECKING(whether to use GDOI key management) |
| 209 | AC_ARG_ENABLE(gdoi, |
| 210 | [AS_HELP_STRING([--enable-gdoi], [enable GDOI key management])], |
| 211 | [], enable_gdoi=no) |
| 212 | if test "$enable_gdoi" = "yes"; then |
| 213 | AC_DEFINE(SRTP_GDOI, 1, [Define to use GDOI.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 214 | GDOI_OBJS=gdoi/srtp+gdoi.o |
| 215 | AC_SUBST(GDOI_OBJS) |
| 216 | fi |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 217 | AC_MSG_RESULT($enable_gdoi) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 218 | |
David McGrew | fec49dd | 2005-09-23 19:34:11 +0000 | [diff] [blame] | 219 | AC_CONFIG_HEADER(crypto/include/config.h:config_in.h) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 220 | |
Marcus Sundberg | efe1273 | 2005-09-29 13:29:21 +0000 | [diff] [blame] | 221 | AC_OUTPUT(Makefile crypto/Makefile doc/Makefile) |
Marcus Sundberg | 4ce29b2 | 2005-09-29 14:29:53 +0000 | [diff] [blame] | 222 | |
| 223 | # This is needed when building outside the source dir. |
| 224 | AS_MKDIR_P(crypto/ae_xfm) |
| 225 | AS_MKDIR_P(crypto/cipher) |
| 226 | AS_MKDIR_P(crypto/hash) |
| 227 | AS_MKDIR_P(crypto/kernel) |
| 228 | AS_MKDIR_P(crypto/math) |
| 229 | AS_MKDIR_P(crypto/replay) |
| 230 | AS_MKDIR_P(crypto/rng) |
| 231 | AS_MKDIR_P(crypto/test) |
| 232 | AS_MKDIR_P(doc) |
| 233 | AS_MKDIR_P(srtp) |
| 234 | AS_MKDIR_P(tables) |
| 235 | AS_MKDIR_P(test) |