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.

298 lines
8.0 KiB

12 years ago
12 years ago
8 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
8 years ago
12 years ago
8 years ago
8 years ago
8 years ago
8 years ago
12 years ago
12 years ago
12 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.7], [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. AC_USE_SYSTEM_EXTENSIONS
  10. AM_INIT_AUTOMAKE([subdir-objects foreign -Wall -Werror])
  11. m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
  12. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  13. AM_MAINTAINER_MODE
  14. AM_DEP_TRACK
  15. dnl Checks for lib
  16. AC_DISABLE_STATIC
  17. AC_DISABLE_SHARED
  18. LT_INIT([dlopen])
  19. dnl Checks for using shared libraries from system
  20. AC_ARG_ENABLE(
  21. [system-shared-lib],
  22. AS_HELP_STRING([--enable-system-shared-lib], [build against shared libraries when possible]),
  23. [
  24. case "${enableval}" in
  25. yes) enable_system_shared_lib=true ;;
  26. no) enable_system_shared_lib=false ;;
  27. *) AC_MSG_ERROR([bad value ${enableval} for --enable-system-shared-lib]) ;;
  28. esac], [enable_system_shared_lib=false])
  29. AM_CONDITIONAL([USE_SYSTEM_SHARED_LIB], [test x$enable_system_shared_lib = xtrue])
  30. dnl Checks for crypto library
  31. AC_ARG_WITH(
  32. [crypto-library],
  33. [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|polarssl|mbedtls @<:@default=openssl@:>@])],
  34. [
  35. case "${withval}" in
  36. openssl|polarssl|mbedtls) ;;
  37. *) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;;
  38. esac
  39. ],
  40. [with_crypto_library="openssl"]
  41. )
  42. dnl Checks for programs.
  43. AC_PROG_CC
  44. AM_PROG_CC_C_O
  45. AC_PROG_INSTALL
  46. AC_PROG_LN_S
  47. AC_PROG_LIBTOOL
  48. AC_PROG_MAKE_SET
  49. AC_LANG_SOURCE
  50. dnl Checks for libev
  51. AM_COND_IF([USE_SYSTEM_SHARED_LIB],
  52. [],
  53. [m4_include([libev/libev.m4])])
  54. dnl Add library for mingw
  55. case $host in
  56. *-mingw*)
  57. LIBS="$LIBS -ladvapi32 -lgdi32 -lws2_32 -lcrypt32"
  58. ;;
  59. *)
  60. ;;
  61. esac
  62. dnl Checks for TLS
  63. AX_TLS([:], [:])
  64. dnl Checks for crypto library
  65. case "${with_crypto_library}" in
  66. openssl)
  67. ss_ZLIB
  68. ss_OPENSSL
  69. AC_DEFINE([USE_CRYPTO_OPENSSL], [1], [Use OpenSSL library])
  70. ;;
  71. polarssl)
  72. ss_POLARSSL
  73. AC_DEFINE([USE_CRYPTO_POLARSSL], [1], [Use PolarSSL library])
  74. ;;
  75. mbedtls)
  76. ss_MBEDTLS
  77. AC_DEFINE([USE_CRYPTO_MBEDTLS], [1], [Use mbed TLS library])
  78. ;;
  79. esac
  80. dnl Checks for Apple CommonCrypto API
  81. AC_ARG_ENABLE(applecc,
  82. AS_HELP_STRING([--enable-applecc], [enable Apple CommonCrypto API support]),
  83. [
  84. AC_CHECK_HEADERS(CommonCrypto/CommonCrypto.h,
  85. [],
  86. [AC_MSG_ERROR([CommonCrypto header files not found.]); break]
  87. )
  88. AC_CHECK_FUNCS([CCCryptorCreateWithMode], ,
  89. [AC_MSG_ERROR([CommonCrypto API needs OS X (>= 10.7) and iOS (>= 5.0).]); break]
  90. )
  91. AC_DEFINE([USE_CRYPTO_APPLECC], [1], [Use Apple CommonCrypto library])
  92. ]
  93. )
  94. dnl Checks for inet_ntop
  95. ss_FUNC_INET_NTOP
  96. dnl Checks for host.
  97. AC_MSG_CHECKING(for what kind of host)
  98. case $host in
  99. *-linux*)
  100. os_support=linux
  101. AC_MSG_RESULT(Linux)
  102. ;;
  103. *-mingw*)
  104. dnl Add custom macros for libev
  105. AC_DEFINE([FD_SETSIZE], [2048], [Reset max file descriptor size.])
  106. AC_DEFINE([EV_FD_TO_WIN32_HANDLE(fd)], [(fd)], [Override libev default fd conversion macro.])
  107. AC_DEFINE([EV_WIN32_HANDLE_TO_FD(handle)], [(handle)], [Override libev default handle conversion macro.])
  108. AC_DEFINE([EV_WIN32_CLOSE_FD(fd)], [closesocket(fd)], [Override libev default fd close macro.])
  109. os_support=mingw
  110. AC_MSG_RESULT(MinGW)
  111. ;;
  112. *)
  113. AC_MSG_RESULT(transparent proxy does not support for $host)
  114. ;;
  115. esac
  116. dnl Checks for pthread
  117. AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS"
  118. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  119. CC="$PTHREAD_CC"], AC_MSG_ERROR(Can not find pthreads. This is required.))
  120. dnl Checks for stack protector
  121. GGL_CHECK_STACK_PROTECTOR([has_stack_protector=yes], [has_stack_protector=no])
  122. # XXX - disable -fstack-protector due to missing libssp_nonshared
  123. case "$host_os" in
  124. *aix*)
  125. AC_MSG_NOTICE([-fstack-protector disabled on AIX])
  126. has_stack_protector=no
  127. ;;
  128. *sunos*)
  129. AC_MSG_NOTICE([-fstack-protector disabled on SunOS])
  130. has_stack_protector=no
  131. ;;
  132. *solaris*)
  133. AC_MSG_NOTICE([-fstack-protector disabled on Solaris])
  134. has_stack_protector=no
  135. ;;
  136. esac
  137. AC_ARG_ENABLE(ssp,
  138. [AS_HELP_STRING(--disable-ssp,Do not compile with -fstack-protector)],
  139. [
  140. enable_ssp="no"
  141. ],
  142. [
  143. enable_ssp="yes"
  144. ])
  145. if test x$has_stack_protector = xyes && test x$enable_ssp = xyes; then
  146. CFLAGS="$CFLAGS -fstack-protector"
  147. AC_MSG_NOTICE([-fstack-protector enabled in CFLAGS])
  148. fi
  149. AM_CONDITIONAL(BUILD_REDIRECTOR, test "$os_support" = "linux")
  150. AM_CONDITIONAL(BUILD_WINCOMPAT, test "$os_support" = "mingw")
  151. dnl Checks for header files.
  152. 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])
  153. dnl A special check required for <net/if.h> on Darwin. See
  154. dnl http://www.gnu.org/software/autoconf/manual/html_node/Header-Portability.html.
  155. AC_CHECK_HEADERS([sys/socket.h])
  156. AC_CHECK_HEADERS([net/if.h], [], [],
  157. [
  158. #include <stdio.h>
  159. #ifdef STDC_HEADERS
  160. # include <stdlib.h>
  161. # include <stddef.h>
  162. #else
  163. # ifdef HAVE_STDLIB_H
  164. # include <stdlib.h>
  165. # endif
  166. #endif
  167. #ifdef HAVE_SYS_SOCKET_H
  168. # include <sys/socket.h>
  169. #endif
  170. ])
  171. case $host in
  172. *-mingw*)
  173. AC_DEFINE([CONNECT_IN_PROGRESS], [WSAEWOULDBLOCK], [errno for incomplete non-blocking connect(2)])
  174. AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([Missing MinGW headers])], [])
  175. ;;
  176. *-linux*)
  177. AC_DEFINE([CONNECT_IN_PROGRESS], [EINPROGRESS], [errno for incomplete non-blocking connect(2)])
  178. dnl Checks for netfilter headers
  179. AC_CHECK_HEADERS([linux/if.h linux/netfilter_ipv4.h linux/netfilter_ipv6/ip6_tables.h],
  180. [], [AC_MSG_ERROR([Missing netfilter headers])],
  181. [[
  182. #if HAVE_LIMITS_H
  183. #include <limits.h>
  184. #endif
  185. /* Netfilter ip(6)tables v1.4.0 has broken headers */
  186. #if HAVE_NETINET_IN_H
  187. #include <netinet/in.h>
  188. #endif
  189. #if HAVE_LINUX_IF_H
  190. #include <linux/if.h>
  191. #endif
  192. #if HAVE_SYS_SOCKET_H
  193. #include <sys/socket.h>
  194. #endif
  195. ]])
  196. ;;
  197. *)
  198. # These are POSIX-like systems using BSD-like sockets API.
  199. AC_DEFINE([CONNECT_IN_PROGRESS], [EINPROGRESS], [errno for incomplete non-blocking connect(2)])
  200. ;;
  201. esac
  202. AC_C_BIGENDIAN
  203. dnl Checks for typedefs, structures, and compiler characteristics.
  204. AC_C_INLINE
  205. AC_TYPE_SSIZE_T
  206. dnl Checks for header files.
  207. AC_HEADER_ASSERT
  208. AC_HEADER_STDC
  209. AC_HEADER_SYS_WAIT
  210. dnl Checks for typedefs, structures, and compiler characteristics.
  211. AC_C_CONST
  212. AC_TYPE_PID_T
  213. AC_TYPE_SIZE_T
  214. AC_TYPE_SSIZE_T
  215. AC_TYPE_UINT16_T
  216. AC_TYPE_UINT8_T
  217. AC_HEADER_TIME
  218. dnl Checks for library functions.
  219. AC_FUNC_FORK
  220. AC_FUNC_SELECT_ARGTYPES
  221. AC_TYPE_SIGNAL
  222. AC_CHECK_FUNCS([memset select setresuid setreuid strerror getpwnam_r setrlimit])
  223. dnl Check for select() into ws2_32 for Msys/Mingw
  224. if test "$ac_cv_func_select" != "yes"; then
  225. AC_MSG_CHECKING([for select in ws2_32])
  226. AC_TRY_LINK([
  227. #ifdef HAVE_WINSOCK2_H
  228. #ifndef WIN32_LEAN_AND_MEAN
  229. #define WIN32_LEAN_AND_MEAN
  230. #endif
  231. #include <winsock2.h>
  232. #endif
  233. ],[
  234. select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
  235. ],[
  236. AC_MSG_RESULT([yes])
  237. HAVE_SELECT="1"
  238. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  239. [Define to 1 if you have the 'select' function.])
  240. HAVE_SYS_SELECT_H="1"
  241. AC_DEFINE_UNQUOTED(HAVE_SYS_SELECT_H, 1,
  242. [Define to 1 if you have the <sys/select.h> header file.])
  243. ],[
  244. AC_MSG_ERROR([no])
  245. ])
  246. fi
  247. AC_CHECK_LIB(socket, connect)
  248. dnl Checks for library functions.
  249. AC_CHECK_FUNCS([malloc memset socket])
  250. dnl Add define for libudns to enable IPv6 support
  251. dnl This is an option defined in the origin configure script
  252. AC_DEFINE([HAVE_IPv6], [1], [Enable IPv6 support in libudns])
  253. AM_COND_IF([USE_SYSTEM_SHARED_LIB],
  254. [],
  255. [AC_CONFIG_SUBDIRS([libsodium])])
  256. AC_CONFIG_FILES([ shadowsocks-libev.pc
  257. Makefile
  258. libcork/Makefile
  259. libipset/Makefile
  260. src/Makefile])
  261. AM_COND_IF([USE_SYSTEM_SHARED_LIB],
  262. [],
  263. [AC_CONFIG_FILES([libudns/Makefile
  264. libev/Makefile])])
  265. AC_OUTPUT