This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport 83f8bb564961ee8fba35156e720bef403d8fa9a7
[metaconfig.git] / U / modified / d_socket.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: d_socket.U,v 3.0.1.2 1997/02/28 15:46:00 ram Exp $
2?RCS:
3?RCS: Copyright (c) 1991-1993, Raphael Manfredi
41322e17 4?RCS:
959f3c4c
JH
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.
10?RCS:
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
14?RCS:
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
17?RCS:
18?RCS: Revision 3.0 1993/08/18 12:07:26 ram
19?RCS: Baseline for dist 3.0 netwide release.
20?RCS:
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 \
7ff213fe 23 d_scm_rights d_sockaddr_sa_len: \
9b04e79a 24 contains echo n c ar nm nm_opt nm_extract Inlibc Csym _a \
2cb64bf6 25 Compile cat rm_try Setvar Hasfield
959f3c4c
JH
26?MAKE: -pick add $@ %<
27?S:d_socket:
28?S: This variable conditionally defines HAS_SOCKET, which indicates
29?S: that the BSD socket interface is supported.
30?S:.
31?S:d_sockpair:
32?S: This variable conditionally defines the HAS_SOCKETPAIR symbol, which
33?S: indicates that the BSD socketpair() is supported.
34?S:.
35?S:d_oldsock:
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.
38?S:.
39?S:d_msg_ctrunc:
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.
43?S:.
44?S:d_msg_dontroute:
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.
48?S:.
49?S:d_msg_oob:
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.
53?S:.
54?S:d_msg_peek:
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.
58?S:.
59?S:d_msg_proxy:
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.
63?S:.
64?S:d_scm_rights:
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.
68?S:.
7ff213fe
MB
69?S:d_sockaddr_sa_len:
70?S: This variable conditionally defines the HAS_SOCKADDR_SA_LEN symbol,
71?S: which indicates that a struct sockaddr structure has the sa_len
72?S: member.
73?S:.
959f3c4c
JH
74?S:socketlib:
75?S: This variable has the names of any libraries needed for socket support.
76?S:.
77?S:sockethdr:
78?S: This variable has any cpp '-I' flags needed for socket support.
79?S:.
80?C:HAS_SOCKET (SOCKET):
81?C: This symbol, if defined, indicates that the BSD socket interface is
82?C: supported.
83?C:.
84?C:HAS_SOCKETPAIR (SOCKETPAIR):
85?C: This symbol, if defined, indicates that the BSD socketpair() call is
86?C: supported.
87?C:.
88?C:USE_OLDSOCKET (OLDSOCKET):
89?C: This symbol, if defined, indicates that the 4.1c BSD socket interface
90?C: is supported instead of the 4.2/4.3 BSD socket interface. For instance,
91?C: there is no setsockopt() call.
92?C:.
93?C:HAS_MSG_CTRUNC:
94?C: This symbol, if defined, indicates that the MSG_CTRUNC is supported.
95?C: Checking just with #ifdef might not be enough because this symbol
96?C: has been known to be an enum.
97?C:.
98?C:HAS_MSG_DONTROUTE:
99?C: This symbol, if defined, indicates that the MSG_DONTROUTE is supported.
100?C: Checking just with #ifdef might not be enough because this symbol
101?C: has been known to be an enum.
102?C:.
103?C:HAS_MSG_OOB:
104?C: This symbol, if defined, indicates that the MSG_OOB is supported.
105?C: Checking just with #ifdef might not be enough because this symbol
106?C: has been known to be an enum.
107?C:.
108?C:HAS_MSG_PEEK:
109?C: This symbol, if defined, indicates that the MSG_PEEK is supported.
110?C: Checking just with #ifdef might not be enough because this symbol
111?C: has been known to be an enum.
112?C:.
113?C:HAS_MSG_PROXY:
114?C: This symbol, if defined, indicates that the MSG_PROXY is supported.
115?C: Checking just with #ifdef might not be enough because this symbol
116?C: has been known to be an enum.
117?C:.
118?C:HAS_SCM_RIGHTS:
119?C: This symbol, if defined, indicates that the SCM_RIGHTS is supported.
120?C: Checking just with #ifdef might not be enough because this symbol
121?C: has been known to be an enum.
122?C:.
7ff213fe
MB
123?C:HAS_SOCKADDR_SA_LEN:
124?C: This symbol, if defined, indicates that the struct sockaddr
125?C: structure has a member called sa_len, indicating the length of
126?C: the structure.
127?C:.
959f3c4c
JH
128?H:#$d_socket HAS_SOCKET /**/
129?H:#$d_sockpair HAS_SOCKETPAIR /**/
7ff213fe 130?H:#$d_sockaddr_sa_len HAS_SOCKADDR_SA_LEN /**/
959f3c4c
JH
131?H:#$d_oldsock USE_OLDSOCKET /**/
132?H:#$d_msg_ctrunc HAS_MSG_CTRUNC /**/
133?H:#$d_msg_dontroute HAS_MSG_DONTROUTE /**/
134?H:#$d_msg_oob HAS_MSG_OOB /**/
135?H:#$d_msg_peek HAS_MSG_PEEK /**/
136?H:#$d_msg_proxy HAS_MSG_PROXY /**/
137?H:#$d_scm_rights HAS_SCM_RIGHTS /**/
959f3c4c
JH
138?H:.
139?T:val net ENUM enum
140?F:try.c
7ff213fe 141?LINT:set d_sockpair d_sockaddr_sa_len
959f3c4c 142?LINT:set d_msg_ctrunc d_msg_dontroute d_msg_oob d_msg_peek d_msg_proxy
cf4de4cc 143?LINT:set d_scm_rights
2f125bce 144: see whether socket exists
959f3c4c
JH
145socketlib=''
146sockethdr=''
959f3c4c
JH
147echo " "
148$echo $n "Hmm... $c" >&4
149if set socket val -f d_socket; eval $csym; $val; then
150 echo "Looks like you have Berkeley networking support." >&4
151 d_socket="$define"
152?X: now check for advanced features
153 if set setsockopt val -f; eval $csym; $val; then
154 d_oldsock="$undef"
155 else
156 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
157 d_oldsock="$define"
158 fi
159else
160?X: HP-UX, for one, puts all the socket stuff in socklib.o. Note that if we
161?X: come here on HP-UX, then we must have used nm to get symbols, or we really
162?X: don't have sockets anyway...
163 if $contains socklib libc.list >/dev/null 2>&1; then
164 echo "Looks like you have Berkeley networking support." >&4
165 d_socket="$define"
166 : we will have to assume that it supports the 4.2 BSD interface
167 d_oldsock="$undef"
168 else
169 echo "You don't have Berkeley networking in libc$_a..." >&4
170?X: look for optional networking libraries
171 if test "X$d_socket" = "X$define"; then
172 echo "...but you seem to believe that you have sockets." >&4
173 else
174 for net in net socket
175 do
176 if test -f /usr/lib/lib$net$_a; then
177?X: space between two '(' needed for ksh
178 ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) || \
179 $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
180 if $contains socket libc.list >/dev/null 2>&1; then
181 d_socket="$define"
182 socketlib="-l$net"
183 case "$net" in
184 net)
185 echo "...but the Wollongong group seems to have hacked it in." >&4
186 sockethdr="-I/usr/netinclude"
187 ;;
188 esac
2cb64bf6 189 echo "Found Berkeley sockets interface in lib$net." >&4
959f3c4c
JH
190?X: now check for advanced features
191 if $contains setsockopt libc.list >/dev/null 2>&1; then
192 d_oldsock="$undef"
193 else
194 echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
195 d_oldsock="$define"
196 fi
197 break
198 fi
199 fi
200 done
201 if test "X$d_socket" != "X$define"; then
202 echo "or anywhere else I see." >&4
203 d_socket="$undef"
204 d_oldsock="$undef"
205 fi
206 fi
207 fi
208fi
209
210@if HAS_SOCKETPAIR || d_sockpair
211: see if socketpair exists
212set socketpair d_sockpair
213eval $inlibc
214
215@end
216
217echo " "
7ff213fe
MB
218?X: ...
219echo "Checking the availability sa_len in the sock struct ..." >&4
220$cat >try.c <<EOF
221#include <sys/types.h>
222#include <sys/socket.h>
223int main() {
224struct sockaddr sa;
225return (sa.sa_len);
226}
227EOF
228val="$undef"
229set try; if eval $compile; then
230 val="$define"
231fi
232set d_sockaddr_sa_len; eval $setvar
233$rm_try
234
235echo " "
959f3c4c
JH
236?X: these constants are known to be troublesomely defined as enums
237?X: so that ifdef will not work for detecting their presence.
2d8cf008 238echo "Checking the availability of certain socket constants..." >&4
959f3c4c
JH
239for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
240 enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
241 $cat >try.c <<EOF
242#include <sys/types.h>
243#include <sys/socket.h>
244int main() {
245 int i = $ENUM;
246}
247EOF
248 val="$undef"
249 set try; if eval $compile; then
250 val="$define"
251 fi
252 set d_${enum}; eval $setvar
2cb64bf6 253 $rm_try
959f3c4c
JH
254done
255