move archname to SigarWrapper

This commit is contained in:
Doug MacEachern 2007-09-03 19:36:03 +00:00
parent 51cd482ece
commit 4a504e6cf4
3 changed files with 53 additions and 57 deletions

View File

@ -2,6 +2,7 @@
package SigarWrapper; package SigarWrapper;
use strict; use strict;
use Config;
use Cwd; use Cwd;
use Exporter; use Exporter;
use File::Path; use File::Path;
@ -10,6 +11,52 @@ use IO::File ();
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw(generate); our @EXPORT = qw(generate);
sub archname {
my $os = lc $^O;
my $vers = $Config{osvers};
my $arch = $Config{archname};
if ($os =~ /win32/) {
return 'x86-winnt';
}
elsif ($os =~ /linux/) {
return 'x86-linux';
}
elsif ($os =~ /hpux/) {
if ($vers =~ /11\./) {
return 'pa-hpux-11';
}
}
elsif ($os =~ /aix/) {
return 'ppc-aix-5';
}
elsif ($os =~ /solaris/) {
if ($arch =~ /sun4/) {
return 'sparc-solaris';
}
elsif ($arch =~ /.86/) {
return 'x86-solaris';
}
}
elsif ($os =~ /darwin/) {
return 'universal-macosx';
}
elsif ($os =~ /freebsd/) {
if($arch =~ /.86/) {
if($vers =~ /6\../ ) {
return 'x86-freebsd-6';
}
}
elsif( $arch =~ /amd64/) {
if($vers =~ /6\../ ) {
return 'amd64-freebsd-6';
}
}
}
return '';
}
my %platforms = ( my %platforms = (
A => "AIX", A => "AIX",
D => "Darwin", D => "Darwin",

View File

@ -1,9 +1,7 @@
use ExtUtils::MakeMaker; use ExtUtils::MakeMaker;
use Config; use Config;
use File::Copy 'cp';
use lib qw(.. lib); use lib qw(.. lib);
use Sigar::ArchName ();
use SigarWrapper (); use SigarWrapper ();
my $installdir; my $installdir;
@ -22,7 +20,11 @@ else {
SigarWrapper::generate(Perl => '.'); SigarWrapper::generate(Perl => '.');
my $archname = Sigar::ArchName->get_name(); my $archname = SigarWrapper::archname();
my $libname = 'sigar';
if ($archname) {
$libname .= '-' . $archname;
}
my $ccname = $Config{ccname}; my $ccname = $Config{ccname};
@ -34,7 +36,7 @@ my $define = {
WriteMakefile( WriteMakefile(
'NAME' => 'Sigar', 'NAME' => 'Sigar',
'VERSION_FROM' => 'Sigar.pm', 'VERSION_FROM' => 'Sigar.pm',
'LIBS' => ["-L$installdir/lib -lsigar-$archname"], 'LIBS' => ["-L$installdir/lib -l$libname"],
'INC' => "-I$installdir/include", 'INC' => "-I$installdir/include",
'DEFINE' => $define, 'DEFINE' => $define,
'depend' => { 'Sigar.c' => 'Sigar_generated.xs' }, 'depend' => { 'Sigar.c' => 'Sigar_generated.xs' },

View File

@ -1,53 +0,0 @@
package Sigar::ArchName;
use strict;
use Config;
sub get_name {
my $os = lc $^O;
my $vers = $Config{osvers};
my $arch = $Config{archname};
if ($os =~ /win32/) {
return 'x86-winnt';
}
elsif ($os =~ /linux/) {
return 'x86-linux';
}
elsif ($os =~ /hpux/) {
if ($vers =~ /11\./) {
return 'pa-hpux-11';
}
}
elsif ($os =~ /aix/) {
return 'ppc-aix-5';
}
elsif ($os =~ /solaris/) {
if ($arch =~ /sun4/) {
return 'sparc-solaris';
}
elsif ($arch =~ /.86/) {
return 'x86-solaris';
}
}
elsif ($os =~ /darwin/) {
return 'universal-macosx';
}
elsif ($os =~ /freebsd/) {
if($arch =~ /.86/) {
if($vers =~ /6\../ ) {
return 'x86-freebsd-6';
}
}
elsif( $arch =~ /amd64/) {
if($vers =~ /6\../ ) {
return 'amd64-freebsd-6';
}
}
}
die "Unsupported platform";
}
1;
__END__