3 # This script has been heavily modified from the Device::Cdio Build.PL
4 # Jonathan Leto <jonathan@leto.net>
5 # Copyright (C) 2006 Rocky Bernstein <rocky@cpan.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 eval { require ExtUtils
::PkgConfig
};
31 print "\nI see that you are a CPANTester, you really should install ExtUtils::PkgConfig !\n"
32 if $ENV{AUTOMATED_TESTING
};
34 ExtUtils::PkgConfig is currently needed to find GSL for the compilation of this module.
35 It may be bundled with Math::GSL in the future.
50 my $obj_ext = $Config{_o
} || ".o";
51 unlink("$tmp.c", "$tmp$obj_ext");
53 if (open(TMPC
, ">", "$tmp.c")) {
57 my $cccmd = $args{cccmd
};
59 my $ccflags = $Config{'ccflags'};
60 $ccflags .= " $args{ccflags}" if $args{ccflags
};
63 $errornull = "2>/dev/null" unless defined $errornull;
68 $cccmd = "$Config{'cc'} -o $tmp $ccflags $tmp.c $errornull"
69 unless defined $cccmd;
71 printf "cccmd = $cccmd\n" if $args{verbose
};
72 my $res = system($cccmd);
73 $ok = defined($res) && $res == 0;
80 *** The test compile of '$tmp.c' failed: status $?
81 *** (the status means: errno = $errno or '$!')
82 *** DO NOT PANIC: this just means that *some* you may get some innocuous
83 *** compiler warnings.
94 my $c_prog = "int main () { return 0; }\n";
95 print "Checking if $Config{cc} supports \"$ccflags\"...";
96 my $result = try_compile
($c_prog, ccflags
=>$ccflags);
106 print "Checking for GSL..";
107 my %gsl_pkgcfg = ExtUtils
::PkgConfig
->find ('gsl');
109 my $MIN_GSL_VERSION = "1.8";
110 my $gv = $gsl_pkgcfg{'modversion'};
111 my $current_minor_version;
114 if ($gv =~ m{\A(\d+(?:\.\d+)+)}) {
115 my @current= split /\./, $1;
116 my @min= split /\./, $MIN_GSL_VERSION;
117 $current_minor_version = $current[1];
118 unless ($current[0] >= $min[0] && $current[1] >= $min[1]) {
121 *** You need to have GSL %s or greater installed. (You have $gv).
122 *** Get GSL at http://www.gnu.org/software/gsl\n", $MIN_GSL_VERSION;
125 print "Found GSL version $gv\n";
131 *** Can't parse GSL version $gv.
132 *** Will continue and keep my fingers crossed for luck.
138 *** Can't find GSL configuration info. Is GSL installed?
139 *** Get GSL at http://www.gnu.org/software/gsl
145 my $ccflags = $gsl_pkgcfg{cflags
};
147 ## Swig produces a number of GCC warnings. Turn them off if we can.
148 $ccflags .= try_cflags
("-Wno-strict-aliasing");
149 $ccflags .= try_cflags
("-Wno-unused-function");
150 $ccflags .= try_cflags
("-Wno-unused-value");
151 $ccflags .= try_cflags
("-Wno-unused-function");
152 $ccflags .= try_cflags
("-Wno-unused-variable");
154 my $ldflags = "$gsl_pkgcfg{libs} -gsl";
155 my $swig_flags = "$gsl_pkgcfg{cflags}"; # -Wall is a bit much
157 if ( $^O
eq 'cygwin' && $Config{shrpenv
} =~ m{\Aenv LD_RUN_PATH=(.*)\Z} ) {
158 $ldflags .= " -L$1 -lperl";
159 # Should we check the 32-ness?
160 $swig_flags = '-DNEED_LONG';
161 } elsif ( $^O
eq 'darwin' ) {
162 $ldflags .= ' -bundle -flat_namespace ';
163 } elsif ($Config{archname
} =~ /x86_64/ ) {
164 $ldflags .= ' -fPIC ';
165 $ccflags .= ' -fPIC ';
167 my @Subsystems = sort qw
/
168 BLAS Diff Machine Statistics
169 Eigen Matrix Poly Wavelet2D
170 BSpline Errno PowInt Wavelet
174 Heapsort Multifit Randist Sum
175 Combination Histogram Multimin Roots
176 Complex Histogram2D Multiroots SF
177 Const Siman IEEEUtils Sys
178 Integration NTuple Sort
179 DHT Interp ODEIV Vector
180 Deriv Linalg Permutation Spline
183 # BSplines appeared in 1.9
184 if ($current_minor_version < 9 ) {
185 @Subsystems = grep { ! /BSpline/ } @Subsystems;
187 my $cleanup = qq{core
*.core Makefile Math
-GSL
-* tmp
* pod2ht
*.tmp _build blib
*.so
*.orig
};
189 my $builder = GSLBuilder
->new(
190 module_name
=> 'Math::GSL',
191 add_to_cleanup
=> [ $cleanup ],
192 create_makefile_pl
=> 'passthrough',
193 dist_abstract
=> 'Interface to the GNU Scientific Library using SWIG',
194 dist_author
=> 'Jonathan Leto <jonathan@leto.net>',
195 dist_version_from
=> 'lib/Math/GSL.pm',
197 extra_linker_flags
=> '-shared ' . $ldflags,
198 extra_compiler_flags
=> $ccflags,
199 swig_flags
=> $swig_flags,
202 'ExtUtils::PkgConfig' => '1.03',
205 'Test::Exception' => 0.21,
206 'Test::Class' => 0.12,
212 map { [ "$_.i" ] } @Subsystems
215 $builder->add_build_element('swig');
216 $builder->create_build_script();
217 print "Have a great day!\n";