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.

226 lines
5.7 KiB

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