I'm reviving a very old thread, to just conclude and have on record what
I ended up doing in case it is of use to anyone else.
Randy Kobes wrote:
On Sat, 30 Jul 2005, Robert May wrote:
[ snipped stuff about XS modules that require a compiler failing test on
smoke
test machines that don't have one ]
Thanks for the reply. We had an off list discussion where imacat
explained this to me and pointed me at an earlier discussion:
http://www.nntp.perl.org/group/perl.module-authors/3708
I support the sentiments in this thread, and do feel that lack of a
compiler (or indeed other pre-requisites) should be reported as
something other than an outright fail; but understand that this is not
the current position. As all the users are Win32, the vast majority
download the ready made PPM's that are distributed, and so I don't
feel strongly that this fail will adversely affect people's decision
to use the module or not.
In the interim, is there any existing code that I could put into my
Makefile.PL that would check for the existence of the executable
pointed to by $Config{'cc'}, so that I could bail-out early with a
suitable warning message, or am I on my own searching $PATH etc.? (I
haven't yet had a chance to look to see how complex Module::Builder's
have_c_compiler() function is, and whether I could just adapt that.)
You'd probably have to reproduce have_c_compiler(), if you wanted to go
that route. Note that just checking if $Config{cc} is defined isn't
enough, as imacat's Config{cc} reports 'cl.exe', but cl.exe isn't
available on the machine. Alternatively, to avoid the FAIL reports, it
may be enough if you just die()d at the 'perl Makefile.PL' stage if
$Config{cc} couldn't be found in the PATH; this though would involve
reproducing the code in File::Which in finding an executable within the
PATH.
I ended up stealing some code ideas from ExtUtils::FakeConfig and added
the following to my Makefile.PL
use File::Spec();
...
# If we got this far, then we have a compiler that
# we want to try to use. Check that we can find the compiler,
# and exit with a nice error message if we can't. This stops
# us from failing CPAN Smoke tests on boxes that don't have
# compilers.
{
my @path = File::Spec->path();
unshift @path, ''; # just in case $Config{cc} is an absolute path
my $found = 0;
foreach my $prog ( map { ( $_, "$_.exe" ) } ($Config{cc}) ) {
foreach my $path ( @path ) {
if( -f File::Spec->catfile( $path, $prog ) ) {
$found=1, last;
}
}
}
if(!$found) {
print STDERR <<__NOCOMPILER;
Makefile.PL was unable to find compiler '$Config{cc}' on your path.
Please check that you have a compiler available and that your
environment is set up correctly.
__NOCOMPILER
exit(1);
}
}
There are some shortcomings with this approach, but it should cope with
most windows environments. Have I missed anything obvious? Does any
set up .bat files as wrappers around their real C compiler, and should I
add a check for '.bat' extensions?
Regards,
Rob.
--
Robert May
Win32::GUI, a perl extension for native Win32 applications
http://perl-win32-gui.sourceforge.net/