1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
use strict;
use ExtUtils::MakeMaker;
use Config;
my ($cc, $exe) = @Config{'cc', '_exe'};
$cc =~ s/\s+-.+$//; #remove possible trailing options
my $found = 0;
my $delim = $^O eq 'MSWin32' ? ';' : ':';
if ($cc =~ m|/|) {
$found = -f "$cc$exe";
}
else {
for my $lib (split $delim, $ENV{PATH}) {
$found = -f "$lib/$cc$exe" and last;
}
}
print <<END;
Inline::C is packaged with Inline.pm because it is the most commonly used
Inline language module. See also: Inline::CPP (C++), ::Java, ::Python,
::Tcl, ::ASM, and ::CPR.
Config.pm indicates that your version of Perl was built with this C compiler:
$cc$exe
END
if ($found) {
print <<END;
I have located this compiler on your system:
END
}
else {
print <<END;
I cannot locate this compiler on your system.
You can install Inline.pm without installing Inline::C. But you'll
need to install another Inline language module (like Inline::Java for
instance) to actually make use of it.
If the aforementioned C compiler really is on your system, please make sure
it can be found in the PATH and then try running this program again. Or if
you think I made an error searching for this compiler, simply answer 'Y' to
the next question.
END
# '
}
my $answer = '';
my $default = $found ? "y" : "n";
while (1) {
$answer = prompt ('Do you want to install Inline::C?', $default);
last if $answer =~ /^(y|yes|n|no)$/i;
}
if ($answer =~ /^(y|yes)$/i) {
WriteMakefile(
NAME => 'Inline::C',
VERSION_FROM => 'C.pm',
clean => {FILES => '_Inline_test/'},
)
}
else {
open MF, "> Makefile" or die "Can't open Makefile for output";
print MF <<'END';
all::
test::
clean::
END
close MF;
}
|