File: xerces_netaccessor_selection.m4

package info (click to toggle)
xerces-c 3.2.4%2Bdebian-1.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,948 kB
  • sloc: cpp: 167,201; xml: 23,619; sh: 4,789; ansic: 3,988; makefile: 1,438; perl: 355; javascript: 18
file content (201 lines) | stat: -rw-r--r-- 6,115 bytes parent folder | download | duplicates (4)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
dnl @synopsis XERCES_NETACCESSOR_SELECTION
dnl
dnl Determines the which netaccessor to use
dnl
dnl @category C
dnl @author James Berry
dnl @version 2005-05-23
dnl @license AllPermissive
dnl
dnl $Id$

AC_DEFUN([XERCES_NETACCESSOR_SELECTION],
	[

	network=yes
	AC_ARG_ENABLE(
	  [network],
	  AS_HELP_STRING([--disable-network], [Disable network support (enabled by default)]),
	  [AS_IF([test x"$enableval" = xno], [network=no])])

	# If network is disabled we don't need to check any of the
	# netaccessors.
	#
	na_list=

	if test x"$network" = xyes; then

	# Checks for libraries.
	AC_CHECK_LIB([socket], [socket])
	AC_CHECK_LIB([nsl], [gethostbyname])

	######################################################
	# Test for availability of each netaccessor on this host.
	# For each netaccessor that's available, and hasn't been disabled, add it to our list.
	# If the netaccessor has been explicitly "enable"d, then vote for it strongly,
	# in upper case.
	######################################################

	AC_REQUIRE([XERCES_CURL_PREFIX])
	AC_MSG_CHECKING([whether we can support the libcurl-based NetAccessor])
	list_add=
	AS_IF([test x"$xerces_cv_curl_present" != x"no"], [
		AC_ARG_ENABLE([netaccessor-curl],
			AS_HELP_STRING([--enable-netaccessor-curl],
				[Enable libcurl-based NetAccessor support]),
			[AS_IF([test x"$enableval" = xyes],
				[list_add=CURL])],
			[list_add=curl])
	])
	AS_IF([test x"$list_add" != x],
		[na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
		[AC_MSG_RESULT(no)]
	)

	AC_MSG_CHECKING([whether we can support the sockets-based NetAccessor])
	list_add=
	AS_IF([test x"$ac_cv_header_sys_socket_h" = xyes],
		[AC_ARG_ENABLE([netaccessor-socket],
			AS_HELP_STRING([--enable-netaccessor-socket],
				[Enable sockets-based NetAccessor support]),
			[AS_IF([test x"$enableval" = xyes],
				[list_add=SOCKET])],
			[list_add=socket])
		])
	AS_IF([test x"$list_add" != x],
		[na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
		[AC_MSG_RESULT(no)]
	)

	# Check for OS-specific netaccessors
	case $host_os in
	darwin*)
		list_add=
		AC_MSG_CHECKING([whether we can support the CFURL NetAccessor (Mac OS X)])
		AS_IF([test x"$ac_cv_header_CoreServices_CoreServices_h" = xyes], [
			AC_ARG_ENABLE([netaccessor-cfurl],
				AS_HELP_STRING([--enable-netaccessor-cfurl],
					[Enable cfurl-based NetAccessor support]),
				[AS_IF([test x"$enableval" = xyes],
					[list_add=CFURL])],
				[list_add=cfurl])
			]
		)
		AS_IF([test x"$list_add" != x],
			[na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
			[AC_MSG_RESULT(no)]
		)
		;;
	windows* | mingw*)
		list_add=
		no_winsock=false
		AC_CHECK_HEADERS([winsock2.h], [], [no_winsock=true])
		AC_MSG_CHECKING([whether we can support the WinSock NetAccessor (Windows)])
		AS_IF([! $no_winsock], [
			AC_ARG_ENABLE([netaccessor-winsock],
				AS_HELP_STRING([--enable-netaccessor-winsock],
					[Enable winsock-based NetAccessor support]),
				[AS_IF([test x"$enableval" = xyes],
					[list_add=WINSOCK])],
				[list_add=winsock])
		])
		AS_IF([test x"$list_add" != x],
			[na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
			[AC_MSG_RESULT(no)]
		)
		;;
	cygwin*)
		# Only add it to the list if the user explicitly asked
                # for it.
		#
		list_add=
		no_winsock=false
		AC_CHECK_HEADERS([winsock2.h], [], [no_winsock=true])
		AC_MSG_CHECKING([whether to use the WinSock NetAccessor (Windows)])
		AS_IF([! $no_winsock], [
			AC_ARG_ENABLE([netaccessor-winsock],
				AS_HELP_STRING([--enable-netaccessor-winsock],
					[Enable winsock-based NetAccessor support]),
				[AS_IF([test x"$enableval" = xyes],
					[list_add=WINSOCK])])
		])
		AS_IF([test x"$list_add" != x],
			[na_list="$na_list -$list_add-"; AC_MSG_RESULT(yes)],
			[AC_MSG_RESULT(no)]
		)
		;;
	esac


	######################################################
	# Determine which netaccessor to use.
	#
	# We do this in two passes. Accessors 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).
	######################################################
	netaccessor=
	az_lower=abcdefghijklmnopqrstuvwxyz
	az_upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
	AC_MSG_CHECKING([for which NetAccessor to use (choices:$na_list)])
	for i in 1 2; do
		# Swap upper/lower case in the na_list. Cannot use tr ranges
                # because of the portability issues.
                #
		na_list=`echo $na_list | tr "$az_lower$az_upper" "$az_upper$az_lower"`

		# Check for each netaccessor, in implicit rank order
		case $na_list in
		*-curl-*)
			netaccessor=curl
			AC_DEFINE([XERCES_USE_NETACCESSOR_CURL], 1, [Define to use the CURL NetAccessor])
			LIBS="${LIBS} ${xerces_cv_curl_libs}"
			break
			;;

		*-winsock-*)
			netaccessor=winsock
			AC_DEFINE([XERCES_USE_NETACCESSOR_WINSOCK], 1, [Define to use the WinSock NetAccessor])
			break
			;;

		*-socket-*)
			netaccessor=socket
			AC_DEFINE([XERCES_USE_NETACCESSOR_SOCKET], 1, [Define to use the Sockets-based NetAccessor])
			break
			;;

		*-cfurl-*)
			netaccessor=cfurl
			AC_DEFINE([XERCES_USE_NETACCESSOR_CFURL], 1, [Define to use the Mac OS X CFURL NetAccessor])
			XERCES_LINK_DARWIN_FRAMEWORK([CoreServices])
			break
			;;
		*)
			AS_IF([test $i -eq 2], [
				AC_MSG_RESULT([none available; there will be no network access!!!])
				]
			)
			;;

		esac
	done

	if test x"$netaccessor" != x; then
		AC_MSG_RESULT($netaccessor)
	fi

	else # network
		netaccessor=disabled # for the report
	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_NETACCESSOR_CURL],		[test x"$netaccessor" = xcurl])
	AM_CONDITIONAL([XERCES_USE_NETACCESSOR_CFURL],		[test x"$netaccessor" = xcfurl])
	AM_CONDITIONAL([XERCES_USE_NETACCESSOR_WINSOCK],	[test x"$netaccessor" = xwinsock])
	AM_CONDITIONAL([XERCES_USE_NETACCESSOR_SOCKET],		[test x"$netaccessor" = xsocket])

	]
)