blob: 7bef4916be1a87ddb355a9562c4d55a4c06b3cb3 [file] [log] [blame]
Cullen Jennings235513a2005-09-21 22:51:36 +00001dnl Process this file with autoconf to produce a configure script.
Pascal Buhlerfd5b3b22018-05-15 21:27:42 +02002AC_INIT([libsrtp2], [2.3.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 Tollefsen0e790752017-01-26 10:59:03 +01005EMPTY_CFLAGS="no"
Idar Tollefsen27d857c2017-01-19 15:28:18 +01006if test "x$CFLAGS" = "x"; then
David McGrewb67061f2005-09-28 14:23:06 +00007 dnl Default value for CFLAGS if not specified.
Idar Tollefsen0e790752017-01-26 10:59:03 +01008 EMPTY_CFLAGS="yes"
David McGrewb67061f2005-09-28 14:23:06 +00009fi
10
Cullen Jennings235513a2005-09-21 22:51:36 +000011dnl Checks for programs.
Idar Tollefsenba304fc2017-05-03 13:09:03 +020012AC_PROG_CC
13AC_PROG_CPP
14AC_ARG_VAR(
15 [EXTRA_CFLAGS],
16 [C compiler flags appended to the regular C compiler flags instead of overriding them])
Idar Tollefsen38e50762017-05-03 11:45:15 +020017AM_PROG_AR
Cullen Jennings235513a2005-09-21 22:51:36 +000018AC_PROG_RANLIB
David McGrewb67061f2005-09-28 14:23:06 +000019AC_PROG_INSTALL
Idar Tollefsen0e790752017-01-26 10:59:03 +010020AC_PROG_SED
Cullen Jennings235513a2005-09-21 22:51:36 +000021
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000022dnl Check the byte order
23AC_C_BIGENDIAN
24
25AC_CANONICAL_HOST
26
27dnl check host_cpu type, set defines appropriately
28case $host_cpu in
Idar Tollefsen5fd11872017-01-19 15:25:12 +010029 i*86 | x86_64 )
Idar Tollefsen5e67d392017-01-20 13:03:52 +010030 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 Tollefsen5fd11872017-01-19 15:25:12 +010032 ;;
33 * )
Idar Tollefsen5e67d392017-01-20 13:03:52 +010034 AC_DEFINE([CPU_RISC], [1], [Define if building for a RISC machine (assume slow byte access).])
Idar Tollefsen5fd11872017-01-19 15:25:12 +010035 ;;
36esac
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000037
38dnl Check if we are on a Windows platform.
39case $host_os in
Idar Tollefsen5fd11872017-01-19 15:25:12 +010040 *cygwin*|*mingw* )
41 EXE=.exe
Idar Tollefsen5fd11872017-01-19 15:25:12 +010042 ;;
43 * )
44 EXE=""
45 ;;
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000046esac
Idar Tollefsen5e67d392017-01-20 13:03:52 +010047AC_SUBST([EXE]) # define executable suffix; this is needed for `make clean'
Marcus Sundbergfaf84ca2007-05-23 17:24:52 +000048
Idar Tollefsen0e790752017-01-26 10:59:03 +010049dnl Checks for supported compiler flags.
50supported_cflags=""
51if test "$EMPTY_CFLAGS" = "no"; then
52 supported_cflags="$CFLAGS"
53fi
54
55dnl For accurate detection, we need warnings as errors.
56dnl I.e. Clang will issue a warning about unsupported flags.
57dnl For the compilation to fail, those warnings needs to be upgraded to errors.
58dnl This will be removed again once the tests are complete (see below).
59WERROR=""
60for w in -Werror -errwarn; do
61 if test "x$WERROR" = "x"; then
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +020062 AC_MSG_CHECKING([whether ${CC-c} accepts $w])
Idar Tollefsen0e790752017-01-26 10:59:03 +010063 save_cflags="$CFLAGS"
64 AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$w"], [CFLAGS="$CFLAGS $w"])
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +020065 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
Idar Tollefsen0e790752017-01-26 10:59:03 +010066 [WERROR="$w"
67 AC_MSG_RESULT([yes])],
68 [CFLAGS="$save_cflags"
69 AC_MSG_RESULT([no])])
70 fi
71done
72
Idar Tollefsen475af062017-03-29 11:40:43 +020073dnl Note that -fPIC is not explicitly added to LDFLAGS.
74dnl Since the compiler is used as the link driver, CFLAGS will be part of the
75dnl link line as well and the linker will get the flag from there.
76dnl Adding it to LDFLAGS explicitly would duplicate the flag on the link line,
77dnl but otherwise do no harm.
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +020078AC_MSG_CHECKING([whether ${CC-c} accepts -fPIC])
Idar Tollefsen0e790752017-01-26 10:59:03 +010079save_cflags="$CFLAGS"
80AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="-fPIC"], [CFLAGS="$CFLAGS -fPIC"])
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +020081AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
Idar Tollefsen0e790752017-01-26 10:59:03 +010082 [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="-fPIC"], [supported_cflags="$supported_cflags -fPIC"])
Idar Tollefsen0e790752017-01-26 10:59:03 +010083 AC_MSG_RESULT([yes])],
84 [CFLAGS="$save_cflags"
85 AC_MSG_RESULT([no])])
86
87if test "$EMPTY_CFLAGS" = "yes"; then
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +020088 for f in -Wall -pedantic -Wstrict-prototypes; do
89 AC_MSG_CHECKING([whether ${CC-c} accepts $f])
Idar Tollefsen0e790752017-01-26 10:59:03 +010090 save_cflags="$CFLAGS"
91 AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"])
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +020092 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
Idar Tollefsen0e790752017-01-26 10:59:03 +010093 [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ühlerbb6ef8a2017-03-29 07:46:21 +0200102 AC_MSG_CHECKING([whether ${CC-c} accepts $f])
Idar Tollefsen0e790752017-01-26 10:59:03 +0100103 save_cflags="$CFLAGS"
104 AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"])
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +0200105 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
Idar Tollefsen0e790752017-01-26 10:59:03 +0100106 [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ühlerbb6ef8a2017-03-29 07:46:21 +0200115 AC_MSG_CHECKING([whether ${CC-c} accepts $f])
Idar Tollefsen0e790752017-01-26 10:59:03 +0100116 save_cflags="$CFLAGS"
117 AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"])
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +0200118 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
Idar Tollefsen0e790752017-01-26 10:59:03 +0100119 [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
124fi
125
126dnl When turning off warnigns, we're expecting unrecognized command line option errors if they're not
127dnl supported. However, the -Wno-<warning> form isn't consulted unless a warning is triggered.
Idar Tollefsenba304fc2017-05-03 13:09:03 +0200128dnl At least that's the case for GCC. So to check which warnings we can turn off, we need to check
Idar Tollefsen0e790752017-01-26 10:59:03 +0100129dnl if they can be turned on, thereby forcing GCC to take the argument into account right away.
130for f in -Wno-language-extension-token; do
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +0200131 AC_MSG_CHECKING([whether ${CC-c} accepts $f])
Idar Tollefsen0e790752017-01-26 10:59:03 +0100132 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ühlerbb6ef8a2017-03-29 07:46:21 +0200135 AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])],
Idar Tollefsen0e790752017-01-26 10:59:03 +0100136 [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])])
140done
141
142dnl Remowing -Werror again
143CFLAGS="$supported_cflags"
Cullen Jennings235513a2005-09-21 22:51:36 +0000144
145dnl Checks for header files.
146AC_HEADER_STDC
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100147AC_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 Jennings235513a2005-09-21 22:51:36 +0000150
Marcus Sundberg8046c3a2005-10-02 20:02:05 +0000151dnl socket() and friends
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100152AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h], [], [], [AC_INCLUDES_DEFAULT])
153AC_CHECK_HEADERS(
154 [windows.h],
155 [AC_CHECK_HEADERS([winsock2.h], [], [], [AC_INCLUDES_DEFAULT])],
156 [], [AC_INCLUDES_DEFAULT])
Marcus Sundberg8046c3a2005-10-02 20:02:05 +0000157
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100158AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, uint64_t])
159AC_CHECK_SIZEOF([unsigned long])
160AC_CHECK_SIZEOF([unsigned long long])
Cullen Jennings235513a2005-09-21 22:51:36 +0000161
162dnl Checks for typedefs, structures, and compiler characteristics.
163AC_C_CONST
164AC_C_INLINE
165AC_TYPE_SIZE_T
166
167dnl Checks for library functions.
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100168AC_CHECK_FUNCS([socket inet_aton usleep sigaction])
David McGrewb67061f2005-09-28 14:23:06 +0000169
Marcus Sundberg8046c3a2005-10-02 20:02:05 +0000170dnl Find socket function if not found yet.
171if test "x$ac_cv_func_socket" = "xno"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100172 AC_CHECK_LIB([socket], [socket])
Marcus Sundberg8046c3a2005-10-02 20:02:05 +0000173 AC_MSG_CHECKING([for socket in -lwsock32])
174 SAVELIBS="$LIBS"
175 LIBS="$LIBS -lwsock32"
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +0200176 AC_LINK_IFELSE(
177 [AC_LANG_SOURCE([
Marcus Sundberg8046c3a2005-10-02 20:02:05 +0000178#include <winsock2.h>
Pascal Bühlerbb6ef8a2017-03-29 07:46:21 +0200179int 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 Sundberg8046c3a2005-10-02 20:02:05 +0000192fi
Cullen Jennings235513a2005-09-21 22:51:36 +0000193
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100194AC_MSG_CHECKING([whether to enable debug logging in all modules])
195AC_ARG_ENABLE([debug-logging],
196 [AS_HELP_STRING([--enable-debug-logging], [Enable debug logging in all modules])],
Pascal Bühler88579e62017-01-30 21:05:37 +0100197 [], enable_debug_logging=no)
198if test "$enable_debug_logging" = "yes"; then
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100199 AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Define to enabled debug logging for all mudules.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000200fi
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100201AC_MSG_RESULT([$enable_debug_logging])
Cullen Jennings235513a2005-09-21 22:51:36 +0000202
Michael Thomas (malinka)1d4460d2016-06-04 19:59:31 -0400203PKG_PROG_PKG_CONFIG
Idar Tollefsenf9c148d2017-02-09 11:10:04 +0100204AS_IF([test "x$PKG_CONFIG" != "x"], [PKG_CONFIG="$PKG_CONFIG --static"])
Michael Thomas (malinka)1d4460d2016-06-04 19:59:31 -0400205
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100206AC_MSG_CHECKING([whether to leverage OpenSSL crypto])
207AC_ARG_ENABLE([openssl],
208 [AS_HELP_STRING([--enable-openssl], [compile in OpenSSL crypto engine])],
209 [], [enable_openssl=no])
210AC_MSG_RESULT([$enable_openssl])
Richard Barnes12872092018-05-16 16:31:16 -0700211
212AC_MSG_CHECKING([whether to leverage NSS crypto])
213AC_ARG_ENABLE([nss],
214 [AS_HELP_STRING([--enable-nss], [compile in NSS crypto engine])],
215 [], [enable_nss=no])
216AC_MSG_RESULT([$enable_nss])
217
jfigusa14b5a02013-03-29 12:24:12 -0400218if test "$enable_openssl" = "yes"; then
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100219 AC_MSG_CHECKING([for user specified OpenSSL directory])
220 AC_ARG_WITH([openssl-dir],
jfigus038d2cf2015-05-11 14:10:11 -0400221 [AS_HELP_STRING([--with-openssl-dir], [Location of OpenSSL installation])],
Idar Tollefsen333fa842017-01-20 16:44:33 +0100222 [if test "x$PKG_CONFIG" != "x" && test -f $with_openssl_dir/lib/pkgconfig/libcrypto.pc; then
223 if test "x$PKG_CONFIG_PATH" = "x"; then
224 export PKG_CONFIG_PATH="$with_openssl_dir/lib/pkgconfig"
225 else
226 export PKG_CONFIG_PATH="$with_openssl_dir/lib/pkgconfig:$PKG_CONFIG_PATH"
227 fi
228 AC_MSG_RESULT([$with_openssl_dir])
229 elif test -d $with_openssl_dir/lib; then
230 CFLAGS="$CFLAGS -I$with_openssl_dir/include"
231 if test "x$LDFLAGS" = "x"; then
232 LDFLAGS="-L$with_openssl_dir/lib"
233 else
234 LDFLAGS="$LDFLAGS -L$with_openssl_dir/lib"
235 fi
236 AC_MSG_RESULT([$with_openssl_dir])
237 else
238 AC_MSG_RESULT([invalid])
239 AC_MSG_FAILURE([Invalid OpenSSL location: $with_openssl_dir])
240 fi],
241 [AC_MSG_RESULT([no])])
jfigus038d2cf2015-05-11 14:10:11 -0400242
Idar Tollefsen333fa842017-01-20 16:44:33 +0100243 if test "x$PKG_CONFIG" != "x"; then
Pascal Bühler6c949b62017-02-09 14:22:36 +0100244 PKG_CHECK_MODULES([crypto], [libcrypto >= 1.0.1],
Idar Tollefsen333fa842017-01-20 16:44:33 +0100245 [CFLAGS="$CFLAGS $crypto_CFLAGS"
246 LIBS="$crypto_LIBS $LIBS"])
247 else
248 AC_CHECK_LIB([dl], [dlopen], [], [AC_MSG_WARN([can't find libdl])])
249 AC_CHECK_LIB([z], [inflate], [], [AC_MSG_WARN([can't find libz])])
250 fi
Cullen Jenningse1de50f2013-05-22 12:27:28 -0600251
Idar Tollefsen333fa842017-01-20 16:44:33 +0100252 AC_SEARCH_LIBS([EVP_EncryptInit], [crypto],
Pascal Bühler6c949b62017-02-09 14:22:36 +0100253 [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])])
Idar Tollefsen333fa842017-01-20 16:44:33 +0100254 AC_SEARCH_LIBS([EVP_aes_128_ctr], [crypto],
Pascal Bühler6c949b62017-02-09 14:22:36 +0100255 [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])])
Idar Tollefsen333fa842017-01-20 16:44:33 +0100256 AC_SEARCH_LIBS([EVP_aes_128_gcm], [crypto],
Pascal Bühler6c949b62017-02-09 14:22:36 +0100257 [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])])
Idar Tollefsen333fa842017-01-20 16:44:33 +0100258
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100259 AC_DEFINE([OPENSSL], [1], [Define this to use OpenSSL crypto.])
jfigus7882dd92013-08-02 16:08:23 -0400260 AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o"
jfigus0d3a2682013-04-02 15:42:37 -0400261 HMAC_OBJS=crypto/hash/hmac_ossl.o
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100262 AC_SUBST([USE_OPENSSL], [1])
jfigus038d2cf2015-05-11 14:10:11 -0400263
Joachim Bauchec465b82018-05-30 12:23:36 +0200264 AC_MSG_CHECKING([if OPENSSL_cleanse is broken])
265 AC_RUN_IFELSE([AC_LANG_PROGRAM([
266 #include <stdio.h>
267 #include <openssl/crypto.h>
268 ], [
269 #define BUFFER_SIZE (16)
270 char buffer[[BUFFER_SIZE]];
271 int i;
272 for (i = 0; i < BUFFER_SIZE; i++) {
273 buffer[[i]] = i & 0xff;
274 }
275 OPENSSL_cleanse(buffer, BUFFER_SIZE);
276 for (i = 0; i < BUFFER_SIZE; i++) {
277 if (buffer[[i]]) {
278 printf("Buffer contents not zero at position %d (is %d)\n", i,
279 buffer[[i]]);
280 return 1;
281 }
282 }
283 ])], [openssl_cleanse_broken=no], [
284 openssl_cleanse_broken=yes
285 AC_DEFINE([OPENSSL_CLEANSE_BROKEN], [1], [Define this if OPENSSL_cleanse is broken.])
286 ])
287 AC_MSG_RESULT([$openssl_cleanse_broken])
288
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100289 AC_MSG_CHECKING([whether to leverage OpenSSL KDF algorithm])
290 AC_ARG_ENABLE([openssl-kdf],
jfigus038d2cf2015-05-11 14:10:11 -0400291 [AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])],
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100292 [], [enable_openssl_kdf=no])
293 AC_MSG_RESULT([$enable_openssl_kdf])
jfigus038d2cf2015-05-11 14:10:11 -0400294 if test "$enable_openssl_kdf" = "yes"; then
Idar Tollefsen333fa842017-01-20 16:44:33 +0100295 AC_SEARCH_LIBS([kdf_srtp], [crypto],
296 [], [AC_MSG_FAILURE([can't find openssl KDF lib])])
297 AC_DEFINE([OPENSSL_KDF], [1], [Define this to use OpenSSL KDF for SRTP.])
jfigus038d2cf2015-05-11 14:10:11 -0400298 fi
Richard Barnes12872092018-05-16 16:31:16 -0700299elif test "$enable_nss" = "yes"; then
300 AC_MSG_CHECKING([for user specified NSS directory])
301 AC_ARG_WITH([nss-dir],
302 [AS_HELP_STRING([--with-nss-dir], [Location of NSS installation])],
303 [if test -d $with_nss_dir/lib; then
304 CFLAGS="$CFLAGS -I$with_nss_dir/include/nspr/"
305 CFLAGS="$CFLAGS -I$with_nss_dir/../public/nss/"
306 if test "x$LDFLAGS" = "x"; then
307 LDFLAGS="-L$with_nss_dir/lib"
308 else
309 LDFLAGS="$LDFLAGS -L$with_nss_dir/lib"
310 fi
311 AC_MSG_RESULT([$with_nss_dir])
312 else
313 AC_MSG_RESULT([invalid])
314 AC_MSG_FAILURE([Invalid OpenSSL location: $with_nss_dir])
315 fi],
316 [AC_MSG_RESULT([no])])
317
318 AC_DEFINE([NSS], [1], [Define this to use NSS crypto.])
319 AES_ICM_OBJS="crypto/cipher/aes_icm_nss.o crypto/cipher/aes_gcm_nss.o"
320
321 # TODO(RLB): Use NSS for HMAC
322 HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"
323
324 # TODO(RLB): Use NSS for KDF
325
326 AC_SUBST([USE_NSS], [1])
jfigusa14b5a02013-03-29 12:24:12 -0400327else
jfigusa3127b82014-11-19 14:46:52 -0500328 AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o"
jfigus0d3a2682013-04-02 15:42:37 -0400329 HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"
jfigusa14b5a02013-03-29 12:24:12 -0400330fi
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100331AC_SUBST([AES_ICM_OBJS])
332AC_SUBST([HMAC_OBJS])
jfigusa14b5a02013-03-29 12:24:12 -0400333
Bernardo Torres79e38ae2014-10-10 05:29:36 -0300334dnl Checking for PCAP
Martin90f7e1b2017-11-02 17:03:18 +0100335
Martin Meszaros96d0b9a2017-11-01 12:31:37 +0100336PCAP_LIB=""
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100337AC_CHECK_LIB([pcap], [pcap_create],
Martin Meszaros96d0b9a2017-11-01 12:31:37 +0100338 [PCAP_LIB="-lpcap"
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100339 AC_DEFINE([HAVE_PCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap)])
340 AC_SUBST([HAVE_PCAP], [1])])
Martin Meszaros3edfada2017-11-01 10:55:33 +0100341
342AC_CHECK_LIB([wpcap], [pcap_create],
Martin Meszaros96d0b9a2017-11-01 12:31:37 +0100343 [PCAP_LIB="-lwpcap"
Martin Meszaros3edfada2017-11-01 10:55:33 +0100344 AC_DEFINE([HAVE_PCAP], [1], [Define to 1 if you have the `winpcap' library (-lwpcap)])
345 AC_SUBST([HAVE_PCAP], [1])])
Martin Meszaros96d0b9a2017-11-01 12:31:37 +0100346AC_SUBST([PCAP_LIB])
347
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100348AC_MSG_CHECKING([whether to redirect logging to stdout])
349AC_ARG_ENABLE([log-stdout],
Pascal Bühler88579e62017-01-30 21:05:37 +0100350 [AS_HELP_STRING([--enable-log-stdout], [redirecting logging to stdout])],
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100351 [], [enable_log_stdout=no])
Pascal Bühler88579e62017-01-30 21:05:37 +0100352if test "$enable_log_stdout" = "yes"; then
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100353 AC_DEFINE([ERR_REPORTING_STDOUT], [1], [Define to redirect logging to stdout.])
Cullen Jennings235513a2005-09-21 22:51:36 +0000354fi
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100355AC_MSG_RESULT([$enable_log_stdout])
Cullen Jennings235513a2005-09-21 22:51:36 +0000356
Pascal Bühlerb969ed52017-02-10 09:03:54 +0100357AC_MSG_CHECKING([wheather to use a file for logging])
358AC_ARG_WITH([log-file],
Pascal Bühler88579e62017-01-30 21:05:37 +0100359 [AS_HELP_STRING([--with-log-file], [Use file for logging])],
360 [AS_CASE([x$with_log_file],
361 [x], [valid_with_log_file="no"],
362 [xyes], [valid_with_log_file="no"],
363 [valid_with_error_file="yes"])
364 AS_IF([test "$valid_with_log_file" = "no"],
365 [AC_MSG_RESULT([invalid])
366 AC_MSG_FAILURE([Invalid value for --with-log-file: "$with_log_file"])],
367 [AC_DEFINE_UNQUOTED([ERR_REPORTING_FILE], ["$with_log_file"], [Logging statments will be writen to this file.])
368 AC_MSG_RESULT([using log file: "$with_log_file"])])],
369 [AC_MSG_RESULT([no])])
370
371AS_IF(
372 [test "$enable_log_stdout" = "yes" && test "x$with_log_file" != "x"],
373 [AC_MSG_FAILURE([Can only use one of --enable-log-stdout and --with-log-file; they are mutually exclusive])])
Cullen Jennings235513a2005-09-21 22:51:36 +0000374
Idar Tollefsenba304fc2017-05-03 13:09:03 +0200375dnl Appending EXTRA_CFLAGS, if given
376AC_MSG_CHECKING([for extra C compiler flags])
377AS_IF([test "x$EXTRA_CFLAGS" != "x"],
378 [AS_IF([test "x$CFLAGS" = "x"],
379 [CFLAGS="$EXTRA_CFLAGS"], [CFLAGS="$CFLAGS $EXTRA_CFLAGS"])
380 AC_MSG_RESULT([$EXTRA_CFLAGS])],
381 [AC_MSG_RESULT(no)])
382
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100383AC_CONFIG_HEADER([crypto/include/config.h:config_in.h])
Cullen Jennings235513a2005-09-21 22:51:36 +0000384
Idar Tollefsen3edfcef2017-01-20 16:14:51 +0100385AC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile libsrtp2.pc])
Saúl Ibarra Corretgéb86063c2014-10-01 11:23:24 +0200386AC_OUTPUT
Marcus Sundberg4ce29b22005-09-29 14:29:53 +0000387
388# This is needed when building outside the source dir.
Idar Tollefsen5e67d392017-01-20 13:03:52 +0100389AS_MKDIR_P([crypto/cipher])
390AS_MKDIR_P([crypto/hash])
391AS_MKDIR_P([crypto/kernel])
392AS_MKDIR_P([crypto/math])
393AS_MKDIR_P([crypto/replay])
394AS_MKDIR_P([crypto/test])
395AS_MKDIR_P([doc])
396AS_MKDIR_P([srtp])
397AS_MKDIR_P([test])