use strict; use 5.6.1; use ExtUtils::MakeMaker; use Config; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. my @ppd; if ($] >= 5.00503) { @ppd = ( ABSTRACT => 'Perl extension that gives read access to GRIB weather data files', AUTHOR => 'Frank Cox ', ); } ## check to see if they called for an alternate compiler on the command line my $ALT_CC = 0; foreach ( @ARGV ) { if ( m/cc=(\w*)/ ) { $ALT_CC = $1; last; } } # Used to check for a 'C' compiler # code stolen from 'threads' module, thank you J Hedden! sub check_cc { require File::Spec; my $cmd = $_[0]; if (-x $cmd or MM->maybe_command($cmd)) { return (1); # CC command found } for my $dir (File::Spec->path(), '.') { my $abs = File::Spec->catfile($dir, $cmd); if (-x $abs or MM->maybe_command($abs)) { return (1); # CC command found } } return; } sub have_cc { eval { require Config_m; }; # ExtUtils::FakeConfig (+ ActivePerl) if ($@) { eval { require Config; }; # Everyone else } my @chunks = split(/ /, $Config::Config{cc}); # $Config{cc} may contain args; try to find out the program part while (@chunks) { if (check_cc("@chunks")) { return (1); # CC command found } pop(@chunks); } return; } if ( not have_cc and not $ALT_CC ) { print STDERR < 'Geo::ReadGRIB', VERSION_FROM => 'lib/Geo/ReadGRIB.pm', # finds $VERSION PREREQ_PM => {}, # e.g., Module::Name => 1.1 LICENSE => 'perl', SKIP => [qw(static static_lib dynamic_lib)], clean => {FILES => "wgrib.exe"}, @ppd, ); sub MY::dynamic { if ( $Config{cc} eq 'cc' or $Config{cc} =~ m|/cc$| or $ALT_CC eq 'cc' ) { return ' dynamic :: $(INST_LIB)/Geo/wgrib.exe @$(NOOP) $(INST_LIB)/Geo/wgrib.exe: $(C_FILES) $(CC) -o $(INST_LIB)/Geo/wgrib.exe wgrib.c -lm '; } else { return ' dynamic :: $(INST_LIB)/Geo/wgrib.exe @$(NOOP) $(INST_LIB)/Geo/wgrib.exe: $(C_FILES) $(CC) -o $(INST_LIB)/Geo/wgrib.exe wgrib.c '; } } sub MY::libscan { my $path = $_[1]; return '' if $path =~ /\B\.svn\b/; return $path; }