2 # This has been heavily modified from the Device::Cdio Build.PL
3 # 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
28 use File
::Spec
::Functions qw
/:ALL/;
31 eval { require ExtUtils
::PkgConfig
};
33 print "\nI see that you are a CPANTester, you really should install ExtUtils::PkgConfig !\n"
34 if $ENV{AUTOMATED_TESTING
};
36 ExtUtils::PkgConfig is currently needed to find GSL for the compilation of this module.
37 It may be bundled with Math::GSL in the future.
52 my $obj_ext = $Config{_o
} || ".o";
53 unlink("$tmp.c", "$tmp$obj_ext");
55 if (open(TMPC
, ">", "$tmp.c")) {
59 my $cccmd = $args{cccmd
};
61 my $ccflags = $Config{'ccflags'};
62 $ccflags .= " $args{ccflags}" if $args{ccflags
};
65 $errornull = "2>/dev/null" unless defined $errornull;
70 $cccmd = "$Config{'cc'} -o $tmp $ccflags $tmp.c $errornull"
71 unless defined $cccmd;
73 printf "cccmd = $cccmd\n" if $args{verbose
};
74 my $res = system($cccmd);
75 $ok = defined($res) && $res == 0;
82 *** The test compile of '$tmp.c' failed: status $?
83 *** (the status means: errno = $errno or '$!')
84 *** DO NOT PANIC: this just means that *some* you may get some innocuous
85 *** compiler warnings.
96 my $c_prog = "int main () { return 0; }\n";
97 print "Checking if $Config{cc} supports \"$ccflags\"...";
98 my $result = try_compile
($c_prog, ccflags
=>$ccflags);
108 print "Checking for GSL..";
109 my %gsl_pkgcfg = ExtUtils
::PkgConfig
->find ('gsl');
111 my $MIN_GSL_VERSION = "1.8";
112 my $gv = $gsl_pkgcfg{'modversion'};
113 my $current_minor_version;
116 if ($gv =~ m{\A(\d+(?:\.\d+)+)}) {
117 my @current= split /\./, $1;
118 my @min= split /\./, $MIN_GSL_VERSION;
119 $current_minor_version = $current[1];
120 unless ($current[0] >= $min[0] && $current[1] >= $min[1]) {
123 *** You need to have GSL %s or greater installed. (You have $gv).
124 *** Get GSL at http://www.gnu.org/software/gsl\n", $MIN_GSL_VERSION;
127 print "Found GSL version $gv\n";
133 *** Can't parse GSL version $gv.
134 *** Will continue and keep my fingers crossed for luck.
140 *** Can't find GSL configuration info. Is GSL installed?
141 *** Get GSL at http://www.gnu.org/software/gsl
147 my $ccflags = $gsl_pkgcfg{cflags
};
149 ## Swig produces a number of GCC warnings. Turn them off if we can.
150 $ccflags .= try_cflags
("-Wno-strict-aliasing");
151 $ccflags .= try_cflags
("-Wno-unused-function");
152 $ccflags .= try_cflags
("-Wno-unused-value");
153 $ccflags .= try_cflags
("-Wno-unused-function");
154 $ccflags .= try_cflags
("-Wno-unused-variable");
156 my $ldflags = "$gsl_pkgcfg{libs} -gsl";
157 my $swig_flags = "$gsl_pkgcfg{cflags}"; # -Wall is a bit much
159 if ( $^O
eq 'cygwin' && $Config{shrpenv
} =~ m{\Aenv LD_RUN_PATH=(.*)\Z} ) {
160 $ldflags .= " -L$1 -lperl";
161 # Should we check the 32-ness?
162 $swig_flags = '-DNEED_LONG';
163 } elsif ( $^O
eq 'darwin' ) {
164 $ldflags .= ' -bundle -flat_namespace ';
166 if ($Config{archname
} =~ /x86_64/ ) {
167 $ldflags .= ' -fPIC -fno-omit-frame-pointer ';
168 $ccflags .= ' -fPIC -fno-omit-frame-pointer ';
171 my @Subsystems = grep { ! /^Test$/ } Math
::GSL
::subsystems
;
173 # BSplines appeared in 1.9
174 if ($current_minor_version < 9 ) {
175 @Subsystems = grep { ! /BSpline/ } @Subsystems;
178 xs
/*_wrap.c core *.core swig/*wrap
.c
179 swig
/*.o Makefile Math
-GSL
-* tmp
* pod2ht
*.tmp _build
180 lib
/Math/GSL
/[A-z]+/* blib
*.so
*.orig
181 } . join " ", map { catfile
( (qw( lib Math GSL ), "$_.pm") ) } @Subsystems;
183 my $builder = GSLBuilder
->new(
184 module_name
=> 'Math::GSL',
185 add_to_cleanup
=> [ $cleanup ],
186 create_makefile_pl
=> 'passthrough',
187 dist_abstract
=> 'Interface to the GNU Scientific Library using SWIG',
188 dist_author
=> 'Jonathan Leto <jonathan@leto.net>',
189 dist_version_from
=> 'lib/Math/GSL.pm',
191 extra_linker_flags
=> '-shared ' . $ldflags,
192 extra_compiler_flags
=> $ccflags,
193 swig_flags
=> $swig_flags,
196 'ExtUtils::PkgConfig' => '1.03',
199 'Test::Exception' => 0.21,
200 'Test::Class' => 0.12,
206 map { [ "swig/$_.i", "pod/$_.pod" ] } @Subsystems ,
209 $builder->add_build_element('swig');
210 $builder->create_build_script();
211 print "Have a great day!\n";