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.

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