source: icXML/icXML-devel/m4/xerces_netaccessor_selection.m4 @ 2723

Last change on this file since 2723 was 2723, checked in by cameron, 6 years ago

Add Xerces build system scripts

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