----- Forwarded message from Alberto Manuel Brand?o Sim?es
<[EMAIL PROTECTED]> -----
From: Alberto Manuel Brand?o Sim?es <[EMAIL PROTECTED]>
Date: 22 Jul 2002 10:28:51 +0100
To: [EMAIL PROTECTED]
Subject: ExtUtils::MakeMaker
X-Mailer: Evolution/1.0.2
Hi.
I'm not sure if sending this mail to the right person.
I'm asking for (at least) two function on MakeMaker API to be used
before the WriteMakefile method:
check_command( "ls", "flex", "cat");
check_module( "XML::DT", v0.19 );
One to check for a command (or program), like 'yacc', 'flex' or
others...
##
sub check_command { # (command1, command2, ... command n)
my $command;
my @answer = ();
my @PATH = split/:/,$ENV{PATH};
while ($command = shift) {
print "Checking for command: $command... ";
my $found = undef;
for my $path (@PATH) {
if ( -x "$path/$command" ) {
push @answer, "$path/$command";
$found = "yes ($path/$command)\n";
}
}
if (defined($found)) {
print $found;
} else {
print "not found\n";
exit
}
}
return @answer;
}
And check for a module (and version). Sometimes it is usefull to check before the
MakeMaker writemakefile be called
##
sub check_module { # (module name, version)
my $module = shift;
my $version = shift || "?";
if ($version eq "?") {
print "Checking for $module existence... ";
my $command = " use $module; ";
my $answer = eval($command);
if ($@) {
print "not found\n";
exit
} else {
print "yes\n";
}
} else {
print "Checking for $module >= ",sprintf("%vd",$version),"... ";
my $command = " use $module; return \$${module}::VERSION;";
my $answer = eval ( $command );
if ($@) {
print "not found\n";
exit
} else {
if (defined($answer)) {
#this line converts a number to a 'v number'
#TODO: this should not be done if it is already a 'v number'
my $t = "v$answer"; $answer = eval($t);
if ($answer ge $version) {
print sprintf("yes (%vd)\n", $answer);
} else {
print sprintf("no (%vd)\n", $answer);
exit
}
} else {
print "?? (this module does not define \$VERSION variable)\n";
}
}
}
}
Regards, Alberto
--
Alberto Manuel B. Simoes
Departamento de Inform?tica - Universidade do Minho
http://alfarrabio.di.uminho.pt/~albie - http://numexp.sf.net
----- End forwarded message -----
--
Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/
Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One
Don't be a lover, girl, I'd like to shamelessly hump your inner child.