configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. AC_PREREQ(2.59)
  2. AC_INIT(srtp, 1.4.2, mcgrew@cisco.com)
  3. AC_CONFIG_AUX_DIR(build)
  4. AM_INIT_AUTOMAKE
  5. CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
  6. CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
  7. LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
  8. #Set default language
  9. AC_LANG_C
  10. # Checks for programs.
  11. AC_PROG_CC
  12. AC_PROG_AWK
  13. AC_PROG_MAKE_SET
  14. AC_PROG_INSTALL
  15. AC_PROG_LIBTOOL
  16. AX_COMPILER_VENDOR
  17. # Optimization
  18. AC_ARG_ENABLE(optimization,
  19. [AC_HELP_STRING([--enable-optimization],[Set if you want us to add max optimising compiler flags])],[enable_optimizer="$enableval"],[enable_optimizer="no"])
  20. if test "${enable_optimizer}" = "yes" ; then
  21. AC_DEFINE([OPTIMZER],[],[Enable Optimization.])
  22. AX_CC_MAXOPT
  23. fi
  24. # Enable debugging
  25. AC_ARG_ENABLE(debug,
  26. [AC_HELP_STRING([--enable-debug],[build with debug information])],[enable_debug="$enable_debug"],[enable_debug="yes"])
  27. if test "${enable_debug}" = "yes"; then
  28. AC_DEFINE([DEBUG],[],[Enable extra debugging.])
  29. AX_CFLAGS_WARN_ALL_ANSI
  30. fi
  31. AM_CONDITIONAL([WANT_DEBUG],[test "${enable_debug}" = "yes"])
  32. IN_LINE=inline
  33. case "$host" in
  34. *-solaris2*)
  35. if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
  36. SOLINK="-Bdynamic -dy -G"
  37. new_AM_CFLAGS="-KPIC -DPIC"
  38. new_AM_LDFLAGS="-R${prefix}/lib"
  39. FUNC_DEF=__func__
  40. IN_LINE=""
  41. elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
  42. SOLINK="-Bdynamic -dy -G"
  43. new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops"
  44. new_AM_LDFLAGS=""
  45. IN_LINE=inline
  46. fi
  47. ;;
  48. *-darwin*)
  49. if test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then
  50. SOLINK="-dynamic -bundle -force-flat-namespace"
  51. new_AM_CFLAGS="-DMACOSX"
  52. new_AM_LDFLAGS=""
  53. fi
  54. ;;
  55. x86_64-*-linux-gnu)
  56. if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
  57. SOLINK="-Bdynamic -dy -G"
  58. new_AM_CFLAGS="-KPIC -DPIC"
  59. new_AM_LDFLAGS="-R${prefix}/lib"
  60. FUNC_DEF=__func__
  61. elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then
  62. SOLINK="-shared -Xlinker -x"
  63. new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops"
  64. new_AM_LDFLAGS=""
  65. fi
  66. ;;
  67. i*6-*-linux-gnu)
  68. if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
  69. SOLINK="-Bdynamic -dy -G"
  70. new_AM_CFLAGS="-KPIC -DPIC"
  71. new_AM_LDFLAGS="-R${prefix}/lib"
  72. FUNC_DEF=__func__
  73. elif test "x${ax_cv_c_compiler_vendor}"="xgnu" ; then
  74. SOLINK="-shared -Xlinker -x"
  75. new_AM_CFLAGS="-fpic -Wall -O4 -fexpensive-optimizations -funroll-loops"
  76. new_AM_LDFLAGS=""
  77. fi
  78. ;;
  79. i*6*-*-freebsd*)
  80. SOLINK="-shared -Xlinker -x"
  81. new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops"
  82. new_AM_LDFLAGS=""
  83. ;;
  84. x86_64-*-freebsd*|amd64-*-freebsd*)
  85. SOLINK="-shared -Xlinker -x"
  86. new_AM_CFLAGS="-fPIC -Wall -O4 -fexpensive-optimizations -funroll-loops"
  87. new_AM_LDFLAGS=""
  88. ;;
  89. esac
  90. # Enable 64 bit build
  91. AC_ARG_ENABLE(64,
  92. [AC_HELP_STRING([--enable-64],[build with 64 bit support])],[enable_64="$enable_64"],[enable_64="no"])
  93. if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
  94. if test "${enable_64}" = "yes"; then
  95. new_AM_CFLAGS="$new_AM_CFLAGS -m64"
  96. fi
  97. fi
  98. AC_SUBST(new_AM_CFLAGS)
  99. AC_SUBST(new_AM_LDFLAGS)
  100. AC_SUBST(SOLINK)
  101. if test "x$FUNC_DEF" != "x"; then
  102. AC_DEFINE_UNQUOTED([__FUNCTION__],[$FUNC_DEF],[define it the right way ;)])
  103. fi
  104. AC_DEFINE_UNQUOTED([inline],[$IN_LINE],[sunpro is bad at inline])
  105. AC_ARG_ENABLE(kernel-linux,
  106. [AS_HELP_STRING([--enable-kernel-linux],
  107. [build library to run in Linux kernel context])],
  108. [], enable_kernel_linux=no)
  109. AC_MSG_CHECKING(whether to build for Linux kernel context)
  110. if test "$enable_kernel_linux" = "yes"; then
  111. AC_DEFINE(SRTP_KERNEL, 1,
  112. [Define to compile for kernel contexts.])
  113. AC_DEFINE(SRTP_KERNEL_LINUX, 1,
  114. [Define to compile for Linux kernel context.])
  115. fi
  116. AC_MSG_RESULT($enable_kernel_linux)
  117. dnl Check for /dev/urandom
  118. AC_CHECK_FILE(/dev/urandom, DEV_URANDOM=/dev/urandom,
  119. [AC_CHECK_FILE(/dev/random, DEV_URANDOM=/dev/random)])
  120. dnl Checks for header files.
  121. AC_HEADER_STDC
  122. AC_CHECK_HEADERS(stdlib.h)
  123. AC_CHECK_HEADERS(unistd.h)
  124. AC_CHECK_HEADERS(stdint.h)
  125. AC_CHECK_HEADERS(sys/uio.h)
  126. AC_CHECK_HEADERS(inttypes.h)
  127. AC_CHECK_HEADERS(sys/types.h)
  128. AC_CHECK_HEADERS(machine/types.h)
  129. AC_CHECK_HEADERS(sys/int_types.h)
  130. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  131. #include <inttypes.h>
  132. #include <byteswap.h>
  133. ]],[[
  134. uint64_t y = 0x1122334455667788LL;
  135. bswap_64(y);
  136. ]])],byteswap_cv_bswap_64_usable=yes,byteswap_cv_bswap_64_usable=no)
  137. if test "x${byteswap_cv_bswap_64_usable}" = "xyes" ; then
  138. AC_DEFINE([HAVE_BYTESWAP_H],1,[define if you have a usable bswap_64 in byteswap.h])
  139. fi
  140. dnl socket() and friends
  141. AC_CHECK_HEADERS(sys/socket.h netinet/in.h arpa/inet.h)
  142. AC_CHECK_HEADERS(windows.h, [AC_CHECK_HEADERS(winsock2.h)])
  143. AC_CHECK_HEADERS(syslog.h)
  144. AC_CHECK_TYPES([int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,uint64_t])
  145. AC_CHECK_SIZEOF(unsigned long)
  146. AC_CHECK_SIZEOF(unsigned long long)
  147. dnl Checks for typedefs, structures, and compiler characteristics.
  148. AC_C_CONST
  149. AC_C_INLINE
  150. AC_TYPE_SIZE_T
  151. dnl Checks for library functions.
  152. AC_CHECK_FUNCS(socket inet_aton usleep sigaction)
  153. dnl Find socket function if not found yet.
  154. if test "x$ac_cv_func_socket" = "xno"; then
  155. AC_CHECK_LIB(socket, socket)
  156. AC_MSG_CHECKING([for socket in -lwsock32])
  157. SAVELIBS="$LIBS"
  158. LIBS="$LIBS -lwsock32"
  159. AC_TRY_LINK([
  160. #include <winsock2.h>
  161. ],[
  162. socket(0, 0, 0);
  163. ],
  164. ac_cv_func_socket=yes
  165. AC_MSG_RESULT(yes),
  166. LIBS="$SAVELIBS"
  167. AC_MSG_RESULT(no))
  168. fi
  169. dnl Check the byte order
  170. AC_C_BIGENDIAN
  171. dnl check host_cpu type, set defines appropriately
  172. case $host_cpu in
  173. i*86 | x86_64 )
  174. AC_DEFINE(CPU_CISC, 1,
  175. [Define if building for a CISC machine (e.g. Intel).])
  176. # Do not enable use of asm for MACOSX
  177. if test "x$new_AM_CFLAGS" != "x-DMACOSX"; then
  178. AC_DEFINE(HAVE_X86, 1,
  179. [Define to use X86 inlined assembly code])
  180. fi
  181. ;;
  182. * )
  183. # CPU_RISC is only supported for big endian machines.
  184. if test "$ac_cv_c_bigendian" = "yes"; then
  185. AC_DEFINE(CPU_RISC, 1,
  186. [Define if building for a RISC machine (assume slow byte access).])
  187. else
  188. AC_DEFINE(CPU_CISC, 1)
  189. fi
  190. ;;
  191. esac
  192. dnl Check if we're on a Windows platform.
  193. case $host_os in
  194. *cygwin*|*mingw* )
  195. EXE=.exe;;
  196. * ) EXE="";;
  197. esac
  198. AC_SUBST(EXE) # define executable suffix; this is needed for `make clean'
  199. AC_MSG_CHECKING(whether to compile in debugging)
  200. AC_ARG_ENABLE(debug,
  201. [AS_HELP_STRING([--disable-debug],
  202. [do not compile in dynamic debugging system])],
  203. [], enable_debug=yes)
  204. if test "$enable_debug" = "yes"; then
  205. AC_DEFINE(ENABLE_DEBUGGING, 1,
  206. [Define to compile in dynamic debugging system.])
  207. fi
  208. AC_MSG_RESULT($enable_debug)
  209. AC_MSG_CHECKING(whether to use ISMAcryp code)
  210. AC_ARG_ENABLE(generic-aesicm,
  211. [AS_HELP_STRING([--enable-generic-aesicm],
  212. [compile in changes for ISMAcryp])],
  213. [], enable_generic_aesicm=no)
  214. if test "$enable_generic_aesicm" = "yes"; then
  215. AC_DEFINE(GENERIC_AESICM, 1, [Define this to use ISMAcryp code.])
  216. fi
  217. AC_MSG_RESULT($enable_generic_aesicm)
  218. AC_MSG_CHECKING(whether to leverage OpenSSL crypto)
  219. AC_ARG_ENABLE(openssl,
  220. [AS_HELP_STRING([--enable-openssl],
  221. [compile in OpenSSL crypto engine])],
  222. [], enable_openssl=no)
  223. if test "$enable_openssl" = "yes"; then
  224. echo $enable_openssl
  225. LDFLAGS="$LDFLAGS $(pkg-config --libs openssl)";
  226. CFLAGS="$CFLAGS $(pkg-config --cflags openssl)";
  227. AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
  228. [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
  229. AC_CHECK_LIB([crypto], [EVP_aes_128_ctr], [],
  230. [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
  231. AC_CHECK_LIB([crypto], [EVP_aes_128_gcm], [],
  232. [AC_MSG_FAILURE([can't find openssl >1.0.1 crypto lib])])
  233. AC_DEFINE(OPENSSL, 1, [Define this to use OpenSSL crypto.])
  234. AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o"
  235. HMAC_OBJS=crypto/hash/hmac_ossl.o
  236. USE_OPENSSL=1
  237. AC_SUBST(USE_OPENSSL)
  238. else
  239. echo $enable_openssl
  240. AES_ICM_OBJS="crypto/cipher/aes_icm.o crypto/cipher/aes.o crypto/cipher/aes_cbc.o"
  241. AC_MSG_CHECKING(which random device to use)
  242. if test "$enable_kernel_linux" = "yes"; then
  243. AC_MSG_RESULT([Linux kernel builtin])
  244. else
  245. if test -n "$DEV_URANDOM"; then
  246. AC_DEFINE_UNQUOTED(DEV_URANDOM, "$DEV_URANDOM",[Path to random device])
  247. AC_MSG_RESULT([$DEV_URANDOM])
  248. else
  249. AC_MSG_RESULT([standard rand() function...])
  250. fi
  251. fi
  252. HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"
  253. fi
  254. AM_CONDITIONAL([ENABLE_OPENSSL],[test "${enable_openssl}" = "yes"])
  255. AC_SUBST(AES_ICM_OBJS)
  256. AC_SUBST(HMAC_OBJS)
  257. AC_MSG_RESULT($enable_openssl)
  258. AC_MSG_CHECKING(whether to use syslog for error reporting)
  259. AC_ARG_ENABLE(syslog,
  260. [AS_HELP_STRING([--enable-syslog], [use syslog for error reporting])],
  261. [], enable_syslog=no)
  262. if test "$enable_syslog" = "yes"; then
  263. AC_DEFINE(USE_SYSLOG, 1, [Define to use syslog logging.])
  264. fi
  265. AC_MSG_RESULT($enable_syslog)
  266. AC_MSG_CHECKING(whether to use stdout for error reporting)
  267. AC_ARG_ENABLE(stdout,
  268. [AS_HELP_STRING([--disable-stdout], [don't use stdout for error reporting])],
  269. [], enable_stdout=yes)
  270. if test "$enable_stdout" = "yes"; then
  271. AC_DEFINE(ERR_REPORTING_STDOUT, 1, [Define to use logging to stdout.])
  272. fi
  273. AC_MSG_RESULT($enable_stdout)
  274. AC_MSG_CHECKING(whether to use /dev/console for error reporting)
  275. AC_ARG_ENABLE(console,
  276. [AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])],
  277. [], enable_console=no)
  278. if test "$enable_console" = "yes"; then
  279. AC_DEFINE(USE_ERR_REPORTING_FILE, 1, [Write errors to this file])
  280. AC_DEFINE(ERR_REPORTING_FILE, "/dev/console", [Report errors to this file.])
  281. fi
  282. AC_MSG_RESULT($enable_console)
  283. AC_MSG_CHECKING(whether to use GDOI key management)
  284. AC_ARG_ENABLE(gdoi,
  285. [AS_HELP_STRING([--enable-gdoi], [enable GDOI key management])],
  286. [], enable_gdoi=no)
  287. if test "$enable_gdoi" = "yes"; then
  288. AC_DEFINE(SRTP_GDOI, 1, [Define to use GDOI.])
  289. GDOI_OBJS=gdoi/srtp+gdoi.o
  290. AC_SUBST(GDOI_OBJS)
  291. fi
  292. AC_MSG_RESULT($enable_gdoi)
  293. AM_CONDITIONAL([GDOI],[test "SRTP_GDOI" = "1"])
  294. AC_CONFIG_HEADERS(crypto/include/config.h:config_in.h)
  295. AC_OUTPUT(Makefile crypto/Makefile doc/Makefile test/Makefile libsrtp2.pc)
  296. # This is needed when building outside the source dir.
  297. AS_MKDIR_P(crypto/cipher)
  298. AS_MKDIR_P(crypto/hash)
  299. AS_MKDIR_P(crypto/kernel)
  300. AS_MKDIR_P(crypto/math)
  301. AS_MKDIR_P(crypto/replay)
  302. AS_MKDIR_P(crypto/test)
  303. AS_MKDIR_P(doc)
  304. AS_MKDIR_P(srtp)
  305. AS_MKDIR_P(tables)
  306. AS_MKDIR_P(test)