diff --git a/bindings/SigarWrapper.pm b/bindings/SigarWrapper.pm index e9d038d4..19dfbc0c 100644 --- a/bindings/SigarWrapper.pm +++ b/bindings/SigarWrapper.pm @@ -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", diff --git a/bindings/perl/Makefile.PL b/bindings/perl/Makefile.PL index fb1e27e3..2b226e4a 100644 --- a/bindings/perl/Makefile.PL +++ b/bindings/perl/Makefile.PL @@ -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' }, diff --git a/bindings/perl/lib/Sigar/ArchName.pm b/bindings/perl/lib/Sigar/ArchName.pm deleted file mode 100644 index d8b75154..00000000 --- a/bindings/perl/lib/Sigar/ArchName.pm +++ /dev/null @@ -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__