1 ?RCS: $Id: d_socket.U,v 3.0.1.2 1997/02/28 15:46:00 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?RCS: $Log: d_socket.U,v $
12 ?RCS: Revision 3.0.1.2 1997/02/28 15:46:00 ram
13 ?RCS: patch61: replaced .a with $_a all over the place
15 ?RCS: Revision 3.0.1.1 1994/01/24 14:08:04 ram
16 ?RCS: patch16: can now safely declare private nm_extract in dependencies
18 ?RCS: Revision 3.0 1993/08/18 12:07:26 ram
19 ?RCS: Baseline for dist 3.0 netwide release.
21 ?MAKE:d_socket d_oldsock d_sockpair socketlib sockethdr \
22 d_msg_ctrunc d_msg_dontroute d_msg_oob d_msg_peek d_msg_proxy \
23 d_scm_rights d_sendmsg d_recvmsg d_msghdr_s d_cmsghdr_s: \
24 contains libc echo n c ar nm nm_opt nm_extract Inlibc Csym _a \
25 Compile cat rm Setvar Hasfield i_sysuio
26 ?MAKE: -pick add $@ %<
28 ?S: This variable conditionally defines HAS_SOCKET, which indicates
29 ?S: that the BSD socket interface is supported.
32 ?S: This variable conditionally defines the HAS_SOCKETPAIR symbol, which
33 ?S: indicates that the BSD socketpair() is supported.
36 ?S: This variable conditionally defines the OLDSOCKET symbol, which
37 ?S: indicates that the BSD socket interface is based on 4.1c and not 4.2.
40 ?S: This variable conditionally defines the HAS_MSG_CTRUNC symbol,
41 ?S: which indicates that the MSG_CTRUNC is available. #ifdef is
42 ?S: not enough because it may be an enum, glibc has been known to do this.
45 ?S: This variable conditionally defines the HAS_MSG_DONTROUTE symbol,
46 ?S: which indicates that the MSG_DONTROUTE is available. #ifdef is
47 ?S: not enough because it may be an enum, glibc has been known to do this.
50 ?S: This variable conditionally defines the HAS_MSG_OOB symbol,
51 ?S: which indicates that the MSG_OOB is available. #ifdef is
52 ?S: not enough because it may be an enum, glibc has been known to do this.
55 ?S: This variable conditionally defines the HAS_MSG_PEEK symbol,
56 ?S: which indicates that the MSG_PEEK is available. #ifdef is
57 ?S: not enough because it may be an enum, glibc has been known to do this.
60 ?S: This variable conditionally defines the HAS_MSG_PROXY symbol,
61 ?S: which indicates that the MSG_PROXY is available. #ifdef is
62 ?S: not enough because it may be an enum, glibc has been known to do this.
65 ?S: This variable conditionally defines the HAS_SCM_RIGHTS symbol,
66 ?S: which indicates that the SCM_RIGHTS is available. #ifdef is
67 ?S: not enough because it may be an enum, glibc has been known to do this.
70 ?S: This variable conditionally defines the HAS_SENDMSG symbol,
71 ?S: which indicates that the sendmsg is supported.
74 ?S: This variable conditionally defines the HAS_RECVMSG symbol,
75 ?S: which indicates that the recvmsg is supported.
78 ?S: This variable conditionally defines the HAS_STRUCT_MSGHDR symbol,
79 ?S: which indicates that the struct msghdr is supported.
82 ?S: This variable conditionally defines the HAS_STRUCT_CMSGHDR symbol,
83 ?S: which indicates that the the struct cmsghdr is supported.
86 ?S: This variable has the names of any libraries needed for socket support.
89 ?S: This variable has any cpp '-I' flags needed for socket support.
91 ?C:HAS_SOCKET (SOCKET):
92 ?C: This symbol, if defined, indicates that the BSD socket interface is
95 ?C:HAS_SOCKETPAIR (SOCKETPAIR):
96 ?C: This symbol, if defined, indicates that the BSD socketpair() call is
99 ?C:USE_OLDSOCKET (OLDSOCKET):
100 ?C: This symbol, if defined, indicates that the 4.1c BSD socket interface
101 ?C: is supported instead of the 4.2/4.3 BSD socket interface. For instance,
102 ?C: there is no setsockopt() call.
105 ?C: This symbol, if defined, indicates that the MSG_CTRUNC is supported.
106 ?C: Checking just with #ifdef might not be enough because this symbol
107 ?C: has been known to be an enum.
109 ?C:HAS_MSG_DONTROUTE:
110 ?C: This symbol, if defined, indicates that the MSG_DONTROUTE is supported.
111 ?C: Checking just with #ifdef might not be enough because this symbol
112 ?C: has been known to be an enum.
115 ?C: This symbol, if defined, indicates that the MSG_OOB is supported.
116 ?C: Checking just with #ifdef might not be enough because this symbol
117 ?C: has been known to be an enum.
120 ?C: This symbol, if defined, indicates that the MSG_PEEK is supported.
121 ?C: Checking just with #ifdef might not be enough because this symbol
122 ?C: has been known to be an enum.
125 ?C: This symbol, if defined, indicates that the MSG_PROXY is supported.
126 ?C: Checking just with #ifdef might not be enough because this symbol
127 ?C: has been known to be an enum.
130 ?C: This symbol, if defined, indicates that the SCM_RIGHTS is supported.
131 ?C: Checking just with #ifdef might not be enough because this symbol
132 ?C: has been known to be an enum.
135 ?C: This symbol, if defined, indicates that the sendmsg is supported
136 ?C: to send messages between sockets. You will also need struct
137 ?C: iovec from <sys/uio.h>, HAS_STRUCT_IOVEC and I_SYSUIO.
140 ?C: This symbol, if defined, indicates that the recvmsg is supported
141 ?C: to send messages between sockets. You will also need struct
142 ?C: iovec from <sys/uio.h>, HAS_STRUCT_IOVEC and I_SYSUIO.
144 ?C:HAS_STRUCT_MSGHDR:
145 ?C: This symbol, if defined, indicates that the struct msghdr
146 ?C: (BSD 4.3 or 4.4) is supported. You will also need struct
147 ?C: iovec from <sys/uio.h>, HAS_STRUCT_IOVEC and I_SYSUIO.
149 ?C:HAS_STRUCT_CMSGHDR:
150 ?C: This symbol, if defined, indicates that the struct cmsghdr
151 ?C: (BSD 4.4) is supported. You will also need struct
152 ?C: iovec from <sys/uio.h>, HAS_STRUCT_IOVEC and I_SYSUIO.
154 ?H:#$d_socket HAS_SOCKET /**/
155 ?H:#$d_sockpair HAS_SOCKETPAIR /**/
156 ?H:#$d_oldsock USE_OLDSOCKET /**/
157 ?H:#$d_msg_ctrunc HAS_MSG_CTRUNC /**/
158 ?H:#$d_msg_dontroute HAS_MSG_DONTROUTE /**/
159 ?H:#$d_msg_oob HAS_MSG_OOB /**/
160 ?H:#$d_msg_peek HAS_MSG_PEEK /**/
161 ?H:#$d_msg_proxy HAS_MSG_PROXY /**/
162 ?H:#$d_scm_rights HAS_SCM_RIGHTS /**/
163 ?H:#$d_sendmsg HAS_SENDMSG /**/
164 ?H:#$d_recvmsg HAS_RECVMSG /**/
165 ?H:#$d_msghdr_s HAS_STRUCT_MSGHDR /**/
166 ?H:#$d_cmsghdr_s HAS_STRUCT_CMSGHDR /**/
171 ?LINT:set d_msg_ctrunc d_msg_dontroute d_msg_oob d_msg_peek d_msg_proxy
172 ?LINT:set d_scm_rights d_sendmsg d_recvmsg d_msghdr_s d_cmsghdr_s
175 : see whether socket exists
177 $echo $n "Hmm... $c" >&4
178 if set socket val -f d_socket; eval $csym; $val; then
179 echo "Looks like you have Berkeley networking support." >&4
181 ?X: now check for advanced features
182 if set setsockopt val -f; eval $csym; $val; then
185 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
189 ?X: HP-UX, for one, puts all the socket stuff in socklib.o. Note that if we
190 ?X: come here on HP-UX, then we must have used nm to get symbols, or we really
191 ?X: don't have sockets anyway...
192 if $contains socklib libc.list >/dev/null 2>&1; then
193 echo "Looks like you have Berkeley networking support." >&4
195 : we will have to assume that it supports the 4.2 BSD interface
198 echo "You don't have Berkeley networking in libc$_a..." >&4
199 ?X: look for optional networking libraries
200 if test "X$d_socket" = "X$define"; then
201 echo "...but you seem to believe that you have sockets." >&4
203 for net in net socket
205 if test -f /usr/lib/lib$net$_a; then
206 ?X: space between two '(' needed for ksh
207 ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) || \
208 $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
209 if $contains socket libc.list >/dev/null 2>&1; then
214 echo "...but the Wollongong group seems to have hacked it in." >&4
215 sockethdr="-I/usr/netinclude"
218 echo "Found Berkeley sockets interface in lib$net." >& 4
219 ?X: now check for advanced features
220 if $contains setsockopt libc.list >/dev/null 2>&1; then
223 echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
230 if test "X$d_socket" != "X$define"; then
231 echo "or anywhere else I see." >&4
239 @if HAS_SOCKETPAIR || d_sockpair
240 : see if socketpair exists
241 set socketpair d_sockpair
247 ?X: these constants are known to be troublesomely defined as enums
248 ?X: so that ifdef will not work for detecting their presence.
249 echo "Checking the availability of certain socket constants..." >& 4
250 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
251 enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
253 #include <sys/types.h>
254 #include <sys/socket.h>
260 set try; if eval $compile; then
263 set d_${enum}; eval $setvar
267 set sendmsg d_sendmsg
270 set recvmsg d_recvmsg
274 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
275 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
277 case "$d_msghdr_s" in
278 "$define") echo "Yup, it does." >&4
280 *) echo "Nope, it doesn't." >&4
284 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
285 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
287 case "$d_cmsghdr_s" in
288 "$define") echo "Yup, it does." >&4
290 *) echo "Nope, it doesn't." >&4