blib/lib/ExtUtils/F77.pm

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