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 ';
164 if ($Config{archname
} =~ /x86_64/ ) {
165 $ldflags .= ' -fPIC -fno-omit-frame-pointer ';
166 $ccflags .= ' -fPIC -fno-omit-frame-pointer ';
168 my @Subsystems = sort qw
/
169 BLAS Diff Machine Statistics
170 Eigen Matrix Poly Wavelet2D
171 BSpline Errno PowInt Wavelet
172 CBLAS FFT Min MatrixComplex
173 CDF Fit QRNG VectorComplex
175 Heapsort Multifit Randist Sum
176 Combination Histogram Multimin Roots
177 Complex Histogram2D Multiroots SF
178 Const Siman IEEEUtils Sys
179 Integration NTuple Sort
180 DHT Interp ODEIV Vector
181 Deriv Linalg Permutation Spline
184 # BSplines appeared in 1.9
185 if ($current_minor_version < 9 ) {
186 @Subsystems = grep { ! /BSpline/ } @Subsystems;
188 my $cleanup = qq{core
*.core swig
/*wrap.c swig/*.o Makefile Math
-GSL
-* tmp
* pod2ht
*.tmp _build lib
/Math/GSL
/[A-z]+/* blib
*.so
*.orig
};
190 my $builder = GSLBuilder
->new(
191 module_name
=> 'Math::GSL',
192 add_to_cleanup
=> [ $cleanup ],
193 create_makefile_pl
=> 'passthrough',
194 dist_abstract
=> 'Interface to the GNU Scientific Library using SWIG',
195 dist_author
=> 'Jonathan Leto <jonathan@leto.net>',
196 dist_version_from
=> 'lib/Math/GSL.pm',
198 extra_linker_flags
=> '-shared ' . $ldflags,
199 extra_compiler_flags
=> $ccflags,
200 swig_flags
=> $swig_flags,
203 'ExtUtils::PkgConfig' => '1.03',
206 'Test::Exception' => 0.21,
207 'Test::Class' => 0.12,
213 map { [ "swig/$_.i" ] } @Subsystems ,
216 $builder->add_build_element('swig');
217 $builder->create_build_script();
218 print "Have a great day!\n";