This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3) may not.
[metaconfig.git] / U / modified / d_socket.U
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
4 ?RCS: 
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 \
23         d_scm_rights: \
24         contains libc echo n c ar nm nm_opt nm_extract Inlibc Csym _a \
25         Compile cat rm Setvar Hasfield
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:.
69 ?S:socketlib:
70 ?S:     This variable has the names of any libraries needed for socket support.
71 ?S:.
72 ?S:sockethdr:
73 ?S:     This variable has any cpp '-I' flags needed for socket support.
74 ?S:.
75 ?C:HAS_SOCKET (SOCKET):
76 ?C:     This symbol, if defined, indicates that the BSD socket interface is
77 ?C:     supported.
78 ?C:.
79 ?C:HAS_SOCKETPAIR (SOCKETPAIR):
80 ?C:     This symbol, if defined, indicates that the BSD socketpair() call is
81 ?C:     supported.
82 ?C:.
83 ?C:USE_OLDSOCKET (OLDSOCKET):
84 ?C:     This symbol, if defined, indicates that the 4.1c BSD socket interface
85 ?C:     is supported instead of the 4.2/4.3 BSD socket interface. For instance,
86 ?C:     there is no setsockopt() call.
87 ?C:.
88 ?C:HAS_MSG_CTRUNC:
89 ?C:     This symbol, if defined, indicates that the MSG_CTRUNC is supported.
90 ?C:     Checking just with #ifdef might not be enough because this symbol
91 ?C:     has been known to be an enum.
92 ?C:.
93 ?C:HAS_MSG_DONTROUTE:
94 ?C:     This symbol, if defined, indicates that the MSG_DONTROUTE 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_OOB:
99 ?C:     This symbol, if defined, indicates that the MSG_OOB 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_PEEK:
104 ?C:     This symbol, if defined, indicates that the MSG_PEEK 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_PROXY:
109 ?C:     This symbol, if defined, indicates that the MSG_PROXY 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_SCM_RIGHTS:
114 ?C:     This symbol, if defined, indicates that the SCM_RIGHTS 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 ?H:#$d_socket   HAS_SOCKET              /**/
119 ?H:#$d_sockpair HAS_SOCKETPAIR  /**/
120 ?H:#$d_oldsock  USE_OLDSOCKET   /**/
121 ?H:#$d_msg_ctrunc       HAS_MSG_CTRUNC  /**/
122 ?H:#$d_msg_dontroute    HAS_MSG_DONTROUTE       /**/
123 ?H:#$d_msg_oob  HAS_MSG_OOB     /**/
124 ?H:#$d_msg_peek HAS_MSG_PEEK    /**/
125 ?H:#$d_msg_proxy        HAS_MSG_PROXY   /**/
126 ?H:#$d_scm_rights       HAS_SCM_RIGHTS  /**/
127 ?H:.
128 ?T:val net ENUM enum
129 ?F:try.c
130 ?LINT:set d_sockpair
131 ?LINT:set d_msg_ctrunc d_msg_dontroute d_msg_oob d_msg_peek d_msg_proxy
132 ?LINT:set d_scm_rights
133 socketlib=''
134 sockethdr=''
135 : see whether socket exists
136 echo " "
137 $echo $n "Hmm... $c" >&4
138 if set socket val -f d_socket; eval $csym; $val; then
139         echo "Looks like you have Berkeley networking support." >&4
140         d_socket="$define"
141 ?X: now check for advanced features
142         if set setsockopt val -f; eval $csym; $val; then
143                 d_oldsock="$undef"
144         else
145                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
146                 d_oldsock="$define"
147         fi
148 else
149 ?X: HP-UX, for one, puts all the socket stuff in socklib.o. Note that if we
150 ?X: come here on HP-UX, then we must have used nm to get symbols, or we really
151 ?X: don't have sockets anyway...
152         if $contains socklib libc.list >/dev/null 2>&1; then
153                 echo "Looks like you have Berkeley networking support." >&4
154                 d_socket="$define"
155                 : we will have to assume that it supports the 4.2 BSD interface
156                 d_oldsock="$undef"
157         else
158                 echo "You don't have Berkeley networking in libc$_a..." >&4
159 ?X: look for optional networking libraries
160                 if test "X$d_socket" = "X$define"; then
161                    echo "...but you seem to believe that you have sockets." >&4
162                 else
163                         for net in net socket
164                         do
165                                 if test -f /usr/lib/lib$net$_a; then
166 ?X: space between two  '(' needed for ksh
167                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
168                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
169                                         if $contains socket libc.list >/dev/null 2>&1; then
170                                                 d_socket="$define"
171                                                 socketlib="-l$net"
172                                                 case "$net" in
173                                                 net)
174                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
175                                                         sockethdr="-I/usr/netinclude"
176                                                         ;;
177                                                 esac
178                                                 echo "Found Berkeley sockets interface in lib$net." >&4 
179 ?X: now check for advanced features
180                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
181                                                         d_oldsock="$undef"
182                                                 else
183                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
184                                                         d_oldsock="$define"
185                                                 fi
186                                                 break
187                                         fi
188                                 fi
189                         done
190                         if test "X$d_socket" != "X$define"; then
191                            echo "or anywhere else I see." >&4
192                            d_socket="$undef"
193                            d_oldsock="$undef"
194                         fi
195                 fi
196         fi
197 fi
198
199 @if HAS_SOCKETPAIR || d_sockpair
200 : see if socketpair exists
201 set socketpair d_sockpair
202 eval $inlibc
203
204 @end
205
206 echo " "
207 ?X: these constants are known to be troublesomely defined as enums
208 ?X: so that ifdef will not work for detecting their presence.
209 echo "Checking the availability of certain socket constants..." >&4
210 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
211         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
212         $cat >try.c <<EOF
213 #include <sys/types.h>
214 #include <sys/socket.h>
215 int main() {
216     int i = $ENUM;
217 }
218 EOF
219         val="$undef"
220         set try; if eval $compile; then
221                 val="$define"
222         fi
223         set d_${enum}; eval $setvar
224         $rm -f try.c try
225 done
226