1use strict; 2use warnings; 3use ExtUtils::MakeMaker; 4 5our ($GSL_includes, $GSL_libs); 6my $msg = undef; 7my $forcebuild=0; 8my $skip = 0; 9 10# this Makefile uses get_gsl_libs which is defined in 11# the parent Makefile.PL 12 13sub gsl_interp_links_ok { 14 my($lib,$inc) = @_; 15 return defined($lib) && defined($inc) && 16 trylink('gsl interp libraries', 17 << 'EOI', 18#include <math.h> 19#include <gsl/gsl_errno.h> 20#include <gsl/gsl_spline.h> 21EOI 22 << 'EOB', $lib, $inc); 23 24 int i; 25 double xi, yi, x[10], y[10]; 26 27 for (i = 0; i < 10; i++) 28 { 29 x[i] = i + 0.5 * sin (i); 30 y[i] = i + cos (i * i); 31 } 32 { 33 gsl_interp_accel *acc 34 = gsl_interp_accel_alloc (); 35 gsl_spline *spline 36 = gsl_spline_alloc (gsl_interp_cspline, 10); 37 38 gsl_spline_init (spline, x, y, 10); 39 40 yi = gsl_spline_eval (spline, x[0] + 0.01, acc); 41 42 gsl_spline_free (spline); 43 gsl_interp_accel_free(acc); 44 } 45 46EOB 47} 48 49if (defined $PDL::Config{WITH_GSL} && $PDL::Config{WITH_GSL}==0) { 50 $msg = "\n Will skip build of PDL::GSL::INTERP on this system \n"; 51 $skip = 1; 52} elsif (defined $PDL::Config{WITH_GSL} && $PDL::Config{WITH_GSL}==1) { 53 print "\n Will forcibly try and build PDL::GSL::INTERP on this system \n\n"; 54 $forcebuild=1; 55} 56 57if (($skip && !$forcebuild) || 58 !gsl_interp_links_ok($GSL_libs, $GSL_includes)) { 59 warn "trying to force GSL build but link test failed\n". 60 "\t -- aborting GSL build\n" if $forcebuild; 61 $msg ||= 62 "\n GSL Libraries not found... Skipping build of PDL::GSL::INTERP.\n"; 63 write_dummy_make( $msg ); 64 return; 65} else { 66 print "\n Building PDL::GSL::INTERP.", 67 "Turn off WITH_GSL if there are any problems\n\n"; 68} 69 70my @pack = (["gsl_interp.pd", qw(INTERP PDL::GSL::INTERP)]); 71my %hash = pdlpp_stdargs_int(@pack); 72 73$hash{INC} .= " $GSL_includes"; 74push @{$hash{LIBS}},$GSL_libs; 75 76undef &MY::postamble; # suppress warning 77*MY::postamble = sub { pdlpp_postamble_int(@pack); }; 78WriteMakefile(%hash); 79