summaryrefslogtreecommitdiff
path: root/mcon/U/d_socket.U
blob: c785cfb516bf8fbb7552b4472057e7ae0dbf6d32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
?RCS: $Id$
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS: 
?RCS: You may redistribute only under the terms of the Artistic Licence,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic Licence; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: d_socket.U,v $
?RCS: Revision 3.0.1.2  1997/02/28  15:46:00  ram
?RCS: patch61: replaced .a with $_a all over the place
?RCS:
?RCS: Revision 3.0.1.1  1994/01/24  14:08:04  ram
?RCS: patch16: can now safely declare private nm_extract in dependencies
?RCS:
?RCS: Revision 3.0  1993/08/18  12:07:26  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:d_socket d_oldsock d_sockpair socketlib sockethdr: contains libc \
	echo n c nm_opt nm_extract Trylink Csym _a cat i_syssock i_winsock2
?MAKE:	-pick add $@ %<
?S:d_socket:
?S:	This variable conditionally defines HAS_SOCKET, which indicates
?S:	that the BSD socket interface is supported.
?S:.
?S:d_sockpair:
?S:	This variable conditionally defines the HAS_SOCKETPAIR symbol, which
?S:	indicates that the BSD socketpair() is supported.
?S:.
?S:d_oldsock:
?S:	This variable conditionally defines the OLDSOCKET symbol, which
?S:	indicates that the BSD socket interface is based on 4.1c and not 4.2.
?S:.
?S:socketlib:
?S:	This variable has the names of any libraries needed for socket support.
?S:.
?S:sockethdr:
?S:	This variable has any cpp -I flags needed for socket support.
?S:.
?C:HAS_SOCKET:
?C:	This symbol, if defined, indicates that the BSD socket interface is
?C:	supported.
?C:.
?C:HAS_SOCKETPAIR:
?C:	This symbol, if defined, indicates that the BSD socketpair() call is
?C:	supported.
?C:.
?C:USE_OLDSOCKET:
?C:	This symbol, if defined, indicates that the 4.1c BSD socket interface
?C:	is supported instead of the 4.2/4.3 BSD socket interface. For instance,
?C:	there is no setsockopt() call.
?C:.
?H:#$d_socket HAS_SOCKET		/**/
?H:#$d_sockpair HAS_SOCKETPAIR	/**/
?H:#$d_oldsock USE_OLDSOCKET	/**/
?H:.
?T:val
?LINT:use libc
?LINT:set d_sockpair
: see whether socket exists
socketlib=''
sockethdr=''
echo " "
$echo $n "Hmm... $c" >&4
if set socket val -f d_socket; eval $csym; $val; then
	echo "Looks like you have Berkeley networking support." >&4
	d_socket="$define"
?X: now check for advanced features
	if set setsockopt val -f; eval $csym; $val; then
		d_oldsock="$undef"
	else
		echo "...but it uses the old 4.1c interface, rather than 4.2" >&4
		d_oldsock="$define"
	fi
else
?X: HP-UX, for one, puts all the socket stuff in socklib.o. Note that if we
?X:	come here on HP-UX, then we must have used nm to get symbols, or we really
?X: don't have sockets anyway...
	if $contains socklib libc.list >/dev/null 2>&1; then
		echo "Looks like you have Berkeley networking support." >&4
		d_socket="$define"
		: we will have to assume that it supports the 4.2 BSD interface
		d_oldsock="$undef"
	else
		echo "You don't have Berkeley networking in libc$_a..." >&4
?X: look for an optional networking library
		if test -f /usr/lib/libnet$_a; then
?X: space between two  '(' needed for ksh
			( (nm $nm_opt /usr/lib/libnet$_a | eval $nm_extract) ||  \
			ar t /usr/lib/libnet$_a) 2>/dev/null >> libc.list
			if $contains socket libc.list >/dev/null 2>&1; then
			echo "...but the Wollongong group seems to have hacked it in." >&4
				socketlib="-lnet"
				sockethdr="-I/usr/netinclude"
				d_socket="$define"
?X: now check for advanced features
				if $contains setsockopt libc.list >/dev/null 2>&1; then
					d_oldsock="$undef"
				else
					echo "...using the old 4.1c interface, rather than 4.2" >&4
					d_oldsock="$define"
				fi
			else
				echo "or even in libnet$_a, which is peculiar." >&4
				d_socket="$undef"
				d_oldsock="$undef"
			fi
		else
			echo "or anywhere else I see." >&4
			d_socket="$undef"
			d_oldsock="$undef"
		fi
	fi
fi

@if HAS_SOCKETPAIR || d_sockpair
: see if socketpair exists
$cat >try.c <<EOC
#$i_syssock I_SYS_SOCKET
#$i_winsock2 I_WINSOCK2
#ifdef I_SYS_SOCKET
#include <sys/socket.h>
#endif
#ifdef I_WINSOCK2
#include <Winsock2.h>
#endif
int main(void)
{
	static int ret, domain, type, protocol, sv[2];
	ret |= socketpair(domain, type, protocol, sv);
	return ret ? 0 : 1;
}
EOC
cyn=socketpair
set d_sockpair
eval $trylink

@end