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.

234 lines
5.9 KiB

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