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.

283 lines
7.3 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
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.4], [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. GGL_CHECK_STACK_PROTECTOR([has_stack_protector=yes], [has_stack_protector=no])
  115. # XXX - disable -fstack-protector due to missing libssp_nonshared
  116. case "$host_os" in
  117. *aix*)
  118. AC_MSG_NOTICE([-fstack-protector disabled on AIX])
  119. has_stack_protector=no
  120. ;;
  121. *sunos*)
  122. AC_MSG_NOTICE([-fstack-protector disabled on SunOS])
  123. has_stack_protector=no
  124. ;;
  125. *solaris*)
  126. AC_MSG_NOTICE([-fstack-protector disabled on Solaris])
  127. has_stack_protector=no
  128. ;;
  129. esac
  130. AC_ARG_ENABLE(ssp,
  131. [AS_HELP_STRING(--disable-ssp,Do not compile with -fstack-protector)],
  132. [
  133. enable_ssp="no"
  134. ],
  135. [
  136. enable_ssp="yes"
  137. ])
  138. if test x$has_stack_protector = xyes && test x$enable_ssp = xyes; then
  139. CFLAGS="$CFLAGS -fstack-protector"
  140. AC_MSG_NOTICE([-fstack-protector enabled in CFLAGS])
  141. fi
  142. AM_CONDITIONAL(BUILD_REDIRECTOR, test "$os_support" = "linux")
  143. AM_CONDITIONAL(BUILD_WINCOMPAT, test "$os_support" = "mingw")
  144. dnl Checks for header files.
  145. 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])
  146. dnl A special check required for <net/if.h> on Darwin. See
  147. dnl http://www.gnu.org/software/autoconf/manual/html_node/Header-Portability.html.
  148. AC_CHECK_HEADERS([sys/socket.h])
  149. AC_CHECK_HEADERS([net/if.h], [], [],
  150. [
  151. #include <stdio.h>
  152. #ifdef STDC_HEADERS
  153. # include <stdlib.h>
  154. # include <stddef.h>
  155. #else
  156. # ifdef HAVE_STDLIB_H
  157. # include <stdlib.h>
  158. # endif
  159. #endif
  160. #ifdef HAVE_SYS_SOCKET_H
  161. # include <sys/socket.h>
  162. #endif
  163. ])
  164. case $host in
  165. *-mingw*)
  166. AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([Missing MinGW headers])], [])
  167. ;;
  168. *-linux*)
  169. dnl Checks for netfilter headers
  170. AC_CHECK_HEADERS([linux/if.h linux/netfilter_ipv4.h linux/netfilter_ipv6/ip6_tables.h],
  171. [], [AC_MSG_ERROR([Missing netfilter headers])],
  172. [[
  173. #if HAVE_LIMITS_H
  174. #include <limits.h>
  175. #endif
  176. /* Netfilter ip(6)tables v1.4.0 has broken headers */
  177. #if HAVE_NETINET_IN_H
  178. #include <netinet/in.h>
  179. #endif
  180. #if HAVE_LINUX_IF_H
  181. #include <net/if.h>
  182. #endif
  183. #if HAVE_SYS_SOCKET_H
  184. #include <sys/socket.h>
  185. #endif
  186. ]])
  187. ;;
  188. *)
  189. # These are POSIX-like systems using BSD-like sockets API.
  190. ;;
  191. esac
  192. AC_C_BIGENDIAN
  193. dnl Checks for typedefs, structures, and compiler characteristics.
  194. AC_C_INLINE
  195. AC_TYPE_SSIZE_T
  196. dnl Checks for header files.
  197. AC_HEADER_ASSERT
  198. AC_HEADER_STDC
  199. AC_HEADER_SYS_WAIT
  200. dnl Checks for typedefs, structures, and compiler characteristics.
  201. AC_C_CONST
  202. AC_TYPE_PID_T
  203. AC_TYPE_SIZE_T
  204. AC_TYPE_SSIZE_T
  205. AC_TYPE_UINT16_T
  206. AC_TYPE_UINT8_T
  207. AC_HEADER_TIME
  208. dnl Checks for library functions.
  209. AC_FUNC_FORK
  210. AC_FUNC_SELECT_ARGTYPES
  211. AC_TYPE_SIGNAL
  212. AC_CHECK_FUNCS([memset select setresuid setreuid strerror getpwnam_r setrlimit])
  213. dnl Check for select() into ws2_32 for Msys/Mingw
  214. if test "$ac_cv_func_select" != "yes"; then
  215. AC_MSG_CHECKING([for select in ws2_32])
  216. AC_TRY_LINK([
  217. #ifdef HAVE_WINSOCK2_H
  218. #ifndef WIN32_LEAN_AND_MEAN
  219. #define WIN32_LEAN_AND_MEAN
  220. #endif
  221. #include <winsock2.h>
  222. #endif
  223. ],[
  224. select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
  225. ],[
  226. AC_MSG_RESULT([yes])
  227. HAVE_SELECT="1"
  228. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  229. [Define to 1 if you have the 'select' function.])
  230. HAVE_SYS_SELECT_H="1"
  231. AC_DEFINE_UNQUOTED(HAVE_SYS_SELECT_H, 1,
  232. [Define to 1 if you have the <sys/select.h> header file.])
  233. ],[
  234. AC_MSG_ERROR([no])
  235. ])
  236. fi
  237. AC_CHECK_LIB(socket, connect)
  238. dnl Checks for library functions.
  239. AC_CHECK_FUNCS([malloc memset socket])
  240. AX_PTHREAD(, AC_MSG_ERROR(Can not find pthreads. This is required.))
  241. AM_COND_IF([USE_SYSTEM_SHARED_LIB],
  242. [],
  243. [AC_CONFIG_SUBDIRS([libsodium])])
  244. AC_CONFIG_FILES([ shadowsocks-libev.pc
  245. Makefile
  246. libcork/Makefile
  247. libipset/Makefile
  248. libudns/Makefile
  249. libev/Makefile
  250. src/Makefile])
  251. AC_OUTPUT