Newer
Older
James David Berry
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
dnl @synopsis XERCES_TRANSCODER_SELECTION
dnl
dnl Determines the which transcoder to use
dnl
dnl @category C
dnl @author James Berry
dnl @version 2005-05-23
dnl @license AllPermissive
dnl
dnl $Id$
AC_DEFUN([XERCES_TRANSCODER_SELECTION],
[
######################################################
# Test for availability of each transcoder on this host.
# For each transcoder that's available, and hasn't been disabled, add it to our list.
# If the transcoder has been explicitly "enable"d, then vote for it strongly,
# in upper case.
######################################################
tc_list=
# Check for iconv support
no_iconv=false
AC_CHECK_HEADERS([wchar.h], [], [no_iconv=true])
AC_CHECK_FUNCS([mblen wcstombs mbstowcs], [], [no_iconv=true])
AC_MSG_CHECKING([whether we can support the iconv Transcoder])
list_add=
AS_IF([! $no_iconv], [
AC_ARG_ENABLE([transcoder-iconv],
AS_HELP_STRING([--enable-transcoder-iconv],
[Enable iconv-based transcoder support]),
[AS_IF([test x"$enableval" = xyes],
[list_add=ICONV])],
[list_add=iconv])
])
AS_IF([test x"$list_add" != x],
[tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
# Check for ICU
AC_REQUIRE([XERCES_ICU_PREFIX])
AC_MSG_CHECKING([whether we can support the ICU Transcoder])
list_add=
AS_IF([test x"$xerces_cv_icu_prefix" != x], [
AC_ARG_ENABLE([transcoder-icu],
AS_HELP_STRING([--enable-transcoder-icu],
[Enable icu-based transcoder support]),
[AS_IF([test x"$enableval" = xyes],
[list_add=ICU])],
[list_add=icu])
])
AS_IF([test x"$list_add" != x],
[tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
# Check for platform-specific transcoders
list_add=
case $host_os in
darwin*)
AC_MSG_CHECKING([whether we can support the MacOSUnicodeConverter Transcoder])
AS_IF([test x"$ac_cv_header_CoreServices_CoreServices_h" = xyes], [
AC_ARG_ENABLE([transcoder-macosunicodeconverter],
AS_HELP_STRING([--enable-transcoder-macosunicodeconverter],
[Enable MacOSUnicodeConverter-based transcoder support]),
[AS_IF([test x"$enableval" = xyes],
[list_add=MACOSUNICODECONVERTER])],
[list_add=macosunicodeconverter])
])
AS_IF([test x"$list_add" != x],
[tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
;;
windows* | cygwin* | mingw*)
AC_MSG_CHECKING([whether we can support the Windows Transcoder])
AC_ARG_ENABLE([transcoder-windows],
AS_HELP_STRING([--enable-transcoder-windows],
[Enable Windows-based transcoder support]),
[AS_IF([test x"$enableval" = xyes],
[list_add=WINDOWS])],
[list_add=windows])
AS_IF([test x"$list_add" != x],
[tc_list="$tc_list -$list_add-"; AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)]
)
;;
esac
# TODO: Tests for additional transcoders
######################################################
# Determine which transcoder to use.
#
# We do this in two passes. Transcoders that have been enabled with "yes",
# and which start out in upper case, get the top priority on the first pass.
# On the second pass, we consider those which are simply available, but
# which were not "disable"d (these won't even be in our list).
######################################################
transcoder=
AC_MSG_CHECKING([for which Transcoder to use (choices:$tc_list)])
for i in 1 2; do
# Swap upper/lower case in the tc_list
tc_list=`echo $tc_list | tr 'A-Za-z' 'a-zA-Z'`
# Check for each transcoder, in implicit rank order
case $tc_list in
*-icu-*)
transcoder=icu
AC_DEFINE([XERCES_USE_TRANSCODER_ICU], 1, [Define to use the ICU-based transcoder])
LIBS="${LIBS} -L${xerces_cv_icu_prefix}/lib -licuuc -licudata"
break
;;
*-macosunicodeconverter-*)
transcoder=macosunicodeconverter
AC_DEFINE([XERCES_USE_TRANSCODER_MACOSUNICODECONVERTER], 1, [Define to use the Mac OS UnicodeConverter-based transcoder])
XERCES_LINK_DARWIN_FRAMEWORK([CoreServices])
break
;;
*-iconv-*)
transcoder=iconv
AC_DEFINE([XERCES_USE_TRANSCODER_ICONV], 1, [Define to use the iconv transcoder])
break
;;
*-windows-*)
transcoder=windows
AC_DEFINE([XERCES_USE_TRANSCODER_WINDOWS], 1, [Define to use the Windows transcoder])
break
;;
*)
AS_IF([test $i -eq 2], [
AC_MSG_RESULT([none])
AC_MSG_ERROR([Xerces cannot function without a transcoder])
]
)
;;
esac
done
if test x"$transcoder" != x; then
AC_MSG_RESULT($transcoder)
fi
# Define the auto-make conditionals which determine what actually gets compiled
# Note that these macros can't be executed conditionally, which is why they're here, not above.
AM_CONDITIONAL([XERCES_USE_TRANSCODER_ICU], [test x"$transcoder" = xicu])
AM_CONDITIONAL([XERCES_USE_TRANSCODER_MACOSUNICODECONVERTER], [test x"$transcoder" = xmacosunicodeconverter])
AM_CONDITIONAL([XERCES_USE_TRANSCODER_ICONV], [test x"$transcoder" = xiconv])
AM_CONDITIONAL([XERCES_USE_TRANSCODER_WINDOWS], [test x"$transcoder" = xwindows])
]
)