This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add sin6_scope_id probe (LeoNerd)
[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 \
5230b858 23 d_scm_rights d_sockaddr_sa_len d_sin6_scope_id: \
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:.
5230b858
MB
74?S:d_sin6_scope_id:
75?S: This variable conditionally defines the HAS_SIN6_SCOPE_ID symbol, which
76?S: indicates that a struct sockaddr_in6 structure has the sin6_scope_id
77?S: member.
78?S:.
959f3c4c
JH
79?S:socketlib:
80?S: This variable has the names of any libraries needed for socket support.
81?S:.
82?S:sockethdr:
83?S: This variable has any cpp '-I' flags needed for socket support.
84?S:.
85?C:HAS_SOCKET (SOCKET):
86?C: This symbol, if defined, indicates that the BSD socket interface is
87?C: supported.
88?C:.
89?C:HAS_SOCKETPAIR (SOCKETPAIR):
90?C: This symbol, if defined, indicates that the BSD socketpair() call is
91?C: supported.
92?C:.
93?C:USE_OLDSOCKET (OLDSOCKET):
94?C: This symbol, if defined, indicates that the 4.1c BSD socket interface
95?C: is supported instead of the 4.2/4.3 BSD socket interface. For instance,
96?C: there is no setsockopt() call.
97?C:.
98?C:HAS_MSG_CTRUNC:
99?C: This symbol, if defined, indicates that the MSG_CTRUNC 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_DONTROUTE:
104?C: This symbol, if defined, indicates that the MSG_DONTROUTE 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_OOB:
109?C: This symbol, if defined, indicates that the MSG_OOB 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_PEEK:
114?C: This symbol, if defined, indicates that the MSG_PEEK 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_MSG_PROXY:
119?C: This symbol, if defined, indicates that the MSG_PROXY 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:.
123?C:HAS_SCM_RIGHTS:
124?C: This symbol, if defined, indicates that the SCM_RIGHTS is supported.
125?C: Checking just with #ifdef might not be enough because this symbol
126?C: has been known to be an enum.
127?C:.
7ff213fe
MB
128?C:HAS_SOCKADDR_SA_LEN:
129?C: This symbol, if defined, indicates that the struct sockaddr
130?C: structure has a member called sa_len, indicating the length of
131?C: the structure.
132?C:.
5230b858
MB
133?C:HAS_SIN6_SCOPE_ID:
134?C: This symbol, if defined, indicates that the struct sockaddr_in6
135?C: structure has a member called sin6_scope_id.
136?C:.
959f3c4c
JH
137?H:#$d_socket HAS_SOCKET /**/
138?H:#$d_sockpair HAS_SOCKETPAIR /**/
7ff213fe 139?H:#$d_sockaddr_sa_len HAS_SOCKADDR_SA_LEN /**/
959f3c4c
JH
140?H:#$d_oldsock USE_OLDSOCKET /**/
141?H:#$d_msg_ctrunc HAS_MSG_CTRUNC /**/
142?H:#$d_msg_dontroute HAS_MSG_DONTROUTE /**/
143?H:#$d_msg_oob HAS_MSG_OOB /**/
144?H:#$d_msg_peek HAS_MSG_PEEK /**/
145?H:#$d_msg_proxy HAS_MSG_PROXY /**/
146?H:#$d_scm_rights HAS_SCM_RIGHTS /**/
5230b858 147?H:#$d_sin6_scope_id HAS_SIN6_SCOPE_ID /**/
959f3c4c
JH
148?H:.
149?T:val net ENUM enum
150?F:try.c
7ff213fe 151?LINT:set d_sockpair d_sockaddr_sa_len
959f3c4c 152?LINT:set d_msg_ctrunc d_msg_dontroute d_msg_oob d_msg_peek d_msg_proxy
5230b858 153?LINT:set d_scm_rights d_sin6_scope_id
2f125bce 154: see whether socket exists
959f3c4c
JH
155socketlib=''
156sockethdr=''
959f3c4c
JH
157echo " "
158$echo $n "Hmm... $c" >&4
159if set socket val -f d_socket; eval $csym; $val; then
160 echo "Looks like you have Berkeley networking support." >&4
161 d_socket="$define"
162?X: now check for advanced features
163 if set setsockopt val -f; eval $csym; $val; then
164 d_oldsock="$undef"
165 else
166 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
167 d_oldsock="$define"
168 fi
169else
170?X: HP-UX, for one, puts all the socket stuff in socklib.o. Note that if we
171?X: come here on HP-UX, then we must have used nm to get symbols, or we really
172?X: don't have sockets anyway...
173 if $contains socklib libc.list >/dev/null 2>&1; then
174 echo "Looks like you have Berkeley networking support." >&4
175 d_socket="$define"
176 : we will have to assume that it supports the 4.2 BSD interface
177 d_oldsock="$undef"
178 else
179 echo "You don't have Berkeley networking in libc$_a..." >&4
180?X: look for optional networking libraries
181 if test "X$d_socket" = "X$define"; then
182 echo "...but you seem to believe that you have sockets." >&4
183 else
184 for net in net socket
185 do
186 if test -f /usr/lib/lib$net$_a; then
187?X: space between two '(' needed for ksh
188 ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) || \
189 $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
190 if $contains socket libc.list >/dev/null 2>&1; then
191 d_socket="$define"
192 socketlib="-l$net"
193 case "$net" in
194 net)
195 echo "...but the Wollongong group seems to have hacked it in." >&4
196 sockethdr="-I/usr/netinclude"
197 ;;
198 esac
2cb64bf6 199 echo "Found Berkeley sockets interface in lib$net." >&4
959f3c4c
JH
200?X: now check for advanced features
201 if $contains setsockopt libc.list >/dev/null 2>&1; then
202 d_oldsock="$undef"
203 else
204 echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
205 d_oldsock="$define"
206 fi
207 break
208 fi
209 fi
210 done
211 if test "X$d_socket" != "X$define"; then
212 echo "or anywhere else I see." >&4
213 d_socket="$undef"
214 d_oldsock="$undef"
215 fi
216 fi
217 fi
218fi
219
220@if HAS_SOCKETPAIR || d_sockpair
221: see if socketpair exists
222set socketpair d_sockpair
223eval $inlibc
224
225@end
226
227echo " "
7ff213fe
MB
228?X: ...
229echo "Checking the availability sa_len in the sock struct ..." >&4
230$cat >try.c <<EOF
231#include <sys/types.h>
232#include <sys/socket.h>
233int main() {
234struct sockaddr sa;
235return (sa.sa_len);
236}
237EOF
238val="$undef"
239set try; if eval $compile; then
240 val="$define"
241fi
242set d_sockaddr_sa_len; eval $setvar
243$rm_try
244
245echo " "
5230b858
MB
246?X: ...
247echo "Checking the availability sin6_scope_id in struct sockaddr_in6 ..." >&4
248$cat >try.c <<EOF
249#include <sys/types.h>
250#include <sys/socket.h>
251#include <netinet/in.h>
252int main() {
253struct sockaddr_in6 sin6;
254return (sin6.sin6_scope_id);
255}
256EOF
257val="$undef"
258set try; if eval $compile; then
259 val="$define"
260fi
261set d_sin6_scope_id; eval $setvar
262$rm_try
263
264echo " "
959f3c4c
JH
265?X: these constants are known to be troublesomely defined as enums
266?X: so that ifdef will not work for detecting their presence.
2d8cf008 267echo "Checking the availability of certain socket constants..." >&4
959f3c4c
JH
268for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
269 enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
270 $cat >try.c <<EOF
271#include <sys/types.h>
272#include <sys/socket.h>
273int main() {
274 int i = $ENUM;
275}
276EOF
277 val="$undef"
278 set try; if eval $compile; then
279 val="$define"
280 fi
281 set d_${enum}; eval $setvar
2cb64bf6 282 $rm_try
959f3c4c
JH
283done
284