Permalink
Browse files

Use the correct swig binary name in GSLBuilder

  • Loading branch information...
1 parent 1efc4dd commit 9d9c24f8051a1bea23c9489914e54d3bbe3e0a5a @leto committed Nov 9, 2012
Showing with 20 additions and 8 deletions.
  1. +2 −7 Build.PL
  2. +18 −1 inc/GSLBuilder.pm
View
9 Build.PL
@@ -264,15 +264,10 @@ print "Have a great day!\n";
sub swig_version {
- # recent versions of Ubuntu call it swig2.0 . Le sigh.
+ my $swig = GSLBuilder::swig_binary_name();
- my $cmd = "swig -version";
+ my $cmd = "$swig -version";
my $out = `$cmd`;
- if ($?) {
- warn "Didn't find 'swig' binary, trying another name";
- }
- $cmd = "swig2.0 -version";
- $out = `$cmd`;
if ($?) {
die "Can't run [$cmd] : $out";
View
19 inc/GSLBuilder.pm
@@ -161,6 +161,23 @@ sub process_swig {
unless($self->up_to_date([$main_swig_file, @deps], $c_file));
}
+sub swig_binary_name {
+ # recent versions of Ubuntu call it swig2.0 . Le sigh.
+ my $cmd = "swig -version";
+ my $out = `$cmd`;
+ if ($?) {
+ $cmd = "swig2.0 -version";
+ $out = `$cmd`;
+
+ if ($?) {
+ die "Can't find the swig binary!";
+ } else {
+ return "swig2.0";
+ }
+ }
+ return "swig";
+}
+
# Invoke swig with -perl -outdir and other options.
sub compile_swig {
my ($self, $file, $c_file, $ver) = @_;
@@ -174,7 +191,7 @@ sub compile_swig {
my $pm_file = "${file_base}.pm";
- my @swig = qw/swig/, defined($p->{swig}) ? ($self->split_like_shell($p->{swig})) : ();
+ my @swig = swig_binary_name(), defined($p->{swig}) ? ($self->split_like_shell($p->{swig})) : ();
my @swig_flags = defined($p->{swig_flags}) ? $self->split_like_shell($p->{swig_flags}) : ();
my $blib_lib = catdir(qw/blib lib/);

0 comments on commit 9d9c24f

Please sign in to comment.