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 | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 5 | EMPTY_CFLAGS="no" |
Idar Tollefsen | 27d857c | 2017-01-19 15:28:18 +0100 | [diff] [blame] | 6 | if test "x$CFLAGS" = "x"; then |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 7 | dnl Default value for CFLAGS if not specified. |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 8 | EMPTY_CFLAGS="yes" |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 9 | fi |
| 10 | |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 11 | dnl Checks for programs. |
Idar Tollefsen | ba304fc | 2017-05-03 13:09:03 +0200 | [diff] [blame] | 12 | AC_PROG_CC |
| 13 | AC_PROG_CPP |
| 14 | AC_ARG_VAR( |
| 15 | [EXTRA_CFLAGS], |
| 16 | [C compiler flags appended to the regular C compiler flags instead of overriding them]) |
Idar Tollefsen | 38e5076 | 2017-05-03 11:45:15 +0200 | [diff] [blame] | 17 | AM_PROG_AR |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 18 | AC_PROG_RANLIB |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 19 | AC_PROG_INSTALL |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 20 | AC_PROG_SED |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 21 | |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 22 | dnl Check the byte order |
| 23 | AC_C_BIGENDIAN |
| 24 | |
| 25 | AC_CANONICAL_HOST |
| 26 | |
| 27 | dnl check host_cpu type, set defines appropriately |
| 28 | case $host_cpu in |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 29 | i*86 | x86_64 ) |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 30 | AC_DEFINE([CPU_CISC], [1], [Define if building for a CISC machine (e.g. Intel).]) |
| 31 | AC_DEFINE([HAVE_X86], [1], [Define to use X86 inlined assembly code]) |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 32 | ;; |
| 33 | * ) |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 34 | 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] | 35 | ;; |
| 36 | esac |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 37 | |
| 38 | dnl Check if we are on a Windows platform. |
| 39 | case $host_os in |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 40 | *cygwin*|*mingw* ) |
| 41 | EXE=.exe |
Idar Tollefsen | 5fd1187 | 2017-01-19 15:25:12 +0100 | [diff] [blame] | 42 | ;; |
| 43 | * ) |
| 44 | EXE="" |
| 45 | ;; |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 46 | esac |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 47 | AC_SUBST([EXE]) # define executable suffix; this is needed for `make clean' |
Marcus Sundberg | faf84ca | 2007-05-23 17:24:52 +0000 | [diff] [blame] | 48 | |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 49 | dnl Checks for supported compiler flags. |
| 50 | supported_cflags="" |
| 51 | if test "$EMPTY_CFLAGS" = "no"; then |
| 52 | supported_cflags="$CFLAGS" |
| 53 | fi |
| 54 | |
| 55 | dnl For accurate detection, we need warnings as errors. |
| 56 | dnl I.e. Clang will issue a warning about unsupported flags. |
| 57 | dnl For the compilation to fail, those warnings needs to be upgraded to errors. |
| 58 | dnl This will be removed again once the tests are complete (see below). |
| 59 | WERROR="" |
| 60 | for w in -Werror -errwarn; do |
| 61 | if test "x$WERROR" = "x"; then |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 62 | AC_MSG_CHECKING([whether ${CC-c} accepts $w]) |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 63 | save_cflags="$CFLAGS" |
| 64 | AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$w"], [CFLAGS="$CFLAGS $w"]) |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 65 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 66 | [WERROR="$w" |
| 67 | AC_MSG_RESULT([yes])], |
| 68 | [CFLAGS="$save_cflags" |
| 69 | AC_MSG_RESULT([no])]) |
| 70 | fi |
| 71 | done |
| 72 | |
Idar Tollefsen | 475af06 | 2017-03-29 11:40:43 +0200 | [diff] [blame^] | 73 | dnl Note that -fPIC is not explicitly added to LDFLAGS. |
| 74 | dnl Since the compiler is used as the link driver, CFLAGS will be part of the |
| 75 | dnl link line as well and the linker will get the flag from there. |
| 76 | dnl Adding it to LDFLAGS explicitly would duplicate the flag on the link line, |
| 77 | dnl but otherwise do no harm. |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 78 | AC_MSG_CHECKING([whether ${CC-c} accepts -fPIC]) |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 79 | save_cflags="$CFLAGS" |
| 80 | AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="-fPIC"], [CFLAGS="$CFLAGS -fPIC"]) |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 81 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 82 | [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="-fPIC"], [supported_cflags="$supported_cflags -fPIC"]) |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 83 | AC_MSG_RESULT([yes])], |
| 84 | [CFLAGS="$save_cflags" |
| 85 | AC_MSG_RESULT([no])]) |
| 86 | |
| 87 | if test "$EMPTY_CFLAGS" = "yes"; then |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 88 | for f in -Wall -pedantic -Wstrict-prototypes; do |
| 89 | AC_MSG_CHECKING([whether ${CC-c} accepts $f]) |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 90 | save_cflags="$CFLAGS" |
| 91 | AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"]) |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 92 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 93 | [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) |
| 94 | AC_MSG_RESULT([yes])], |
| 95 | [CFLAGS="$save_cflags" |
| 96 | AC_MSG_RESULT([no])]) |
| 97 | done |
| 98 | |
| 99 | OOPT="" |
| 100 | for f in -O4 -O3; do |
| 101 | if test "x$OOPT" = "x"; then |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 102 | AC_MSG_CHECKING([whether ${CC-c} accepts $f]) |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 103 | save_cflags="$CFLAGS" |
| 104 | AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"]) |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 105 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 106 | [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) |
| 107 | OOPT="$f" |
| 108 | AC_MSG_RESULT([yes])], |
| 109 | [CFLAGS="$save_cflags" |
| 110 | AC_MSG_RESULT([no])]) |
| 111 | fi |
| 112 | done |
| 113 | |
| 114 | for f in -fexpensive-optimizations -funroll-loops; do |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 115 | AC_MSG_CHECKING([whether ${CC-c} accepts $f]) |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 116 | save_cflags="$CFLAGS" |
| 117 | AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"]) |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 118 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 119 | [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) |
| 120 | AC_MSG_RESULT([yes])], |
| 121 | [CFLAGS="$save_cflags" |
| 122 | AC_MSG_RESULT([no])]) |
| 123 | done |
| 124 | fi |
| 125 | |
| 126 | dnl When turning off warnigns, we're expecting unrecognized command line option errors if they're not |
| 127 | dnl supported. However, the -Wno-<warning> form isn't consulted unless a warning is triggered. |
Idar Tollefsen | ba304fc | 2017-05-03 13:09:03 +0200 | [diff] [blame] | 128 | dnl At least that's the case for GCC. So to check which warnings we can turn off, we need to check |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 129 | dnl if they can be turned on, thereby forcing GCC to take the argument into account right away. |
| 130 | for f in -Wno-language-extension-token; do |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 131 | AC_MSG_CHECKING([whether ${CC-c} accepts $f]) |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 132 | save_cflags="$CFLAGS" |
| 133 | testf=$(echo "$f" | $SED 's|-Wno-\(.*\)|-W\1|g') |
| 134 | AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$testf"], [CFLAGS="$CFLAGS $testf"]) |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 135 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], |
Idar Tollefsen | 0e79075 | 2017-01-26 10:59:03 +0100 | [diff] [blame] | 136 | [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) |
| 137 | AC_MSG_RESULT([yes])], |
| 138 | [CFLAGS="$save_cflags" |
| 139 | AC_MSG_RESULT([no])]) |
| 140 | done |
| 141 | |
| 142 | dnl Remowing -Werror again |
| 143 | CFLAGS="$supported_cflags" |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 144 | |
| 145 | dnl Checks for header files. |
| 146 | AC_HEADER_STDC |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 147 | AC_CHECK_HEADERS( |
| 148 | [unistd.h byteswap.h stdint.h sys/uio.h inttypes.h sys/types.h machine/types.h sys/int_types.h], |
| 149 | [], [], [AC_INCLUDES_DEFAULT]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 150 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 151 | dnl socket() and friends |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 152 | AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h], [], [], [AC_INCLUDES_DEFAULT]) |
| 153 | AC_CHECK_HEADERS( |
| 154 | [windows.h], |
| 155 | [AC_CHECK_HEADERS([winsock2.h], [], [], [AC_INCLUDES_DEFAULT])], |
| 156 | [], [AC_INCLUDES_DEFAULT]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 157 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 158 | AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, uint64_t]) |
| 159 | AC_CHECK_SIZEOF([unsigned long]) |
| 160 | AC_CHECK_SIZEOF([unsigned long long]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 161 | |
| 162 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 163 | AC_C_CONST |
| 164 | AC_C_INLINE |
| 165 | AC_TYPE_SIZE_T |
| 166 | |
| 167 | dnl Checks for library functions. |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 168 | AC_CHECK_FUNCS([socket inet_aton usleep sigaction]) |
David McGrew | b67061f | 2005-09-28 14:23:06 +0000 | [diff] [blame] | 169 | |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 170 | dnl Find socket function if not found yet. |
| 171 | if test "x$ac_cv_func_socket" = "xno"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 172 | AC_CHECK_LIB([socket], [socket]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 173 | AC_MSG_CHECKING([for socket in -lwsock32]) |
| 174 | SAVELIBS="$LIBS" |
| 175 | LIBS="$LIBS -lwsock32" |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 176 | AC_LINK_IFELSE( |
| 177 | [AC_LANG_SOURCE([ |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 178 | #include <winsock2.h> |
Pascal Bühler | bb6ef8a | 2017-03-29 07:46:21 +0200 | [diff] [blame] | 179 | int main(void) |
| 180 | { |
| 181 | int fd = socket(0, 0, 0); |
| 182 | if (fd < 0) |
| 183 | return -1; |
| 184 | else |
| 185 | return 0; |
| 186 | } |
| 187 | ])], |
| 188 | [ac_cv_func_socket=yes |
| 189 | AC_MSG_RESULT([yes])], |
| 190 | [LIBS="$SAVELIBS" |
| 191 | AC_MSG_RESULT([no])]) |
Marcus Sundberg | 8046c3a | 2005-10-02 20:02:05 +0000 | [diff] [blame] | 192 | fi |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 193 | |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 194 | AC_MSG_CHECKING([whether to enable debug logging in all modules]) |
| 195 | AC_ARG_ENABLE([debug-logging], |
| 196 | [AS_HELP_STRING([--enable-debug-logging], [Enable debug logging in all modules])], |
Pascal Bühler | 88579e6 | 2017-01-30 21:05:37 +0100 | [diff] [blame] | 197 | [], enable_debug_logging=no) |
| 198 | if test "$enable_debug_logging" = "yes"; then |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 199 | AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Define to enabled debug logging for all mudules.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 200 | fi |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 201 | AC_MSG_RESULT([$enable_debug_logging]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 202 | |
Michael Thomas (malinka) | 1d4460d | 2016-06-04 19:59:31 -0400 | [diff] [blame] | 203 | PKG_PROG_PKG_CONFIG |
Idar Tollefsen | f9c148d | 2017-02-09 11:10:04 +0100 | [diff] [blame] | 204 | AS_IF([test "x$PKG_CONFIG" != "x"], [PKG_CONFIG="$PKG_CONFIG --static"]) |
Michael Thomas (malinka) | 1d4460d | 2016-06-04 19:59:31 -0400 | [diff] [blame] | 205 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 206 | AC_MSG_CHECKING([whether to leverage OpenSSL crypto]) |
| 207 | AC_ARG_ENABLE([openssl], |
| 208 | [AS_HELP_STRING([--enable-openssl], [compile in OpenSSL crypto engine])], |
| 209 | [], [enable_openssl=no]) |
| 210 | AC_MSG_RESULT([$enable_openssl]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 211 | if test "$enable_openssl" = "yes"; then |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 212 | AC_MSG_CHECKING([for user specified OpenSSL directory]) |
| 213 | AC_ARG_WITH([openssl-dir], |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 214 | [AS_HELP_STRING([--with-openssl-dir], [Location of OpenSSL installation])], |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 215 | [if test "x$PKG_CONFIG" != "x" && test -f $with_openssl_dir/lib/pkgconfig/libcrypto.pc; then |
| 216 | if test "x$PKG_CONFIG_PATH" = "x"; then |
| 217 | export PKG_CONFIG_PATH="$with_openssl_dir/lib/pkgconfig" |
| 218 | else |
| 219 | export PKG_CONFIG_PATH="$with_openssl_dir/lib/pkgconfig:$PKG_CONFIG_PATH" |
| 220 | fi |
| 221 | AC_MSG_RESULT([$with_openssl_dir]) |
| 222 | elif test -d $with_openssl_dir/lib; then |
| 223 | CFLAGS="$CFLAGS -I$with_openssl_dir/include" |
| 224 | if test "x$LDFLAGS" = "x"; then |
| 225 | LDFLAGS="-L$with_openssl_dir/lib" |
| 226 | else |
| 227 | LDFLAGS="$LDFLAGS -L$with_openssl_dir/lib" |
| 228 | fi |
| 229 | AC_MSG_RESULT([$with_openssl_dir]) |
| 230 | else |
| 231 | AC_MSG_RESULT([invalid]) |
| 232 | AC_MSG_FAILURE([Invalid OpenSSL location: $with_openssl_dir]) |
| 233 | fi], |
| 234 | [AC_MSG_RESULT([no])]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 235 | |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 236 | if test "x$PKG_CONFIG" != "x"; then |
Pascal Bühler | 6c949b6 | 2017-02-09 14:22:36 +0100 | [diff] [blame] | 237 | PKG_CHECK_MODULES([crypto], [libcrypto >= 1.0.1], |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 238 | [CFLAGS="$CFLAGS $crypto_CFLAGS" |
| 239 | LIBS="$crypto_LIBS $LIBS"]) |
| 240 | else |
| 241 | AC_CHECK_LIB([dl], [dlopen], [], [AC_MSG_WARN([can't find libdl])]) |
| 242 | AC_CHECK_LIB([z], [inflate], [], [AC_MSG_WARN([can't find libz])]) |
| 243 | fi |
Cullen Jennings | e1de50f | 2013-05-22 12:27:28 -0600 | [diff] [blame] | 244 | |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 245 | AC_SEARCH_LIBS([EVP_EncryptInit], [crypto], |
Pascal Bühler | 6c949b6 | 2017-02-09 14:22:36 +0100 | [diff] [blame] | 246 | [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])]) |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 247 | AC_SEARCH_LIBS([EVP_aes_128_ctr], [crypto], |
Pascal Bühler | 6c949b6 | 2017-02-09 14:22:36 +0100 | [diff] [blame] | 248 | [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])]) |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 249 | AC_SEARCH_LIBS([EVP_aes_128_gcm], [crypto], |
Pascal Bühler | 6c949b6 | 2017-02-09 14:22:36 +0100 | [diff] [blame] | 250 | [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])]) |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 251 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 252 | AC_DEFINE([OPENSSL], [1], [Define this to use OpenSSL crypto.]) |
jfigus | 7882dd9 | 2013-08-02 16:08:23 -0400 | [diff] [blame] | 253 | 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] | 254 | HMAC_OBJS=crypto/hash/hmac_ossl.o |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 255 | AC_SUBST([USE_OPENSSL], [1]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 256 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 257 | AC_MSG_CHECKING([whether to leverage OpenSSL KDF algorithm]) |
| 258 | AC_ARG_ENABLE([openssl-kdf], |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 259 | [AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])], |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 260 | [], [enable_openssl_kdf=no]) |
| 261 | AC_MSG_RESULT([$enable_openssl_kdf]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 262 | if test "$enable_openssl_kdf" = "yes"; then |
Idar Tollefsen | 333fa84 | 2017-01-20 16:44:33 +0100 | [diff] [blame] | 263 | AC_SEARCH_LIBS([kdf_srtp], [crypto], |
| 264 | [], [AC_MSG_FAILURE([can't find openssl KDF lib])]) |
| 265 | AC_DEFINE([OPENSSL_KDF], [1], [Define this to use OpenSSL KDF for SRTP.]) |
jfigus | 038d2cf | 2015-05-11 14:10:11 -0400 | [diff] [blame] | 266 | fi |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 267 | else |
jfigus | a3127b8 | 2014-11-19 14:46:52 -0500 | [diff] [blame] | 268 | AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o" |
jfigus | 0d3a268 | 2013-04-02 15:42:37 -0400 | [diff] [blame] | 269 | HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o" |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 270 | fi |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 271 | AC_SUBST([AES_ICM_OBJS]) |
| 272 | AC_SUBST([HMAC_OBJS]) |
jfigus | a14b5a0 | 2013-03-29 12:24:12 -0400 | [diff] [blame] | 273 | |
Bernardo Torres | 79e38ae | 2014-10-10 05:29:36 -0300 | [diff] [blame] | 274 | dnl Checking for PCAP |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 275 | AC_CHECK_LIB([pcap], [pcap_create], |
| 276 | [LIBS="-lpcap $LIBS" |
| 277 | AC_DEFINE([HAVE_PCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap)]) |
| 278 | AC_SUBST([HAVE_PCAP], [1])]) |
Bernardo Torres | 79e38ae | 2014-10-10 05:29:36 -0300 | [diff] [blame] | 279 | |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 280 | AC_MSG_CHECKING([whether to redirect logging to stdout]) |
| 281 | AC_ARG_ENABLE([log-stdout], |
Pascal Bühler | 88579e6 | 2017-01-30 21:05:37 +0100 | [diff] [blame] | 282 | [AS_HELP_STRING([--enable-log-stdout], [redirecting logging to stdout])], |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 283 | [], [enable_log_stdout=no]) |
Pascal Bühler | 88579e6 | 2017-01-30 21:05:37 +0100 | [diff] [blame] | 284 | if test "$enable_log_stdout" = "yes"; then |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 285 | AC_DEFINE([ERR_REPORTING_STDOUT], [1], [Define to redirect logging to stdout.]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 286 | fi |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 287 | AC_MSG_RESULT([$enable_log_stdout]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 288 | |
Pascal Bühler | b969ed5 | 2017-02-10 09:03:54 +0100 | [diff] [blame] | 289 | AC_MSG_CHECKING([wheather to use a file for logging]) |
| 290 | AC_ARG_WITH([log-file], |
Pascal Bühler | 88579e6 | 2017-01-30 21:05:37 +0100 | [diff] [blame] | 291 | [AS_HELP_STRING([--with-log-file], [Use file for logging])], |
| 292 | [AS_CASE([x$with_log_file], |
| 293 | [x], [valid_with_log_file="no"], |
| 294 | [xyes], [valid_with_log_file="no"], |
| 295 | [valid_with_error_file="yes"]) |
| 296 | AS_IF([test "$valid_with_log_file" = "no"], |
| 297 | [AC_MSG_RESULT([invalid]) |
| 298 | AC_MSG_FAILURE([Invalid value for --with-log-file: "$with_log_file"])], |
| 299 | [AC_DEFINE_UNQUOTED([ERR_REPORTING_FILE], ["$with_log_file"], [Logging statments will be writen to this file.]) |
| 300 | AC_MSG_RESULT([using log file: "$with_log_file"])])], |
| 301 | [AC_MSG_RESULT([no])]) |
| 302 | |
| 303 | AS_IF( |
| 304 | [test "$enable_log_stdout" = "yes" && test "x$with_log_file" != "x"], |
| 305 | [AC_MSG_FAILURE([Can only use one of --enable-log-stdout and --with-log-file; they are mutually exclusive])]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 306 | |
Idar Tollefsen | ba304fc | 2017-05-03 13:09:03 +0200 | [diff] [blame] | 307 | dnl Appending EXTRA_CFLAGS, if given |
| 308 | AC_MSG_CHECKING([for extra C compiler flags]) |
| 309 | AS_IF([test "x$EXTRA_CFLAGS" != "x"], |
| 310 | [AS_IF([test "x$CFLAGS" = "x"], |
| 311 | [CFLAGS="$EXTRA_CFLAGS"], [CFLAGS="$CFLAGS $EXTRA_CFLAGS"]) |
| 312 | AC_MSG_RESULT([$EXTRA_CFLAGS])], |
| 313 | [AC_MSG_RESULT(no)]) |
| 314 | |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 315 | AC_CONFIG_HEADER([crypto/include/config.h:config_in.h]) |
Cullen Jennings | 235513a | 2005-09-21 22:51:36 +0000 | [diff] [blame] | 316 | |
Idar Tollefsen | 3edfcef | 2017-01-20 16:14:51 +0100 | [diff] [blame] | 317 | AC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile libsrtp2.pc]) |
Saúl Ibarra Corretgé | b86063c | 2014-10-01 11:23:24 +0200 | [diff] [blame] | 318 | AC_OUTPUT |
Marcus Sundberg | 4ce29b2 | 2005-09-29 14:29:53 +0000 | [diff] [blame] | 319 | |
| 320 | # This is needed when building outside the source dir. |
Idar Tollefsen | 5e67d39 | 2017-01-20 13:03:52 +0100 | [diff] [blame] | 321 | AS_MKDIR_P([crypto/cipher]) |
| 322 | AS_MKDIR_P([crypto/hash]) |
| 323 | AS_MKDIR_P([crypto/kernel]) |
| 324 | AS_MKDIR_P([crypto/math]) |
| 325 | AS_MKDIR_P([crypto/replay]) |
| 326 | AS_MKDIR_P([crypto/test]) |
| 327 | AS_MKDIR_P([doc]) |
| 328 | AS_MKDIR_P([srtp]) |
| 329 | AS_MKDIR_P([test]) |