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.

198 lines
4.9 KiB

12 years ago
12 years ago
10 years ago
11 years ago
12 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
10 years ago
12 years ago
11 years ago
12 years ago
12 years ago
11 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.4], [max.c.lv@gmail.com])
  5. AC_CONFIG_SRCDIR([src/encrypt.c])
  6. AC_CONFIG_HEADERS([config.h])
  7. AM_INIT_AUTOMAKE([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 Checks for inet_ntop
  65. ss_FUNC_INET_NTOP
  66. dnl Checks for host.
  67. AC_MSG_CHECKING(for what kind of host)
  68. case $host in
  69. *-linux*)
  70. os_support=linux
  71. AC_MSG_RESULT(Linux)
  72. ;;
  73. *-mingw*)
  74. dnl Add custom macros for libev
  75. AC_DEFINE([FD_SETSIZE], [2048], [Reset max file descriptor size.])
  76. AC_DEFINE([EV_FD_TO_WIN32_HANDLE(fd)], [(fd)], [Override libev default fd conversion macro.])
  77. AC_DEFINE([EV_WIN32_HANDLE_TO_FD(handle)], [(handle)], [Override libev default handle conversion macro.])
  78. AC_DEFINE([EV_WIN32_CLOSE_FD(fd)], [closesocket(fd)], [Override libev default fd close macro.])
  79. os_support=mingw
  80. AC_MSG_RESULT(MinGW)
  81. ;;
  82. *)
  83. AC_MSG_RESULT(transparent proxy does not support for $host)
  84. ;;
  85. esac
  86. AM_CONDITIONAL(BUILD_REDIRECTOR, test "$os_support" = "linux")
  87. AM_CONDITIONAL(BUILD_WINCOMPAT, test "$os_support" = "mingw")
  88. dnl Checks for header files.
  89. 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])
  90. case $host in
  91. *-mingw*)
  92. AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([Missing MinGW headers])], [])
  93. ;;
  94. *)
  95. # These are POSIX-like systems using BSD-like sockets API.
  96. ;;
  97. esac
  98. dnl A special check required for <net/if.h> on Darwin. See
  99. dnl http://www.gnu.org/software/autoconf/manual/html_node/Header-Portability.html.
  100. AC_CHECK_HEADERS([sys/socket.h])
  101. AC_CHECK_HEADERS([net/if.h], [], [],
  102. [
  103. #include <stdio.h>
  104. #ifdef STDC_HEADERS
  105. # include <stdlib.h>
  106. # include <stddef.h>
  107. #else
  108. # ifdef HAVE_STDLIB_H
  109. # include <stdlib.h>
  110. # endif
  111. #endif
  112. #ifdef HAVE_SYS_SOCKET_H
  113. # include <sys/socket.h>
  114. #endif
  115. ])
  116. AC_C_BIGENDIAN
  117. dnl Checks for typedefs, structures, and compiler characteristics.
  118. AC_C_INLINE
  119. AC_TYPE_SSIZE_T
  120. dnl Checks for header files.
  121. AC_HEADER_ASSERT
  122. AC_HEADER_STDC
  123. AC_HEADER_SYS_WAIT
  124. dnl Checks for typedefs, structures, and compiler characteristics.
  125. AC_C_CONST
  126. AC_TYPE_PID_T
  127. AC_TYPE_SIZE_T
  128. AC_TYPE_SSIZE_T
  129. AC_TYPE_UINT16_T
  130. AC_TYPE_UINT8_T
  131. AC_HEADER_TIME
  132. dnl Checks for library functions.
  133. AC_FUNC_FORK
  134. AC_FUNC_SELECT_ARGTYPES
  135. AC_TYPE_SIGNAL
  136. AC_CHECK_FUNCS([memset select setresuid setreuid strerror getpwnam_r])
  137. dnl Check for select() into ws2_32 for Msys/Mingw
  138. if test "$ac_cv_func_select" != "yes"; then
  139. AC_MSG_CHECKING([for select in ws2_32])
  140. AC_TRY_LINK([
  141. #ifdef HAVE_WINSOCK2_H
  142. #ifndef WIN32_LEAN_AND_MEAN
  143. #define WIN32_LEAN_AND_MEAN
  144. #endif
  145. #include <winsock2.h>
  146. #endif
  147. ],[
  148. select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
  149. ],[
  150. AC_MSG_RESULT([yes])
  151. HAVE_SELECT="1"
  152. AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
  153. [Define to 1 if you have the `select' function.])
  154. HAVE_SYS_SELECT_H="1"
  155. AC_DEFINE_UNQUOTED(HAVE_SYS_SELECT_H, 1,
  156. [Define to 1 if you have the <sys/select.h> header file.])
  157. ],[
  158. AC_MSG_ERROR([no])
  159. ])
  160. fi
  161. AC_SYS_LARGEFILE
  162. AC_CHECK_LIB(socket, connect)
  163. dnl Checks for library functions.
  164. AC_CHECK_FUNCS([malloc memset socket])
  165. ACX_PTHREAD
  166. AC_CONFIG_MACRO_DIR([m4])
  167. AC_CONFIG_FILES([Makefile
  168. libasyncns/Makefile
  169. libev/Makefile
  170. src/Makefile])
  171. AC_OUTPUT