-# $Id: Embed.pm,v 1.1.1.1 2002/01/16 19:27:19 schwern Exp $
require 5.002;
package ExtUtils::Embed;
require Exporter;
-require FileHandle;
use Config;
-use Getopt::Std;
-use File::Spec;
+require File::Spec;
#Only when we need them
#require ExtUtils::MakeMaker;
);
use strict;
-$VERSION = 1.26;
+# This is not a dual-life module, so no need for development version numbers
+$VERSION = '1.31';
@ISA = qw(Exporter);
@EXPORT = qw(&xsinit &ldopts
@mods = @$mods if $mods;
}
else {
- getopts('o:s:');
+ require Getopt::Std;
+ Getopt::Std::getopts('o:s:');
$file = $opt_o if defined $opt_o;
$std = $opt_s if defined $opt_s;
@mods = @ARGV;
$fh = \*STDOUT;
}
else {
- $fh = new FileHandle "> $file";
+ open $fh, '>', $file
+ or die "Can't open '$file': $!";
}
push(@mods, static_ext()) if defined $std;
return <<EOF;
#include <EXTERN.h>
#include <perl.h>
+#include <XSUB.h>
EOF
}
my(@exts) = @_;
my($pname,@retval,%seen);
my($dl) = canon('/','DynaLoader');
- push(@retval, "\tchar *file = __FILE__;\n");
- push(@retval, "\tdXSUB_SYS;\n") if $] > 5.002;
+ push(@retval, "\tstatic const char file[] = __FILE__;\n");
+ push(@retval, "\tdXSUB_SYS;\n");
+ push(@retval, "\tPERL_UNUSED_CONTEXT;\n");
push(@retval, "\n");
foreach $_ (@exts){
sub static_ext {
unless (scalar @Extensions) {
- @Extensions = sort split /\s+/, $Config{static_ext};
+ my $static_ext = $Config{static_ext};
+ $static_ext =~ s/^\s+//;
+ @Extensions = sort split /\s+/, $static_ext;
unshift @Extensions, qw(DynaLoader);
}
@Extensions;
sub _escape {
my $arg = shift;
+ return $$arg if $^O eq 'VMS'; # parens legal in qualifier lists
$$arg =~ s/([\(\)])/\\$1/g;
}
if ($^O eq 'MSWin32') {
$libperl = $Config{libperl};
}
- else {
+ elsif ($^O eq 'os390' && $Config{usedl}) {
+ # Nothing for OS/390 (z/OS) dynamic.
+ } else {
$libperl = (grep(/^-l\w*perl\w*$/, @link_args))[0]
|| ($Config{libperl} =~ /^lib(\w+)(\Q$lib_ext\E|\.\Q$Config{dlext}\E)$/
? "-l$1" : '')
- || "-lperl";
+ || "-lperl";
}
my $lpath = File::Spec->catdir($Config{archlibexp}, 'CORE');
s:^(lib|ext)/(auto/)?::;
s:/\w+\.\w+$::;
}
- grep(s:/:$as:, @ext) if ($as ne '/');
+ map(s:/:$as:, @ext) if ($as ne '/');
@ext;
}
perl -MExtUtils::Embed -e ldopts
-This will print arguments for linking with B<libperl.a>, B<DynaLoader> and
+This will print arguments for linking with B<libperl> and
extensions found in B<$Config{static_ext}>. This includes libraries
found in B<$Config{libs}> and the first ModuleName.a library
for each extension that is found by searching B<@INC> or the path
This will do the same as the above example, along with printing additional arguments for linking with the B<Socket> extension.
-
- perl -MExtUtils::Embed -e ldopts -- DynaLoader
-
-
-This will print arguments for linking with just the B<DynaLoader> extension
-and B<libperl.a>.
-
-
perl -MExtUtils::Embed -e ldopts -- -std Msql -- -L/usr/msql/lib -lmsql
-
Any arguments after the second '--' token are additional linker
arguments that will be examined for potential conflict. If there is no
conflict, the additional arguments will be part of the output.