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.

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