xtrans.m4 revision a1910677
1dnl
2dnl Copyright (c) 2005, 2025, Oracle and/or its affiliates.
3dnl
4dnl Permission is hereby granted, free of charge, to any person obtaining a
5dnl copy of this software and associated documentation files (the "Software"),
6dnl to deal in the Software without restriction, including without limitation
7dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
8dnl and/or sell copies of the Software, and to permit persons to whom the
9dnl Software is furnished to do so, subject to the following conditions:
10dnl
11dnl The above copyright notice and this permission notice (including the next
12dnl paragraph) shall be included in all copies or substantial portions of the
13dnl Software.
14dnl
15dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21dnl DEALINGS IN THE SOFTWARE.
22dnl
23
24# XTRANS_TCP_FLAGS()
25# ------------------
26# Find needed libraries for TCP sockets, and check for IPv6 support
27AC_DEFUN([XTRANS_TCP_FLAGS],[
28 # SVR4 hides these in libraries other than libc
29 AC_SEARCH_LIBS(socket, [socket])
30 AC_SEARCH_LIBS(gethostbyname, [nsl])
31 if test "$ac_cv_search_socket$ac_cv_search_gethostbyname" = "nono"; then
32   AC_CHECK_LIB([ws2_32],[main])
33 fi
34
35 # Needs to come after above checks for libsocket & libnsl for SVR4 systems
36 AC_CHECK_FUNCS([getaddrinfo inet_ntop])
37
38 AC_ARG_ENABLE(ipv6,
39	AS_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),
40	[IPV6CONN=$enableval],
41	[IPV6CONN=$ac_cv_func_getaddrinfo])
42 AC_MSG_CHECKING([if IPv6 support should be built])
43 if test "$IPV6CONN" = "yes"; then
44	AC_DEFINE(IPv6,1,[Support IPv6 for TCP connections])
45 fi
46 AC_MSG_RESULT($IPV6CONN)
47
48 # 4.3BSD-Reno added a new member to struct sockaddr_in
49 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
50	AC_DEFINE([BSD44SOCKETS],1,
51 	    [Define to 1 if `struct sockaddr_in' has a `sin_len' member]), [], [
52#include <sys/types.h>
53#include <sys/socket.h>
54#include <netinet/in.h>
55 ])
56
57 # POSIX.1g changed the type of pointer passed to getsockname/getpeername/etc.
58 # and added a type defined to be large enough to hold any sockaddr format.
59 AC_CHECK_TYPES([socklen_t, struct sockaddr_storage], [], [], [
60AC_INCLUDES_DEFAULT
61#include <sys/socket.h>
62 ])
63
64 # XPG4v2/UNIX95 added msg_control - check to see if we need to define
65 # _XOPEN_SOURCE to get it (such as on Solaris)
66 AC_CHECK_MEMBER([struct msghdr.msg_control], [], [],
67                 [
68AC_INCLUDES_DEFAULT
69#include <sys/socket.h>
70                 ])
71 # First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03
72 if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
73     unset ac_cv_member_struct_msghdr_msg_control
74     AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600])
75     AC_CHECK_MEMBER([struct msghdr.msg_control],
76                     [AC_DEFINE([_XOPEN_SOURCE], [600],
77                       [Defined if needed to expose struct msghdr.msg_control])
78                     ], [], [
79#define _XOPEN_SOURCE 600
80AC_INCLUDES_DEFAULT
81#include <sys/socket.h>
82                     ])
83 fi
84 # If that didn't work, fall back to XPG5/UNIX98 with C89
85 if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
86     unset ac_cv_member_struct_msghdr_msg_control
87     AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500])
88     AC_CHECK_MEMBER([struct msghdr.msg_control],
89                     [AC_DEFINE([_XOPEN_SOURCE], [500],
90                       [Defined if needed to expose struct msghdr.msg_control])
91                     ], [], [
92#define _XOPEN_SOURCE 500
93AC_INCLUDES_DEFAULT
94#include <sys/socket.h>
95                     ])
96 fi
97
98
99]) # XTRANS_TCP_FLAGS
100
101# XTRANS_CONNECTION_FLAGS()
102# -------------------------
103# Standard checks for which Xtrans transports to use by the Xorg packages
104# that use Xtrans functions
105AC_DEFUN([XTRANS_CONNECTION_FLAGS],[
106 AC_REQUIRE([AC_CANONICAL_HOST])
107 [case $host_os in
108	mingw*)	unixdef="no"   ;;
109	*)	unixdef="yes"  ;;
110 esac]
111 AC_ARG_ENABLE(unix-transport,
112	AS_HELP_STRING([--enable-unix-transport],[Enable UNIX domain socket transport]),
113	[UNIXCONN=$enableval], [UNIXCONN=$unixdef])
114 AC_MSG_CHECKING([if Xtrans should support UNIX socket connections])
115 if test "$UNIXCONN" = "yes"; then
116	AC_DEFINE(UNIXCONN,1,[Support UNIX socket connections])
117 fi
118 AC_MSG_RESULT($UNIXCONN)
119 AC_ARG_ENABLE(tcp-transport,
120	AS_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]),
121	[TCPCONN=$enableval], [TCPCONN=yes])
122 AC_MSG_CHECKING([if Xtrans should support TCP socket connections])
123 AC_MSG_RESULT($TCPCONN)
124 if test "$TCPCONN" = "yes"; then
125	AC_DEFINE(TCPCONN,1,[Support TCP socket connections])
126	XTRANS_TCP_FLAGS
127 fi
128 [case $host_os in
129	solaris*)		localdef="yes" ;;
130	*)			localdef="no"  ;;
131 esac]
132 AC_ARG_ENABLE(local-transport,
133	AS_HELP_STRING([--enable-local-transport],[Enable os-specific local transport]),
134	[LOCALCONN=$enableval], [LOCALCONN=$localdef])
135 AC_MSG_CHECKING([if Xtrans should support os-specific local connections])
136 AC_MSG_RESULT($LOCALCONN)
137 if test "$LOCALCONN" = "yes"; then
138	AC_DEFINE(LOCALCONN,1,[Support os-specific local connections])
139 fi
140
141 # Other functions Xtrans may need
142 AC_CHECK_FUNCS([strcasecmp strlcpy])
143
144]) # XTRANS_CONNECTION_FLAGS
145
146
147# XTRANS_SECURE_RPC_FLAGS()
148# -------------------------
149# Check for Secure RPC functions - must come after XTRANS_TCP_FLAGS
150# so that any necessary networking libraries are already found
151AC_DEFUN([XTRANS_SECURE_RPC_FLAGS],
152[AC_REQUIRE([XTRANS_TCP_FLAGS])
153 AC_ARG_ENABLE(secure-rpc,
154	AS_HELP_STRING([--enable-secure-rpc],[Enable Secure RPC]),
155        [SECURE_RPC=$enableval], [SECURE_RPC="try"])
156
157 if test "x$SECURE_RPC" = "xyes" -o "x$SECURE_RPC" = "xtry" ; then
158	FOUND_SECURE_RPC="no"
159	AC_CHECK_FUNCS([authdes_seccreate authdes_create],
160			[FOUND_SECURE_RPC="yes"])
161	if test "x$FOUND_SECURE_RPC" = "xno" ; then
162		if test "x$SECURE_RPC" = "xyes" ; then
163	AC_MSG_ERROR([Secure RPC requested, but required functions not found])
164		fi
165		SECURE_RPC="no"
166	else
167		dnl FreeBSD keeps getsecretkey in librpcsvc
168		AC_SEARCH_LIBS(getsecretkey, [rpcsvc])
169		SECURE_RPC="yes"
170	fi
171 fi
172 AC_MSG_CHECKING([if Secure RPC authentication ("SUN-DES-1") should be supported])
173 if test "x$SECURE_RPC" = "xyes" ; then
174	AC_DEFINE(SECURE_RPC, 1, [Support Secure RPC ("SUN-DES-1") authentication for X11 clients])
175 fi
176 AC_MSG_RESULT($SECURE_RPC)
177]) # XTRANS_SECURE_RPC_FLAGS
178
179