| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Alien::Build::Interpolate::Default; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 11 |  |  | 11 |  | 253730 | use strict; | 
|  | 11 |  |  |  |  | 37 |  | 
|  | 11 |  |  |  |  | 366 |  | 
| 4 | 11 |  |  | 11 |  | 57 | use warnings; | 
|  | 11 |  |  |  |  | 23 |  | 
|  | 11 |  |  |  |  | 288 |  | 
| 5 | 11 |  |  | 11 |  | 220 | use 5.008004; | 
|  | 11 |  |  |  |  | 40 |  | 
| 6 | 11 |  |  | 11 |  | 585 | use parent qw( Alien::Build::Interpolate ); | 
|  | 11 |  |  |  |  | 374 |  | 
|  | 11 |  |  |  |  | 95 |  | 
| 7 | 11 |  |  | 11 |  | 1631 | use File::chdir; | 
|  | 11 |  |  |  |  | 5061 |  | 
|  | 11 |  |  |  |  | 1281 |  | 
| 8 | 11 |  |  | 11 |  | 1233 | use File::Which qw( which ); | 
|  | 11 |  |  |  |  | 2247 |  | 
|  | 11 |  |  |  |  | 554 |  | 
| 9 | 11 |  |  | 11 |  | 650 | use Capture::Tiny qw( capture ); | 
|  | 11 |  |  |  |  | 28707 |  | 
|  | 11 |  |  |  |  | 15445 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | # ABSTRACT: Default interpolator for Alien::Build | 
| 12 |  |  |  |  |  |  | our $VERSION = '2.45'; # VERSION | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | sub _config | 
| 15 |  |  |  |  |  |  | { | 
| 16 | 0 |  |  | 0 |  | 0 | $Config::Config{$_[0]}; | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | sub new | 
| 21 |  |  |  |  |  |  | { | 
| 22 | 69 |  |  | 69 | 1 | 29670 | my($class) = @_; | 
| 23 | 69 |  |  |  |  | 443 | my $self = $class->SUPER::new(@_); | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 69 |  |  | 0 |  | 544 | $self->add_helper( ar => sub { _config 'ar' }, 'Config' ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | $self->add_helper( bison => undef, sub { | 
| 30 | 2 |  |  | 2 |  | 4 | my $helper = shift; | 
| 31 | 2 | 100 |  |  |  | 8 | if(which 'bison') | 
| 32 |  |  |  |  |  |  | { | 
| 33 | 1 |  |  |  |  | 14 | $helper->code(sub { 'bison' }); | 
|  | 1 |  |  |  |  | 6 |  | 
| 34 | 1 |  |  |  |  | 4 | return  (); | 
| 35 |  |  |  |  |  |  | } | 
| 36 |  |  |  |  |  |  | else | 
| 37 |  |  |  |  |  |  | { | 
| 38 | 1 |  |  |  |  | 12 | return 'Alien::bison' => '0.17'; | 
| 39 |  |  |  |  |  |  | } | 
| 40 | 69 |  |  |  |  | 476 | }); | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | $self->add_helper( bzip2 => undef, sub { | 
| 44 | 0 |  |  | 0 |  | 0 | my $helper = shift; | 
| 45 | 0 | 0 |  |  |  | 0 | if(which 'bzip2') | 
| 46 |  |  |  |  |  |  | { | 
| 47 | 0 |  |  |  |  | 0 | $helper->code( sub { 'bzip2' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 48 | 0 |  |  |  |  | 0 | return (); | 
| 49 |  |  |  |  |  |  | } | 
| 50 |  |  |  |  |  |  | else | 
| 51 |  |  |  |  |  |  | { | 
| 52 | 0 |  |  |  |  | 0 | return 'Alien::Libbz2' => '0.04'; | 
| 53 |  |  |  |  |  |  | } | 
| 54 | 69 |  |  |  |  | 468 | }); | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 69 |  |  | 0 |  | 394 | $self->add_helper( cc => sub { _config 'cc' }, 'Config' ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  |  | 
| 60 | 0 |  |  | 0 |  | 0 | $self->add_helper( cmake => sub { 'cmake' }, sub { | 
| 61 | 0 | 0 |  | 0 |  | 0 | if(which 'cmake') | 
| 62 |  |  |  |  |  |  | { | 
| 63 | 0 |  |  |  |  | 0 | return (); | 
| 64 |  |  |  |  |  |  | } | 
| 65 |  |  |  |  |  |  | else | 
| 66 |  |  |  |  |  |  | { | 
| 67 | 0 |  |  |  |  | 0 | return 'Alien::CMake' => '0.07'; | 
| 68 |  |  |  |  |  |  | } | 
| 69 | 69 |  |  |  |  | 496 | }); | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 69 |  |  | 0 |  | 364 | $self->add_helper( cp => sub { _config 'cp' }, 'Config' ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 69 | 0 |  | 0 |  | 458 | $self->add_helper( devnull => sub { $^O eq 'MSWin32' ? 'NUL' : '/dev/null' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | $self->add_helper( flex => undef, sub { | 
| 79 | 0 |  |  | 0 |  | 0 | my $helper = shift; | 
| 80 | 0 | 0 |  |  |  | 0 | if(which 'flex') | 
| 81 |  |  |  |  |  |  | { | 
| 82 | 0 |  |  |  |  | 0 | $helper->code(sub { 'flex' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 83 | 0 |  |  |  |  | 0 | return  (); | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  | else | 
| 86 |  |  |  |  |  |  | { | 
| 87 | 0 |  |  |  |  | 0 | return 'Alien::flex' => '0.08'; | 
| 88 |  |  |  |  |  |  | } | 
| 89 | 69 |  |  |  |  | 542 | }); | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 69 |  |  |  |  | 280 | $self->add_helper( gmake => undef, 'Alien::gmake' => '0.11' ); | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  |  | 
| 95 | 69 |  |  | 0 |  | 449 | $self->add_helper( install => sub { 'install' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  |  | 
| 98 | 69 |  |  | 0 |  | 387 | $self->add_helper( ld => sub { _config 'ld' }, 'Config' ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  |  | 
| 101 | 69 |  |  |  |  | 266 | $self->add_helper( m4 => undef, 'Alien::m4' => '0.08' ); | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  |  | 
| 104 | 69 | 50 |  |  |  | 298 | if($^O eq 'MSWin32') | 
| 105 |  |  |  |  |  |  | { | 
| 106 |  |  |  |  |  |  | # TL;DR: dmake is bad, and shouldn't be used to build anything but older | 
| 107 |  |  |  |  |  |  | # versions of Windows Perl that don't support gmake. | 
| 108 | 0 |  |  |  |  | 0 | my $perl_make = _config 'make'; | 
| 109 | 0 |  |  |  |  | 0 | my $my_make; | 
| 110 |  |  |  |  |  |  | $self->add_helper( make => sub { | 
| 111 | 0 | 0 |  | 0 |  | 0 | return $my_make if defined $my_make; | 
| 112 |  |  |  |  |  |  |  | 
| 113 | 0 | 0 | 0 |  |  | 0 | if( $perl_make ne 'dmake' && which $perl_make ) | 
| 114 |  |  |  |  |  |  | { | 
| 115 |  |  |  |  |  |  | # assume if it is called nmake or gmake that it really is what it | 
| 116 |  |  |  |  |  |  | # says it is. | 
| 117 | 0 | 0 | 0 |  |  | 0 | if( $perl_make eq 'nmake' || $perl_make eq 'gmake' ) | 
| 118 |  |  |  |  |  |  | { | 
| 119 | 0 |  |  |  |  | 0 | return $my_make = $perl_make; | 
| 120 |  |  |  |  |  |  | } | 
| 121 |  |  |  |  |  |  |  | 
| 122 | 0 |  |  |  |  | 0 | my $out = capture { system $perl_make, '--version' }; | 
|  | 0 |  |  |  |  | 0 |  | 
| 123 | 0 | 0 | 0 |  |  | 0 | if( $out =~ /GNU make/i || $out =~ /Microsoft \(R\) Program Maintenance/ ) | 
| 124 |  |  |  |  |  |  | { | 
| 125 | 0 |  |  |  |  | 0 | return $my_make = $perl_make; | 
| 126 |  |  |  |  |  |  | } | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | } | 
| 129 |  |  |  |  |  |  |  | 
| 130 |  |  |  |  |  |  | # if we see something that looks like it might be gmake, use that. | 
| 131 | 0 |  |  |  |  | 0 | foreach my $try (qw( gmake mingw32-make )) | 
| 132 |  |  |  |  |  |  | { | 
| 133 | 0 | 0 |  |  |  | 0 | return $my_make = $try if which $try; | 
| 134 |  |  |  |  |  |  | } | 
| 135 |  |  |  |  |  |  |  | 
| 136 | 0 | 0 |  |  |  | 0 | if( which 'make' ) | 
| 137 |  |  |  |  |  |  | { | 
| 138 | 0 |  |  |  |  | 0 | my $out = capture { system 'make', '--version' }; | 
|  | 0 |  |  |  |  | 0 |  | 
| 139 | 0 | 0 | 0 |  |  | 0 | if( $out =~ /GNU make/i || $out =~ /Microsoft \(R\) Program Maintenance/ ) | 
| 140 |  |  |  |  |  |  | { | 
| 141 | 0 |  |  |  |  | 0 | return $my_make = 'make'; | 
| 142 |  |  |  |  |  |  | } | 
| 143 |  |  |  |  |  |  | } | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | # if we see something that looks like it might be nmake, use that. | 
| 146 | 0 |  |  |  |  | 0 | foreach my $try (qw( nmake )) | 
| 147 |  |  |  |  |  |  | { | 
| 148 | 0 | 0 |  |  |  | 0 | return $my_make = $try if which $try; | 
| 149 |  |  |  |  |  |  | } | 
| 150 |  |  |  |  |  |  |  | 
| 151 | 0 |  |  |  |  | 0 | $my_make = $perl_make; | 
| 152 | 0 |  |  |  |  | 0 | }); | 
| 153 |  |  |  |  |  |  | } | 
| 154 |  |  |  |  |  |  | else | 
| 155 |  |  |  |  |  |  | { | 
| 156 | 69 |  |  | 0 |  | 547 | $self->add_helper( make => sub { _config 'make' }, 'Config' ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 157 |  |  |  |  |  |  | } | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  |  | 
| 160 | 69 | 50 |  | 1 |  | 441 | $self->add_helper( mkdir_deep => sub { $^O eq 'MSWin32' ? 'md' : 'mkdir -p'}, 'Alien::Build' => '1.04' ); | 
|  | 1 |  |  |  |  | 14 |  | 
| 161 | 69 | 50 |  | 4 |  | 386 | $self->add_helper( make_path  => sub { $^O eq 'MSWin32' ? 'md' : 'mkdir -p'}, 'Alien::Build' => '1.05' ); | 
|  | 4 |  |  |  |  | 48 |  | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | $self->add_helper( nasm => undef, sub { | 
| 165 | 0 |  |  | 0 |  | 0 | my $helper = shift; | 
| 166 | 0 | 0 |  |  |  | 0 | if(which 'nasm') | 
| 167 |  |  |  |  |  |  | { | 
| 168 | 0 |  |  |  |  | 0 | $helper->code(sub { 'nasm' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 169 | 0 |  |  |  |  | 0 | return  (); | 
| 170 |  |  |  |  |  |  | } | 
| 171 |  |  |  |  |  |  | else | 
| 172 |  |  |  |  |  |  | { | 
| 173 | 0 |  |  |  |  | 0 | return 'Alien::nasm' => '0.11'; | 
| 174 |  |  |  |  |  |  | } | 
| 175 | 69 |  |  |  |  | 448 | }); | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  |  | 
| 178 |  |  |  |  |  |  | $self->add_helper( patch => undef, sub { | 
| 179 | 0 |  |  | 0 |  | 0 | my $helper = shift; | 
| 180 | 0 | 0 |  |  |  | 0 | if(which 'patch') | 
| 181 |  |  |  |  |  |  | { | 
| 182 | 0 | 0 |  |  |  | 0 | if($^O eq 'MSWin32') | 
| 183 |  |  |  |  |  |  | { | 
| 184 | 0 |  |  |  |  | 0 | $helper->code(sub { 'patch --binary' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 185 |  |  |  |  |  |  | } | 
| 186 |  |  |  |  |  |  | else | 
| 187 |  |  |  |  |  |  | { | 
| 188 | 0 |  |  |  |  | 0 | $helper->code(sub { 'patch' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 189 |  |  |  |  |  |  | } | 
| 190 | 0 |  |  |  |  | 0 | return  (); | 
| 191 |  |  |  |  |  |  | } | 
| 192 |  |  |  |  |  |  | else | 
| 193 |  |  |  |  |  |  | { | 
| 194 | 0 |  |  |  |  | 0 | return 'Alien::patch' => '0.09'; | 
| 195 |  |  |  |  |  |  | } | 
| 196 | 69 |  |  |  |  | 527 | }); | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | $self->add_helper( perl => sub { | 
| 200 | 0 |  |  | 0 |  | 0 | my $perl = Devel::FindPerl::find_perl_interpreter(); | 
| 201 | 0 | 0 |  |  |  | 0 | $perl =~ s{\\}{/}g if $^O eq 'MSWin32'; | 
| 202 | 0 |  |  |  |  | 0 | $perl; | 
| 203 | 69 |  |  |  |  | 427 | }, 'Devel::FindPerl' ); | 
| 204 |  |  |  |  |  |  |  | 
| 205 |  |  |  |  |  |  |  | 
| 206 | 69 |  |  |  |  | 280 | $self->add_helper( pkgconf => undef, 'Alien::pkgconf' => 0.06 ); | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | $self->add_helper( cwd => sub { | 
| 210 | 1 |  |  | 1 |  | 10 | my $cwd = "$CWD"; | 
| 211 | 1 | 50 |  |  |  | 45 | $cwd =~ s{\\}{/}g if $^O eq 'MSWin32'; | 
| 212 | 1 |  |  |  |  | 6 | $cwd; | 
| 213 | 69 |  |  |  |  | 428 | } ); | 
| 214 |  |  |  |  |  |  |  | 
| 215 |  |  |  |  |  |  |  | 
| 216 | 69 |  |  | 0 |  | 470 | $self->add_helper( sh => sub { 'sh' }, 'Alien::MSYS' => '0.07' ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  |  | 
| 219 | 69 |  |  | 0 |  | 480 | $self->add_helper( rm => sub { _config 'rm' }, 'Config' ); | 
|  | 0 |  |  |  |  | 0 |  | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  |  | 
| 223 |  |  |  |  |  |  | $self->add_helper( xz => undef, sub { | 
| 224 | 0 |  |  | 0 |  | 0 | my $helper = shift; | 
| 225 | 0 | 0 |  |  |  | 0 | if(which 'xz') | 
| 226 |  |  |  |  |  |  | { | 
| 227 | 0 |  |  |  |  | 0 | $helper->code(sub { 'xz' }); | 
|  | 0 |  |  |  |  | 0 |  | 
| 228 | 0 |  |  |  |  | 0 | return  (); | 
| 229 |  |  |  |  |  |  | } | 
| 230 |  |  |  |  |  |  | else | 
| 231 |  |  |  |  |  |  | { | 
| 232 | 0 |  |  |  |  | 0 | return 'Alien::xz' => '0.02'; | 
| 233 |  |  |  |  |  |  | } | 
| 234 | 69 |  |  |  |  | 446 | }); | 
| 235 |  |  |  |  |  |  |  | 
| 236 | 69 |  |  |  |  | 264 | $self; | 
| 237 |  |  |  |  |  |  | } | 
| 238 |  |  |  |  |  |  |  | 
| 239 |  |  |  |  |  |  | 1; | 
| 240 |  |  |  |  |  |  |  | 
| 241 |  |  |  |  |  |  | __END__ |