configure.in 6.33 KB
Newer Older
Cullen Jennings's avatar
Cullen Jennings committed
1
dnl Process this file with autoconf to produce a configure script.
jfigus's avatar
jfigus committed
2
AC_INIT([libsrtp2], [2.0.1-pre], [https://github.com/cisco/libsrtp/issues])
Cullen Jennings's avatar
Cullen Jennings committed
3

4 5 6
dnl Must come before AC_PROG_CC
if test -z "$CFLAGS"; then
   dnl Default value for CFLAGS if not specified.
7
   CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops"
8 9
fi

Cullen Jennings's avatar
Cullen Jennings committed
10
dnl Checks for programs.
11
AM_PROG_AR
Cullen Jennings's avatar
Cullen Jennings committed
12 13
AC_PROG_RANLIB
AC_PROG_CC
14
AC_PROG_INSTALL
Cullen Jennings's avatar
Cullen Jennings committed
15

16 17 18 19 20 21 22
dnl Check the byte order
AC_C_BIGENDIAN

AC_CANONICAL_HOST

dnl check host_cpu type, set defines appropriately
case $host_cpu in
23
     i*86 | x86_64 )
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
	AC_DEFINE(CPU_CISC, 1,
	   [Define if building for a CISC machine (e.g. Intel).])
        AC_DEFINE(HAVE_X86, 1,
	   [Define to use X86 inlined assembly code]);; 
	* )
	   AC_DEFINE(CPU_RISC, 1,
	    [Define if building for a RISC machine (assume slow byte access).])
	;;
esac	

dnl Check if we are on a Windows platform.
case $host_os in
    *cygwin*|*mingw* ) 
	EXE=.exe
	HOST_IS_WINDOWS=yes
	;;
    * )
	EXE=""
	;;
esac
AC_SUBST(EXE)   # define executable suffix; this is needed for `make clean'

Cullen Jennings's avatar
Cullen Jennings committed
46 47 48 49 50

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_HEADERS(unistd.h)
51
AC_CHECK_HEADERS(byteswap.h)
Cullen Jennings's avatar
Cullen Jennings committed
52 53
AC_CHECK_HEADERS(stdint.h)
AC_CHECK_HEADERS(sys/uio.h)
Randell Jesup's avatar
Randell Jesup committed
54
AC_CHECK_HEADERS(inttypes.h)
55
AC_CHECK_HEADERS(sys/types.h)
Cullen Jennings's avatar
Cullen Jennings committed
56 57 58
AC_CHECK_HEADERS(machine/types.h)
AC_CHECK_HEADERS(sys/int_types.h)

59 60 61 62
dnl socket() and friends
AC_CHECK_HEADERS(sys/socket.h netinet/in.h arpa/inet.h)
AC_CHECK_HEADERS(windows.h, [AC_CHECK_HEADERS(winsock2.h)])

Randell Jesup's avatar
Randell Jesup committed
63
AC_CHECK_TYPES([int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,uint64_t])
64 65
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned long long)
Cullen Jennings's avatar
Cullen Jennings committed
66 67 68 69 70 71 72

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T

dnl Checks for library functions.
73
AC_CHECK_FUNCS(socket inet_aton usleep sigaction)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

dnl Find socket function if not found yet.
if test "x$ac_cv_func_socket" = "xno"; then
  AC_CHECK_LIB(socket, socket)
  AC_MSG_CHECKING([for socket in -lwsock32])
  SAVELIBS="$LIBS"
  LIBS="$LIBS -lwsock32"
  AC_TRY_LINK([
#include <winsock2.h>
],[
socket(0, 0, 0);
],
    ac_cv_func_socket=yes
    AC_MSG_RESULT(yes),
    LIBS="$SAVELIBS"
    AC_MSG_RESULT(no))
fi
Cullen Jennings's avatar
Cullen Jennings committed
91

92 93 94 95 96 97 98 99
AC_MSG_CHECKING(whether to compile in debugging)
AC_ARG_ENABLE(debug,
  [AS_HELP_STRING([--disable-debug],
		  [do not compile in dynamic debugging system])],
  [], enable_debug=yes)
if test "$enable_debug" = "yes"; then
   AC_DEFINE(ENABLE_DEBUGGING, 1,
      [Define to compile in dynamic debugging system.])
Cullen Jennings's avatar
Cullen Jennings committed
100
fi
101 102 103 104 105 106 107 108 109
AC_MSG_RESULT($enable_debug)

AC_MSG_CHECKING(whether to use ISMAcryp code)
AC_ARG_ENABLE(generic-aesicm,
  [AS_HELP_STRING([--enable-generic-aesicm],
		  [compile in changes for ISMAcryp])],
  [], enable_generic_aesicm=no)
if test "$enable_generic_aesicm" = "yes"; then
   AC_DEFINE(GENERIC_AESICM, 1, [Define this to use ISMAcryp code.])
Cullen Jennings's avatar
Cullen Jennings committed
110
fi
111 112
AC_MSG_RESULT($enable_generic_aesicm)

113 114 115 116 117
AC_MSG_CHECKING(whether to leverage OpenSSL crypto)
AC_ARG_ENABLE(openssl,
  [AS_HELP_STRING([--enable-openssl],
		  [compile in OpenSSL crypto engine])],
  [], enable_openssl=no)
118
AC_MSG_RESULT($enable_openssl)
119
if test "$enable_openssl" = "yes"; then
120 121 122 123 124 125 126
   AC_MSG_CHECKING(for user specified OpenSSL directory)
   AC_ARG_WITH(openssl-dir,
      [AS_HELP_STRING([--with-openssl-dir], [Location of OpenSSL installation])],
      [openssl_dir="$withval"], openssl_dir="")

   LDFLAGS="$LDFLAGS -L$openssl_dir/lib $(pkg-config --libs openssl)";
   CFLAGS="$CFLAGS -I$openssl_dir/include $(pkg-config --cflags openssl)";
127

128
   AC_CHECK_LIB([dl], [dlopen], [],
129
             [AC_MSG_WARN([can't find libdl])])
130
   AC_CHECK_LIB([z], [inflate], [],
131
             [AC_MSG_WARN([can't find libz])])
132
   AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
133 134 135
             [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
   AC_CHECK_LIB([crypto], [EVP_aes_128_ctr], [],
             [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
136 137
   AC_CHECK_LIB([crypto], [EVP_aes_128_gcm], [],
             [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
138
   AC_DEFINE(OPENSSL, 1, [Define this to use OpenSSL crypto.])
139
   AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o"
140 141 142
   HMAC_OBJS=crypto/hash/hmac_ossl.o
   USE_OPENSSL=1
   AC_SUBST(USE_OPENSSL)
143 144 145 146 147 148 149 150 151 152 153

   AC_MSG_CHECKING(whether to leverage OpenSSL KDF algorithm)
   AC_ARG_ENABLE(openssl-kdf,
      [AS_HELP_STRING([--enable-openssl-kdf], [Use OpenSSL KDF algorithm])],
      [], enable_openssl_kdf=no)
   AC_MSG_RESULT($enable_openssl_kdf)
   if test "$enable_openssl_kdf" = "yes"; then
      AC_CHECK_LIB([crypto], [kdf_srtp], [],
             [AC_MSG_FAILURE([can't find openssl KDF lib])])
      AC_DEFINE(OPENSSL_KDF, 1, [Define this to use OpenSSL KDF for SRTP.])
   fi
154
else
155
   AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o"
156
   HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"
157
fi
158 159
AC_SUBST(AES_ICM_OBJS)                              
AC_SUBST(HMAC_OBJS)
160

161
dnl Checking for PCAP
162 163 164 165 166 167 168
AC_CHECK_LIB([pcap],[pcap_create],
    [PCAP=1
     LIBS="-lpcap $LIBS"
     HAVE_PCAP=1
     AC_DEFINE(HAVE_PCAP, 1, [Define to 1 if you have the `pcap' library (-lpcap)])
     AC_SUBST(HAVE_PCAP)
])
169

170 171
AC_MSG_CHECKING(whether to use stdout for error reporting)
AC_ARG_ENABLE(stdout,
172 173
  [AS_HELP_STRING([--enable-stdout], [use stdout for debug/error reporting])],
  [], enable_stdout=no)
174 175
if test "$enable_stdout" = "yes"; then
   AC_DEFINE(ERR_REPORTING_STDOUT, 1, [Define to use logging to stdout.])
Cullen Jennings's avatar
Cullen Jennings committed
176
fi
177 178 179 180 181 182 183 184 185
AC_MSG_RESULT($enable_stdout)

AC_MSG_CHECKING(whether to use /dev/console for error reporting)
AC_ARG_ENABLE(console,
  [AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])],
  [], enable_console=no)
if test "$enable_console" = "yes"; then
   AC_DEFINE(USE_ERR_REPORTING_FILE, 1, [Write errors to this file])
   AC_DEFINE(ERR_REPORTING_FILE, "/dev/console", [Report errors to this file.])
Cullen Jennings's avatar
Cullen Jennings committed
186
fi
187 188
AC_MSG_RESULT($enable_console)

189
AC_CONFIG_HEADER(crypto/include/config.h:config_in.h)
Cullen Jennings's avatar
Cullen Jennings committed
190

191 192 193
AC_CHECK_PROG(PKG_CONFIG, pkg-config, yes)
if test "x$PKG_CONFIG" != "x"; then
    HAVE_PKG_CONFIG=1
194
    AC_CONFIG_FILES([libsrtp2.pc])
195 196 197 198 199 200
else
    HAVE_PKG_CONFIG=0
fi
AC_SUBST(HAVE_PKG_CONFIG)
AC_CONFIG_FILES([Makefile crypto/Makefile doc/Makefile])
AC_OUTPUT
201 202 203 204 205 206 207 208 209 210 211

# This is needed when building outside the source dir.
AS_MKDIR_P(crypto/cipher)
AS_MKDIR_P(crypto/hash)
AS_MKDIR_P(crypto/kernel)
AS_MKDIR_P(crypto/math)
AS_MKDIR_P(crypto/replay)
AS_MKDIR_P(crypto/test)
AS_MKDIR_P(doc)
AS_MKDIR_P(srtp)
AS_MKDIR_P(test)