This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove explicit support for pre-7.0 VMS and pre-6.0 DEC C.
[perl5.git] / cpan / Socket / Makefile.PL
CommitLineData
42793c05 1use ExtUtils::MakeMaker;
735631af 2use ExtUtils::Constant 0.23 'WriteConstants';
d6a66728 3use Config;
1584259f
PLE
4
5my @DEFINES;
6unless( $ENV{PERL_CORE} ) {
7 # Building standalone, not as core.
8 require ExtUtils::CChecker;
9 my $cc = ExtUtils::CChecker->new;
10
11 my %defines = (
12 # -Dfoo func() $Config{key}
13 HAS_GETADDRINFO => [ "getaddrinfo", "d_getaddrinfo" ],
14 HAS_GETNAMEINFO => [ "getnameinfo", "d_getnameinfo" ],
15 HAS_INET_ATON => [ "inet_aton", "d_inetaton" ],
16 HAS_INETNTOP => [ "inet_ntop", "d_inetntop" ],
17 HAS_INETPTON => [ "inet_pton", "d_inetpton" ],
18 );
19
20 foreach my $define ( sort keys %defines ) {
21 my ( $func, $key ) = @{$defines{$define}};
22 next if exists $Config{$key};
23
24 $cc->try_compile_run(
25 define => $define,
26 source => <<"EOF" )
27#include <sys/types.h>
28#include <sys/socket.h>
29#include <netdb.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32int main(int argc, char *argv[]) {
33 void *p = &$func;
34 return 0;
35}
36EOF
37 and print "$func() found\n"
38 or print "$func() not found\n";
39 }
40
41 unless( exists $Config{d_sockaddr_sa_len} ) {
42 $cc->try_compile_run(
43 define => "HAS_SOCKADDR_SA_LEN",
44 source => <<'EOF' )
45#include <sys/types.h>
46#include <sys/socket.h>
47int main(int argc, char *argv[]) {
48 struct sockaddr sa;
49 sa.sa_len = 0;
50 return 0;
51}
52EOF
53 and print "sockaddr has sa_len\n"
54 or print "sockaddr does not have sa_len\n";
55 }
56
57 unless( exists $Config{d_sin6_scope_id} ) {
58 $cc->try_compile_run(
59 define => "HAS_SIN6_SCOPE_ID",
60 source => <<'EOF' )
61#include <sys/types.h>
62#include <sys/socket.h>
63#include <netinet/in.h>
64int main(int argc, char *argv[]) {
65 struct sockaddr_in6 sin6;
66 sin6.sin6_scope_id = 0;
67 return 0;
68}
69EOF
70 and print "sockaddr_in6 has sin6_scope_id\n"
71 or print "sockaddr_in6 does not have sin6_scope_id\n";
72 }
73
74 @DEFINES = @{ $cc->extra_compiler_flags };
75}
76
4ad3186e 77WriteMakefile(
d6a66728 78 NAME => 'Socket',
c07a80fd 79 VERSION_FROM => 'Socket.pm',
d6a66728 80 ($Config{libs} =~ /(-lsocks\S*)/ ? (LIBS => [ "$1" ] ) : ()),
d6a66728 81 XSPROTOARG => '-noprototypes', # XXX remove later?
ece2ffd9 82 realclean => {FILES=> 'const-c.inc const-xs.inc'},
1584259f
PLE
83 DEFINE => join( " ", @DEFINES ),
84 CONFIGURE_REQUIRES => {
85 'ExtUtils::CChecker' => 0,
86 'ExtUtils::Constant' => '0.23',
87 },
4ad3186e 88);
7198d2fd
JH
89my @names = (qw(AF_802 AF_AAL AF_APPLETALK AF_CCITT AF_CHAOS AF_CTF
90 AF_DATAKIT AF_DECnet AF_DLI AF_ECMA AF_GOSIP AF_HYLINK
91 AF_IMPLINK AF_INET AF_INET6 AF_ISO AF_KEY
92 AF_LAST AF_LAT AF_LINK AF_MAX AF_NBS AF_NIT AF_NS
93 AF_OSI AF_OSINET AF_PUP AF_ROUTE AF_SNA
94 AF_UNIX AF_UNSPEC AF_USER AF_WAN AF_X25
0369a5a5
PLE
95 AI_ADDRCONFIG AI_ALL AI_CANONIDN AI_CANONNAME AI_IDN
96 AI_IDN_ALLOW_UNASSIGNED AI_IDN_USE_STD3_ASCII_RULES
97 AI_NUMERICHOST AI_NUMERICSERV AI_PASSIVE AI_V4MAPPED
98 EAI_ADDRFAMILY EAI_AGAIN EAI_BADFLAGS EAI_BADHINTS EAI_FAIL
99 EAI_FAMILY EAI_NODATA EAI_NONAME EAI_PROTOCOL EAI_SERVICE
100 EAI_SOCKTYPE EAI_SYSTEM
131c565a
SP
101 IOV_MAX IP_OPTIONS IP_HDRINCL IP_TOS IP_TTL IP_RECVOPTS
102 IP_RECVRETOPTS IP_RETOPTS
4f5bb87f
PLE
103 IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP IPV6_MTU
104 IPV6_MTU_DISCOVER IPV6_MULTICAST_HOPS IPV6_MULTICAST_IF
105 IPV6_MULTICAST_LOOP IPV6_UNICAST_HOPS IPV6_V6ONLY
7198d2fd
JH
106 MSG_BCAST MSG_BTAG MSG_CTLFLAGS MSG_CTLIGNORE MSG_DONTWAIT
107 MSG_EOF MSG_EOR MSG_ERRQUEUE MSG_ETAG MSG_FIN
108 MSG_MAXIOVLEN MSG_MCAST MSG_NOSIGNAL MSG_RST MSG_SYN
109 MSG_TRUNC MSG_URG MSG_WAITALL MSG_WIRE
0369a5a5
PLE
110 NI_DGRAM NI_IDN NI_IDN_ALLOW_UNASSIGNED
111 NI_IDN_USE_STD3_ASCII_RULES NI_NAMEREQD NI_NOFQDN
112 NI_NUMERICHOST NI_NUMERICSERV
7198d2fd
JH
113 PF_802 PF_AAL PF_APPLETALK PF_CCITT PF_CHAOS PF_CTF
114 PF_DATAKIT PF_DECnet PF_DLI PF_ECMA PF_GOSIP PF_HYLINK
115 PF_IMPLINK PF_INET PF_INET6 PF_ISO PF_KEY
116 PF_LAST PF_LAT PF_LINK PF_MAX PF_NBS PF_NIT PF_NS
117 PF_OSI PF_OSINET PF_PUP PF_ROUTE PF_SNA
118 PF_UNIX PF_UNSPEC PF_USER PF_WAN PF_X25
119 SCM_CONNECT SCM_CREDENTIALS SCM_CREDS SCM_TIMESTAMP
120 SOCK_DGRAM SOCK_RAW SOCK_RDM SOCK_SEQPACKET SOCK_STREAM
121 SOL_SOCKET SOMAXCONN
122 SO_ACCEPTCONN SO_ATTACH_FILTER SO_BACKLOG SO_BROADCAST
123 SO_CHAMELEON SO_DEBUG SO_DETACH_FILTER SO_DGRAM_ERRIND
124 SO_DONTLINGER SO_DONTROUTE SO_ERROR SO_FAMILY
125 SO_KEEPALIVE SO_LINGER SO_OOBINLINE
126 SO_PASSCRED SO_PASSIFNAME SO_PEERCRED
127 SO_PROTOCOL SO_PROTOTYPE
128 SO_RCVBUF SO_RCVLOWAT SO_RCVTIMEO
129 SO_REUSEADDR SO_REUSEPORT
130 SO_SECURITY_AUTHENTICATION
131 SO_SECURITY_ENCRYPTION_NETWORK
132 SO_SECURITY_ENCRYPTION_TRANSPORT
133 SO_SNDBUF SO_SNDLOWAT SO_SNDTIMEO
134 SO_STATE SO_TYPE SO_USELOOPBACK SO_XOPEN SO_XSE
135 TCP_KEEPALIVE TCP_MAXRT TCP_MAXSEG TCP_NODELAY TCP_STDURG
f686127b
SF
136 TCP_CORK TCP_KEEPIDLE TCP_KEEPINTVL TCP_KEEPCNT
137 TCP_SYNCNT TCP_LINGER2 TCP_DEFER_ACCEPT TCP_WINDOW_CLAMP
138 TCP_INFO TCP_QUICKACK TCP_CONGESTION TCP_MD5SIG
7198d2fd
JH
139 UIO_MAXIOV
140 ),
131c565a
SP
141 {name=>"IPPROTO_IP", type=>"IV", default=>["IV", 0]},
142 {name=>"IPPROTO_IPV6", type=>"IV", default=>["IV", 41]},
143 {name=>"IPPROTO_RAW", type=>"IV", default=>["IV", 255]},
29f89f33
GA
144 {name=>"IPPROTO_ICMP", type=>"IV", default=>["IV", 1]},
145 {name=>"IPPROTO_TCP", type=>"IV", default=>["IV", 6]},
146 {name=>"IPPROTO_UDP", type=>"IV", default=>["IV", 17]},
0552bf3a
NC
147 {name=>"SHUT_RD", type=>"IV", default=>["IV", "0"]},
148 {name=>"SHUT_WR", type=>"IV", default=>["IV", "1"]},
149 {name=>"SHUT_RDWR", type=>"IV", default=>["IV", "2"]},
150);
151
152push @names,
153 {name=>$_, type=>"IV",
154 macro=>["#if defined($_) || defined(HAS_$_) /* might be an enum */\n",
155 "#endif\n"]}
156foreach qw (MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS);
157
44559db1 158push @names,
0552bf3a
NC
159{name => $_, type => "SV",
160 pre=>"struct in_addr ip_address; ip_address.s_addr = htonl($_);",
d3d34884 161 value => "newSVpvn_flags((char *)&ip_address,sizeof(ip_address), SVs_TEMP)",}
0552bf3a
NC
162 foreach qw(INADDR_ANY INADDR_LOOPBACK INADDR_NONE INADDR_BROADCAST);
163
6b0aeb77
PLE
164push @names,
165{name => $_, type => "SV",
166 macro=>["#ifdef ${_}_INIT\n",
167 "#endif\n"],
168 pre=>"struct in6_addr ip6_address = ${_}_INIT;",
169 value => "newSVpvn_flags((char *)&ip6_address,sizeof(ip6_address), SVs_TEMP)",}
170 foreach qw(IN6ADDR_ANY IN6ADDR_LOOPBACK);
171
0552bf3a 172WriteConstants(
7f39e0ae 173 PROXYSUBS => {autoload => 1},
0552bf3a
NC
174 NAME => 'Socket',
175 NAMES => \@names,
176);