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.4 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
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.8], [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([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. case $host in
  104. *-mingw*)
  105. AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([Missing MinGW headers])], [])
  106. ;;
  107. *)
  108. # These are POSIX-like systems using BSD-like sockets API.
  109. ;;
  110. esac
  111. dnl A special check required for <net/if.h> on Darwin. See
  112. dnl http://www.gnu.org/software/autoconf/manual/html_node/Header-Portability.html.
  113. AC_CHECK_HEADERS([sys/socket.h])
  114. AC_CHECK_HEADERS([net/if.h], [], [],
  115. [
  116. #include <stdio.h>
  117. #ifdef STDC_HEADERS
  118. # include <stdlib.h>
  119. # include <stddef.h>
  120. #else
  121. # ifdef HAVE_STDLIB_H
  122. # include <stdlib.h>
  123. # endif
  124. #endif
  125. #ifdef HAVE_SYS_SOCKET_H
  126. # include <sys/socket.h>
  127. #endif
  128. ])
  129. AC_C_BIGENDIAN
  130. dnl Checks for typedefs, structures, and compiler characteristics.
  131. AC_C_INLINE
  132. AC_TYPE_SSIZE_T
  133. dnl Checks for header files.
  134. AC_HEADER_ASSERT
  135. AC_HEADER_STDC
  136. AC_HEADER_SYS_WAIT
  137. dnl Checks for typedefs, structures, and compiler characteristics.
  138. AC_C_CONST
  139. AC_TYPE_PID_T
  140. AC_TYPE_SIZE_T
  141. AC_TYPE_SSIZE_T
  142. AC_TYPE_UINT16_T
  143. AC_TYPE_UINT8_T
  144. AC_HEADER_TIME
  145. dnl Checks for library functions.
  146. AC_FUNC_FORK
  147. AC_FUNC_SELECT_ARGTYPES
  148. AC_TYPE_SIGNAL
  149. AC_CHECK_FUNCS([memset select setresuid setreuid strerror getpwnam_r setrlimit])
  150. dnl Check for select() into ws2_32 for Msys/Mingw
  151. if test "$ac_cv_func_select" != "yes"; then
  152. AC_MSG_CHECKING([for select in ws2_32])
  153. AC_TRY_LINK([
  154. #ifdef HAVE_WINSOCK2_H
  155. #ifndef WIN32_LEAN_AND_MEAN
  156. #define WIN32_LEAN_AND_MEAN
  157. #endif
  158. #include <winsock2.h>
  159. #endif
  160. ],[
  161. select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
  162. ],[
  163. AC_MSG_RESULT([yes])
  164. HAVE_SELECT="1"
  165. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  166. [Define to 1 if you have the `select' function.])
  167. HAVE_SYS_SELECT_H="1"
  168. AC_DEFINE_UNQUOTED(HAVE_SYS_SELECT_H, 1,
  169. [Define to 1 if you have the <sys/select.h> header file.])
  170. ],[
  171. AC_MSG_ERROR([no])
  172. ])
  173. fi
  174. AC_SYS_LARGEFILE
  175. AC_CHECK_LIB(socket, connect)
  176. dnl Checks for library functions.
  177. AC_CHECK_FUNCS([malloc memset socket])
  178. ACX_PTHREAD
  179. LT_INIT([dlopen])
  180. AC_CONFIG_FILES([Makefile
  181. libcork/Makefile
  182. libipset/Makefile
  183. libasyncns/Makefile
  184. libev/Makefile
  185. src/Makefile])
  186. AC_OUTPUT