1use strict; 2use warnings; 3use ExtUtils::MakeMaker; 4 5sub get_gsl_config { 6 my ($flags) = @_; 7 no warnings 'exec'; 8 `gsl-config $flags`; 9} 10 11# the real stuff happens in the subdirs 12# 13# DJB (12/30/03) 14# - would it not make sense to do all the checks here and just 15# write a dummy makefile if GSL support is not available 16# (as done with some of the other modules; or is it possible/desireable 17# to compile only some of the GSL modules here?) 18# 19sub get_gsl_libs { 20 warn << 'EOW' if ref $PDL::Config{GSL_LIBS}; 21 The GSL_LIBS config variable must be a string (!) 22 not a reference. You should probably leave it undefined 23 and rely on gsl-config. Build will likely fail. 24EOW 25 26 my $lib = ($PDL::Config{GSL_LIBS} or 27 get_gsl_config('--libs') or 28 warn "\tno GSL link info (libgsl probably not available)\n"); 29 my $inc = ($PDL::Config{GSL_INC} or 30 get_gsl_config('--cflags') or 31 warn "\tno GSL include info (libgsl probably not available)\n\n"); 32 chomp $lib; chomp $inc; 33 34 # print STDERR "Lib: $lib\nInc: $inc\n"; 35 36 return ($inc,$lib); 37} 38 39# these will be used in the subdirs 40our ($GSL_includes, $GSL_libs) = get_gsl_libs(); 41 42# Version check 43my $MINVERSION = "1.3"; 44my $version = get_gsl_config('--version'); 45chomp $version if defined $version; 46my $new_enough = 0; 47 48if (!defined($version) or $version =~ /^\s*$/) { 49 warn "\tno GSL version info found (gsl-config not installed?)\n\n"; 50 $version = 'UNKNOWN VERSION'; 51} else { 52 my @is_parts =split /\./,$version; 53 my @needed_parts=split /\./,$MINVERSION; 54 55 $needed_parts[-1]--; 56 for (my $i=0; $i<=$#needed_parts; $i++) { 57 my $is_part=(exists $is_parts[$i] ? $is_parts[$i] : 0); 58 $new_enough=($is_part > $needed_parts[$i]); 59 last if ($new_enough); 60 } 61} 62 63undef &MY::postamble; # suppress warning 64*MY::postamble = sub {}; 65if (! $new_enough) { 66 write_dummy_make("Not building GSL modules: GSL version $version found, but need at least $MINVERSION"); 67 $PDL::Config{WITH_GSL} = 0; 68} elsif ( defined($PDL::Config{WITH_GSL}) and ! $PDL::Config{WITH_GSL} ) { 69 write_dummy_make("Not building GSL modules: WITH_GSL=> 0"); 70} else { 71 $PDL::Config{WITH_GSL} = 1; 72 WriteMakefile( 73 'NAME' => 'PDL::GSL', 74 (eval ($ExtUtils::MakeMaker::VERSION) >= 6.57_02 ? ('NO_MYMETA' => 1) : ()), 75 ); 76} 77