This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Apply NetBSD patch-ae: another gcc sparc64 bug.
[perl5.git] / lib / ExtUtils / Embed.t
index 08c7cab..b6ddd0f 100644 (file)
@@ -17,17 +17,39 @@ print "1..9\n";
 my $cc = $Config{'cc'};
 my $cl  = ($^O eq 'MSWin32' && $cc eq 'cl');
 my $exe = 'embed_test' . $Config{'exe_ext'};
-my $inc = File::Spec->catdir($INC[0],"..");
-my $lib = File::Spec->catdir($INC[0],"..");
+my $obj = 'embed_test' . $Config{'obj_ext'};
+my $inc = File::Spec->updir;
+my $lib = File::Spec->updir;
 my @cmd;
-if ($cl) {
+my (@cmd2) if $^O eq 'VMS';
+
+if ($^O eq 'VMS') {
+    push(@cmd,$cc,"/Obj=$obj");
+    my (@incs) = ($inc);
+    my $crazy = ccopts();
+    if ($crazy =~ s#/inc[^=/]*=([\w\$\_\-\.\[\]\:]+)##i) {
+        push(@incs,$1);
+    }
+    if ($crazy =~ s/-I([a-zA-Z0-9\$\_\-\.\[\]\:]*)//) {
+        push(@incs,$1);
+    }
+    $crazy =~ s#/Obj[^=/]*=[\w\$\_\-\.\[\]\:]+##i;
+    push(@cmd,"/Include=(".join(',',@incs).")");
+    push(@cmd,$crazy);
+    push(@cmd,"embed_test.c");
+
+    push(@cmd2,$Config{'ld'}, $Config{'ldflags'}, "/exe=$exe"); 
+    push(@cmd2,"$obj,[-]perlshr.opt/opt,[-]perlshr_attr.opt/opt");
+
+} else {
+   if ($cl) {
     push(@cmd,$cc,"-Fe$exe");
-}
-else {
+   }
+   else {
     push(@cmd,$cc,'-o' => $exe);
-}
-push(@cmd,"-I$inc",ccopts(),'embed_test.c');
-if ($^O eq 'MSWin32') {
+   }
+   push(@cmd,"-I$inc",ccopts(),'embed_test.c');
+   if ($^O eq 'MSWin32') {
     $inc = File::Spec->catdir($inc,'win32');
     push(@cmd,"-I$inc");
     $inc = File::Spec->catdir($inc,'include');
@@ -38,22 +60,50 @@ if ($^O eq 'MSWin32') {
     else {
        push(@cmd,"-L$lib",File::Spec->catfile($lib,$Config{'libperl'}),$Config{'libc'});
     }
-}
-else {
+   }
+   else {
     push(@cmd,"-L$lib",'-lperl');
+   }
+   {
+    local $SIG{__WARN__} = sub {
+       warn $_[0] unless $_[0] =~ /No library found for -lperl/
+    };
+    push(@cmd,ldopts());
+   }
+
+   if ($^O eq 'aix') { # AIX needs an explicit symbol export list.
+    my ($perl_exp) = grep { -f } qw(perl.exp ../perl.exp);
+    die "where is perl.exp?\n" unless defined $perl_exp;
+    for (@cmd) {
+        s!-bE:(\S+)!-bE:$perl_exp!;
+    }
+   } elsif ($^O eq 'cygwin') { # Cygwin needs the libperl copied
+     my $v_e_r_s = $Config{version};
+     $v_e_r_s =~ tr/./_/;
+     system("cp ../libperl$v_e_r_s.dll ./");    # for test 1
+     system("cp ../$Config{'libperl'} ../libperl.a");    # for test 1
+   }
 }
-push(@cmd,ldopts());
-
-print "# @cmd"; # where is the newline coming from? ldopts()?
-print "not " if system(join(' ',@cmd));
-print "ok 1\n";
-
-my $embed_test = File::Spec->catfile(File::Spec->curdir, "embed_test");
-
-print "not " if system($embed_test);
-print "ok 9\n";
-
-unlink($exe,"embed_test.c");
+my $status;
+my $display_cmd = "@cmd";
+chomp($display_cmd); # where is the newline coming from? ldopts()?
+print "# $display_cmd\n"; 
+$status = system(join(' ',@cmd));
+if ($^O eq 'VMS' && !$status) {
+  print "# @cmd2\n";
+  $status = system(join(' ',@cmd2)); 
+}
+print (($status? 'not ': '')."ok 1\n");
+
+my $embed_test = File::Spec->catfile(File::Spec->curdir, $exe);
+$embed_test = "run/nodebug $exe" if $^O eq 'VMS';
+print "# embed_test = $embed_test\n";
+$status = system($embed_test);
+print (($status? 'not ':'')."ok 9 # $status\n");
+unlink($exe,"embed_test.c",$obj);
+unlink("embed_test.map","embed_test.lis") if $^O eq 'VMS';
+unlink(glob("./libperl*.dll")) if $^O eq 'cygwin';
+unlink("../libperl.a")         if $^O eq 'cygwin';
 
 # gcc -g -I.. -L../ -o perl_test perl_test.c -lperl `../perl -I../lib -MExtUtils::Embed -I../ -e ccopts -e ldopts`