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.

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