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.

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