line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package ExtUtils::F77; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
490
|
use Config; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1217
|
|
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
|
|
|
|
|
|
|
$VERSION = "1.19_2"; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
print "Loaded ExtUtils::F77 version $VERSION\n"; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
%F77config=(); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
########## Win32 Specific ############## |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
if ($^O =~ /MSWin/i) { |
61
|
|
|
|
|
|
|
my @version; |
62
|
|
|
|
|
|
|
if ($Config{cc} =~ /x86_64\-w64\-mingw32\-gcc/) { |
63
|
|
|
|
|
|
|
# This must be gcc-4.x.x |
64
|
|
|
|
|
|
|
$gcc = 'x86_64-w64-mingw32-gcc'; |
65
|
|
|
|
|
|
|
$gfortran = 'x86_64-w64-mingw32-gfortran'; |
66
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
$gcc = 'gcc'; |
71
|
|
|
|
|
|
|
@version = split /\./, $Config{gccversion}; |
72
|
|
|
|
|
|
|
$fallback_compiler = $version[0] >= 4 ? 'GFortran' : 'G77'; |
73
|
|
|
|
|
|
|
$gfortran = 'gfortran'; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else { |
76
|
|
|
|
|
|
|
$gcc = 'gcc'; |
77
|
|
|
|
|
|
|
$gfortran = 'gfortran'; |
78
|
|
|
|
|
|
|
$fallback_compiler = 'G77'; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else { |
82
|
|
|
|
|
|
|
# No change from version 1.16. |
83
|
|
|
|
|
|
|
$gcc = 'gcc'; |
84
|
|
|
|
|
|
|
$gfortran = 'gfortran'; |
85
|
|
|
|
|
|
|
$fallback_compiler = 'G77'; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
############## End of Win32 Specific ############## |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
$F77config{MinGW}{G77}{Link} = sub { |
91
|
|
|
|
|
|
|
my @libs = ('g2c', 'f2c'); |
92
|
|
|
|
|
|
|
my ($dir, $lib, $test); |
93
|
|
|
|
|
|
|
foreach $test (@libs) { |
94
|
|
|
|
|
|
|
$dir = `g77 -print-file-name=lib$test.a`; |
95
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if (defined $dir && $dir ne "lib$test.a") { |
100
|
|
|
|
|
|
|
$lib = $test; # Found an existing library |
101
|
|
|
|
|
|
|
last; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
if ( defined $dir && defined $lib) { |
106
|
|
|
|
|
|
|
$dir =~ s,/lib$lib.a$,,; |
107
|
|
|
|
|
|
|
} else { |
108
|
|
|
|
|
|
|
$dir = "/usr/local/lib"; |
109
|
|
|
|
|
|
|
$lib = "f2c"; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
return( "-L$dir -L/usr/lib -l$lib -lm" ); |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$F77config{MinGW}{GFortran}{Link} = sub { |
115
|
|
|
|
|
|
|
$dir = `$gfortran -print-file-name=libgfortran.a`; |
116
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if ( defined $dir ) { |
122
|
|
|
|
|
|
|
$dir =~ s,/libgfortran.a$,,; |
123
|
|
|
|
|
|
|
} else { |
124
|
|
|
|
|
|
|
$dir = "/usr/local/lib"; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
return( "-L$dir -L/usr/lib -lgfortran -lquadmath -lm" ); |
127
|
|
|
|
|
|
|
}; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
$F77config{MinGW}{G77}{Trail_} = 1; |
130
|
|
|
|
|
|
|
$F77config{MinGW}{GFortran}{Trail_} = 1; |
131
|
|
|
|
|
|
|
$F77config{MinGW}{G77}{Compiler} = find_in_path('g77','f77','fort77'); |
132
|
|
|
|
|
|
|
$F77config{MinGW}{GFortran}{Compiler} = "$gfortran"; |
133
|
|
|
|
|
|
|
$F77config{MinGW}{G77}{Cflags} = '-O'; |
134
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
$dir = find_highest_SC("/usr/lang/SC*"); |
143
|
|
|
|
|
|
|
return "" unless $dir; # Failure |
144
|
|
|
|
|
|
|
print "$Pkg: Found Fortran latest version lib dir $dir\n"; |
145
|
|
|
|
|
|
|
return "-L$dir -lF77 -lm"; |
146
|
|
|
|
|
|
|
}; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# Whether symbols (subroutine names etc.) have trailing underscores |
149
|
|
|
|
|
|
|
# (true/false) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
$F77config{Sunos}{F77}{Trail_} = 1; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# Name of default compiler - corresponds to one of the above keys |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
$F77config{Sunos}{DEFAULT} = 'F77'; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Program to run to actually compile stuff |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
$F77config{Sunos}{F77}{Compiler} = 'f77'; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Associated compiler flags |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$F77config{Sunos}{F77}{Cflags} = '-O'; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
############ Rest of database is here ############ |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
### Solaris ### |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$F77config{Solaris}{F77}{Link} = sub { |
170
|
|
|
|
|
|
|
my $NSPATH; |
171
|
|
|
|
|
|
|
my $dir; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
#find the SUNWspro entry of nonstandard inst. in LD_LIBRARY_PATH |
174
|
|
|
|
|
|
|
if ( defined $ENV{'LD_LIBRARY_PATH'} && |
175
|
|
|
|
|
|
|
$ENV{'LD_LIBRARY_PATH'} =~ m{([^:]*SUNWspro[^/]*)} ) |
176
|
|
|
|
|
|
|
{ |
177
|
|
|
|
|
|
|
$NSPATH = $1; |
178
|
|
|
|
|
|
|
} |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
elsif ( defined $ENV{'PATH'} ) { |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
foreach ( split (/:/,$ENV{PATH}) ) { |
183
|
|
|
|
|
|
|
if ( m{(.*SUNWspro[^/]*)} ) { |
184
|
|
|
|
|
|
|
$NSPATH = $1; |
185
|
|
|
|
|
|
|
last; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
if (defined $NSPATH) { |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
print "$Pkg: Found F77 path:--->$NSPATH\n"; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
$dir = find_highest_SC("$NSPATH/WS*/lib") || |
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
|
|
|
|
|
|
|
unless ( $dir ) |
202
|
|
|
|
|
|
|
{ |
203
|
|
|
|
|
|
|
print "$Pkg: Trying $NSPATH/lib\n"; |
204
|
|
|
|
|
|
|
$dir = "$NSPATH/lib" if glob("$NSPATH/lib/libF77*"); |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
} else { |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
return "" unless $dir; # Failure |
210
|
|
|
|
|
|
|
print "$Pkg: Found Fortran latest version lib dir $dir\n"; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
my @libs; |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
# determine libraries. F77 and M77 aren't available in the latest |
215
|
|
|
|
|
|
|
# compilers |
216
|
|
|
|
|
|
|
my $vcruft = qx/$F77config{Solaris}{F77}{Compiler} -V 2>&1/; |
217
|
|
|
|
|
|
|
if ( $vcruft =~ /Forte Developer 7/ |
218
|
|
|
|
|
|
|
|| $vcruft =~ /f90:/ |
219
|
|
|
|
|
|
|
) |
220
|
|
|
|
|
|
|
{ |
221
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
push @libs, qw/ |
240
|
|
|
|
|
|
|
-lF77 |
241
|
|
|
|
|
|
|
-lM77 |
242
|
|
|
|
|
|
|
-lsunmath |
243
|
|
|
|
|
|
|
-lm |
244
|
|
|
|
|
|
|
/; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
join( ' ', "-L$dir", @libs ); |
248
|
|
|
|
|
|
|
}; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
$F77config{Solaris}{F77}{Trail_} = 1; |
252
|
|
|
|
|
|
|
$F77config{Solaris}{F77}{Compiler} = 'f77'; |
253
|
|
|
|
|
|
|
$F77config{Solaris}{F77}{Cflags} = '-O'; |
254
|
|
|
|
|
|
|
$F77config{Solaris}{DEFAULT} = 'F77'; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
### Generic GNU-77 or F2C system ### |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$F77config{Generic}{GNU}{Trail_} = 1; |
259
|
|
|
|
|
|
|
$F77config{Generic}{GNU}{Cflags} = ' '; # <---need this space! |
260
|
|
|
|
|
|
|
$F77config{Generic}{GNU}{Link} = link_gnufortran_compiler('g77', 'gfortran', 'g95', 'fort77'); |
261
|
|
|
|
|
|
|
$F77config{Generic}{GNU}{Compiler} = find_in_path('g77', "$gfortran", 'g95','fort77'); |
262
|
|
|
|
|
|
|
$F77config{Generic}{DEFAULT} = 'GNU'; |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
### cygwin ### |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
$F77config{Cygwin}{GNU}{Trail_} = 1; |
267
|
|
|
|
|
|
|
$F77config{Cygwin}{GNU}{Cflags} = '-O'; # <---need this space! |
268
|
|
|
|
|
|
|
$F77config{Cygwin}{GNU}{Link} = link_gnufortran_compiler('g77', 'gfortran', 'g95', 'fort77'); |
269
|
|
|
|
|
|
|
$F77config{Cygwin}{GNU}{Compiler} = find_in_path('g77', "$gfortran", 'g95','fort77'); |
270
|
|
|
|
|
|
|
$F77config{Cygwin}{DEFAULT} = 'GNU'; |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
### Linux ### |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
$F77config{Linux}{GNU} = $F77config{Generic}{GNU}; |
275
|
|
|
|
|
|
|
$F77config{Linux}{DEFAULT} = 'GNU'; |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
### DEC OSF/1 ### |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
$F77config{Dec_osf}{F77}{Link} = "-L/usr/lib -lUfor -lfor -lFutil -lm -lots -lc"; |
280
|
|
|
|
|
|
|
$F77config{Dec_osf}{F77}{Trail_} = 1; |
281
|
|
|
|
|
|
|
$F77config{Dec_osf}{F77}{Compiler} = 'f77'; |
282
|
|
|
|
|
|
|
$F77config{Dec_osf}{F77}{Cflags} = '-O'; |
283
|
|
|
|
|
|
|
$F77config{Dec_osf}{DEFAULT} = 'F77'; |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
### HP/UX ### |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
$F77config{Hpux}{F77}{Link} = "-L/usr/lib -lcl -lm"; |
288
|
|
|
|
|
|
|
$F77config{Hpux}{F77}{Trail_} = 0; |
289
|
|
|
|
|
|
|
$F77config{Hpux}{F77}{Compiler} = 'f77'; |
290
|
|
|
|
|
|
|
$F77config{Hpux}{F77}{Cflags} = '-O'; |
291
|
|
|
|
|
|
|
$F77config{Hpux}{DEFAULT} = 'F77'; |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
### IRIX ### |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# From: Ovidiu Toader |
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
|
|
|
|
|
|
|
if (ucfirst($Config{'osname'}) eq "Irix") |
304
|
|
|
|
|
|
|
{ |
305
|
|
|
|
|
|
|
my ($cflags,$mips,$default_abi,$abi,$mips_dir,$libs); |
306
|
|
|
|
|
|
|
$cflags = $Config{cc}; |
307
|
|
|
|
|
|
|
($mips) = ($cflags =~ /(-mips\d)/g); |
308
|
|
|
|
|
|
|
$mips = "" if ! defined($mips); |
309
|
|
|
|
|
|
|
$mips_dir = $mips;$mips_dir =~ s/-//g; |
310
|
|
|
|
|
|
|
$default_abi = $Config{osvers} >= 6.4 ? "-n32" : "-o32"; |
311
|
|
|
|
|
|
|
GET_ABI: |
312
|
|
|
|
|
|
|
{ |
313
|
|
|
|
|
|
|
# -32 seems to be synonymous for -o32 (CS) |
314
|
|
|
|
|
|
|
$abi = "-o32",last GET_ABI if $cflags =~ /-o?32/; |
315
|
|
|
|
|
|
|
$abi = "-n32",last GET_ABI if $cflags =~ /-n32/; |
316
|
|
|
|
|
|
|
$abi = "-64",last GET_ABI if $cflags =~ /-64/; |
317
|
|
|
|
|
|
|
$abi = $default_abi; |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
if ( $abi eq "-64" ){ |
320
|
|
|
|
|
|
|
$libs = ( (-r "/usr/lib64/$mips_dir") && (-d _) && (-x _) ) ? |
321
|
|
|
|
|
|
|
"-L/usr/lib64/$mips_dir" : ""; |
322
|
|
|
|
|
|
|
$libs .= " -L/usr/lib64 -lfortran -lm"; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
if ( $abi eq "-n32" ){ |
325
|
|
|
|
|
|
|
$libs = ( (-r "/usr/lib32/$mips_dir") && (-d _) && (-x _) ) ? |
326
|
|
|
|
|
|
|
"-L/usr/lib32/$mips_dir" : ""; |
327
|
|
|
|
|
|
|
$libs .= " -L/usr/lib32 -lfortran -lm"; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
if ( $abi eq "-o32" ){ |
330
|
|
|
|
|
|
|
$libs = "-L/usr/lib -lF77 -lI77 -lU77 -lisam -lm"; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
$F77config{Irix}{F77}{Cflags} = "$abi $mips"; |
333
|
|
|
|
|
|
|
$F77config{Irix}{F77}{Link} = "$libs"; |
334
|
|
|
|
|
|
|
$F77config{Irix}{F77}{Trail_} = 1; |
335
|
|
|
|
|
|
|
$F77config{Irix}{F77}{Compiler} = "f77 $abi"; |
336
|
|
|
|
|
|
|
$F77config{Irix}{DEFAULT} = 'F77'; |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
### AIX ### |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
$F77config{Aix}{F77}{Link} = "-L/usr/lib -lxlf90 -lxlf -lc -lm"; |
342
|
|
|
|
|
|
|
$F77config{Aix}{F77}{Trail_} = 0; |
343
|
|
|
|
|
|
|
$F77config{Aix}{DEFAULT} = 'F77'; |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
### FreeBSD ### |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
$F77config{Freebsd}{F77}{Trail_} = 1; |
348
|
|
|
|
|
|
|
$F77config{Freebsd}{F77}{Link} = '-L/usr/lib -lf2c -lm'; |
349
|
|
|
|
|
|
|
$F77config{Freebsd}{DEFAULT} = 'F77'; |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
### VMS ### |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
$F77config{VMS}{Fortran}{Trail_} = 0; |
354
|
|
|
|
|
|
|
$F77config{VMS}{Fortran}{Link} = ' '; # <---need this space! |
355
|
|
|
|
|
|
|
$F77config{VMS}{DEFAULT} = 'Fortran'; |
356
|
|
|
|
|
|
|
$F77config{VMS}{Fortran}{Compiler} = 'Fortran'; |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
### Darwin (Mac OS X) ### |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
$F77config{Darwin}{GNU} = $F77config{Generic}{GNU}; |
361
|
|
|
|
|
|
|
$F77config{Darwin}{DEFAULT} = 'GNU'; |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
############ End of database is here ############ |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=head1 SYNOPSIS |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
use ExtUtils::F77; # Automatic guess |
369
|
|
|
|
|
|
|
use ExtUtils::F77 qw(sunos); # Specify system |
370
|
|
|
|
|
|
|
use ExtUtils::F77 qw(linux g77); # Specify system and compiler |
371
|
|
|
|
|
|
|
$fortranlibs = ExtUtils::F77->runtime; |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=cut |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
# Package variables |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
$Runtime = "-LSNAFU -lwontwork"; |
379
|
|
|
|
|
|
|
$RuntimeOK = 0; |
380
|
|
|
|
|
|
|
$Trail_ = 1; |
381
|
|
|
|
|
|
|
$Pkg = ""; |
382
|
|
|
|
|
|
|
$Compiler = ""; |
383
|
|
|
|
|
|
|
$Cflags = ""; |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
sub get; # See below |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
# All the figuring out occurs during import - this is because |
388
|
|
|
|
|
|
|
# a lot of the answers depend on a lot of the guesswork. |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
sub import { |
391
|
1
|
|
|
1
|
|
4
|
no warnings; # Shuts up complaints on Win32 when running PDL tests |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1838
|
|
392
|
1
|
|
|
1
|
|
6
|
$Pkg = shift; |
393
|
1
|
|
|
|
|
2
|
my $system = ucfirst(shift); # Set package variables |
394
|
1
|
|
|
|
|
0
|
my $compiler = ucfirst(shift); |
395
|
1
|
|
|
|
|
2
|
$Runtime = "-LSNAFU -lwontwork"; |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
# Guesses if system/compiler not specified. |
398
|
|
|
|
|
|
|
|
399
|
1
|
50
|
|
|
|
8
|
$system = ucfirst $Config{'osname'} unless $system; |
400
|
1
|
50
|
|
|
|
6
|
$system = 'Cygwin' if $system =~ /Cygwin/; |
401
|
1
|
50
|
|
|
|
5
|
$compiler = get $F77config{$system}{DEFAULT} unless $compiler; |
402
|
|
|
|
|
|
|
|
403
|
1
|
50
|
|
|
|
30
|
print "$Pkg: Using system=$system compiler=" . |
404
|
|
|
|
|
|
|
(defined $compiler ? $compiler : "") . "\n"; |
405
|
|
|
|
|
|
|
|
406
|
1
|
50
|
|
|
|
5
|
if (defined($ENV{F77LIBS})) { |
407
|
0
|
|
|
|
|
0
|
print "Overriding Fortran libs from value of enviroment variable F77LIBS = $ENV{F77LIBS}\n"; |
408
|
0
|
|
|
|
|
0
|
$Runtime = $ENV{F77LIBS}; |
409
|
|
|
|
|
|
|
} |
410
|
|
|
|
|
|
|
else { |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
# Try this combination |
413
|
|
|
|
|
|
|
|
414
|
1
|
50
|
33
|
|
|
17
|
if ( defined( $compiler ) and defined( $F77config{$system} )){ |
415
|
1
|
|
|
|
|
3
|
my $flibs = get ($F77config{$system}{$compiler}{Link}); |
416
|
1
|
50
|
|
|
|
3
|
if ($flibs ne "") { |
417
|
0
|
|
|
|
|
0
|
$Runtime = $flibs;# . gcclibs(); |
418
|
|
|
|
|
|
|
# We don't want to append gcc libs if we are using |
419
|
|
|
|
|
|
|
# non gnu compilers. Initially, explicitly check for |
420
|
|
|
|
|
|
|
# use of sun compiler |
421
|
|
|
|
|
|
|
#$Runtime .= gcclibs($flibs) unless $flibs =~ /sunmath/; |
422
|
|
|
|
|
|
|
#(Note appending gcclibs seems to be no longer required) |
423
|
0
|
0
|
|
|
|
0
|
$Runtime =~ s|L([a-z,A-Z]):|L//$1|g if $^O =~ /cygwin/i; |
424
|
0
|
0
|
|
|
|
0
|
$Runtime = ' ' if $^O eq 'VMS'; # <-- need this space! |
425
|
0
|
|
|
|
|
0
|
print "Runtime: $Runtime\n"; |
426
|
0
|
|
|
|
|
0
|
$ok = 1; |
427
|
0
|
0
|
|
|
|
0
|
if ($compiler eq 'GNU') { # Special gfortran case since it seems to have lots of random libs |
428
|
0
|
|
|
|
|
0
|
print "Found compiler=$compiler - skipping validation of $Runtime \n"; |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
}else { |
431
|
0
|
0
|
|
|
|
0
|
$ok = validate_libs($Runtime) if $flibs ne "" ; |
432
|
|
|
|
|
|
|
} |
433
|
|
|
|
|
|
|
} |
434
|
|
|
|
|
|
|
}else { |
435
|
0
|
|
|
|
|
0
|
$Runtime = $ok = ""; |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
# If it doesn't work try Generic + GNU77 |
439
|
|
|
|
|
|
|
|
440
|
1
|
50
|
33
|
|
|
3
|
unless (("$Runtime" ne "-LSNAFU -lwontwork") && $ok) { |
441
|
1
|
|
|
|
|
6
|
print <<"EOD"; |
442
|
|
|
|
|
|
|
$Pkg: Unable to guess and/or validate system/compiler configuration |
443
|
|
|
|
|
|
|
$Pkg: Will try system=Generic Compiler=$fallback_compiler |
444
|
|
|
|
|
|
|
EOD |
445
|
|
|
|
|
|
|
$system = |
446
|
1
|
50
|
33
|
|
|
9
|
$Config{cc} =~ /\bgcc/ && $^O =~ /MSWin32/i ? "MinGW" |
447
|
|
|
|
|
|
|
:"Generic"; |
448
|
1
|
|
|
|
|
2
|
$compiler = $fallback_compiler; |
449
|
1
|
|
|
|
|
3
|
my $flibs = get ($F77config{$system}{$compiler}{Link}); |
450
|
1
|
|
|
|
|
2
|
$Runtime = $flibs ; #. gcclibs($flibs); # Note gcclibs appears to be no longer required. |
451
|
1
|
50
|
|
|
|
2
|
$ok = validate_libs($Runtime) if $flibs ne ""; |
452
|
1
|
50
|
33
|
|
|
6
|
print "$Pkg: Well that didn't appear to validate. Well I will try it anyway.\n" |
453
|
|
|
|
|
|
|
unless $Runtime && $ok; |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
|
456
|
1
|
|
|
|
|
1
|
$RuntimeOK = $ok; |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
} # Not overriding |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
# Now get the misc info for the methods. |
461
|
|
|
|
|
|
|
|
462
|
1
|
50
|
|
|
|
2
|
if (defined( $F77config{$system}{$compiler}{Trail_} )){ |
463
|
0
|
|
|
|
|
0
|
$Trail_ = get $F77config{$system}{$compiler}{Trail_}; |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
else{ |
466
|
1
|
|
|
|
|
4
|
print << "EOD"; |
467
|
|
|
|
|
|
|
$Pkg: There does not appear to be any configuration info about |
468
|
|
|
|
|
|
|
$Pkg: names with trailing underscores for system $system. Will assume |
469
|
|
|
|
|
|
|
$Pkg: F77 names have trailing underscores. |
470
|
|
|
|
|
|
|
EOD |
471
|
1
|
|
|
|
|
1
|
$Trail_ = 1; |
472
|
|
|
|
|
|
|
} |
473
|
|
|
|
|
|
|
|
474
|
1
|
50
|
|
|
|
3
|
if (defined( $F77config{$system}{$compiler}{Compiler} )) { |
475
|
0
|
|
|
|
|
0
|
$Compiler = get $F77config{$system}{$compiler}{Compiler}; |
476
|
|
|
|
|
|
|
} else { |
477
|
1
|
|
|
|
|
2
|
print << "EOD"; |
478
|
|
|
|
|
|
|
$Pkg: There does not appear to be any configuration info about |
479
|
|
|
|
|
|
|
$Pkg: the F77 compiler name. Will assume 'f77'. |
480
|
|
|
|
|
|
|
EOD |
481
|
1
|
|
|
|
|
2
|
$Compiler = 'f77'; |
482
|
|
|
|
|
|
|
} |
483
|
1
|
|
|
|
|
2
|
print "$Pkg: Compiler: $Compiler\n"; |
484
|
|
|
|
|
|
|
|
485
|
1
|
50
|
|
|
|
2
|
if (defined( $F77config{$system}{$compiler}{Cflags} )) { |
486
|
0
|
|
|
|
|
0
|
$Cflags = get $F77config{$system}{$compiler}{Cflags} ; |
487
|
|
|
|
|
|
|
} else { |
488
|
1
|
|
|
|
|
3
|
print << "EOD"; |
489
|
|
|
|
|
|
|
$Pkg: There does not appear to be any configuration info about |
490
|
|
|
|
|
|
|
$Pkg: the options for the F77 compiler. Will assume none |
491
|
|
|
|
|
|
|
$Pkg: necessary. |
492
|
|
|
|
|
|
|
EOD |
493
|
1
|
|
|
|
|
1
|
$Cflags = ''; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
|
496
|
1
|
|
|
|
|
1033
|
print "$Pkg: Cflags: $Cflags\n"; |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
} # End of import () |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=head1 METHODS |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
The following methods are provided: |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=over 4 |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
=item * B |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
Returns a list of F77 runtime libraries. |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
$fortranlibs = ExtUtils::F77->runtime; |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=item * B |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
Returns TRUE only if runtime libraries have been found successfully. |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=item * B |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
Returns true if F77 names have trailing underscores. |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=item * B |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Returns command to execute the compiler (e.g. 'f77'). |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=item * B |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
Returns compiler flags. |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
=item * B |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
Test to see if compiler actually works. |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=back |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
More methods will probably be added in the future. |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=cut |
537
|
|
|
|
|
|
|
|
538
|
0
|
|
|
0
|
1
|
0
|
sub runtime { return $Runtime; } |
539
|
0
|
|
|
0
|
1
|
0
|
sub runtimeok { return $RuntimeOK; } |
540
|
0
|
|
|
0
|
1
|
0
|
sub trail_ { return $Trail_; } |
541
|
0
|
|
|
0
|
1
|
0
|
sub compiler { return $Compiler; } |
542
|
0
|
|
|
0
|
1
|
0
|
sub cflags { return $Cflags; } |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
### Minor internal utility routines ### |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
# Get hash entry, evaluating code references |
547
|
|
|
|
|
|
|
|
548
|
3
|
50
|
|
3
|
0
|
8
|
sub get { ref($_[0]) eq "CODE" ? &{$_[0]} : $_[0] }; |
|
0
|
|
|
|
|
0
|
|
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
# Test if any files exist matching glob |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
sub any_exists { |
553
|
0
|
|
|
0
|
0
|
0
|
my @glob = glob(shift); |
554
|
0
|
|
|
|
|
0
|
return scalar(@glob); |
555
|
|
|
|
|
|
|
} |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
# Find highest version number of SCN.N(.N) directories |
558
|
|
|
|
|
|
|
# (Nasty SunOS/Solaris naming scheme for F77 libs] |
559
|
|
|
|
|
|
|
sub find_highest_SC { |
560
|
0
|
|
|
0
|
0
|
0
|
print "$Pkg: Scanning for $_[0]\n"; |
561
|
0
|
|
|
|
|
0
|
my @glob = glob(shift); |
562
|
0
|
|
|
|
|
0
|
my %n=(); |
563
|
0
|
|
|
|
|
0
|
for (@glob) { |
564
|
|
|
|
|
|
|
#print "Found $_\n"; |
565
|
0
|
0
|
|
|
|
0
|
if ( m|/SC(\d)\.(\d)/?.*$| ) { |
566
|
0
|
|
|
|
|
0
|
$n{$_} = $1 *100 + $2 * 10; |
567
|
|
|
|
|
|
|
} |
568
|
0
|
0
|
|
|
|
0
|
if ( m|/SC(\d)\.(\d)\.(\d)/?.*$| ) { |
569
|
0
|
|
|
|
|
0
|
$n{$_} = $1 *100 + $2 * 10 + $3; |
570
|
|
|
|
|
|
|
} |
571
|
|
|
|
|
|
|
} |
572
|
0
|
|
|
|
|
0
|
my @sorted_dirs = grep {-f "$_/libF77.a"} sort {$n{$a} <=> $n{$b}} @glob; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
573
|
|
|
|
|
|
|
|
574
|
0
|
|
|
|
|
0
|
return pop @sorted_dirs; # Highest N |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
# Validate a string of form "-Ldir -lfoo -lbar" |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
sub validate_libs { |
580
|
0
|
|
|
0
|
0
|
0
|
print "$Pkg: Validating $_[0] "; |
581
|
0
|
|
|
|
|
0
|
my @args = split(' ',shift()); |
582
|
0
|
|
|
|
|
0
|
my $pat; |
583
|
0
|
|
|
|
|
0
|
my $ret = 1; |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
# Create list of directories to search (with common defaults) |
586
|
|
|
|
|
|
|
|
587
|
0
|
|
|
|
|
0
|
my @path = (); |
588
|
0
|
|
|
|
|
0
|
for (@args, "/usr/lib", "/lib") { |
589
|
0
|
0
|
0
|
|
|
0
|
push @path, $1 if /^-L(.+)$/ && -d $1; |
590
|
|
|
|
|
|
|
} |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
# Search directories |
593
|
|
|
|
|
|
|
|
594
|
0
|
|
|
|
|
0
|
for (@args) { |
595
|
0
|
0
|
|
|
|
0
|
next if /^-L/; |
596
|
0
|
0
|
|
|
|
0
|
next if $_ eq "-lm"; # Ignore this common guy |
597
|
0
|
0
|
|
|
|
0
|
if (/^-l(.+)$/) { |
598
|
0
|
|
|
|
|
0
|
$pat = join(" ", map {$_."/lib".$1.".*"} @path); # Join dirs + file |
|
0
|
|
|
|
|
0
|
|
599
|
|
|
|
|
|
|
#print "Checking for $pat\n"; |
600
|
0
|
0
|
|
|
|
0
|
unless (any_exists($pat)) { |
601
|
0
|
|
|
|
|
0
|
print "\n$Pkg: Unable to find library $_" ; |
602
|
0
|
|
|
|
|
0
|
$ret = 0; |
603
|
|
|
|
|
|
|
} |
604
|
|
|
|
|
|
|
} |
605
|
|
|
|
|
|
|
} |
606
|
0
|
0
|
|
|
|
0
|
print $ret ? "[ok]\n" : "\n"; |
607
|
0
|
|
|
|
|
0
|
return $ret; |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
sub testcompiler { |
612
|
|
|
|
|
|
|
|
613
|
0
|
|
|
0
|
1
|
0
|
my $file = File::Spec->tmpdir . "/testf77$$"; |
614
|
0
|
|
|
|
|
0
|
$file =~ s/\\/\//g; # For Win32 |
615
|
|
|
|
|
|
|
|
616
|
0
|
|
|
|
|
0
|
my $ret; |
617
|
0
|
|
|
|
|
0
|
open(OUT,">$file.f"); |
618
|
0
|
|
|
|
|
0
|
print OUT " print *, 'Hello World'\n"; |
619
|
0
|
|
|
|
|
0
|
print OUT " end\n"; |
620
|
0
|
|
|
|
|
0
|
close(OUT); |
621
|
0
|
|
|
|
|
0
|
print "Compiling the test Fortran program...\n"; |
622
|
0
|
|
|
|
|
0
|
system "$Compiler $Cflags $file.f -o ${file}_exe"; |
623
|
0
|
|
|
|
|
0
|
print "Executing the test program...\n"; |
624
|
0
|
0
|
|
|
|
0
|
if (`${file}_exe` ne " Hello World\n") { |
625
|
0
|
|
|
|
|
0
|
print "Test of Fortran Compiler FAILED. \n"; |
626
|
0
|
|
|
|
|
0
|
print "Do not know how to compile Fortran on your system\n"; |
627
|
0
|
|
|
|
|
0
|
$ret=0; |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
else{ |
630
|
0
|
|
|
|
|
0
|
print "Congratulations you seem to have a working f77!\n"; |
631
|
0
|
|
|
|
|
0
|
$ret=1; |
632
|
|
|
|
|
|
|
} |
633
|
0
|
0
|
|
|
|
0
|
unlink("${file}_exe"); unlink("$file.f"); unlink("$file.o") if -e "$file.o"; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
634
|
0
|
|
|
|
|
0
|
return $ret; |
635
|
|
|
|
|
|
|
}; |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
# gcclibs() routine |
638
|
|
|
|
|
|
|
# Return gcc link libs (e.g. -L/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3_U1/2.7.0 -lgcc) |
639
|
|
|
|
|
|
|
# Note this routine appears to be no longer required - gcc3 or 4 change? - and is |
640
|
|
|
|
|
|
|
# NO LONGER CALLED from anywhere in the code. Use of this routine in the future |
641
|
|
|
|
|
|
|
# is DEPRECATED. Retain here just in case this logic is ever needed again, |
642
|
|
|
|
|
|
|
# - Karl Glazebrook Dec/2010 |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
sub gcclibs { |
645
|
0
|
|
|
0
|
0
|
0
|
my $flibs = shift; # Fortran libs |
646
|
0
|
|
|
|
|
0
|
my $isgcc = $Config{'cc'} eq "$gcc"; |
647
|
0
|
0
|
0
|
|
|
0
|
if (!$isgcc && $^O ne 'VMS') { |
648
|
0
|
|
|
|
|
0
|
print "Checking for gcc in disguise:\n"; |
649
|
0
|
0
|
|
|
|
0
|
$isgcc = 1 if $Config{gccversion}; |
650
|
0
|
|
|
|
|
0
|
my $string; |
651
|
0
|
0
|
|
|
|
0
|
if ($isgcc) { |
652
|
0
|
|
|
|
|
0
|
$string = "Compiler is gcc version $Config{gccversion}"; |
653
|
0
|
0
|
|
|
|
0
|
$string .= "\n" unless $string =~ /\n$/; |
654
|
|
|
|
|
|
|
} else { |
655
|
0
|
|
|
|
|
0
|
$string = "Not gcc\n"; |
656
|
|
|
|
|
|
|
} |
657
|
0
|
|
|
|
|
0
|
print $string; |
658
|
|
|
|
|
|
|
} |
659
|
0
|
0
|
0
|
|
|
0
|
if ($isgcc or ($flibs =~ /-lg2c/) or ($flibs =~ /-lf2c/) ) { |
|
|
|
0
|
|
|
|
|
660
|
|
|
|
|
|
|
# Don't link to libgcc on MS Windows iff we're using gfortran. |
661
|
0
|
0
|
0
|
|
|
0
|
unless($fallback_compiler eq 'GFortran' && $^O =~ /MSWin/i) { |
662
|
0
|
|
|
|
|
0
|
$gccdir = `$gcc -m32 -print-libgcc-file-name`; chomp $gccdir; |
|
0
|
|
|
|
|
0
|
|
663
|
0
|
|
|
|
|
0
|
$gccdir =~ s/\/libgcc.a//; |
664
|
0
|
|
|
|
|
0
|
return " -L$gccdir -lgcc"; |
665
|
|
|
|
|
|
|
}else{ |
666
|
0
|
|
|
|
|
0
|
return ""; |
667
|
|
|
|
|
|
|
} |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
}else{ |
670
|
0
|
|
|
|
|
0
|
return ""; |
671
|
|
|
|
|
|
|
} |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
# Try and find a program in the users PATH |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
sub find_in_path { |
677
|
5
|
|
|
5
|
0
|
6
|
my @names = @_; |
678
|
5
|
|
|
|
|
2
|
my @path; |
679
|
5
|
50
|
|
|
|
7
|
if ($^O =~ /mswin32/i) { |
680
|
0
|
|
|
|
|
0
|
for(@names) { $_ .= '.exe'} |
|
0
|
|
|
|
|
0
|
|
681
|
0
|
|
|
|
|
0
|
@path = split(";", $ENV{PATH}); |
682
|
|
|
|
|
|
|
} |
683
|
5
|
|
|
|
|
18
|
else {@path = split(":",$ENV{PATH})} |
684
|
5
|
|
|
|
|
5
|
my ($name,$dir); |
685
|
5
|
|
|
|
|
3
|
for $name (@names) { |
686
|
19
|
50
|
|
|
|
25
|
return $name if exists $CACHE{$name}; |
687
|
19
|
|
|
|
|
13
|
for $dir (@path) { |
688
|
133
|
50
|
|
|
|
795
|
if (-x $dir."/$name") { |
689
|
0
|
|
|
|
|
0
|
print "Found compiler $name\n"; |
690
|
0
|
|
|
|
|
0
|
$CACHE{$name}++; |
691
|
0
|
|
|
|
|
0
|
return $name; |
692
|
|
|
|
|
|
|
} |
693
|
|
|
|
|
|
|
} |
694
|
|
|
|
|
|
|
} |
695
|
5
|
50
|
|
|
|
8
|
return '' if $^O eq 'VMS'; |
696
|
5
|
|
|
|
|
12
|
return undef; |
697
|
|
|
|
|
|
|
# die "Unable to find a fortran compiler using names: ".join(" ",@names); |
698
|
|
|
|
|
|
|
} |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
# Based on code from Tim Jeness, tries to figure out the correct GNU |
701
|
|
|
|
|
|
|
# fortran compiler libs |
702
|
|
|
|
|
|
|
sub link_gnufortran_compiler { |
703
|
2
|
50
|
|
2
|
0
|
6
|
return () if $^O =~ /MSWin32/i; # Unneeded for MinGW, emits warnings if allowed to proceed. |
704
|
2
|
|
|
|
|
4
|
my @try = @_; |
705
|
2
|
|
|
|
|
3
|
my $compiler = find_in_path( @try ); |
706
|
|
|
|
|
|
|
# all the compilers and their libraries |
707
|
2
|
|
|
|
|
10
|
my %complibs = ( |
708
|
|
|
|
|
|
|
g77 => [qw/ g2c f2c /], |
709
|
|
|
|
|
|
|
f77 => [qw/ g2c f2c /], |
710
|
|
|
|
|
|
|
fort77 => [qw/ g2c f2c /], |
711
|
|
|
|
|
|
|
gfortran => [qw/ gfortran /], |
712
|
|
|
|
|
|
|
g95 => [qw/ f95 /], |
713
|
|
|
|
|
|
|
); |
714
|
2
|
50
|
|
|
|
8
|
return () unless defined $compiler; |
715
|
0
|
|
|
|
|
|
my @libs = @{$complibs{$compiler}}; |
|
0
|
|
|
|
|
|
|
716
|
0
|
|
|
|
|
|
my ($dir, $lib, $test); |
717
|
0
|
|
|
|
|
|
foreach $test (@libs) { |
718
|
0
|
|
|
|
|
|
$dir = `$compiler -print-file-name=lib$test.a`; |
719
|
0
|
|
|
|
|
|
chomp $dir; |
720
|
|
|
|
|
|
|
# Note that -print-file-name returns just the library name |
721
|
|
|
|
|
|
|
# if it cant be found - make sure that we only accept the |
722
|
|
|
|
|
|
|
# directory if it returns a proper path (or matches a /) |
723
|
0
|
0
|
0
|
|
|
|
if (defined $dir && $dir ne "lib$test.a") { |
724
|
0
|
|
|
|
|
|
$lib = $test; # Found an existing library |
725
|
0
|
|
|
|
|
|
$dir =~ s,/lib$lib.a$,,; |
726
|
0
|
|
|
|
|
|
last; |
727
|
|
|
|
|
|
|
} else { |
728
|
|
|
|
|
|
|
# Try the same thing again but looking for the .so file |
729
|
|
|
|
|
|
|
# rather than the .a file. |
730
|
0
|
|
|
|
|
|
$dir = `$compiler -print-file-name=lib$test.so`; |
731
|
0
|
|
|
|
|
|
chomp $dir; |
732
|
0
|
0
|
0
|
|
|
|
if (defined $dir && $dir ne "lib$test.so") { |
733
|
0
|
|
|
|
|
|
$lib = $test; # Found an existing library |
734
|
0
|
|
|
|
|
|
$dir =~ s,/lib$lib.so$,,; |
735
|
0
|
|
|
|
|
|
last; |
736
|
|
|
|
|
|
|
} else { |
737
|
0
|
|
|
|
|
|
$dir = "/usr/local/lib"; |
738
|
0
|
|
|
|
|
|
$lib = "f2c"; |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
} |
741
|
|
|
|
|
|
|
} |
742
|
|
|
|
|
|
|
# Get compiler version number |
743
|
0
|
|
|
|
|
|
my @t =`$compiler --version`; $t[0] =~ /(\d+).(\d)+.(\d+)/; |
|
0
|
|
|
|
|
|
|
744
|
0
|
|
|
|
|
|
my $version = "$1.$2"; # Major version number |
745
|
0
|
|
|
|
|
|
print "ExtUtils::F77: $compiler version $version.$3\n"; |
746
|
|
|
|
|
|
|
# Sigh special case random extra gfortran libs to avoid PERL_DL_NONLAZY meltdowns. KG 25/10/2015 |
747
|
0
|
|
|
|
|
|
$append = ""; |
748
|
0
|
0
|
0
|
|
|
|
if ( $Config{osname} =~ /darwin/ && $Config{osvers} >= 14 |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
749
|
|
|
|
|
|
|
&& $compiler eq 'gfortran' && $version >= 4.9 ) { # Add extra libs for gfortran versions >= 4.9 and OS X |
750
|
0
|
|
|
|
|
|
$append = "-lgcc_ext.10.5 -lgcc_s.10.5 -lquadmath"; |
751
|
0
|
|
|
|
|
|
return( "-L$dir $append -L/usr/lib -l$lib -lm" ); |
752
|
|
|
|
|
|
|
} |
753
|
0
|
|
|
|
|
|
return( "-L$dir -L/usr/lib -l$lib -lm" ); |
754
|
|
|
|
|
|
|
} |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
=head1 AUTHOR |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
Karl Glazebrook (karlglazebrook@mac.com). |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
=cut |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
1; # Return true |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
|