This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
evat => eval as found by Tom Hukins
[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:
65a32477 5?RCS: You may redistribute only under the terms of the Artistic License,
959f3c4c
JH
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
65a32477 8?RCS: that same Artistic License; a copy of which may be found at the root
959f3c4c
JH
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 \
c6527476 23 d_scm_rights d_sockaddr_sa_len d_sockaddr_in6 d_sin6_scope_id \
f58608e3 24 d_ip_mreq d_ip_mreq_source d_ipv6_mreq d_ipv6_mreq_source: \
9b04e79a 25 contains echo n c ar nm nm_opt nm_extract Inlibc Csym _a \
9c11722e 26 Compile cat rm_try Setvar Hasfield sysroot
959f3c4c
JH
27?MAKE: -pick add $@ %<
28?S:d_socket:
29?S: This variable conditionally defines HAS_SOCKET, which indicates
30?S: that the BSD socket interface is supported.
31?S:.
32?S:d_sockpair:
33?S: This variable conditionally defines the HAS_SOCKETPAIR symbol, which
34?S: indicates that the BSD socketpair() is supported.
35?S:.
36?S:d_oldsock:
37?S: This variable conditionally defines the OLDSOCKET symbol, which
38?S: indicates that the BSD socket interface is based on 4.1c and not 4.2.
39?S:.
40?S:d_msg_ctrunc:
41?S: This variable conditionally defines the HAS_MSG_CTRUNC symbol,
42?S: which indicates that the MSG_CTRUNC is available. #ifdef is
43?S: not enough because it may be an enum, glibc has been known to do this.
44?S:.
45?S:d_msg_dontroute:
46?S: This variable conditionally defines the HAS_MSG_DONTROUTE symbol,
47?S: which indicates that the MSG_DONTROUTE is available. #ifdef is
48?S: not enough because it may be an enum, glibc has been known to do this.
49?S:.
50?S:d_msg_oob:
51?S: This variable conditionally defines the HAS_MSG_OOB symbol,
52?S: which indicates that the MSG_OOB is available. #ifdef is
53?S: not enough because it may be an enum, glibc has been known to do this.
54?S:.
55?S:d_msg_peek:
56?S: This variable conditionally defines the HAS_MSG_PEEK symbol,
57?S: which indicates that the MSG_PEEK is available. #ifdef is
58?S: not enough because it may be an enum, glibc has been known to do this.
59?S:.
60?S:d_msg_proxy:
61?S: This variable conditionally defines the HAS_MSG_PROXY symbol,
62?S: which indicates that the MSG_PROXY is available. #ifdef is
63?S: not enough because it may be an enum, glibc has been known to do this.
64?S:.
65?S:d_scm_rights:
66?S: This variable conditionally defines the HAS_SCM_RIGHTS symbol,
67?S: which indicates that the SCM_RIGHTS is available. #ifdef is
68?S: not enough because it may be an enum, glibc has been known to do this.
69?S:.
7ff213fe
MB
70?S:d_sockaddr_sa_len:
71?S: This variable conditionally defines the HAS_SOCKADDR_SA_LEN symbol,
72?S: which indicates that a struct sockaddr structure has the sa_len
73?S: member.
74?S:.
c6527476
MB
75?S:d_sockaddr_in6:
76?S: This variable conditionally defines the HAS_SOCKADDR_IN6 symbol, which
77?S: indicates the availability of a struct sockaddr_in6.
78?S:.
5230b858
MB
79?S:d_sin6_scope_id:
80?S: This variable conditionally defines the HAS_SIN6_SCOPE_ID symbol, which
81?S: indicates that a struct sockaddr_in6 structure has the sin6_scope_id
82?S: member.
83?S:.
6acd3030
MB
84?S:d_ip_mreq:
85?S: This variable conditionally defines the HAS_IP_MREQ symbol, which
86?S: indicates the availability of a struct ip_mreq.
87?S:.
f58608e3
MB
88?S:d_ip_mreq_source:
89?S: This variable conditionally defines the HAS_IP_MREQ_SOURCE symbol,
90?S: which indicates the availability of a struct ip_mreq_source.
91?S:.
c6527476
MB
92?S:d_ipv6_mreq:
93?S: This variable conditionally defines the HAS_IPV6_MREQ symbol, which
94?S: indicates the availability of a struct ipv6_mreq.
95?S:.
f58608e3
MB
96?S:d_ipv6_mreq_source:
97?S: This variable conditionally defines the HAS_IPV6_MREQ_SOURCE symbol,
98?S: which indicates the availability of a struct ipv6_mreq_source.
99?S:.
959f3c4c
JH
100?S:socketlib:
101?S: This variable has the names of any libraries needed for socket support.
102?S:.
103?S:sockethdr:
104?S: This variable has any cpp '-I' flags needed for socket support.
105?S:.
106?C:HAS_SOCKET (SOCKET):
107?C: This symbol, if defined, indicates that the BSD socket interface is
108?C: supported.
109?C:.
110?C:HAS_SOCKETPAIR (SOCKETPAIR):
111?C: This symbol, if defined, indicates that the BSD socketpair() call is
112?C: supported.
113?C:.
114?C:USE_OLDSOCKET (OLDSOCKET):
115?C: This symbol, if defined, indicates that the 4.1c BSD socket interface
116?C: is supported instead of the 4.2/4.3 BSD socket interface. For instance,
117?C: there is no setsockopt() call.
118?C:.
119?C:HAS_MSG_CTRUNC:
120?C: This symbol, if defined, indicates that the MSG_CTRUNC is supported.
121?C: Checking just with #ifdef might not be enough because this symbol
122?C: has been known to be an enum.
123?C:.
124?C:HAS_MSG_DONTROUTE:
125?C: This symbol, if defined, indicates that the MSG_DONTROUTE is supported.
126?C: Checking just with #ifdef might not be enough because this symbol
127?C: has been known to be an enum.
128?C:.
129?C:HAS_MSG_OOB:
130?C: This symbol, if defined, indicates that the MSG_OOB is supported.
131?C: Checking just with #ifdef might not be enough because this symbol
132?C: has been known to be an enum.
133?C:.
134?C:HAS_MSG_PEEK:
135?C: This symbol, if defined, indicates that the MSG_PEEK is supported.
136?C: Checking just with #ifdef might not be enough because this symbol
137?C: has been known to be an enum.
138?C:.
139?C:HAS_MSG_PROXY:
140?C: This symbol, if defined, indicates that the MSG_PROXY is supported.
141?C: Checking just with #ifdef might not be enough because this symbol
142?C: has been known to be an enum.
143?C:.
144?C:HAS_SCM_RIGHTS:
145?C: This symbol, if defined, indicates that the SCM_RIGHTS is supported.
146?C: Checking just with #ifdef might not be enough because this symbol
147?C: has been known to be an enum.
148?C:.
7ff213fe
MB
149?C:HAS_SOCKADDR_SA_LEN:
150?C: This symbol, if defined, indicates that the struct sockaddr
151?C: structure has a member called sa_len, indicating the length of
152?C: the structure.
153?C:.
c6527476
MB
154?C:HAS_SOCKADDR_IN6:
155?C: This symbol, if defined, indicates the availability of
156?C: struct sockaddr_in6;
157?C:.
5230b858
MB
158?C:HAS_SIN6_SCOPE_ID:
159?C: This symbol, if defined, indicates that the struct sockaddr_in6
160?C: structure has a member called sin6_scope_id.
161?C:.
6acd3030
MB
162?C:HAS_IP_MREQ:
163?C: This symbol, if defined, indicates the availability of
164?C: struct ip_mreq;
165?C:.
f58608e3
MB
166?C:HAS_IP_MREQ_SOURCE:
167?C: This symbol, if defined, indicates the availability of
168?C: struct ip_mreq_source;
169?C:.
c6527476
MB
170?C:HAS_IPV6_MREQ:
171?C: This symbol, if defined, indicates the availability of
172?C: struct ipv6_mreq;
173?C:.
f58608e3
MB
174?C:HAS_IPV6_MREQ_SOURCE:
175?C: This symbol, if defined, indicates the availability of
176?C: struct ipv6_mreq_source;
177?C:.
959f3c4c
JH
178?H:#$d_socket HAS_SOCKET /**/
179?H:#$d_sockpair HAS_SOCKETPAIR /**/
7ff213fe 180?H:#$d_sockaddr_sa_len HAS_SOCKADDR_SA_LEN /**/
959f3c4c
JH
181?H:#$d_oldsock USE_OLDSOCKET /**/
182?H:#$d_msg_ctrunc HAS_MSG_CTRUNC /**/
183?H:#$d_msg_dontroute HAS_MSG_DONTROUTE /**/
184?H:#$d_msg_oob HAS_MSG_OOB /**/
185?H:#$d_msg_peek HAS_MSG_PEEK /**/
186?H:#$d_msg_proxy HAS_MSG_PROXY /**/
187?H:#$d_scm_rights HAS_SCM_RIGHTS /**/
c6527476 188?H:#$d_sockaddr_in6 HAS_SOCKADDR_IN6 /**/
5230b858 189?H:#$d_sin6_scope_id HAS_SIN6_SCOPE_ID /**/
6acd3030 190?H:#$d_ip_mreq HAS_IP_MREQ /**/
f58608e3 191?H:#$d_ip_mreq_source HAS_IP_MREQ_SOURCE /**/
c6527476 192?H:#$d_ipv6_mreq HAS_IPV6_MREQ /**/
f58608e3 193?H:#$d_ipv6_mreq_source HAS_IPV6_MREQ_SOURCE /**/
959f3c4c
JH
194?H:.
195?T:val net ENUM enum
7ff213fe 196?LINT:set d_sockpair d_sockaddr_sa_len
959f3c4c 197?LINT:set d_msg_ctrunc d_msg_dontroute d_msg_oob d_msg_peek d_msg_proxy
f58608e3
MB
198?LINT:set d_scm_rights d_sockaddr_in6 d_sin6_scope_id d_ip_mreq
199?LINT:set d_ip_mreq_source d_ipv6_mreq d_ipv6_mreq_source
2f125bce 200: see whether socket exists
959f3c4c
JH
201socketlib=''
202sockethdr=''
959f3c4c
JH
203echo " "
204$echo $n "Hmm... $c" >&4
205if set socket val -f d_socket; eval $csym; $val; then
9c11722e
MB
206 echo "Looks like you have Berkeley networking support." >&4
207 d_socket="$define"
959f3c4c 208?X: now check for advanced features
9c11722e
MB
209 if set setsockopt val -f; eval $csym; $val; then
210 d_oldsock="$undef"
211 else
212 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
213 d_oldsock="$define"
214 fi
959f3c4c
JH
215else
216?X: HP-UX, for one, puts all the socket stuff in socklib.o. Note that if we
217?X: come here on HP-UX, then we must have used nm to get symbols, or we really
218?X: don't have sockets anyway...
9c11722e
MB
219 if $contains socklib libc.list >/dev/null 2>&1; then
220 echo "Looks like you have Berkeley networking support." >&4
221 d_socket="$define"
222 : we will have to assume that it supports the 4.2 BSD interface
223 d_oldsock="$undef"
224 else
225 echo "You don't have Berkeley networking in libc$_a..." >&4
959f3c4c 226?X: look for optional networking libraries
9c11722e
MB
227 if test "X$d_socket" = "X$define"; then
228 echo "...but you seem to believe that you have sockets." >&4
229 else
230 for net in net socket
231 do
232 if test -f $sysroot/usr/lib/lib$net$_a; then
959f3c4c 233?X: space between two '(' needed for ksh
9c11722e
MB
234 ( ($nm $nm_opt $sysroot/usr/lib/lib$net$_a | eval $nm_extract) || \
235 $ar t $sysroot/usr/lib/lib$net$_a) 2>/dev/null >> libc.list
236 if $contains socket libc.list >/dev/null 2>&1; then
237 d_socket="$define"
238 socketlib="-l$net"
239 case "$net" in
240 net)
241 echo "...but the Wollongong group seems to have hacked it in." >&4
242 sockethdr="-I$sysroot/usr/netinclude"
243 ;;
244 esac
245 echo "Found Berkeley sockets interface in lib$net." >&4
959f3c4c 246?X: now check for advanced features
9c11722e
MB
247 if $contains setsockopt libc.list >/dev/null 2>&1; then
248 d_oldsock="$undef"
249 else
250 echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
251 d_oldsock="$define"
959f3c4c 252 fi
9c11722e
MB
253 break
254 fi
959f3c4c 255 fi
9c11722e
MB
256 done
257 if test "X$d_socket" != "X$define"; then
258 echo "or anywhere else I see." >&4
259 d_socket="$undef"
260 d_oldsock="$undef"
261 fi
959f3c4c 262 fi
9c11722e 263 fi
959f3c4c
JH
264fi
265
266@if HAS_SOCKETPAIR || d_sockpair
267: see if socketpair exists
268set socketpair d_sockpair
269eval $inlibc
270
271@end
272
273echo " "
7ff213fe
MB
274?X: ...
275echo "Checking the availability sa_len in the sock struct ..." >&4
276$cat >try.c <<EOF
277#include <sys/types.h>
278#include <sys/socket.h>
279int main() {
280struct sockaddr sa;
281return (sa.sa_len);
282}
283EOF
284val="$undef"
285set try; if eval $compile; then
9c11722e 286 val="$define"
7ff213fe
MB
287fi
288set d_sockaddr_sa_len; eval $setvar
289$rm_try
290
291echo " "
5230b858 292?X: ...
c6527476
MB
293echo "Checking the availability struct sockaddr_in6 ..." >&4
294$cat >try.c <<EOF
295#include <sys/types.h>
296#include <sys/socket.h>
297#include <netinet/in.h>
298int main() {
299struct sockaddr_in6 sin6;
300return (sin6.sin6_family);
301}
302EOF
303val="$undef"
304set try; if eval $compile; then
9c11722e 305 val="$define"
c6527476
MB
306fi
307set d_sockaddr_in6; eval $setvar
308$rm_try
309
310echo " "
311?X: ...
5230b858
MB
312echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
313$cat >try.c <<EOF
314#include <sys/types.h>
315#include <sys/socket.h>
316#include <netinet/in.h>
317int main() {
318struct sockaddr_in6 sin6;
319return (sin6.sin6_scope_id);
320}
321EOF
322val="$undef"
323set try; if eval $compile; then
9c11722e 324 val="$define"
5230b858
MB
325fi
326set d_sin6_scope_id; eval $setvar
327$rm_try
328
329echo " "
c6527476 330?X: ...
6acd3030
MB
331echo "Checking the availability struct ip_mreq ..." >&4
332$cat >try.c <<EOF
333#include <sys/types.h>
334#include <sys/socket.h>
335#include <netinet/in.h>
336int main() {
337struct ip_mreq mreq;
338return (mreq.imr_multiaddr.s_addr);
339}
340EOF
341val="$undef"
342set try; if eval $compile; then
343 val="$define"
344fi
345set d_ip_mreq; eval $setvar
346$rm_try
347
348echo " "
349?X: ...
f58608e3
MB
350echo "Checking the availability struct ip_mreq_source ..." >&4
351$cat >try.c <<EOF
352#include <sys/types.h>
353#include <sys/socket.h>
354#include <netinet/in.h>
355int main() {
356struct ip_mreq_source mreq;
357return (mreq.imr_multiaddr.s_addr);
358}
359EOF
360val="$undef"
361set try; if eval $compile; then
362 val="$define"
363fi
364set d_ip_mreq_source; eval $setvar
365$rm_try
366
367echo " "
368?X: ...
c6527476
MB
369echo "Checking the availability struct ipv6_mreq ..." >&4
370$cat >try.c <<EOF
371#include <sys/types.h>
372#include <sys/socket.h>
373#include <netinet/in.h>
374int main() {
375struct ipv6_mreq mreq;
376return (mreq.ipv6mr_interface);
377}
378EOF
379val="$undef"
380set try; if eval $compile; then
9c11722e 381 val="$define"
c6527476
MB
382fi
383set d_ipv6_mreq; eval $setvar
384$rm_try
385
386echo " "
f58608e3
MB
387?X: ...
388echo "Checking the availability struct ipv6_mreq_source ..." >&4
389$cat >try.c <<EOF
390#include <sys/types.h>
391#include <sys/socket.h>
392#include <netinet/in.h>
393int main() {
394struct ipv6_mreq_source mreq;
395return (mreq.imr_multiaddr.s_addr);
396}
397EOF
398val="$undef"
399set try; if eval $compile; then
400 val="$define"
401fi
402set d_ipv6_mreq_source; eval $setvar
403$rm_try
404
405echo " "
959f3c4c
JH
406?X: these constants are known to be troublesomely defined as enums
407?X: so that ifdef will not work for detecting their presence.
2d8cf008 408echo "Checking the availability of certain socket constants..." >&4
959f3c4c 409for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
9c11722e
MB
410 enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
411 $cat >try.c <<EOF
959f3c4c
JH
412#include <sys/types.h>
413#include <sys/socket.h>
414int main() {
415 int i = $ENUM;
416}
417EOF
9c11722e
MB
418 val="$undef"
419 set try; if eval $compile; then
420 val="$define"
421 fi
422 set d_${enum}; eval $setvar
423 $rm_try
959f3c4c
JH
424done
425