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.

201 lines
6.0 KiB

  1. dnl @synopsis XERCES_NETACCESSOR_SELECTION
  2. dnl
  3. dnl Determines the which netaccessor to use
  4. dnl
  5. dnl @category C
  6. dnl @author James Berry
  7. dnl @version 2005-05-23
  8. dnl @license AllPermissive
  9. dnl
  10. dnl $Id: xerces_netaccessor_selection.m4 835245 2009-11-12 05:57:31Z borisk $
  11. AC_DEFUN([XERCES_NETACCESSOR_SELECTION],
  12. [
  13. network=yes
  14. AC_ARG_ENABLE(
  15. [network],
  16. AS_HELP_STRING([--disable-network], [Disable network support (enabled by default)]),
  17. [AS_IF([test x"$enableval" = xno], [network=no])])
  18. # If network is disabled we don't need to check any of the
  19. # netaccessors.
  20. #
  21. na_list=
  22. if test x"$network" = xyes; then
  23. # Checks for libraries.
  24. AC_CHECK_LIB([socket], [socket])
  25. AC_CHECK_LIB([nsl], [gethostbyname])
  26. ######################################################
  27. # Test for availability of each netaccessor on this host.
  28. # For each netaccessor that's available, and hasn't been disabled, add it to our list.
  29. # If the netaccessor has been explicitly "enable"d, then vote for it strongly,
  30. # in upper case.
  31. ######################################################
  32. AC_REQUIRE([XERCES_CURL_PREFIX])
  33. AC_MSG_CHECKING([whether we can support the libcurl-based NetAccessor])
  34. list_add=
  35. AS_IF([test x"$xerces_cv_curl_present" != x"no"], [
  36. AC_ARG_ENABLE([netaccessor-curl],
  37. AS_HELP_STRING([--enable-netaccessor-curl],
  38. [Enable libcurl-based NetAccessor support]),
  39. [AS_IF([test x"$enableval" = xyes],
  40. [list_add=CURL])],
  41. [list_add=curl])
  42. ])
  43. AS_IF([test x"$list_add" != x],
  44. [na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
  45. [AC_MSG_RESULT(no)]
  46. )
  47. AC_MSG_CHECKING([whether we can support the sockets-based NetAccessor])
  48. list_add=
  49. AS_IF([test x"$ac_cv_header_sys_socket_h" = xyes],
  50. [AC_ARG_ENABLE([netaccessor-socket],
  51. AS_HELP_STRING([--enable-netaccessor-socket],
  52. [Enable sockets-based NetAccessor support]),
  53. [AS_IF([test x"$enableval" = xyes],
  54. [list_add=SOCKET])],
  55. [list_add=socket])
  56. ])
  57. AS_IF([test x"$list_add" != x],
  58. [na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
  59. [AC_MSG_RESULT(no)]
  60. )
  61. # Check for OS-specific netaccessors
  62. case $host_os in
  63. darwin*)
  64. list_add=
  65. AC_MSG_CHECKING([whether we can support the CFURL NetAccessor (Mac OS X)])
  66. AS_IF([test x"$ac_cv_header_CoreServices_CoreServices_h" = xyes], [
  67. AC_ARG_ENABLE([netaccessor-cfurl],
  68. AS_HELP_STRING([--enable-netaccessor-cfurl],
  69. [Enable cfurl-based NetAccessor support]),
  70. [AS_IF([test x"$enableval" = xyes],
  71. [list_add=CFURL])],
  72. [list_add=cfurl])
  73. ]
  74. )
  75. AS_IF([test x"$list_add" != x],
  76. [na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
  77. [AC_MSG_RESULT(no)]
  78. )
  79. ;;
  80. windows* | mingw*)
  81. list_add=
  82. no_winsock=false
  83. AC_CHECK_HEADERS([winsock2.h], [], [no_winsock=true])
  84. AC_MSG_CHECKING([whether we can support the WinSock NetAccessor (Windows)])
  85. AS_IF([! $no_winsock], [
  86. AC_ARG_ENABLE([netaccessor-winsock],
  87. AS_HELP_STRING([--enable-netaccessor-winsock],
  88. [Enable winsock-based NetAccessor support]),
  89. [AS_IF([test x"$enableval" = xyes],
  90. [list_add=WINSOCK])],
  91. [list_add=winsock])
  92. ])
  93. AS_IF([test x"$list_add" != x],
  94. [na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
  95. [AC_MSG_RESULT(no)]
  96. )
  97. ;;
  98. cygwin*)
  99. # Only add it to the list if the user explicitly asked
  100. # for it.
  101. #
  102. list_add=
  103. no_winsock=false
  104. AC_CHECK_HEADERS([winsock2.h], [], [no_winsock=true])
  105. AC_MSG_CHECKING([whether to use the WinSock NetAccessor (Windows)])
  106. AS_IF([! $no_winsock], [
  107. AC_ARG_ENABLE([netaccessor-winsock],
  108. AS_HELP_STRING([--enable-netaccessor-winsock],
  109. [Enable winsock-based NetAccessor support]),
  110. [AS_IF([test x"$enableval" = xyes],
  111. [list_add=WINSOCK])])
  112. ])
  113. AS_IF([test x"$list_add" != x],
  114. [na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
  115. [AC_MSG_RESULT(no)]
  116. )
  117. ;;
  118. esac
  119. ######################################################
  120. # Determine which netaccessor to use.
  121. #
  122. # We do this in two passes. Accessors that have been enabled with "yes",
  123. # and which start out in upper case, get the top priority on the first pass.
  124. # On the second pass, we consider those which are simply available, but
  125. # which were not "disable"d (these won't even be in our list).
  126. ######################################################
  127. netaccessor=
  128. az_lower=abcdefghijklmnopqrstuvwxyz
  129. az_upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
  130. AC_MSG_CHECKING([for which NetAccessor to use (choices:$na_list)])
  131. for i in 1 2; do
  132. # Swap upper/lower case in the na_list. Cannot use tr ranges
  133. # because of the portability issues.
  134. #
  135. na_list=`echo $na_list | tr "$az_lower$az_upper" "$az_upper$az_lower"`
  136. # Check for each netaccessor, in implicit rank order
  137. case $na_list in
  138. *-curl-*)
  139. netaccessor=curl
  140. AC_DEFINE([XERCES_USE_NETACCESSOR_CURL], 1, [Define to use the CURL NetAccessor])
  141. LIBS="${LIBS} ${xerces_cv_curl_libs}"
  142. break
  143. ;;
  144. *-winsock-*)
  145. netaccessor=winsock
  146. AC_DEFINE([XERCES_USE_NETACCESSOR_WINSOCK], 1, [Define to use the WinSock NetAccessor])
  147. break
  148. ;;
  149. *-socket-*)
  150. netaccessor=socket
  151. AC_DEFINE([XERCES_USE_NETACCESSOR_SOCKET], 1, [Define to use the Sockets-based NetAccessor])
  152. break
  153. ;;
  154. *-cfurl-*)
  155. netaccessor=cfurl
  156. AC_DEFINE([XERCES_USE_NETACCESSOR_CFURL], 1, [Define to use the Mac OS X CFURL NetAccessor])
  157. XERCES_LINK_DARWIN_FRAMEWORK([CoreServices])
  158. break
  159. ;;
  160. *)
  161. AS_IF([test $i -eq 2], [
  162. AC_MSG_RESULT([none available; there will be no network access!!!])
  163. ]
  164. )
  165. ;;
  166. esac
  167. done
  168. if test x"$netaccessor" != x; then
  169. AC_MSG_RESULT($netaccessor)
  170. fi
  171. else # network
  172. netaccessor=disabled # for the report
  173. fi
  174. # Define the auto-make conditionals which determine what actually gets compiled
  175. # Note that these macros can't be executed conditionally, which is why they're here, not above.
  176. AM_CONDITIONAL([XERCES_USE_NETACCESSOR_CURL], [test x"$netaccessor" = xcurl])
  177. AM_CONDITIONAL([XERCES_USE_NETACCESSOR_CFURL], [test x"$netaccessor" = xcfurl])
  178. AM_CONDITIONAL([XERCES_USE_NETACCESSOR_WINSOCK], [test x"$netaccessor" = xwinsock])
  179. AM_CONDITIONAL([XERCES_USE_NETACCESSOR_SOCKET], [test x"$netaccessor" = xsocket])
  180. ]
  181. )