1*90e502c7SAndroid Build Coastguard Workerdnl Process this file with autoconf to produce a configure script. 2*90e502c7SAndroid Build Coastguard WorkerAC_INIT([libsrtp2], [2.3.0-pre], [https://github.com/cisco/libsrtp/issues]) 3*90e502c7SAndroid Build Coastguard Worker 4*90e502c7SAndroid Build Coastguard Workerdnl Must come before AC_PROG_CC 5*90e502c7SAndroid Build Coastguard WorkerEMPTY_CFLAGS="no" 6*90e502c7SAndroid Build Coastguard Workerif test "x$CFLAGS" = "x"; then 7*90e502c7SAndroid Build Coastguard Worker dnl Default value for CFLAGS if not specified. 8*90e502c7SAndroid Build Coastguard Worker EMPTY_CFLAGS="yes" 9*90e502c7SAndroid Build Coastguard Workerfi 10*90e502c7SAndroid Build Coastguard Worker 11*90e502c7SAndroid Build Coastguard Workerdnl Checks for programs. 12*90e502c7SAndroid Build Coastguard WorkerAC_PROG_CC 13*90e502c7SAndroid Build Coastguard WorkerAC_PROG_CPP 14*90e502c7SAndroid Build Coastguard WorkerAC_PROG_CXX 15*90e502c7SAndroid Build Coastguard WorkerAC_ARG_VAR( 16*90e502c7SAndroid Build Coastguard Worker [EXTRA_CFLAGS], 17*90e502c7SAndroid Build Coastguard Worker [C compiler flags appended to the regular C compiler flags instead of overriding them]) 18*90e502c7SAndroid Build Coastguard WorkerAM_PROG_AR 19*90e502c7SAndroid Build Coastguard WorkerAC_PROG_RANLIB 20*90e502c7SAndroid Build Coastguard WorkerAC_PROG_INSTALL 21*90e502c7SAndroid Build Coastguard WorkerAC_PROG_SED 22*90e502c7SAndroid Build Coastguard Worker 23*90e502c7SAndroid Build Coastguard Workerdnl Check the byte order 24*90e502c7SAndroid Build Coastguard WorkerAC_C_BIGENDIAN 25*90e502c7SAndroid Build Coastguard Worker 26*90e502c7SAndroid Build Coastguard WorkerAC_CANONICAL_HOST 27*90e502c7SAndroid Build Coastguard Worker 28*90e502c7SAndroid Build Coastguard Workerdnl check host_cpu type, set defines appropriately 29*90e502c7SAndroid Build Coastguard Workercase $host_cpu in 30*90e502c7SAndroid Build Coastguard Worker i*86 | x86_64 ) 31*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([CPU_CISC], [1], [Define if building for a CISC machine (e.g. Intel).]) 32*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([HAVE_X86], [1], [Define to use X86 inlined assembly code]) 33*90e502c7SAndroid Build Coastguard Worker ;; 34*90e502c7SAndroid Build Coastguard Worker * ) 35*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([CPU_RISC], [1], [Define if building for a RISC machine (assume slow byte access).]) 36*90e502c7SAndroid Build Coastguard Worker ;; 37*90e502c7SAndroid Build Coastguard Workeresac 38*90e502c7SAndroid Build Coastguard Worker 39*90e502c7SAndroid Build Coastguard Workerdnl Check if we are on a Windows platform. 40*90e502c7SAndroid Build Coastguard Workercase $host_os in 41*90e502c7SAndroid Build Coastguard Worker *cygwin*|*mingw* ) 42*90e502c7SAndroid Build Coastguard Worker EXE=.exe 43*90e502c7SAndroid Build Coastguard Worker ;; 44*90e502c7SAndroid Build Coastguard Worker * ) 45*90e502c7SAndroid Build Coastguard Worker EXE="" 46*90e502c7SAndroid Build Coastguard Worker ;; 47*90e502c7SAndroid Build Coastguard Workeresac 48*90e502c7SAndroid Build Coastguard WorkerAC_SUBST([EXE]) # define executable suffix; this is needed for `make clean' 49*90e502c7SAndroid Build Coastguard Worker 50*90e502c7SAndroid Build Coastguard Workerdnl Checks for supported compiler flags. 51*90e502c7SAndroid Build Coastguard Workersupported_cflags="" 52*90e502c7SAndroid Build Coastguard Workerif test "$EMPTY_CFLAGS" = "no"; then 53*90e502c7SAndroid Build Coastguard Worker supported_cflags="$CFLAGS" 54*90e502c7SAndroid Build Coastguard Workerfi 55*90e502c7SAndroid Build Coastguard Worker 56*90e502c7SAndroid Build Coastguard Workerdnl For accurate detection, we need warnings as errors. 57*90e502c7SAndroid Build Coastguard Workerdnl I.e. Clang will issue a warning about unsupported flags. 58*90e502c7SAndroid Build Coastguard Workerdnl For the compilation to fail, those warnings needs to be upgraded to errors. 59*90e502c7SAndroid Build Coastguard Workerdnl This will be removed again once the tests are complete (see below). 60*90e502c7SAndroid Build Coastguard WorkerWERROR="" 61*90e502c7SAndroid Build Coastguard Workerfor w in -Werror -errwarn; do 62*90e502c7SAndroid Build Coastguard Worker if test "x$WERROR" = "x"; then 63*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([whether ${CC-c} accepts $w]) 64*90e502c7SAndroid Build Coastguard Worker save_cflags="$CFLAGS" 65*90e502c7SAndroid Build Coastguard Worker AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$w"], [CFLAGS="$CFLAGS $w"]) 66*90e502c7SAndroid Build Coastguard Worker AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], 67*90e502c7SAndroid Build Coastguard Worker [WERROR="$w" 68*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([yes])], 69*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$save_cflags" 70*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([no])]) 71*90e502c7SAndroid Build Coastguard Worker fi 72*90e502c7SAndroid Build Coastguard Workerdone 73*90e502c7SAndroid Build Coastguard Worker 74*90e502c7SAndroid Build Coastguard Workerdnl Note that -fPIC is not explicitly added to LDFLAGS. 75*90e502c7SAndroid Build Coastguard Workerdnl Since the compiler is used as the link driver, CFLAGS will be part of the 76*90e502c7SAndroid Build Coastguard Workerdnl link line as well and the linker will get the flag from there. 77*90e502c7SAndroid Build Coastguard Workerdnl Adding it to LDFLAGS explicitly would duplicate the flag on the link line, 78*90e502c7SAndroid Build Coastguard Workerdnl but otherwise do no harm. 79*90e502c7SAndroid Build Coastguard WorkerAC_MSG_CHECKING([whether ${CC-c} accepts -fPIC]) 80*90e502c7SAndroid Build Coastguard Workersave_cflags="$CFLAGS" 81*90e502c7SAndroid Build Coastguard WorkerAS_IF([test "x$CFLAGS" = "x"], [CFLAGS="-fPIC"], [CFLAGS="$CFLAGS -fPIC"]) 82*90e502c7SAndroid Build Coastguard WorkerAC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], 83*90e502c7SAndroid Build Coastguard Worker [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="-fPIC"], [supported_cflags="$supported_cflags -fPIC"]) 84*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([yes])], 85*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$save_cflags" 86*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([no])]) 87*90e502c7SAndroid Build Coastguard Worker 88*90e502c7SAndroid Build Coastguard Workerif test "$EMPTY_CFLAGS" = "yes"; then 89*90e502c7SAndroid Build Coastguard Worker for f in -Wall -pedantic -Wstrict-prototypes; do 90*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([whether ${CC-c} accepts $f]) 91*90e502c7SAndroid Build Coastguard Worker save_cflags="$CFLAGS" 92*90e502c7SAndroid Build Coastguard Worker AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"]) 93*90e502c7SAndroid Build Coastguard Worker AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], 94*90e502c7SAndroid Build Coastguard Worker [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) 95*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([yes])], 96*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$save_cflags" 97*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([no])]) 98*90e502c7SAndroid Build Coastguard Worker done 99*90e502c7SAndroid Build Coastguard Worker 100*90e502c7SAndroid Build Coastguard Worker OOPT="" 101*90e502c7SAndroid Build Coastguard Worker for f in -O4 -O3; do 102*90e502c7SAndroid Build Coastguard Worker if test "x$OOPT" = "x"; then 103*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([whether ${CC-c} accepts $f]) 104*90e502c7SAndroid Build Coastguard Worker save_cflags="$CFLAGS" 105*90e502c7SAndroid Build Coastguard Worker AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"]) 106*90e502c7SAndroid Build Coastguard Worker AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], 107*90e502c7SAndroid Build Coastguard Worker [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) 108*90e502c7SAndroid Build Coastguard Worker OOPT="$f" 109*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([yes])], 110*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$save_cflags" 111*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([no])]) 112*90e502c7SAndroid Build Coastguard Worker fi 113*90e502c7SAndroid Build Coastguard Worker done 114*90e502c7SAndroid Build Coastguard Worker 115*90e502c7SAndroid Build Coastguard Worker for f in -fexpensive-optimizations -funroll-loops; do 116*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([whether ${CC-c} accepts $f]) 117*90e502c7SAndroid Build Coastguard Worker save_cflags="$CFLAGS" 118*90e502c7SAndroid Build Coastguard Worker AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$f"], [CFLAGS="$CFLAGS $f"]) 119*90e502c7SAndroid Build Coastguard Worker AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], 120*90e502c7SAndroid Build Coastguard Worker [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) 121*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([yes])], 122*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$save_cflags" 123*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([no])]) 124*90e502c7SAndroid Build Coastguard Worker done 125*90e502c7SAndroid Build Coastguard Workerfi 126*90e502c7SAndroid Build Coastguard Worker 127*90e502c7SAndroid Build Coastguard Workerdnl When turning off warnigns, we're expecting unrecognized command line option errors if they're not 128*90e502c7SAndroid Build Coastguard Workerdnl supported. However, the -Wno-<warning> form isn't consulted unless a warning is triggered. 129*90e502c7SAndroid Build Coastguard Workerdnl At least that's the case for GCC. So to check which warnings we can turn off, we need to check 130*90e502c7SAndroid Build Coastguard Workerdnl if they can be turned on, thereby forcing GCC to take the argument into account right away. 131*90e502c7SAndroid Build Coastguard Workerfor f in -Wno-language-extension-token; do 132*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([whether ${CC-c} accepts $f]) 133*90e502c7SAndroid Build Coastguard Worker save_cflags="$CFLAGS" 134*90e502c7SAndroid Build Coastguard Worker testf=$(echo "$f" | $SED 's|-Wno-\(.*\)|-W\1|g') 135*90e502c7SAndroid Build Coastguard Worker AS_IF([test "x$CFLAGS" = "x"], [CFLAGS="$testf"], [CFLAGS="$CFLAGS $testf"]) 136*90e502c7SAndroid Build Coastguard Worker AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], 137*90e502c7SAndroid Build Coastguard Worker [AS_IF([test "x$supported_cflags" = "x"], [supported_cflags="$f"], [supported_cflags="$supported_cflags $f"]) 138*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([yes])], 139*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$save_cflags" 140*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([no])]) 141*90e502c7SAndroid Build Coastguard Workerdone 142*90e502c7SAndroid Build Coastguard Worker 143*90e502c7SAndroid Build Coastguard Workerdnl Remowing -Werror again 144*90e502c7SAndroid Build Coastguard WorkerCFLAGS="$supported_cflags" 145*90e502c7SAndroid Build Coastguard Worker 146*90e502c7SAndroid Build Coastguard Workerdnl Checks for header files. 147*90e502c7SAndroid Build Coastguard WorkerAC_HEADER_STDC 148*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_HEADERS( 149*90e502c7SAndroid Build Coastguard Worker [unistd.h byteswap.h stdint.h sys/uio.h inttypes.h sys/types.h machine/types.h sys/int_types.h], 150*90e502c7SAndroid Build Coastguard Worker [], [], [AC_INCLUDES_DEFAULT]) 151*90e502c7SAndroid Build Coastguard Worker 152*90e502c7SAndroid Build Coastguard Workerdnl socket() and friends 153*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h], [], [], [AC_INCLUDES_DEFAULT]) 154*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_HEADERS( 155*90e502c7SAndroid Build Coastguard Worker [windows.h], 156*90e502c7SAndroid Build Coastguard Worker [AC_CHECK_HEADERS([winsock2.h], [], [], [AC_INCLUDES_DEFAULT])], 157*90e502c7SAndroid Build Coastguard Worker [], [AC_INCLUDES_DEFAULT]) 158*90e502c7SAndroid Build Coastguard Worker 159*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, uint64_t]) 160*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_SIZEOF([unsigned long]) 161*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_SIZEOF([unsigned long long]) 162*90e502c7SAndroid Build Coastguard Worker 163*90e502c7SAndroid Build Coastguard Workerdnl Checks for typedefs, structures, and compiler characteristics. 164*90e502c7SAndroid Build Coastguard WorkerAC_C_CONST 165*90e502c7SAndroid Build Coastguard WorkerAC_C_INLINE 166*90e502c7SAndroid Build Coastguard WorkerAC_TYPE_SIZE_T 167*90e502c7SAndroid Build Coastguard Worker 168*90e502c7SAndroid Build Coastguard Workerdnl Checks for library functions. 169*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_FUNCS([socket inet_aton usleep sigaction]) 170*90e502c7SAndroid Build Coastguard Worker 171*90e502c7SAndroid Build Coastguard Workerdnl Find socket function if not found yet. 172*90e502c7SAndroid Build Coastguard Workerif test "x$ac_cv_func_socket" = "xno"; then 173*90e502c7SAndroid Build Coastguard Worker AC_CHECK_LIB([socket], [socket]) 174*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([for socket in -lwsock32]) 175*90e502c7SAndroid Build Coastguard Worker SAVELIBS="$LIBS" 176*90e502c7SAndroid Build Coastguard Worker LIBS="$LIBS -lwsock32" 177*90e502c7SAndroid Build Coastguard Worker AC_LINK_IFELSE( 178*90e502c7SAndroid Build Coastguard Worker [AC_LANG_SOURCE([ 179*90e502c7SAndroid Build Coastguard Worker#include <winsock2.h> 180*90e502c7SAndroid Build Coastguard Workerint main(void) 181*90e502c7SAndroid Build Coastguard Worker{ 182*90e502c7SAndroid Build Coastguard Worker int fd = socket(0, 0, 0); 183*90e502c7SAndroid Build Coastguard Worker if (fd < 0) 184*90e502c7SAndroid Build Coastguard Worker return -1; 185*90e502c7SAndroid Build Coastguard Worker else 186*90e502c7SAndroid Build Coastguard Worker return 0; 187*90e502c7SAndroid Build Coastguard Worker} 188*90e502c7SAndroid Build Coastguard Worker ])], 189*90e502c7SAndroid Build Coastguard Worker [ac_cv_func_socket=yes 190*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([yes])], 191*90e502c7SAndroid Build Coastguard Worker [LIBS="$SAVELIBS" 192*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([no])]) 193*90e502c7SAndroid Build Coastguard Workerfi 194*90e502c7SAndroid Build Coastguard Worker 195*90e502c7SAndroid Build Coastguard WorkerAC_MSG_CHECKING([whether to enable debug logging in all modules]) 196*90e502c7SAndroid Build Coastguard WorkerAC_ARG_ENABLE([debug-logging], 197*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--enable-debug-logging], [Enable debug logging in all modules])], 198*90e502c7SAndroid Build Coastguard Worker [], enable_debug_logging=no) 199*90e502c7SAndroid Build Coastguard Workerif test "$enable_debug_logging" = "yes"; then 200*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([ENABLE_DEBUG_LOGGING], [1], [Define to enabled debug logging for all mudules.]) 201*90e502c7SAndroid Build Coastguard Workerfi 202*90e502c7SAndroid Build Coastguard WorkerAC_MSG_RESULT([$enable_debug_logging]) 203*90e502c7SAndroid Build Coastguard Worker 204*90e502c7SAndroid Build Coastguard WorkerPKG_PROG_PKG_CONFIG 205*90e502c7SAndroid Build Coastguard WorkerAS_IF([test "x$PKG_CONFIG" != "x"], [PKG_CONFIG="$PKG_CONFIG --static"]) 206*90e502c7SAndroid Build Coastguard Worker 207*90e502c7SAndroid Build Coastguard WorkerAC_MSG_CHECKING([whether to leverage OpenSSL crypto]) 208*90e502c7SAndroid Build Coastguard WorkerAC_ARG_ENABLE([openssl], 209*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--enable-openssl], [compile in OpenSSL crypto engine])], 210*90e502c7SAndroid Build Coastguard Worker [], [enable_openssl=no]) 211*90e502c7SAndroid Build Coastguard WorkerAC_MSG_RESULT([$enable_openssl]) 212*90e502c7SAndroid Build Coastguard Worker 213*90e502c7SAndroid Build Coastguard WorkerAC_MSG_CHECKING([whether to leverage NSS crypto]) 214*90e502c7SAndroid Build Coastguard WorkerAC_ARG_ENABLE([nss], 215*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--enable-nss], [compile in NSS crypto engine])], 216*90e502c7SAndroid Build Coastguard Worker [], [enable_nss=no]) 217*90e502c7SAndroid Build Coastguard WorkerAC_MSG_RESULT([$enable_nss]) 218*90e502c7SAndroid Build Coastguard Worker 219*90e502c7SAndroid Build Coastguard Workerif test "$enable_openssl" = "yes"; then 220*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([for user specified OpenSSL directory]) 221*90e502c7SAndroid Build Coastguard Worker AC_ARG_WITH([openssl-dir], 222*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--with-openssl-dir], [Location of OpenSSL installation])], 223*90e502c7SAndroid Build Coastguard Worker [if test "x$PKG_CONFIG" != "x" && test -f $with_openssl_dir/lib/pkgconfig/libcrypto.pc; then 224*90e502c7SAndroid Build Coastguard Worker if test "x$PKG_CONFIG_PATH" = "x"; then 225*90e502c7SAndroid Build Coastguard Worker export PKG_CONFIG_PATH="$with_openssl_dir/lib/pkgconfig" 226*90e502c7SAndroid Build Coastguard Worker else 227*90e502c7SAndroid Build Coastguard Worker export PKG_CONFIG_PATH="$with_openssl_dir/lib/pkgconfig:$PKG_CONFIG_PATH" 228*90e502c7SAndroid Build Coastguard Worker fi 229*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([$with_openssl_dir]) 230*90e502c7SAndroid Build Coastguard Worker elif test -d $with_openssl_dir/lib; then 231*90e502c7SAndroid Build Coastguard Worker CFLAGS="$CFLAGS -I$with_openssl_dir/include" 232*90e502c7SAndroid Build Coastguard Worker if test "x$LDFLAGS" = "x"; then 233*90e502c7SAndroid Build Coastguard Worker LDFLAGS="-L$with_openssl_dir/lib" 234*90e502c7SAndroid Build Coastguard Worker else 235*90e502c7SAndroid Build Coastguard Worker LDFLAGS="$LDFLAGS -L$with_openssl_dir/lib" 236*90e502c7SAndroid Build Coastguard Worker fi 237*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([$with_openssl_dir]) 238*90e502c7SAndroid Build Coastguard Worker else 239*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([invalid]) 240*90e502c7SAndroid Build Coastguard Worker AC_MSG_FAILURE([Invalid OpenSSL location: $with_openssl_dir]) 241*90e502c7SAndroid Build Coastguard Worker fi], 242*90e502c7SAndroid Build Coastguard Worker [AC_MSG_RESULT([no])]) 243*90e502c7SAndroid Build Coastguard Worker 244*90e502c7SAndroid Build Coastguard Worker if test "x$PKG_CONFIG" != "x"; then 245*90e502c7SAndroid Build Coastguard Worker PKG_CHECK_MODULES([crypto], [libcrypto >= 1.0.1], 246*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$CFLAGS $crypto_CFLAGS" 247*90e502c7SAndroid Build Coastguard Worker LIBS="$crypto_LIBS $LIBS"]) 248*90e502c7SAndroid Build Coastguard Worker else 249*90e502c7SAndroid Build Coastguard Worker AC_CHECK_LIB([dl], [dlopen], [], [AC_MSG_WARN([can't find libdl])]) 250*90e502c7SAndroid Build Coastguard Worker AC_CHECK_LIB([z], [inflate], [], [AC_MSG_WARN([can't find libz])]) 251*90e502c7SAndroid Build Coastguard Worker fi 252*90e502c7SAndroid Build Coastguard Worker 253*90e502c7SAndroid Build Coastguard Worker AC_SEARCH_LIBS([EVP_EncryptInit], [crypto], 254*90e502c7SAndroid Build Coastguard Worker [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])]) 255*90e502c7SAndroid Build Coastguard Worker AC_SEARCH_LIBS([EVP_aes_128_ctr], [crypto], 256*90e502c7SAndroid Build Coastguard Worker [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])]) 257*90e502c7SAndroid Build Coastguard Worker AC_SEARCH_LIBS([EVP_aes_128_gcm], [crypto], 258*90e502c7SAndroid Build Coastguard Worker [], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])]) 259*90e502c7SAndroid Build Coastguard Worker 260*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([GCM], [1], [Define this to use AES-GCM.]) 261*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([OPENSSL], [1], [Define this to use OpenSSL crypto.]) 262*90e502c7SAndroid Build Coastguard Worker AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o" 263*90e502c7SAndroid Build Coastguard Worker HMAC_OBJS=crypto/hash/hmac_ossl.o 264*90e502c7SAndroid Build Coastguard Worker AC_SUBST([USE_EXTERNAL_CRYPTO], [1]) 265*90e502c7SAndroid Build Coastguard Worker 266*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([if OPENSSL_cleanse is broken]) 267*90e502c7SAndroid Build Coastguard Worker AC_RUN_IFELSE([AC_LANG_PROGRAM([ 268*90e502c7SAndroid Build Coastguard Worker #include <stdio.h> 269*90e502c7SAndroid Build Coastguard Worker #include <openssl/crypto.h> 270*90e502c7SAndroid Build Coastguard Worker ], [ 271*90e502c7SAndroid Build Coastguard Worker #define BUFFER_SIZE (16) 272*90e502c7SAndroid Build Coastguard Worker char buffer[[BUFFER_SIZE]]; 273*90e502c7SAndroid Build Coastguard Worker int i; 274*90e502c7SAndroid Build Coastguard Worker for (i = 0; i < BUFFER_SIZE; i++) { 275*90e502c7SAndroid Build Coastguard Worker buffer[[i]] = i & 0xff; 276*90e502c7SAndroid Build Coastguard Worker } 277*90e502c7SAndroid Build Coastguard Worker OPENSSL_cleanse(buffer, BUFFER_SIZE); 278*90e502c7SAndroid Build Coastguard Worker for (i = 0; i < BUFFER_SIZE; i++) { 279*90e502c7SAndroid Build Coastguard Worker if (buffer[[i]]) { 280*90e502c7SAndroid Build Coastguard Worker printf("Buffer contents not zero at position %d (is %d)\n", i, 281*90e502c7SAndroid Build Coastguard Worker buffer[[i]]); 282*90e502c7SAndroid Build Coastguard Worker return 1; 283*90e502c7SAndroid Build Coastguard Worker } 284*90e502c7SAndroid Build Coastguard Worker } 285*90e502c7SAndroid Build Coastguard Worker ])], [openssl_cleanse_broken=no], [ 286*90e502c7SAndroid Build Coastguard Worker openssl_cleanse_broken=yes 287*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([OPENSSL_CLEANSE_BROKEN], [1], [Define this if OPENSSL_cleanse is broken.]) 288*90e502c7SAndroid Build Coastguard Worker ]) 289*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([$openssl_cleanse_broken]) 290*90e502c7SAndroid Build Coastguard Worker 291*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([whether to leverage OpenSSL KDF algorithm]) 292*90e502c7SAndroid Build Coastguard Worker AC_ARG_ENABLE([openssl-kdf], 293*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])], 294*90e502c7SAndroid Build Coastguard Worker [], [enable_openssl_kdf=no]) 295*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([$enable_openssl_kdf]) 296*90e502c7SAndroid Build Coastguard Worker if test "$enable_openssl_kdf" = "yes"; then 297*90e502c7SAndroid Build Coastguard Worker AC_SEARCH_LIBS([kdf_srtp], [crypto], 298*90e502c7SAndroid Build Coastguard Worker [], [AC_MSG_FAILURE([can't find openssl KDF lib])]) 299*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([OPENSSL_KDF], [1], [Define this to use OpenSSL KDF for SRTP.]) 300*90e502c7SAndroid Build Coastguard Worker fi 301*90e502c7SAndroid Build Coastguard Workerelif test "$enable_nss" = "yes"; then 302*90e502c7SAndroid Build Coastguard Worker AC_MSG_CHECKING([for user specified NSS directory]) 303*90e502c7SAndroid Build Coastguard Worker AC_ARG_WITH([nss-dir], 304*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--with-nss-dir], [Location of NSS installation])], 305*90e502c7SAndroid Build Coastguard Worker [if test "x$PKG_CONFIG" != "x" && test -f $with_nss_dir/lib/pkgconfig/nss.pc; then 306*90e502c7SAndroid Build Coastguard Worker if test "x$PKG_CONFIG_PATH" = "x"; then 307*90e502c7SAndroid Build Coastguard Worker export PKG_CONFIG_PATH="$with_nss_dir/lib/pkgconfig" 308*90e502c7SAndroid Build Coastguard Worker else 309*90e502c7SAndroid Build Coastguard Worker export PKG_CONFIG_PATH="$with_nss_dir/lib/pkgconfig:$PKG_CONFIG_PATH" 310*90e502c7SAndroid Build Coastguard Worker fi 311*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([$with_nss_dir]) 312*90e502c7SAndroid Build Coastguard Worker elif test -d $with_nss_dir/lib; then 313*90e502c7SAndroid Build Coastguard Worker CFLAGS="$CFLAGS -I$with_nss_dir/include" 314*90e502c7SAndroid Build Coastguard Worker CFLAGS="$CFLAGS -I$with_nss_dir/../public/nss" 315*90e502c7SAndroid Build Coastguard Worker if test "x$LDFLAGS" = "x"; then 316*90e502c7SAndroid Build Coastguard Worker LDFLAGS="-L$with_nss_dir/lib" 317*90e502c7SAndroid Build Coastguard Worker else 318*90e502c7SAndroid Build Coastguard Worker LDFLAGS="$LDFLAGS -L$with_nss_dir/lib" 319*90e502c7SAndroid Build Coastguard Worker fi 320*90e502c7SAndroid Build Coastguard Worker nss_skip_pkg_config=yes 321*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([$with_nss_dir]) 322*90e502c7SAndroid Build Coastguard Worker else 323*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([invalid]) 324*90e502c7SAndroid Build Coastguard Worker AC_MSG_FAILURE([Invalid NSS location: $with_nss_dir]) 325*90e502c7SAndroid Build Coastguard Worker fi 326*90e502c7SAndroid Build Coastguard Worker AC_SUBST([CRYPTO_LIBDIR], [$with_nss_dir/lib])], 327*90e502c7SAndroid Build Coastguard Worker [AC_MSG_RESULT([no])]) 328*90e502c7SAndroid Build Coastguard Worker 329*90e502c7SAndroid Build Coastguard Worker if test "x$PKG_CONFIG" != "x" && test "$nss_skip_pkg_config" != "yes"; then 330*90e502c7SAndroid Build Coastguard Worker PKG_CHECK_MODULES([nss], [nss], 331*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$CFLAGS $nss_CFLAGS" 332*90e502c7SAndroid Build Coastguard Worker LIBS="$nss_LIBS $LIBS"]) 333*90e502c7SAndroid Build Coastguard Worker else 334*90e502c7SAndroid Build Coastguard Worker AC_CHECK_HEADERS( 335*90e502c7SAndroid Build Coastguard Worker [nss.h], 336*90e502c7SAndroid Build Coastguard Worker [], [AC_MSG_FAILURE([can't find useable NSS headers])], 337*90e502c7SAndroid Build Coastguard Worker [AC_INCLUDES_DEFAULT]) 338*90e502c7SAndroid Build Coastguard Worker AC_CHECK_LIB( 339*90e502c7SAndroid Build Coastguard Worker [nspr4], [PR_GetError], 340*90e502c7SAndroid Build Coastguard Worker [], [AC_MSG_WARN([can't find libnspr4])]) 341*90e502c7SAndroid Build Coastguard Worker AC_CHECK_LIB( 342*90e502c7SAndroid Build Coastguard Worker [nss3], [NSS_NoDB_Init], 343*90e502c7SAndroid Build Coastguard Worker [], [AC_MSG_FAILURE([can't find useable libnss3])]) 344*90e502c7SAndroid Build Coastguard Worker fi 345*90e502c7SAndroid Build Coastguard Worker 346*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([GCM], [1], [Define this to use AES-GCM.]) 347*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([NSS], [1], [Define this to use NSS crypto.]) 348*90e502c7SAndroid Build Coastguard Worker AES_ICM_OBJS="crypto/cipher/aes_icm_nss.o crypto/cipher/aes_gcm_nss.o" 349*90e502c7SAndroid Build Coastguard Worker 350*90e502c7SAndroid Build Coastguard Worker # TODO(RLB): Use NSS for HMAC 351*90e502c7SAndroid Build Coastguard Worker HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o" 352*90e502c7SAndroid Build Coastguard Worker 353*90e502c7SAndroid Build Coastguard Worker # TODO(RLB): Use NSS for KDF 354*90e502c7SAndroid Build Coastguard Worker 355*90e502c7SAndroid Build Coastguard Worker AC_SUBST([USE_EXTERNAL_CRYPTO], [1]) 356*90e502c7SAndroid Build Coastguard Workerelse 357*90e502c7SAndroid Build Coastguard Worker AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o" 358*90e502c7SAndroid Build Coastguard Worker HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o" 359*90e502c7SAndroid Build Coastguard Workerfi 360*90e502c7SAndroid Build Coastguard WorkerAC_SUBST([AES_ICM_OBJS]) 361*90e502c7SAndroid Build Coastguard WorkerAC_SUBST([HMAC_OBJS]) 362*90e502c7SAndroid Build Coastguard Worker 363*90e502c7SAndroid Build Coastguard Workerdnl Checking for PCAP 364*90e502c7SAndroid Build Coastguard Worker 365*90e502c7SAndroid Build Coastguard WorkerPCAP_LIB="" 366*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_LIB([pcap], [pcap_create], 367*90e502c7SAndroid Build Coastguard Worker [PCAP_LIB="-lpcap" 368*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([HAVE_PCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap)]) 369*90e502c7SAndroid Build Coastguard Worker AC_SUBST([HAVE_PCAP], [1])]) 370*90e502c7SAndroid Build Coastguard Worker 371*90e502c7SAndroid Build Coastguard WorkerAC_CHECK_LIB([wpcap], [pcap_create], 372*90e502c7SAndroid Build Coastguard Worker [PCAP_LIB="-lwpcap" 373*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([HAVE_PCAP], [1], [Define to 1 if you have the `winpcap' library (-lwpcap)]) 374*90e502c7SAndroid Build Coastguard Worker AC_SUBST([HAVE_PCAP], [1])]) 375*90e502c7SAndroid Build Coastguard WorkerAC_SUBST([PCAP_LIB]) 376*90e502c7SAndroid Build Coastguard Worker 377*90e502c7SAndroid Build Coastguard WorkerAC_MSG_CHECKING([whether to redirect logging to stdout]) 378*90e502c7SAndroid Build Coastguard WorkerAC_ARG_ENABLE([log-stdout], 379*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--enable-log-stdout], [redirecting logging to stdout])], 380*90e502c7SAndroid Build Coastguard Worker [], [enable_log_stdout=no]) 381*90e502c7SAndroid Build Coastguard Workerif test "$enable_log_stdout" = "yes"; then 382*90e502c7SAndroid Build Coastguard Worker AC_DEFINE([ERR_REPORTING_STDOUT], [1], [Define to redirect logging to stdout.]) 383*90e502c7SAndroid Build Coastguard Workerfi 384*90e502c7SAndroid Build Coastguard WorkerAC_MSG_RESULT([$enable_log_stdout]) 385*90e502c7SAndroid Build Coastguard Worker 386*90e502c7SAndroid Build Coastguard WorkerAC_MSG_CHECKING([wheather to use a file for logging]) 387*90e502c7SAndroid Build Coastguard WorkerAC_ARG_WITH([log-file], 388*90e502c7SAndroid Build Coastguard Worker [AS_HELP_STRING([--with-log-file], [Use file for logging])], 389*90e502c7SAndroid Build Coastguard Worker [AS_CASE([x$with_log_file], 390*90e502c7SAndroid Build Coastguard Worker [x], [valid_with_log_file="no"], 391*90e502c7SAndroid Build Coastguard Worker [xyes], [valid_with_log_file="no"], 392*90e502c7SAndroid Build Coastguard Worker [valid_with_error_file="yes"]) 393*90e502c7SAndroid Build Coastguard Worker AS_IF([test "$valid_with_log_file" = "no"], 394*90e502c7SAndroid Build Coastguard Worker [AC_MSG_RESULT([invalid]) 395*90e502c7SAndroid Build Coastguard Worker AC_MSG_FAILURE([Invalid value for --with-log-file: "$with_log_file"])], 396*90e502c7SAndroid Build Coastguard Worker [AC_DEFINE_UNQUOTED([ERR_REPORTING_FILE], ["$with_log_file"], [Logging statments will be writen to this file.]) 397*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([using log file: "$with_log_file"])])], 398*90e502c7SAndroid Build Coastguard Worker [AC_MSG_RESULT([no])]) 399*90e502c7SAndroid Build Coastguard Worker 400*90e502c7SAndroid Build Coastguard WorkerAS_IF( 401*90e502c7SAndroid Build Coastguard Worker [test "$enable_log_stdout" = "yes" && test "x$with_log_file" != "x"], 402*90e502c7SAndroid Build Coastguard Worker [AC_MSG_FAILURE([Can only use one of --enable-log-stdout and --with-log-file; they are mutually exclusive])]) 403*90e502c7SAndroid Build Coastguard Worker 404*90e502c7SAndroid Build Coastguard Workerdnl Appending EXTRA_CFLAGS, if given 405*90e502c7SAndroid Build Coastguard WorkerAC_MSG_CHECKING([for extra C compiler flags]) 406*90e502c7SAndroid Build Coastguard WorkerAS_IF([test "x$EXTRA_CFLAGS" != "x"], 407*90e502c7SAndroid Build Coastguard Worker [AS_IF([test "x$CFLAGS" = "x"], 408*90e502c7SAndroid Build Coastguard Worker [CFLAGS="$EXTRA_CFLAGS"], [CFLAGS="$CFLAGS $EXTRA_CFLAGS"]) 409*90e502c7SAndroid Build Coastguard Worker AC_MSG_RESULT([$EXTRA_CFLAGS])], 410*90e502c7SAndroid Build Coastguard Worker [AC_MSG_RESULT(no)]) 411*90e502c7SAndroid Build Coastguard Worker 412*90e502c7SAndroid Build Coastguard WorkerAC_CONFIG_HEADER([crypto/include/config.h:config_in.h]) 413*90e502c7SAndroid Build Coastguard Worker 414*90e502c7SAndroid Build Coastguard WorkerAC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile fuzzer/Makefile libsrtp2.pc]) 415*90e502c7SAndroid Build Coastguard WorkerAC_OUTPUT 416*90e502c7SAndroid Build Coastguard Worker 417*90e502c7SAndroid Build Coastguard Worker# This is needed when building outside the source dir. 418*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([crypto/cipher]) 419*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([crypto/hash]) 420*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([crypto/kernel]) 421*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([crypto/math]) 422*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([crypto/replay]) 423*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([crypto/test]) 424*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([doc]) 425*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([srtp]) 426*90e502c7SAndroid Build Coastguard WorkerAS_MKDIR_P([test]) 427