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;
use strict;
use Config;
use Cwd;
use Exporter;
use File::Path;
@ -10,6 +11,52 @@ use IO::File ();
our @ISA = qw(Exporter);
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 = (
A => "AIX",
D => "Darwin",

View File

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