You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
6.6 KiB

12 years ago
12 years ago
9 years ago
11 years ago
12 years ago
12 years ago
10 years ago
12 years ago
12 years ago
12 years ago
11 years ago
12 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
11 years ago
10 years ago
11 years ago
12 years ago
  1. dnl -*- Autoconf -*-
  2. dnl Process this file with autoconf to produce a configure script.
  3. AC_PREREQ([2.67])
  4. AC_INIT([shadowsocks-libev], [2.4.1], [max.c.lv@gmail.com])
  5. AC_CONFIG_SRCDIR([src/encrypt.c])
  6. AC_CONFIG_HEADERS([config.h])
  7. AC_CONFIG_AUX_DIR(auto)
  8. AC_CONFIG_MACRO_DIR([m4])
  9. AM_INIT_AUTOMAKE([subdir-objects foreign -Wall -Werror])
  10. m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
  11. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  12. AM_MAINTAINER_MODE
  13. AM_DEP_TRACK
  14. dnl Checks for lib
  15. AC_DISABLE_STATIC
  16. AC_DISABLE_SHARED
  17. LT_INIT([dlopen])
  18. dnl Checks for using shared libraries from system
  19. AC_ARG_ENABLE(
  20. [system-shared-lib],
  21. AS_HELP_STRING([--enable-system-shared-lib], [build against shared libraries when possible]),
  22. [
  23. case "${enableval}" in
  24. yes) enable_system_shared_lib=true ;;
  25. no) enable_system_shared_lib=false ;;
  26. *) AC_MSG_ERROR([bad value ${enableval} for --enable-system-shared-lib]) ;;
  27. esac], [enable_system_shared_lib=false])
  28. AM_CONDITIONAL([USE_SYSTEM_SHARED_LIB], [test x$enable_system_shared_lib = xtrue])
  29. dnl Checks for crypto library
  30. AC_ARG_WITH(
  31. [crypto-library],
  32. [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|polarssl|mbedtls @<:@default=openssl@:>@])],
  33. [
  34. case "${withval}" in
  35. openssl|polarssl|mbedtls) ;;
  36. *) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;;
  37. esac
  38. ],
  39. [with_crypto_library="openssl"]
  40. )
  41. dnl Checks for programs.
  42. AC_PROG_CC
  43. AM_PROG_CC_C_O
  44. AC_PROG_INSTALL
  45. AC_PROG_LN_S
  46. AC_PROG_LIBTOOL
  47. AC_PROG_MAKE_SET
  48. AC_LANG_SOURCE
  49. dnl Checks for libev
  50. m4_include([libev/libev.m4])
  51. dnl Add library for mingw
  52. case $host in
  53. *-mingw*)
  54. LIBS="$LIBS -ladvapi32 -lgdi32 -lws2_32 -lcrypt32"
  55. ;;
  56. *)
  57. ;;
  58. esac
  59. dnl Checks for TLS
  60. AX_TLS([:], [:])
  61. dnl Checks for crypto library
  62. case "${with_crypto_library}" in
  63. openssl)
  64. ss_ZLIB
  65. ss_OPENSSL
  66. AC_DEFINE([USE_CRYPTO_OPENSSL], [1], [Use OpenSSL library])
  67. ;;
  68. polarssl)
  69. ss_POLARSSL
  70. AC_DEFINE([USE_CRYPTO_POLARSSL], [1], [Use PolarSSL library])
  71. ;;
  72. mbedtls)
  73. ss_MBEDTLS
  74. AC_DEFINE([USE_CRYPTO_MBEDTLS], [1], [Use mbed TLS library])
  75. ;;
  76. esac
  77. dnl Checks for Apple CommonCrypto API
  78. AC_ARG_ENABLE(applecc,
  79. AS_HELP_STRING([--enable-applecc], [enable Apple CommonCrypto API support]),
  80. [
  81. AC_CHECK_HEADERS(CommonCrypto/CommonCrypto.h,
  82. [],
  83. [AC_MSG_ERROR([CommonCrypto header files not found.]); break]
  84. )
  85. AC_CHECK_FUNCS([CCCryptorCreateWithMode], ,
  86. [AC_MSG_ERROR([CommonCrypto API needs OS X (>= 10.7) and iOS (>= 5.0).]); break]
  87. )
  88. AC_DEFINE([USE_CRYPTO_APPLECC], [1], [Use Apple CommonCrypto library])
  89. ]
  90. )
  91. dnl Checks for inet_ntop
  92. ss_FUNC_INET_NTOP
  93. dnl Checks for host.
  94. AC_MSG_CHECKING(for what kind of host)
  95. case $host in
  96. *-linux*)
  97. os_support=linux
  98. AC_MSG_RESULT(Linux)
  99. ;;
  100. *-mingw*)
  101. dnl Add custom macros for libev
  102. AC_DEFINE([FD_SETSIZE], [2048], [Reset max file descriptor size.])
  103. AC_DEFINE([EV_FD_TO_WIN32_HANDLE(fd)], [(fd)], [Override libev default fd conversion macro.])
  104. AC_DEFINE([EV_WIN32_HANDLE_TO_FD(handle)], [(handle)], [Override libev default handle conversion macro.])
  105. AC_DEFINE([EV_WIN32_CLOSE_FD(fd)], [closesocket(fd)], [Override libev default fd close macro.])
  106. os_support=mingw
  107. AC_MSG_RESULT(MinGW)
  108. ;;
  109. *)
  110. AC_MSG_RESULT(transparent proxy does not support for $host)
  111. ;;
  112. esac
  113. AM_CONDITIONAL(BUILD_REDIRECTOR, test "$os_support" = "linux")
  114. AM_CONDITIONAL(BUILD_WINCOMPAT, test "$os_support" = "mingw")
  115. dnl Checks for header files.
  116. AC_CHECK_HEADERS([limits.h stdint.h inttypes.h arpa/inet.h fcntl.h langinfo.h locale.h netdb.h netinet/in.h stdlib.h string.h strings.h unistd.h sys/ioctl.h])
  117. dnl A special check required for <net/if.h> on Darwin. See
  118. dnl http://www.gnu.org/software/autoconf/manual/html_node/Header-Portability.html.
  119. AC_CHECK_HEADERS([sys/socket.h])
  120. AC_CHECK_HEADERS([net/if.h], [], [],
  121. [
  122. #include <stdio.h>
  123. #ifdef STDC_HEADERS
  124. # include <stdlib.h>
  125. # include <stddef.h>
  126. #else
  127. # ifdef HAVE_STDLIB_H
  128. # include <stdlib.h>
  129. # endif
  130. #endif
  131. #ifdef HAVE_SYS_SOCKET_H
  132. # include <sys/socket.h>
  133. #endif
  134. ])
  135. case $host in
  136. *-mingw*)
  137. AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([Missing MinGW headers])], [])
  138. ;;
  139. *-linux*)
  140. dnl Checks for netfilter headers
  141. AC_CHECK_HEADERS([linux/if.h linux/netfilter_ipv4.h linux/netfilter_ipv6/ip6_tables.h],
  142. [], [AC_MSG_ERROR([Missing netfilter headers])],
  143. [[
  144. #if HAVE_LIMITS_H
  145. #include <limits.h>
  146. #endif
  147. /* Netfilter ip(6)tables v1.4.0 has broken headers */
  148. #if HAVE_NETINET_IN_H
  149. #include <netinet/in.h>
  150. #endif
  151. #if HAVE_LINUX_IF_H
  152. #include <net/if.h>
  153. #endif
  154. #if HAVE_SYS_SOCKET_H
  155. #include <sys/socket.h>
  156. #endif
  157. ]])
  158. ;;
  159. *)
  160. # These are POSIX-like systems using BSD-like sockets API.
  161. ;;
  162. esac
  163. AC_C_BIGENDIAN
  164. dnl Checks for typedefs, structures, and compiler characteristics.
  165. AC_C_INLINE
  166. AC_TYPE_SSIZE_T
  167. dnl Checks for header files.
  168. AC_HEADER_ASSERT
  169. AC_HEADER_STDC
  170. AC_HEADER_SYS_WAIT
  171. dnl Checks for typedefs, structures, and compiler characteristics.
  172. AC_C_CONST
  173. AC_TYPE_PID_T
  174. AC_TYPE_SIZE_T
  175. AC_TYPE_SSIZE_T
  176. AC_TYPE_UINT16_T
  177. AC_TYPE_UINT8_T
  178. AC_HEADER_TIME
  179. dnl Checks for library functions.
  180. AC_FUNC_FORK
  181. AC_FUNC_SELECT_ARGTYPES
  182. AC_TYPE_SIGNAL
  183. AC_CHECK_FUNCS([memset select setresuid setreuid strerror getpwnam_r setrlimit])
  184. dnl Check for select() into ws2_32 for Msys/Mingw
  185. if test "$ac_cv_func_select" != "yes"; then
  186. AC_MSG_CHECKING([for select in ws2_32])
  187. AC_TRY_LINK([
  188. #ifdef HAVE_WINSOCK2_H
  189. #ifndef WIN32_LEAN_AND_MEAN
  190. #define WIN32_LEAN_AND_MEAN
  191. #endif
  192. #include <winsock2.h>
  193. #endif
  194. ],[
  195. select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
  196. ],[
  197. AC_MSG_RESULT([yes])
  198. HAVE_SELECT="1"
  199. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  200. [Define to 1 if you have the `select' function.])
  201. HAVE_SYS_SELECT_H="1"
  202. AC_DEFINE_UNQUOTED(HAVE_SYS_SELECT_H, 1,
  203. [Define to 1 if you have the <sys/select.h> header file.])
  204. ],[
  205. AC_MSG_ERROR([no])
  206. ])
  207. fi
  208. AC_SYS_LARGEFILE
  209. AC_CHECK_LIB(socket, connect)
  210. dnl Checks for library functions.
  211. AC_CHECK_FUNCS([malloc memset socket])
  212. ACX_PTHREAD
  213. if test "$acx_pthread_ok" != "yes"; then
  214. AC_MSG_ERROR([Missing Pthread Library])
  215. else
  216. LIBS="$LIBS $PTHREAD_LIBS"
  217. fi
  218. AM_COND_IF([USE_SYSTEM_SHARED_LIB],
  219. [],
  220. [AC_CONFIG_SUBDIRS([libsodium])])
  221. AC_CONFIG_FILES([ shadowsocks-libev.pc
  222. Makefile
  223. libcork/Makefile
  224. libipset/Makefile
  225. libudns/Makefile
  226. libev/Makefile
  227. src/Makefile])
  228. AC_OUTPUT