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.

214 lines
5.3 KiB

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