use SigarBuild.pm

This commit is contained in:
Doug MacEachern 2009-02-24 19:07:51 -08:00
parent b2a1f5cbd5
commit 349b7caaf6
1 changed files with 30 additions and 18 deletions

View File

@ -1,31 +1,43 @@
use ExtUtils::MakeMaker; use ExtUtils::MakeMaker;
use strict;
use Config; use Config;
use File::Basename qw(basename);
use File::Copy qw(copy);
use lib qw(.. lib); use lib qw(.. lib);
use SigarWrapper (); use SigarWrapper ();
use SigarBuild ();
my $gen_xs = 'Sigar_generated.xs';
my(@mm_args);
my(@clean_files) = ($gen_xs);
my $installdir;
if ($ARGV[0]) { if ($ARGV[0]) {
$installdir = $ARGV[0]; #link against installed libsigar
my $installdir = $ARGV[0];
@mm_args = (
LIBS => ["-L$installdir/lib -lsigar"],
INC => "-I$installdir/include",
);
} }
else { else {
#check binary-dist location and svn source location #all sources in Sigar.so
for (qw(../../sigar-bin ../java/sigar-bin)) { my $flags = SigarBuild::flags();
if (-e $_) { my(@inline_src) = SigarBuild::inline_src($flags);
$installdir = $_; push @clean_files, @inline_src;
last; my(@object) = ('Sigar.o', map { s/c$/o/; $_ } @inline_src);
} my(@libs) = map { "-l$_" } @{$flags->{libs}};
}
@mm_args = (
OBJECT => "@object",
LIBS => ["@libs"],
INC => "@{$flags->{cppflags}}",
dynamic_lib => { OTHERLDFLAGS => "@{$flags->{ldflags}}" },
);
} }
SigarWrapper::generate(Perl => '.'); SigarWrapper::generate(Perl => '.');
my $archname = SigarWrapper::archname();
my $libname = 'sigar';
if ($archname) {
$libname .= '-' . $archname;
}
my $ccname = $Config{ccname}; my $ccname = $Config{ccname};
my $define = { my $define = {
@ -36,8 +48,8 @@ my $define = {
WriteMakefile( WriteMakefile(
'NAME' => 'Sigar', 'NAME' => 'Sigar',
'VERSION_FROM' => 'Sigar.pm', 'VERSION_FROM' => 'Sigar.pm',
'LIBS' => ["-L$installdir/lib -l$libname"],
'INC' => "-I$installdir/include",
'DEFINE' => $define, 'DEFINE' => $define,
'depend' => { 'Sigar.c' => 'Sigar_generated.xs' }, 'depend' => { 'Sigar.c' => $gen_xs },
'realclean' => { FILES => "@clean_files" },
@mm_args,
); );