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.

217 lines
7.1 KiB

  1. dnl @synopsis XERCES_TRANSCODER_SELECTION
  2. dnl
  3. dnl Determines the which transcoder 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_transcoder_selection.m4 835245 2009-11-12 05:57:31Z borisk $
  11. AC_DEFUN([XERCES_TRANSCODER_SELECTION],
  12. [
  13. ######################################################
  14. # Test for availability of each transcoder on this host.
  15. # For each transcoder that's available, and hasn't been disabled, add it to our list.
  16. # If the transcoder has been explicitly "enable"d, then vote for it strongly,
  17. # in upper case.
  18. ######################################################
  19. tc_list=
  20. # Check for GNU iconv support
  21. no_GNUiconv=false
  22. AC_CHECK_HEADERS([iconv.h wchar.h string.h stdlib.h stdio.h ctype.h locale.h errno.h], [], [no_GNUiconv=true])
  23. # The code in iconv needs just on of these include files
  24. AC_CHECK_HEADER([endian.h],
  25. [],
  26. [
  27. AC_CHECK_HEADER([machine/endian.h],
  28. [],
  29. [
  30. AC_CHECK_HEADER([arpa/nameser_compat.h],
  31. [],
  32. [no_GNUiconv=true])
  33. ])
  34. ])
  35. AC_CHECK_FUNCS([iconv_open iconv_close iconv], [], [no_GNUiconv=true])
  36. AC_MSG_CHECKING([whether we can support the GNU iconv Transcoder])
  37. list_add=
  38. AS_IF([! $no_GNUiconv], [
  39. AC_ARG_ENABLE([transcoder-gnuiconv],
  40. AS_HELP_STRING([--enable-transcoder-gnuiconv],
  41. [Enable GNU iconv-based transcoder support]),
  42. [AS_IF([test x"$enableval" = xyes],
  43. [list_add=GNUICONV])],
  44. [list_add=gnuiconv])
  45. ])
  46. AS_IF([test x"$list_add" != x],
  47. [tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
  48. [AC_MSG_RESULT(no)]
  49. )
  50. # Check for iconv support
  51. no_iconv=false
  52. AC_CHECK_HEADERS([wchar.h], [], [no_iconv=true])
  53. AC_CHECK_FUNCS([mblen wcstombs mbstowcs], [], [no_iconv=true])
  54. AC_MSG_CHECKING([whether we can support the iconv Transcoder])
  55. list_add=
  56. AS_IF([! $no_iconv], [
  57. AC_ARG_ENABLE([transcoder-iconv],
  58. AS_HELP_STRING([--enable-transcoder-iconv],
  59. [Enable iconv-based transcoder support]),
  60. [AS_IF([test x"$enableval" = xyes],
  61. [list_add=ICONV])],
  62. [list_add=iconv])
  63. ])
  64. AS_IF([test x"$list_add" != x],
  65. [tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
  66. [AC_MSG_RESULT(no)]
  67. )
  68. # Check for ICU
  69. AC_REQUIRE([XERCES_ICU_PREFIX])
  70. AC_MSG_CHECKING([whether we can support the ICU Transcoder])
  71. list_add=
  72. AS_IF([test x"$xerces_cv_icu_present" != x"no"], [
  73. AC_ARG_ENABLE([transcoder-icu],
  74. AS_HELP_STRING([--enable-transcoder-icu],
  75. [Enable icu-based transcoder support]),
  76. [AS_IF([test x"$enableval" = xyes],
  77. [list_add=ICU])],
  78. [list_add=icu])
  79. ])
  80. AS_IF([test x"$list_add" != x],
  81. [tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
  82. [AC_MSG_RESULT(no)]
  83. )
  84. # Check for platform-specific transcoders
  85. list_add=
  86. case $host_os in
  87. darwin*)
  88. AC_MSG_CHECKING([whether we can support the MacOSUnicodeConverter Transcoder])
  89. AS_IF([test x"$ac_cv_header_CoreServices_CoreServices_h" = xyes], [
  90. AC_ARG_ENABLE([transcoder-macosunicodeconverter],
  91. AS_HELP_STRING([--enable-transcoder-macosunicodeconverter],
  92. [Enable MacOSUnicodeConverter-based transcoder support]),
  93. [AS_IF([test x"$enableval" = xyes],
  94. [list_add=MACOSUNICODECONVERTER])],
  95. [list_add=macosunicodeconverter])
  96. ])
  97. AS_IF([test x"$list_add" != x],
  98. [tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
  99. [AC_MSG_RESULT(no)]
  100. )
  101. ;;
  102. windows* | mingw*)
  103. AC_MSG_CHECKING([whether we can support the Windows Transcoder])
  104. AC_ARG_ENABLE([transcoder-windows],
  105. AS_HELP_STRING([--enable-transcoder-windows],
  106. [Enable Windows-based transcoder support]),
  107. [AS_IF([test x"$enableval" = xyes],
  108. [list_add=WINDOWS])],
  109. [list_add=windows])
  110. AS_IF([test x"$list_add" != x],
  111. [tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
  112. [AC_MSG_RESULT(no)]
  113. )
  114. ;;
  115. cygwin*)
  116. # Only add it to the list if the user explicitly asked
  117. # for it.
  118. #
  119. AC_MSG_CHECKING([whether to use the Windows Transcoder])
  120. AC_ARG_ENABLE([transcoder-windows],
  121. AS_HELP_STRING([--enable-transcoder-windows],
  122. [Enable Windows-based transcoder support]),
  123. [AS_IF([test x"$enableval" = xyes],
  124. [list_add=WINDOWS])])
  125. AS_IF([test x"$list_add" != x],
  126. [tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
  127. [AC_MSG_RESULT(no)]
  128. )
  129. ;;
  130. esac
  131. # TODO: Tests for additional transcoders
  132. ######################################################
  133. # Determine which transcoder to use.
  134. #
  135. # We do this in two passes. Transcoders that have been enabled with "yes",
  136. # and which start out in upper case, get the top priority on the first pass.
  137. # On the second pass, we consider those which are simply available, but
  138. # which were not "disable"d (these won't even be in our list).
  139. ######################################################
  140. transcoder=
  141. az_lower=abcdefghijklmnopqrstuvwxyz
  142. az_upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
  143. AC_MSG_CHECKING([for which Transcoder to use (choices:$tc_list)])
  144. for i in 1 2; do
  145. # Swap upper/lower case in the tc_list. Cannot use tr ranges
  146. # because of the portability issues.
  147. #
  148. tc_list=`echo $tc_list | tr "$az_lower$az_upper" "$az_upper$az_lower"`
  149. # Check for each transcoder, in implicit rank order
  150. case $tc_list in
  151. *-icu-*)
  152. transcoder=icu
  153. AC_DEFINE([XERCES_USE_TRANSCODER_ICU], 1, [Define to use the ICU-based transcoder])
  154. LIBS="${LIBS} ${xerces_cv_icu_libs}"
  155. break
  156. ;;
  157. *-macosunicodeconverter-*)
  158. transcoder=macosunicodeconverter
  159. AC_DEFINE([XERCES_USE_TRANSCODER_MACOSUNICODECONVERTER], 1, [Define to use the Mac OS UnicodeConverter-based transcoder])
  160. XERCES_LINK_DARWIN_FRAMEWORK([CoreServices])
  161. break
  162. ;;
  163. *-gnuiconv-*)
  164. transcoder=gnuiconv
  165. AC_DEFINE([XERCES_USE_TRANSCODER_GNUICONV], 1, [Define to use the GNU iconv transcoder])
  166. break
  167. ;;
  168. *-windows-*)
  169. transcoder=windows
  170. AC_DEFINE([XERCES_USE_TRANSCODER_WINDOWS], 1, [Define to use the Windows transcoder])
  171. break
  172. ;;
  173. *-iconv-*)
  174. transcoder=iconv
  175. AC_DEFINE([XERCES_USE_TRANSCODER_ICONV], 1, [Define to use the iconv transcoder])
  176. break
  177. ;;
  178. *)
  179. AS_IF([test $i -eq 2], [
  180. AC_MSG_RESULT([none])
  181. AC_MSG_ERROR([Xerces cannot function without a transcoder])
  182. ]
  183. )
  184. ;;
  185. esac
  186. done
  187. if test x"$transcoder" != x; then
  188. AC_MSG_RESULT($transcoder)
  189. fi
  190. # Define the auto-make conditionals which determine what actually gets compiled
  191. # Note that these macros can't be executed conditionally, which is why they're here, not above.
  192. AM_CONDITIONAL([XERCES_USE_TRANSCODER_ICU], [test x"$transcoder" = xicu])
  193. AM_CONDITIONAL([XERCES_USE_TRANSCODER_MACOSUNICODECONVERTER], [test x"$transcoder" = xmacosunicodeconverter])
  194. AM_CONDITIONAL([XERCES_USE_TRANSCODER_GNUICONV], [test x"$transcoder" = xgnuiconv])
  195. AM_CONDITIONAL([XERCES_USE_TRANSCODER_ICONV], [test x"$transcoder" = xiconv])
  196. AM_CONDITIONAL([XERCES_USE_TRANSCODER_WINDOWS], [test x"$transcoder" = xwindows])
  197. ]
  198. )