Update Socket to CPAN version 1.97
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Fri, 16 Dec 2011 22:37:41 +0000 (22:37 +0000)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Fri, 16 Dec 2011 23:31:59 +0000 (23:31 +0000)
  [DELTA]

  1.97    CHANGES:
         * Rewritten Makefile.PL configure-time logic to use only core's
           ExtUtils::CBuilder rather than CPAN's ExtUtils::CChecker
         * Fix implementation of synthesized newSVpvn_flags() to also work on
           threaded 5.10.0
         * Set INSTALLDIRS=perl on perl before 5.11; required as it's
           replacing a core module

Porting/Maintainers.pl
cpan/Socket/Makefile.PL
cpan/Socket/Socket.pm
cpan/Socket/Socket.xs
pod/perldelta.pod

index ad30159..aaf20a5 100755 (executable)
@@ -1612,7 +1612,7 @@ use File::Glob qw(:case);
 
     'Socket' => {
         'MAINTAINER'   => 'pevans',
-        'DISTRIBUTION' => 'PEVANS/Socket-1.96.tar.gz',
+        'DISTRIBUTION' => 'PEVANS/Socket-1.97.tar.gz',
         'FILES'        => q[cpan/Socket],
         'UPSTREAM'     => 'cpan',
     },
index bedca39..43cc833 100644 (file)
+#!perl
+use strict;
+use warnings;
+
 use ExtUtils::MakeMaker;
 use ExtUtils::Constant 0.23 'WriteConstants';
 use Config;
 
 my @DEFINES;
-unless( $ENV{PERL_CORE} ) {
-    # Building standalone, not as core.
-    require ExtUtils::CChecker;
-    my $cc = ExtUtils::CChecker->new;
-
-    my %defines = (
-       # -Dfoo               func()        $Config{key}
-       HAS_GETADDRINFO => [ "getaddrinfo", "d_getaddrinfo" ],
-       HAS_GETNAMEINFO => [ "getnameinfo", "d_getnameinfo" ],
-       HAS_INET_ATON   => [ "inet_aton",   "d_inetaton" ],
-       HAS_INETNTOP    => [ "inet_ntop",   "d_inetntop" ],
-       HAS_INETPTON    => [ "inet_pton",   "d_inetpton" ],
-    );
 
-    foreach my $define ( sort keys %defines ) {
-       my ( $func, $key ) = @{$defines{$define}};
-       next if exists $Config{$key};
+my $cb;
+my $seq = 0;
+sub check_for
+{
+    my %args = @_;
+    return if exists $Config{$args{confkey}};
+
+    require ExtUtils::CBuilder;
+    $cb ||= ExtUtils::CBuilder->new( quiet => 1 );
+
+    my $main = $args{main};
+
+    print "Checking $args{define}...\n";
 
-       $cc->try_compile_run(
-           define => $define,
-           source => <<"EOF" )
+    my $file_base = "test-$seq"; $seq++;
+
+    my $file_source = "$file_base.c";
+
+    {
+       open( my $file_source_fh, ">", $file_source ) or die "Cannot write $file_source - $!";
+       print $file_source_fh <<"EOF";
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-int main(int argc, char *argv[]) {
-    void *p = &$func;
+int main(int argc, char *argv[])
+  {
+    $main
     return 0;
-}
+  }
 EOF
-           and print "$func() found\n"
-           or  print "$func() not found\n";
     }
 
-    unless( exists $Config{d_sockaddr_sa_len} ) {
-       $cc->try_compile_run(
-           define => "HAS_SOCKADDR_SA_LEN",
-           source => <<'EOF' )
-#include <sys/types.h>
-#include <sys/socket.h>
-int main(int argc, char *argv[]) {
-    struct sockaddr sa;
-    sa.sa_len = 0;
-    return 0;
+    my $file_obj = eval { $cb->compile( source => $file_source ) };
+    unlink $file_source;
+
+    return 0 unless defined $file_obj;
+
+    my $file_exe = eval { $cb->link_executable( objects => $file_obj ) };
+    unlink $file_obj;
+
+    return 0 unless defined $file_exe;
+
+    # Don't need to try running it
+    unlink $file_exe;
+
+    push @DEFINES, $args{define};
 }
-EOF
-           and print "sockaddr has sa_len\n"
-           or  print "sockaddr does not have sa_len\n";
-    }
 
-    unless( exists $Config{d_sin6_scope_id} ) {
-       $cc->try_compile_run(
-           define => "HAS_SIN6_SCOPE_ID",
-           source => <<'EOF' )
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-int main(int argc, char *argv[]) {
-    struct sockaddr_in6 sin6;
-    sin6.sin6_scope_id = 0;
-    return 0;
+sub check_for_func
+{
+    my %args = @_;
+    my $func = delete $args{func};
+    check_for( %args, main => "void *p = &$func;" );
 }
-EOF
-           and print "sockaddr_in6 has sin6_scope_id\n"
-           or  print "sockaddr_in6 does not have sin6_scope_id\n";
-    }
 
-    @DEFINES = @{ $cc->extra_compiler_flags };
+my %defines = (
+    # -Dfoo               func()        $Config{key}
+    HAS_GETADDRINFO => [ "getaddrinfo", "d_getaddrinfo" ],
+    HAS_GETNAMEINFO => [ "getnameinfo", "d_getnameinfo" ],
+    HAS_INET_ATON   => [ "inet_aton",   "d_inetaton" ],
+    HAS_INETNTOP    => [ "inet_ntop",   "d_inetntop" ],
+    HAS_INETPTON    => [ "inet_pton",   "d_inetpton" ],
+);
+
+foreach my $define ( sort keys %defines ) {
+    my ( $func, $key ) = @{$defines{$define}};
+    check_for_func( 
+       confkey => $key,
+       define  => $define,
+       func    => $func
+    );
 }
 
+check_for(
+    confkey => "d_sockaddr_sa_len",
+    define  => "HAS_SOCKADDR_SA_LEN",
+    main    => "struct sockaddr sa; sa.sa_len = 0;"
+);
+
+check_for(
+    confkey => "d_sin6_scope_id",
+    define  => "HAS_SIN6_SCOPE_ID",
+    main    => "struct sockaddr_in6 sin6; sin6.sin6_scope_id = 0;"
+);
+
+my %makefile_args;
+
+# Since we're providing a later version of a core module, before 5.12 the
+# @INC order is wrong so we'll have to go in perl rather than site dirs
+$makefile_args{INSTALLDIRS} = "perl" if $] < 5.012;
+
 WriteMakefile(
     NAME        => 'Socket',
     VERSION_FROM => 'Socket.pm',
    ($Config{libs} =~ /(-lsocks\S*)/ ? (LIBS => [ "$1" ] ) : ()),
     XSPROTOARG   => '-noprototypes',           # XXX remove later?
     realclean => {FILES=> 'const-c.inc const-xs.inc'},
-    DEFINE       => join( " ", @DEFINES ),
+    DEFINE       => join( " ", map { "-D$_" } @DEFINES ),
     CONFIGURE_REQUIRES => {
-       'ExtUtils::CChecker' => 0,
+       'ExtUtils::CBuilder' => 0,
        'ExtUtils::Constant' => '0.23',
     },
+    %makefile_args,
 );
 my @names = (
     qw(
index 25eb5f3..17fda97 100644 (file)
@@ -2,7 +2,7 @@ package Socket;
 
 use strict;
 
-our $VERSION = '1.96';
+our $VERSION = '1.97';
 
 =head1 NAME
 
index 1e3eeb0..febe0b4 100644 (file)
@@ -85,12 +85,14 @@ NETINET_DEFINE_CONTEXT
 #endif
 
 #ifdef NEED_newSVpvn_flags
-static SV *newSVpvn_flags(pTHX_ const char *s, STRLEN len, U32 flags)
+static SV *my_newSVpvn_flags(pTHX_ const char *s, STRLEN len, U32 flags)
 {
   SV *sv = newSVpvn(s, len);
   SvFLAGS(sv) |= (flags & SVf_UTF8);
   return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv;
 }
+
+#define newSVpvn_flags(s,len,flags) my_newSVpvn_flags(aTHX_ s,len,flags)
 #endif
 
 #ifndef HAS_INET_ATON
index 5f57b52..1d45594 100644 (file)
@@ -458,7 +458,7 @@ it was not, adding a note will help whoever compiles perl5160delta.
 
 =item *
 
-L<Socket> has been upgraded from version 1.94_02 to version 1.96.
+L<Socket> has been upgraded from version 1.94_02 to version 1.97.
 
 =item *