blib/lib/ExtUtils/F77.pm

filter: Statementstmt 49.1% 167 / 340 Branchbran 18.5% 26 / 140 Conditioncond 5.6% 4 / 71 MC/DCmcdc 0.0% 0 / 41 Subroutinesub 62.5% 20 / 32 Podpod 37.5% 6 / 16 totaltotal 34.8% 223 / 640 CC 82 SCAR 42.9
CC
82
Cov
36%
__ANON__
210.0
gcclibs
132.0
validate_libs
110.0
CRAP 73.3
↑ Summary
1 package ExtUtils::F77;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Text::ParseWords;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Which qw(which);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = "1.24";
12 1 our $DEBUG;
13  
14 5 ▶sub debug { return if !$DEBUG; warn @_ }
Subroutine debug: called CC=2 SCAR=7.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless $ExtUtils::F77::DEBUG 0 5 5
15  
16 1 print "Loaded ExtUtils::F77 version $VERSION\n";
17  
18 1 my %F77config=();
19 1 my $Runtime = "-LSNAFU -lwontwork";
20 1 my $RuntimeOK = 0;
21 1 my $Trail_ = 1;
22 1 my $Pkg = "";
23 1 my $Compiler = "";
24 1 my $Cflags = "";
25 1 my ($gcc, $gfortran, $fallback_compiler);
26  
27 # all the compilers and their libraries
28 1 my %COMPLIBS = (
29 g77 => [qw/ g2c f2c /],
30 f77 => [qw/ g2c f2c /],
31 fort77 => [qw/ g2c f2c /],
32 gfortran => [qw/ gfortran /],
33 g95 => [qw/ f95 /],
34 );
35  
36 ########## Win32 Specific ##############
37  
38 1 ▶if ($^O =~ /MSWin/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /MSWin/i) { } 0 1 1
39 0 my @version;
40 0 ▶ if ($Config{cc} =~ /x86_64\-w64\-mingw32\-gcc/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ExtUtils::F77::Config{'cc'} =~ /x86_64\-w64\-mingw32\-gcc/) { } 0 0 0
elsif ($ExtUtils::F77::Config{'gccversion'}) { } 0 0 0
41 # This must be gcc-4.x.x
42 0 $gcc = 'x86_64-w64-mingw32-gcc';
43 0 $gfortran = 'x86_64-w64-mingw32-gfortran';
44 0 $fallback_compiler = 'GFortran';
45 }
46 elsif ($Config{gccversion}) {
47 # Different fortran compiler for gcc-4.x.x (and later) versus gcc-3.x.x
48 0 $gcc = 'gcc';
49 0 @version = split /\./, $Config{gccversion};
50 0 ▶ $fallback_compiler = $version[0] >= 4 ? 'GFortran' : 'G77';
Branch: 1 branch
BranchTrueFalseTotal
$version[0] >= 4 ? : 0 0 0
51 0 $gfortran = 'gfortran';
52 }
53 else {
54 0 $gcc = 'gcc';
55 0 $gfortran = 'gfortran';
56 0 $fallback_compiler = 'G77';
57 }
58 }
59 else {
60 # No change from version 1.16.
61 1 $gcc = 'gcc';
62 1 $gfortran = 'gfortran';
63 1 $fallback_compiler = 'G77';
64 }
65  
66 ############## End of Win32 Specific ##############
67  
68 # Database starts here. Basically we have a large hash specifying
69 # entries for each os/compiler combination. Entries can be code refs
70 # in which case they are executed and the returned value used. This
71 # allows us to be quite smart.
72  
73 # Hash key convention is uppercase first letter of
74 # hash keys. First key is usually the name of the architecture as
75 # returned by Config (modulo ucfirst()).
76  
77 # Format is: OS, then compiler-family, then specific keys:
78  
79 # DEFAULT: as a compiler-family, gives name of default compiler-family - corresponds to one of the keys
80  
81 # Link: Code to figure out and return link-string for this architecture
82 # Returns false if it can't find anything sensible.
83  
84 # Trail_: Whether symbols (subroutine names etc.) have trailing underscores
85 # (true/false)
86  
87 # Compiler: Program to run to actually compile stuff
88  
89 # Cflags: Associated compiler flags
90  
91 sub gfortran_make_linkline {
92 0 ▶ my ($dir, $lib, $defaultdir, $defaultlib, $append) = @_;
Subroutine gfortran_make_linkline: not called CC=4 SCAR=30.0
Pod undocumented
93 0 ▶ $dir ||= $defaultdir;
Condition0%0/3
$dir ||= $defaultdir
l!l&&r!l&&!r
000
MC/DC0%0/2
$dir ||= $defaultdir
$dir $defaultdir
Truth table0%0/3
A ||= B
A= $dirB= $defaultdir
ABresult
1X1
011
000
94 0 ▶ $lib ||= $defaultlib;
Condition0%0/3
$lib ||= $defaultlib
l!l&&r!l&&!r
000
MC/DC0%0/2
$lib ||= $defaultlib
$lib $defaultlib
Truth table0%0/3
A ||= B
A= $libB= $defaultlib
ABresult
1X1
011
000
95 0 ▶ $append ||= '';
Condition0%0/2
$append ||= ""
l!l
00
MC/DC0%0/1
$append ||= ""
$append
Truth table0%0/2
A
A= $append
Aresult
11
00
96 0 return( qq{"-L$dir" -L/usr/lib -l$lib $append -lm} );
97 }
98  
99 sub gfortran_find_libdir {
100 0 ▶ my ($compiler, $lib) = @_;
Subroutine gfortran_find_libdir: not called CC=4 SCAR=30.0
Pod undocumented
101 0 for my $suffix (qw(a so)) {
102 0 my $filename = "lib$lib.$suffix";
103 0 my $dir = `$compiler -print-file-name=$filename`;
104 0 chomp $dir;
105 # Note that -print-file-name returns just the library name
106 # if it cant be found - make sure that we only accept the
107 # directory if it returns a proper path (or matches a /)
108 0 ▶ next if !defined $dir or $dir eq $lib;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $dir or $dir eq $lib 0 0 0
Condition0%0/3
not defined $dir or $dir eq $lib
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $dir or $dir eq $lib
not defined $dir $dir eq $lib
Truth table0%0/3
not(A) or B
A= not defined $dirB= $dir eq $lib
ABresult
1X1
011
000
109 0 $dir =~ s,/$filename$,,;
110 0 return $dir;
111 }
112 }
113  
114 $F77config{MinGW}{G77}{Link} = sub {
115 0 ▶ my @libs = ('g2c', 'f2c');
Subroutine __ANON__: not called CC=3 SCAR=24.8
116 0 my ($dir, $lib, $test);
117 0 foreach $test (@libs) {
118 0 $dir = gfortran_find_libdir('g77', $test);
119 0 ▶ $lib = $test, last if defined $dir;
Branch: 1 branch
BranchTrueFalseTotal
if defined $dir 0 0 0
120 }
121 0 gfortran_make_linkline($dir, $lib, "/usr/local/lib", "f2c");
122 1 };
123 1 $F77config{MinGW}{G77}{Trail_} = 1;
124 1 $F77config{MinGW}{G77}{Compiler} = find_in_path('g77','f77','fort77');
125 1 $F77config{MinGW}{G77}{Cflags} = '-O';
126  
127 $F77config{MinGW}{GFortran}{Link} = sub {
128 0 ▶ my $dir = gfortran_find_libdir($gfortran, 'gfortran');
Subroutine __ANON__: not called CC=1 SCAR=6.9
129 0 gfortran_make_linkline($dir, "gfortran", "/usr/local/lib", "", '-lquadmath');
130 1 };
131 1 $F77config{MinGW}{GFortran}{Trail_} = 1;
132 1 $F77config{MinGW}{GFortran}{Compiler} = "$gfortran";
133 1 $F77config{MinGW}{GFortran}{Cflags} = '-O';
134  
135 ### SunOS (use this as a template for new entries) ###
136  
137 $F77config{Sunos}{F77}{Link} = sub {
138 0 ▶ my $dir = find_highest_SC("/usr/lang/SC*");
Subroutine __ANON__: not called CC=2 SCAR=17.9
139 0 ▶ return "" unless $dir; # Failure
Branch: 1 branch
BranchTrueFalseTotal
unless $dir 0 0 0
140 0 debug "$Pkg: Found Fortran latest version lib dir $dir\n";
141 0 return qq{"-L$dir" -lF77 -lm};
142 1 };
143 1 $F77config{Sunos}{F77}{Trail_} = 1;
144 1 $F77config{Sunos}{F77}{Compiler} = 'f77';
145 1 $F77config{Sunos}{F77}{Cflags} = '-O';
146  
147 1 $F77config{Sunos}{DEFAULT} = 'F77';
148  
149 ############ Rest of database is here ############
150  
151 ### Solaris ###
152  
153 $F77config{Solaris}{F77}{Link} = sub {
154 0 ▶ my $NSPATH;
Subroutine __ANON__: not called CC=14 SCAR=53.5
155 my $dir;
156  
157 #find the SUNWspro entry of nonstandard inst. in LD_LIBRARY_PATH
158 0 ▶ if ( defined $ENV{'LD_LIBRARY_PATH'} &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined $ENV{'LD_LIBRARY_PATH'} and $ENV{'LD_LIBRARY_PATH'} =~ m[([^:]*SUNWspro[^/]*)]) { } 0 0 0
elsif (defined $ENV{'PATH'}) { } 0 0 0
Condition0%0/3
defined $ENV{"LD_LIBRARY_PATH"} and $ENV{"LD_LIBRARY_PATH"} =~ m[([^:]*SUNWspro[^/]*)]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ENV{"LD_LIBRARY_PATH"} and $ENV{"LD_LIBRARY_PATH"} =~ m[([^:]*SUNWspro[^/]*)]
defined $ENV{"LD_LIBRARY_PATH"} $ENV{"LD_LIBRARY_PATH"} =~ m[([^:]*SUNWspro[^/]*)]
Truth table0%0/3
A and B
A= defined $ENV{"LD_LIBRARY_PATH"}B= $ENV{"LD_LIBRARY_PATH"} =~ m[([^:]*SUNWspro[^/]*)]
ABresult
0X0
100
111
159 $ENV{'LD_LIBRARY_PATH'} =~ m{([^:]*SUNWspro[^/]*)} )
160 {
161 0 $NSPATH = $1;
162 }
163  
164 elsif ( defined $ENV{'PATH'} ) {
165  
166 0 foreach ( split (/:/,$ENV{PATH}) ) {
167 0 ▶ if ( m{(.*SUNWspro[^/]*)} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (m[(.*SUNWspro[^/]*)]) 0 0 0
168 0 $NSPATH = $1;
169 0 last;
170 }
171 }
172 }
173  
174 0 ▶ if (defined $NSPATH) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $NSPATH) 0 0 0
175 0 debug "$Pkg: Found F77 path:--->$NSPATH\n";
176  
177 0 ▶ $dir = find_highest_SC("$NSPATH/WS*/lib") ||
Condition0%0/6
find_highest_SC("$NSPATH/WS*/lib") || find_highest_SC("$NSPATH/SC*/lib") || find_highest_SC("$NSPATH/sunwspro*/SUNWspro/SC*/lib")
l!l&&r!l&&!r
000
find_highest_SC("$NSPATH/WS*/lib") or find_highest_SC("$NSPATH/SC*/lib")
l!l&&r!l&&!r
000
MC/DC0%0/3
find_highest_SC("$NSPATH/WS*/lib") || find_highest_SC("$NSPATH/SC*/lib") || find_highest_SC("$NSPATH/sunwspro*/SUNWspro/SC*/lib")
find_highest_SC("$NSPATH/WS*/lib") find_highest_SC("$NSPATH/SC*/lib") find_highest_SC("$NSPATH/sunwspro*/SUNWspro/SC*/lib")
Truth table0%0/4
A or B || C
A= find_highest_SC("$NSPATH/WS*/lib")B= find_highest_SC("$NSPATH/SC*/lib")C= find_highest_SC("$NSPATH/sunwspro*/SUNWspro/SC*/lib")
ABCresult
1XX1
01X1
0011
0000
178 find_highest_SC("$NSPATH/SC*/lib") ||
179 find_highest_SC("$NSPATH/sunwspro*/SUNWspro/SC*/lib");
180  
181 # that failed. try $NSPATH/lib. use glob to
182 # match for libF77.*, as libF77.a isn't there anymore?
183 0 ▶ unless ( $dir )
Branch: 1 branch
BranchTrueFalseTotal
unless ($dir) 0 0 0
184 {
185 0 debug "$Pkg: Trying $NSPATH/lib\n";
186 0 ▶ $dir = "$NSPATH/lib" if glob("$NSPATH/lib/libF77*");
Branch: 1 branch
BranchTrueFalseTotal
if glob "$NSPATH/lib/libF77*" 0 0 0
187 }
188 }
189 0 ▶ return "" unless $dir; # Failure
Branch: 1 branch
BranchTrueFalseTotal
unless $dir 0 0 0
190 0 debug "$Pkg: Found Fortran latest version lib dir $dir\n";
191  
192 0 my @libs;
193  
194 # determine libraries. F77 and M77 aren't available in the latest
195 # compilers
196 0 my $vcruft = qx/$F77config{Solaris}{F77}{Compiler} -V 2>&1/;
197 0 ▶ if ( $vcruft =~ /Forte Developer 7/
Branch: 1 branch
BranchTrueFalseTotal
if ($vcruft =~ /Forte Developer 7/ or $vcruft =~ /f90:/) { } 0 0 0
Condition0%0/3
$vcruft =~ /Forte Developer 7/ or $vcruft =~ /f90:/
l!l&&r!l&&!r
000
MC/DC0%0/2
$vcruft =~ /Forte Developer 7/ or $vcruft =~ /f90:/
$vcruft =~ /Forte Developer 7/ $vcruft =~ /f90:/
Truth table0%0/3
A or B
A= $vcruft =~ /Forte Developer 7/B= $vcruft =~ /f90:/
ABresult
1X1
011
000
198 || $vcruft =~ /f90:/
199 )
200 {
201 0 push @libs, qw/
202 -lf77compat
203 -lfui
204 -lfai
205 -lfai2
206 -lfsumai
207 -lfprodai
208 -lfminlai
209 -lfmaxlai
210 -lfminvai
211 -lfmaxvai
212 -lfsu
213 -lsunmath
214 -lm
215 /;
216 }
217 else
218 {
219 0 push @libs, qw/
220 -lF77
221 -lM77
222 -lsunmath
223 -lm
224 /;
225 }
226  
227 0 join( ' ', qq{"-L$dir"}, @libs );
228 1 };
229 1 $F77config{Solaris}{F77}{Trail_} = 1;
230 1 $F77config{Solaris}{F77}{Compiler} = 'f77';
231 1 $F77config{Solaris}{F77}{Cflags} = '-O';
232  
233 1 $F77config{Solaris}{DEFAULT} = 'F77';
234  
235 ### Generic GNU-77 or F2C system ###
236  
237 1 $F77config{Generic}{GNU}{Trail_} = 1;
238 1 $F77config{Generic}{GNU}{Cflags} = ' '; # <---need this space!
239 1 $F77config{Generic}{GNU}{Link} = link_gnufortran_compiler('gfortran', 'g77', 'g95', 'fort77');
240 1 $F77config{Generic}{GNU}{Compiler} = find_in_path("$gfortran", 'g77', 'g95','fort77');
241  
242 1 $F77config{Generic}{DEFAULT} = 'GNU';
243  
244 ### cygwin ###
245  
246 1 $F77config{Cygwin}{GNU}{Trail_} = 1;
247 1 $F77config{Cygwin}{GNU}{Cflags} = '-O'; # <---need this space!
248 1 $F77config{Cygwin}{GNU}{Link} = link_gnufortran_compiler('g77', 'gfortran', 'g95', 'fort77');
249 1 $F77config{Cygwin}{GNU}{Compiler} = find_in_path('g77', "$gfortran", 'g95','fort77');
250  
251 1 $F77config{Cygwin}{DEFAULT} = 'GNU';
252  
253 ### Linux ###
254  
255 1 $F77config{Linux}{GNU} = $F77config{Generic}{GNU};
256  
257 1 $F77config{Linux}{DEFAULT} = 'GNU';
258  
259 ### DEC OSF/1 ###
260  
261 1 $F77config{Dec_osf}{F77}{Link} = "-L/usr/lib -lUfor -lfor -lFutil -lm -lots -lc";
262 1 $F77config{Dec_osf}{F77}{Trail_} = 1;
263 1 $F77config{Dec_osf}{F77}{Compiler} = 'f77';
264 1 $F77config{Dec_osf}{F77}{Cflags} = '-O';
265  
266 1 $F77config{Dec_osf}{DEFAULT} = 'F77';
267  
268 ### HP/UX ###
269  
270 1 $F77config{Hpux}{F77}{Link} = "-L/usr/lib -lcl -lm";
271 1 $F77config{Hpux}{F77}{Trail_} = 0;
272 1 $F77config{Hpux}{F77}{Compiler} = 'f77';
273 1 $F77config{Hpux}{F77}{Cflags} = '-O';
274  
275 1 $F77config{Hpux}{DEFAULT} = 'F77';
276  
277 ### IRIX ###
278  
279 # From: Ovidiu Toader <ovi@physics.utoronto.ca>
280 # For an SGI running IRIX 6.4 or higher (probably lower than 6.4 also)
281 # there is a new abi, -64, which produces 64 bit executables. This is no
282 # longer an experimental feature and I am using it exclusively without any
283 # problem. The code below is what I use instead of original IRIX section
284 # in the ExtUtils::F77 package. It adds the -64 flag and it is supposed to
285 # provide the same functionality as the old code for a non -64 abi.
286  
287 1 ▶if (ucfirst($Config{'osname'}) eq "Irix")
Branch: 1 branch
BranchTrueFalseTotal
if (ucfirst $ExtUtils::F77::Config{"osname"} eq "Irix") 0 1 1
288 {
289 0 my ($cflags,$mips,$default_abi,$abi,$mips_dir,$libs);
290 0 $cflags = $Config{cc};
291 0 ($mips) = ($cflags =~ /(-mips\d)/g);
292 0 ▶ $mips = "" if ! defined($mips);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mips 0 0 0
293 0 $mips_dir = $mips;$mips_dir =~ s/-//g;
294 0 ▶ $default_abi = $Config{osvers} >= 6.4 ? "-n32" : "-o32";
Branch: 1 branch
BranchTrueFalseTotal
$ExtUtils::F77::Config{'osvers'} >= 6.4 ? : 0 0 0
295 GET_ABI:
296 {
297 # -32 seems to be synonymous for -o32 (CS)
298 0 ▶ $abi = "-o32",last GET_ABI if $cflags =~ /-o?32/;
Branch: 1 branch
BranchTrueFalseTotal
if $cflags =~ /-o?32/ 0 0 0
299 0 ▶ $abi = "-n32",last GET_ABI if $cflags =~ /-n32/;
Branch: 1 branch
BranchTrueFalseTotal
if $cflags =~ /-n32/ 0 0 0
300 0 ▶ $abi = "-64",last GET_ABI if $cflags =~ /-64/;
Branch: 1 branch
BranchTrueFalseTotal
if $cflags =~ /-64/ 0 0 0
301 0 $abi = $default_abi;
302 }
303 0 ▶ if ( $abi eq "-64" ){
Branch: 1 branch
BranchTrueFalseTotal
if ($abi eq -64) 0 0 0
304 0 ▶ $libs = ( (-r "/usr/lib64/$mips_dir") && (-d _) && (-x _) ) ?
Branch: 1 branch
BranchTrueFalseTotal
-r "/usr/lib64/$mips_dir" && -d _ && -x _ ? : 0 0 0
Condition0%0/6
-r "/usr/lib64/$mips_dir" and -d _ and -x _
!ll&&!rl&&r
000
-r "/usr/lib64/$mips_dir" and -d _
!ll&&!rl&&r
000
MC/DC0%0/3
-r "/usr/lib64/$mips_dir" and -d _ and -x _
-r "/usr/lib64/$mips_dir" -d _ -x _
Truth table0%0/4
A and B and C
A= -r "/usr/lib64/$mips_dir"B= -d _C= -x _
ABCresult
0XX0
10X0
1100
1111
305 "-L/usr/lib64/$mips_dir" : "";
306 0 $libs .= " -L/usr/lib64 -lfortran -lm";
307 }
308 0 ▶ if ( $abi eq "-n32" ){
Branch: 1 branch
BranchTrueFalseTotal
if ($abi eq "-n32") 0 0 0
309 0 ▶ $libs = ( (-r "/usr/lib32/$mips_dir") && (-d _) && (-x _) ) ?
Branch: 1 branch
BranchTrueFalseTotal
-r "/usr/lib32/$mips_dir" && -d _ && -x _ ? : 0 0 0
Condition0%0/6
-r "/usr/lib32/$mips_dir" and -d _ and -x _
!ll&&!rl&&r
000
-r "/usr/lib32/$mips_dir" and -d _
!ll&&!rl&&r
000
MC/DC0%0/3
-r "/usr/lib32/$mips_dir" and -d _ and -x _
-r "/usr/lib32/$mips_dir" -d _ -x _
Truth table0%0/4
A and B and C
A= -r "/usr/lib32/$mips_dir"B= -d _C= -x _
ABCresult
0XX0
10X0
1100
1111
310 "-L/usr/lib32/$mips_dir" : "";
311 0 $libs .= " -L/usr/lib32 -lfortran -lm";
312 }
313 0 ▶ if ( $abi eq "-o32" ){
Branch: 1 branch
BranchTrueFalseTotal
if ($abi eq "-o32") 0 0 0
314 0 $libs = "-L/usr/lib -lF77 -lI77 -lU77 -lisam -lm";
315 }
316 0 $F77config{Irix}{F77}{Cflags} = "$abi $mips";
317 0 $F77config{Irix}{F77}{Link} = "$libs";
318 0 $F77config{Irix}{F77}{Trail_} = 1;
319 0 $F77config{Irix}{F77}{Compiler} = "f77 $abi";
320  
321 0 $F77config{Irix}{DEFAULT} = 'F77';
322 }
323  
324 ### AIX ###
325  
326 1 $F77config{Aix}{F77}{Link} = "-L/usr/lib -lxlf90 -lxlf -lc -lm";
327 1 $F77config{Aix}{F77}{Trail_} = 0;
328  
329 1 $F77config{Aix}{DEFAULT} = 'F77';
330  
331 ### FreeBSD ###
332  
333 1 ▶if($^O =~ /Freebsd/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O =~ /Freebsd/i) 0 1 1
334 0 $gfortran = 'gfortran48'; # requires rewrite
335 0 $fallback_compiler = 'G77';
336 }
337  
338 $F77config{Freebsd}{G77}{Link} = sub {
339 0 ▶ my $dir = gfortran_find_libdir('g77-34', 'g2c');
Subroutine __ANON__: not called CC=1 SCAR=6.9
340 0 gfortran_make_linkline($dir, 'g2c', "/usr/local/lib", '');
341 1 };
342 1 $F77config{Freebsd}{G77}{Trail_} = 1;
343 1 $F77config{Freebsd}{G77}{Compiler} = 'g77-34';
344 1 $F77config{Freebsd}{G77}{Cflags} = '-O2';
345  
346 $F77config{Freebsd}{GFortran}{Link} = sub {
347 0 ▶ my $dir = gfortran_find_libdir($gfortran, 'gfortran');
Subroutine __ANON__: not called CC=1 SCAR=6.9
348 0 gfortran_make_linkline($dir, "gfortran", "/usr/local/lib", "");
349 1 };
350 1 $F77config{Freebsd}{GFortran}{Trail_} = 1;
351 1 $F77config{Freebsd}{GFortran}{Compiler} = "$gfortran";
352 1 $F77config{Freebsd}{GFortran}{Cflags} = '-O2';
353  
354 1 $F77config{Freebsd}{DEFAULT} = 'GFortran';
355  
356 ### VMS ###
357  
358 1 $F77config{VMS}{Fortran}{Link} = ' '; # <---need this space!
359 1 $F77config{VMS}{Fortran}{Trail_} = 0;
360 1 $F77config{VMS}{Fortran}{Compiler} = 'Fortran';
361  
362 1 $F77config{VMS}{DEFAULT} = 'Fortran';
363  
364 ### Darwin (Mac OS X) ###
365  
366 1 $F77config{Darwin}{GNU} = $F77config{Generic}{GNU};
367 1 $F77config{Darwin}{DEFAULT} = 'GNU';
368  
369 ############ End of database is here ############
370  
371 sub get; # See below
372  
373 # All the figuring out occurs during import - this is because
374 # a lot of the answers depend on a lot of the guesswork.
375  
376 sub import {
377 1 ▶ no warnings; # Shuts up complaints on Win32 when running PDL tests
Subroutine BEGIN: called CC=1 SCAR=0.0
378 1 ▶ $Pkg = shift;
Subroutine import: called CC=24 SCAR=44.0
379 1 my $system = ucfirst(shift); # Set package variables
380 1 my $compiler = ucfirst(shift);
381 1 $Runtime = "-LSNAFU -lwontwork";
382  
383 # Guesses if system/compiler not specified.
384  
385 1 ▶ $system = ucfirst $Config{'osname'} unless $system;
Branch: 1 branch
BranchTrueFalseTotal
unless $system 1 0 1
386 1 ▶ $system = 'Cygwin' if $system =~ /Cygwin/;
Branch: 1 branch
BranchTrueFalseTotal
if $system =~ /Cygwin/ 0 1 1
387 1 ▶ $compiler = get $F77config{$system}{DEFAULT} unless $compiler;
Branch: 1 branch
BranchTrueFalseTotal
unless $compiler 1 0 1
388  
389 1 ▶ debug "$Pkg: Using system=$system compiler=" .
Branch: 1 branch
BranchTrueFalseTotal
defined $compiler ? : 1 0 1
390 (defined $compiler ? $compiler : "<undefined>") . "\n";
391  
392 1 ▶ if (defined($ENV{F77LIBS})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{'F77LIBS'}) { } 0 1 1
393 0 debug "Overriding Fortran libs from value of enviroment variable F77LIBS = $ENV{F77LIBS}\n";
394 0 $Runtime = $ENV{F77LIBS};
395 }
396 else {
397  
398 # Try this combination
399  
400 1 my $ok;
401 1 ▶ if ( defined( $compiler ) and defined( $F77config{$system} )){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $compiler and defined $F77config{$system}) { } 1 0 1
Condition33%1/3
defined $compiler and defined $F77config{$system}
!ll&&!rl&&r
001
MC/DC0%0/2
defined $compiler and defined $F77config{$system}
defined $compiler defined $F77config{$system}
Truth table33%1/3
A and B
A= defined $compilerB= defined $F77config{$system}
ABresult
0X0
100
111
402 1 my $flibs = get ($F77config{$system}{$compiler}{Link});
403 1 ▶ if ($flibs ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($flibs ne "") 0 1 1
404 0 $Runtime = $flibs;# . gcclibs();
405 # We don't want to append gcc libs if we are using
406 # non gnu compilers. Initially, explicitly check for
407 # use of sun compiler
408 #$Runtime .= gcclibs($flibs) unless $flibs =~ /sunmath/;
409 #(Note appending gcclibs seems to be no longer required)
410 0 ▶ $Runtime =~ s|L([a-z,A-Z]):|L//$1|g if $^O =~ /cygwin/i;
Branch: 1 branch
BranchTrueFalseTotal
if $^O =~ /cygwin/i 0 0 0
411 0 ▶ $Runtime = ' ' if $^O eq 'VMS'; # <-- need this space!
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "VMS" 0 0 0
412 0 debug "Runtime: $Runtime\n";
413 0 $ok = 1;
414 0 ▶ if ($compiler eq 'GNU') { # Special gfortran case since it seems to have lots of random libs
Branch: 1 branch
BranchTrueFalseTotal
if ($compiler eq 'GNU') { } 0 0 0
415 0 debug "Found compiler=$compiler - skipping validation of $Runtime \n";
416  
417 } else {
418 0 ▶ $ok = validate_libs($Runtime) if $flibs ne "" ;
Branch: 1 branch
BranchTrueFalseTotal
if $flibs ne "" 0 0 0
419 }
420 }
421 } else {
422 0 $Runtime = $ok = "";
423 }
424  
425 # If it doesn't work try Generic + GNU77
426  
427 1 ▶ unless (("$Runtime" ne "-LSNAFU -lwontwork") && $ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("$Runtime" ne "-LSNAFU -lwontwork" and $ok) 1 0 1
Condition33%1/3
"$Runtime" ne "-LSNAFU -lwontwork" and $ok
!ll&&!rl&&r
100
MC/DC0%0/2
"$Runtime" ne "-LSNAFU -lwontwork" and $ok
"$Runtime" ne "-LSNAFU -lwontwork" $ok
Truth table33%1/3
A and B
A= "$Runtime" ne "-LSNAFU -lwontwork"B= $ok
ABresult
0X0
100
111
428 $system =
429 1 ▶ $Config{cc} =~ /\bgcc/ && $^O =~ /MSWin32/i ? "MinGW"
Branch: 2 branches
BranchTrueFalseTotal
$ExtUtils::F77::Config{'cc'} =~ /\bgcc/ && $^O =~ /MSWin32/i ? : 0 1 1
$^O =~ /Freebsd/i ? : 0 1 1
Condition33%1/3
$ExtUtils::F77::Config{"cc"} =~ /\bgcc/ and $^O =~ /MSWin32/i
!ll&&!rl&&r
100
MC/DC0%0/2
$ExtUtils::F77::Config{"cc"} =~ /\bgcc/ and $^O =~ /MSWin32/i
$ExtUtils::F77::Config{"cc"} =~ /\bgcc/ $^O =~ /MSWin32/i
Truth table33%1/3
A and B
A= $ExtUtils::F77::Config{"cc"} =~ /\bgcc/B= $^O =~ /MSWin32/i
ABresult
0X0
100
111
430 : $^O =~ /Freebsd/i ? "Freebsd"
431 :"Generic";
432 1 $compiler = $fallback_compiler;
433 1 warn <<"EOD";
434 $Pkg: Unable to guess and/or validate system/compiler configuration
435 $Pkg: Will try system=$system Compiler=$compiler
436 EOD
437 1 my $flibs = get ($F77config{$system}{$compiler}{Link});
438 1 $Runtime = $flibs ; #. gcclibs($flibs); # Note gcclibs appears to be no longer required.
439 1 ▶ $ok = validate_libs($Runtime) if $flibs ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $flibs ne "" 0 1 1
440 1 ▶ warn "$Pkg: Well that didn't appear to validate. Well I will try it anyway.\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $Runtime and $ok 1 0 1
Condition33%1/3
$Runtime and $ok
!ll&&!rl&&r
100
MC/DC0%0/2
$Runtime and $ok
$Runtime $ok
Truth table33%1/3
A and B
A= $RuntimeB= $ok
ABresult
0X0
100
111
441 unless $Runtime && $ok;
442 }
443  
444 1 $RuntimeOK = $ok;
445  
446 } # Not overriding
447  
448 # Now get the misc info for the methods.
449  
450 1 ▶ if (defined( $F77config{$system}{$compiler}{Trail_} )){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $F77config{$system}{$compiler}{'Trail_'}) { } 0 1 1
451 0 $Trail_ = get $F77config{$system}{$compiler}{Trail_};
452 } else {
453 1 warn << "EOD";
454 $Pkg: There does not appear to be any configuration info about
455 $Pkg: names with trailing underscores for system $system. Will assume
456 $Pkg: F77 names have trailing underscores.
457 EOD
458 1 $Trail_ = 1;
459 }
460  
461 1 ▶ if (defined( $F77config{$system}{$compiler}{Compiler} )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $F77config{$system}{$compiler}{'Compiler'}) { } 0 1 1
462 0 $Compiler = get $F77config{$system}{$compiler}{Compiler};
463 } else {
464 1 warn << "EOD";
465 $Pkg: There does not appear to be any configuration info about
466 $Pkg: the F77 compiler name. Will assume 'f77'.
467 EOD
468 1 $Compiler = 'f77';
469 }
470 1 debug "$Pkg: Compiler: $Compiler\n";
471  
472 1 ▶ if (defined( $F77config{$system}{$compiler}{Cflags} )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $F77config{$system}{$compiler}{'Cflags'}) { } 0 1 1
473 0 $Cflags = get $F77config{$system}{$compiler}{Cflags} ;
474 } else {
475 1 warn << "EOD";
476 $Pkg: There does not appear to be any configuration info about
477 $Pkg: the options for the F77 compiler. Will assume none
478 $Pkg: necessary.
479 EOD
480 1 $Cflags = '';
481 }
482  
483 1 debug "$Pkg: Cflags: $Cflags\n";
484  
485 } # End of import ()
486  
487 1 ▶sub runtime { return $Runtime; }
Subroutine runtime: called CC=1 SCAR=0.0
Pod documented
488 1 ▶sub runtimeok { return $RuntimeOK; }
Subroutine runtimeok: called CC=1 SCAR=0.0
Pod documented
489 1 ▶sub trail_ { return $Trail_; }
Subroutine trail_: called CC=1 SCAR=0.0
Pod documented
490 2 ▶sub compiler { return $Compiler; }
Subroutine compiler: called CC=1 SCAR=0.0
Pod documented
491 1 ▶sub cflags { return $Cflags; }
Subroutine cflags: called CC=1 SCAR=0.0
Pod documented
492  
493 ### Minor internal utility routines ###
494  
495 # Get hash entry, evaluating code references
496  
497 3 ▶sub get { ref($_[0]) eq "CODE" ? &{$_[0]} : $_[0] };
Subroutine get: called CC=2 SCAR=9.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'CODE' ? : 0 3 3
498  
499 # Test if any files exist matching glob
500  
501 sub any_exists {
502 0 ▶ my @glob = glob(shift);
Subroutine any_exists: not called CC=1 SCAR=6.9
Pod undocumented
503 0 return scalar(@glob);
504 }
505  
506 # Find highest version number of SCN.N(.N) directories
507 # (Nasty SunOS/Solaris naming scheme for F77 libs]
508 sub find_highest_SC {
509 0 ▶ debug "$Pkg: Scanning for $_[0]\n";
Subroutine find_highest_SC: not called CC=4 SCAR=30.0
Pod undocumented
510 0 my @glob = glob(shift);
511 0 my %n=();
512 0 for (@glob) {
513 #debug "Found $_\n";
514 0 ▶ if ( m|/SC(\d)\.(\d)/?.*$| ) {
Branch: 1 branch
BranchTrueFalseTotal
if (m[/SC(\d)\.(\d)/?.*$]) 0 0 0
515 0 $n{$_} = $1 *100 + $2 * 10;
516 }
517 0 ▶ if ( m|/SC(\d)\.(\d)\.(\d)/?.*$| ) {
Branch: 1 branch
BranchTrueFalseTotal
if (m[/SC(\d)\.(\d)\.(\d)/?.*$]) 0 0 0
518 0 $n{$_} = $1 *100 + $2 * 10 + $3;
519 }
520 }
521 0 my @sorted_dirs = grep {-f "$_/libF77.a"} sort {$n{$a} <=> $n{$b}} @glob;
522  
523 0 return pop @sorted_dirs; # Highest N
524 }
525  
526 # Validate a string of form "-Ldir -lfoo -lbar"
527  
528 sub validate_libs {
529 0 ▶ debug "$Pkg: Validating $_[0] ";
Subroutine validate_libs: not called CC=10 SCAR=47.0
Pod undocumented
530 0 my @args = shellwords(shift());
531 0 my $pat;
532 0 my $ret = 1;
533  
534 # Create list of directories to search (with common defaults)
535  
536 0 my @path = ();
537 0 for (@args, "/usr/lib", "/lib") {
538 0 ▶ push @path, $1 if /^-L(.+)$/ && -d $1;
Branch: 1 branch
BranchTrueFalseTotal
if /^-L(.+)$/ and -d $1 0 0 0
Condition0%0/3
/^-L(.+)$/ and -d $1
!ll&&!rl&&r
000
MC/DC0%0/2
/^-L(.+)$/ and -d $1
/^-L(.+)$/ -d $1
Truth table0%0/3
A and B
A= /^-L(.+)$/B= -d $1
ABresult
0X0
100
111
539 }
540  
541 # Search directories
542  
543 0 for (@args) {
544 0 ▶ next if /^-L/;
Branch: 1 branch
BranchTrueFalseTotal
if /^-L/ 0 0 0
545 0 ▶ next if $_ eq "-lm"; # Ignore this common guy
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "-lm" 0 0 0
546 0 ▶ if (/^-l(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^-l(.+)$/) 0 0 0
547 0 $pat = join(" ", map {$_."/lib".$1.".*"} @path); # Join dirs + file
548 #debug "Checking for $pat\n";
549 0 ▶ unless (any_exists($pat)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (any_exists($pat)) 0 0 0
550 0 debug "\n$Pkg: Unable to find library $_" ;
551 0 $ret = 0;
552 }
553 }
554 }
555 0 ▶ debug $ret ? "[ok]\n" : "\n";
Branch: 1 branch
BranchTrueFalseTotal
$ret ? : 0 0 0
556 0 return $ret;
557 }
558  
559  
560 sub testcompiler {
561  
562 1 ▶ my $file = File::Spec->tmpdir . "/testf77$$";
Subroutine testcompiler: called CC=3 SCAR=11.1
Pod documented
563 1 $file =~ s/\\/\//g; # For Win32
564  
565 1 my $ret;
566 1 open(OUT,">$file.f");
567 1 print OUT " write(*,*) 'Hello World'\n";
568 1 print OUT " end\n";
569 1 close(OUT);
570 1 debug "Compiling the test Fortran program...\n";
571 1 system "$Compiler $Cflags $file.f -o ${file}_exe";
572 1 debug "Executing the test program...\n";
573 1 ▶ if (`${file}_exe` ne " Hello World\n") {
Branch: 1 branch
BranchTrueFalseTotal
if (`${file}_exe` ne " Hello World\n") { } 1 0 1
574 1 warn "Test of Fortran Compiler FAILED. \n";
575 1 warn "Do not know how to compile Fortran on your system\n";
576 1 $ret=0;
577 }
578 else{
579 0 debug "Congratulations you seem to have a working f77!\n";
580 0 $ret=1;
581 }
582 1 ▶ unlink("${file}_exe"); unlink("$file.f"); unlink("$file.o") if -e "$file.o";
Branch: 1 branch
BranchTrueFalseTotal
if -e "$file.o" 0 1 1
583 1 return $ret;
584 };
585  
586 # gcclibs() routine
587 # Return gcc link libs (e.g. -L/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3_U1/2.7.0 -lgcc)
588 # Note this routine appears to be no longer required - gcc3 or 4 change? - and is
589 # NO LONGER CALLED from anywhere in the code. Use of this routine in the future
590 # is DEPRECATED. Retain here just in case this logic is ever needed again,
591 # - Karl Glazebrook Dec/2010
592  
593 sub gcclibs {
594 0 ▶ my $flibs = shift; # Fortran libs
Subroutine gcclibs: not called CC=11 SCAR=48.8
Pod undocumented
595 0 my $isgcc = $Config{'cc'} eq "$gcc";
596 0 ▶ if (!$isgcc && $^O ne 'VMS') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $isgcc and $^O ne "VMS") 0 0 0
Condition0%0/3
not $isgcc and $^O ne "VMS"
!ll&&!rl&&r
000
MC/DC0%0/2
not $isgcc and $^O ne "VMS"
not $isgcc $^O ne "VMS"
Truth table0%0/3
not(A) and B
A= not $isgccB= $^O ne "VMS"
ABresult
0X0
100
111
597 0 debug "Checking for gcc in disguise:\n";
598 0 ▶ $isgcc = 1 if $Config{gccversion};
Branch: 1 branch
BranchTrueFalseTotal
if $ExtUtils::F77::Config{"gccversion"} 0 0 0
599 0 my $string;
600 0 ▶ if ($isgcc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isgcc) { } 0 0 0
601 0 $string = "Compiler is gcc version $Config{gccversion}";
602 0 ▶ $string .= "\n" unless $string =~ /\n$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ /\n$/ 0 0 0
603 } else {
604 0 $string = "Not gcc\n";
605 }
606 0 debug $string;
607 }
608 0 ▶ if ($isgcc or ($flibs =~ /-lg2c/) or ($flibs =~ /-lf2c/) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($isgcc or $flibs =~ /-lg2c/ or $flibs =~ /-lf2c/) { } 0 0 0
Condition0%0/6
$isgcc or $flibs =~ /-lg2c/ or $flibs =~ /-lf2c/
l!l&&r!l&&!r
000
$isgcc or $flibs =~ /-lg2c/
l!l&&r!l&&!r
000
MC/DC0%0/3
$isgcc or $flibs =~ /-lg2c/ or $flibs =~ /-lf2c/
$isgcc $flibs =~ /-lg2c/ $flibs =~ /-lf2c/
Truth table0%0/4
A or B or C
A= $isgccB= $flibs =~ /-lg2c/C= $flibs =~ /-lf2c/
ABCresult
1XX1
01X1
0011
0000
609 # Don't link to libgcc on MS Windows iff we're using gfortran.
610 0 ▶ unless ($fallback_compiler eq 'GFortran' && $^O =~ /MSWin/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fallback_compiler eq 'GFortran' and $^O =~ /MSWin/i) { } 0 0 0
Condition0%0/3
$fallback_compiler eq "GFortran" and $^O =~ /MSWin/i
!ll&&!rl&&r
000
MC/DC0%0/2
$fallback_compiler eq "GFortran" and $^O =~ /MSWin/i
$fallback_compiler eq "GFortran" $^O =~ /MSWin/i
Truth table0%0/3
A and B
A= $fallback_compiler eq "GFortran"B= $^O =~ /MSWin/i
ABresult
0X0
100
111
611 0 my $gccdir = `$gcc -m32 -print-libgcc-file-name`; chomp $gccdir;
612 0 $gccdir =~ s/\/libgcc.a//;
613 0 return qq{ "-L$gccdir" -lgcc};
614 } else {
615 0 return "";
616 }
617  
618 }else{
619 0 return "";
620 }
621 }
622  
623 # Try and find a program in the users PATH
624 sub find_in_path {
625 19 ▶ my $found = first { which $_ } @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine find_in_path: called CC=3 SCAR=13.3
Pod undocumented
626 5 ▶ return ($^O eq 'VMS' ? '' : undef) if !$found;
Branch: 2 branches
BranchTrueFalseTotal
unless $found 5 0 5
$^O eq 'VMS' ? : 0 5 5
627 0 debug "Found compiler $found\n";
628 0 return $found;
629 }
630  
631 # Based on code from Tim Jeness, tries to figure out the correct GNU
632 # fortran compiler libs
633 sub link_gnufortran_compiler {
634 2 ▶ return () if $^O =~ /MSWin32/i; # Unneeded for MinGW, emits warnings if allowed to proceed.
Subroutine link_gnufortran_compiler: called CC=9 SCAR=40.1
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $^O =~ /MSWin32/i 0 2 2
635 2 my @try = @_;
636 2 my $compiler = find_in_path( @try );
637 2 ▶ return () unless defined $compiler;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $compiler 2 0 2
638 # Get compiler version number
639 0 my @t =`$compiler --version`; $t[0] =~ /(\d+).(\d)+.(\d+)/;
640 0 my $version = "$1.$2"; # Major version number
641 0 debug "ExtUtils::F77: $compiler version $version.$3\n";
642 # Sigh special case random extra gfortran libs to avoid PERL_DL_NONLAZY meltdowns. KG 25/10/2015
643 0 my $append = "";
644 0 ▶ if ( $Config{osname} =~ /darwin/ && $Config{osvers} >= 14
Branch: 1 branch
BranchTrueFalseTotal
if ($ExtUtils::F77::Config{"osname"} =~ /darwin/ and $ExtUtils::F77::Config{"osvers"} >= 14 and $compiler eq "gfortran" and $version >= "4.9") 0 0 0
Condition0%0/9
$ExtUtils::F77::Config{"osname"} =~ /darwin/ and $ExtUtils::F77::Config{"osvers"} >= 14 and $compiler eq "gfortran" and $version >= "4.9"
!ll&&!rl&&r
000
$ExtUtils::F77::Config{"osname"} =~ /darwin/ and $ExtUtils::F77::Config{"osvers"} >= 14 and $compiler eq "gfortran"
!ll&&!rl&&r
000
$ExtUtils::F77::Config{"osname"} =~ /darwin/ and $ExtUtils::F77::Config{"osvers"} >= 14
!ll&&!rl&&r
000
MC/DC0%0/4
$ExtUtils::F77::Config{"osname"} =~ /darwin/ and $ExtUtils::F77::Config{"osvers"} >= 14 and $compiler eq "gfortran" and $version >= "4.9"
$ExtUtils::F77::Config{"osname"} =~ /darwin/ $ExtUtils::F77::Config{"osvers"} >= 14 $compiler eq "gfortran" $version >= "4.9"
Truth table0%0/5
A and B and C and D
A= $ExtUtils::F77::Config{"osname"} =~ /darwin/B= $ExtUtils::F77::Config{"osvers"} >= 14C= $compiler eq "gfortran"D= $version >= "4.9"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
645 && $compiler eq 'gfortran' && $version >= 4.9 ) {
646 # Add extra libs for gfortran versions >= 4.9 and OS X
647 0 $append = "-lgcc_ext.10.5 -lgcc_s.10.5 -lquadmath";
648 }
649 0 my @libs = @{$COMPLIBS{$compiler}};
650 0 my ($dir, $lib, $test);
651 0 foreach $test (@libs) {
652 0 $dir = gfortran_find_libdir($compiler, $test);
653 0 ▶ $lib = $test, last if defined $dir;
Branch: 1 branch
BranchTrueFalseTotal
if defined $dir 0 0 0
654 }
655 0 gfortran_make_linkline($dir, $lib, "/usr/local/lib", "f2c", $append);
656 }
657  
658 1 1; # Return true
659  
660 __END__
↑ Summary