| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package ExtUtils::F77; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
528
|
use Config; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
1295
|
|
|
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.20"; |
|
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
|
|
|
|
|
|
|
if($^O =~ /Freebsd/i) { |
|
348
|
|
|
|
|
|
|
$gfortran = 'gfortran48'; # requires rewrite |
|
349
|
|
|
|
|
|
|
$fallback_compiler = 'G77'; |
|
350
|
|
|
|
|
|
|
} |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
$F77config{Freebsd}{G77}{Link} = sub { |
|
353
|
|
|
|
|
|
|
$dir = `g77-34 -print-file-name=libg2c.a`; |
|
354
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if( defined $dir ) { |
|
360
|
|
|
|
|
|
|
$dir =~ s,/libg2c.a$,,; |
|
361
|
|
|
|
|
|
|
} else { |
|
362
|
|
|
|
|
|
|
$dir = "/usr/local/lib"; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
|
|
|
|
|
|
return( "-L$dir -L/usr/lib -lg2c -lm" ); |
|
365
|
|
|
|
|
|
|
}; |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
$F77config{Freebsd}{GFortran}{Link} = sub { |
|
368
|
|
|
|
|
|
|
$dir = `$gfortran -print-file-name=libgfortran.a`; |
|
369
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if( defined $dir ) { |
|
375
|
|
|
|
|
|
|
$dir =~ s,/libgfortran.a$,,; |
|
376
|
|
|
|
|
|
|
} else { |
|
377
|
|
|
|
|
|
|
$dir = "/usr/local/lib"; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
return( "-L$dir -L/usr/lib -lgfortran -lm" ); |
|
380
|
|
|
|
|
|
|
}; |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
$F77config{Freebsd}{G77}{Trail_} = 1; |
|
383
|
|
|
|
|
|
|
$F77config{Freebsd}{GFortran}{Trail_} = 1; |
|
384
|
|
|
|
|
|
|
$F77config{Freebsd}{G77}{Compiler} = 'g77-34'; |
|
385
|
|
|
|
|
|
|
$F77config{Freebsd}{GFortran}{Compiler} = "$gfortran"; |
|
386
|
|
|
|
|
|
|
$F77config{Freebsd}{G77}{Cflags} = '-O2'; |
|
387
|
|
|
|
|
|
|
$F77config{Freebsd}{GFortran}{Cflags} = '-O2'; |
|
388
|
|
|
|
|
|
|
$F77config{Freebsd}{DEFAULT} = 'GFortran'; |
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
### VMS ### |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
$F77config{VMS}{Fortran}{Trail_} = 0; |
|
394
|
|
|
|
|
|
|
$F77config{VMS}{Fortran}{Link} = ' '; # <---need this space! |
|
395
|
|
|
|
|
|
|
$F77config{VMS}{DEFAULT} = 'Fortran'; |
|
396
|
|
|
|
|
|
|
$F77config{VMS}{Fortran}{Compiler} = 'Fortran'; |
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
### Darwin (Mac OS X) ### |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
$F77config{Darwin}{GNU} = $F77config{Generic}{GNU}; |
|
401
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
$Runtime = "-LSNAFU -lwontwork"; |
|
419
|
|
|
|
|
|
|
$RuntimeOK = 0; |
|
420
|
|
|
|
|
|
|
$Trail_ = 1; |
|
421
|
|
|
|
|
|
|
$Pkg = ""; |
|
422
|
|
|
|
|
|
|
$Compiler = ""; |
|
423
|
|
|
|
|
|
|
$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
|
|
|
1
|
|
4
|
no warnings; # Shuts up complaints on Win32 when running PDL tests |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
1709
|
|
|
432
|
1
|
|
|
1
|
|
5
|
$Pkg = shift; |
|
433
|
1
|
|
|
|
|
2
|
my $system = ucfirst(shift); # Set package variables |
|
434
|
1
|
|
|
|
|
1
|
my $compiler = ucfirst(shift); |
|
435
|
1
|
|
|
|
|
8
|
$Runtime = "-LSNAFU -lwontwork"; |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
# Guesses if system/compiler not specified. |
|
438
|
|
|
|
|
|
|
|
|
439
|
1
|
50
|
|
|
|
7
|
$system = ucfirst $Config{'osname'} unless $system; |
|
440
|
1
|
50
|
|
|
|
3
|
$system = 'Cygwin' if $system =~ /Cygwin/; |
|
441
|
1
|
50
|
|
|
|
3
|
$compiler = get $F77config{$system}{DEFAULT} unless $compiler; |
|
442
|
|
|
|
|
|
|
|
|
443
|
1
|
50
|
|
|
|
21
|
print "$Pkg: Using system=$system compiler=" . |
|
444
|
|
|
|
|
|
|
(defined $compiler ? $compiler : "") . "\n"; |
|
445
|
|
|
|
|
|
|
|
|
446
|
1
|
50
|
|
|
|
3
|
if (defined($ENV{F77LIBS})) { |
|
447
|
0
|
|
|
|
|
0
|
print "Overriding Fortran libs from value of enviroment variable F77LIBS = $ENV{F77LIBS}\n"; |
|
448
|
0
|
|
|
|
|
0
|
$Runtime = $ENV{F77LIBS}; |
|
449
|
|
|
|
|
|
|
} |
|
450
|
|
|
|
|
|
|
else { |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
# Try this combination |
|
453
|
|
|
|
|
|
|
|
|
454
|
1
|
50
|
33
|
|
|
5
|
if ( defined( $compiler ) and defined( $F77config{$system} )){ |
|
455
|
1
|
|
|
|
|
2
|
my $flibs = get ($F77config{$system}{$compiler}{Link}); |
|
456
|
1
|
50
|
|
|
|
2
|
if ($flibs ne "") { |
|
457
|
0
|
|
|
|
|
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
|
0
|
|
|
|
0
|
$Runtime =~ s|L([a-z,A-Z]):|L//$1|g if $^O =~ /cygwin/i; |
|
464
|
0
|
0
|
|
|
|
0
|
$Runtime = ' ' if $^O eq 'VMS'; # <-- need this space! |
|
465
|
0
|
|
|
|
|
0
|
print "Runtime: $Runtime\n"; |
|
466
|
0
|
|
|
|
|
0
|
$ok = 1; |
|
467
|
0
|
0
|
|
|
|
0
|
if ($compiler eq 'GNU') { # Special gfortran case since it seems to have lots of random libs |
|
468
|
0
|
|
|
|
|
0
|
print "Found compiler=$compiler - skipping validation of $Runtime \n"; |
|
469
|
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
}else { |
|
471
|
0
|
0
|
|
|
|
0
|
$ok = validate_libs($Runtime) if $flibs ne "" ; |
|
472
|
|
|
|
|
|
|
} |
|
473
|
|
|
|
|
|
|
} |
|
474
|
|
|
|
|
|
|
}else { |
|
475
|
0
|
|
|
|
|
0
|
$Runtime = $ok = ""; |
|
476
|
|
|
|
|
|
|
} |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
# If it doesn't work try Generic + GNU77 |
|
479
|
|
|
|
|
|
|
|
|
480
|
1
|
50
|
33
|
|
|
3
|
unless (("$Runtime" ne "-LSNAFU -lwontwork") && $ok) { |
|
481
|
1
|
|
|
|
|
5
|
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
|
50
|
33
|
|
|
10
|
$Config{cc} =~ /\bgcc/ && $^O =~ /MSWin32/i ? "MinGW" |
|
|
|
50
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
: $^O =~ /Freebsd/i ? "Freebsd" |
|
488
|
|
|
|
|
|
|
:"Generic"; |
|
489
|
1
|
|
|
|
|
1
|
$compiler = $fallback_compiler; |
|
490
|
1
|
|
|
|
|
4
|
my $flibs = get ($F77config{$system}{$compiler}{Link}); |
|
491
|
1
|
|
|
|
|
2
|
$Runtime = $flibs ; #. gcclibs($flibs); # Note gcclibs appears to be no longer required. |
|
492
|
1
|
50
|
|
|
|
3
|
$ok = validate_libs($Runtime) if $flibs ne ""; |
|
493
|
1
|
50
|
33
|
|
|
5
|
print "$Pkg: Well that didn't appear to validate. Well I will try it anyway.\n" |
|
494
|
|
|
|
|
|
|
unless $Runtime && $ok; |
|
495
|
|
|
|
|
|
|
} |
|
496
|
|
|
|
|
|
|
|
|
497
|
1
|
|
|
|
|
1
|
$RuntimeOK = $ok; |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
} # Not overriding |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
# Now get the misc info for the methods. |
|
502
|
|
|
|
|
|
|
|
|
503
|
1
|
50
|
|
|
|
2
|
if (defined( $F77config{$system}{$compiler}{Trail_} )){ |
|
504
|
0
|
|
|
|
|
0
|
$Trail_ = get $F77config{$system}{$compiler}{Trail_}; |
|
505
|
|
|
|
|
|
|
} |
|
506
|
|
|
|
|
|
|
else{ |
|
507
|
1
|
|
|
|
|
4
|
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
|
|
|
|
|
1
|
$Trail_ = 1; |
|
513
|
|
|
|
|
|
|
} |
|
514
|
|
|
|
|
|
|
|
|
515
|
1
|
50
|
|
|
|
2
|
if (defined( $F77config{$system}{$compiler}{Compiler} )) { |
|
516
|
0
|
|
|
|
|
0
|
$Compiler = get $F77config{$system}{$compiler}{Compiler}; |
|
517
|
|
|
|
|
|
|
} else { |
|
518
|
1
|
|
|
|
|
2
|
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
|
|
|
|
|
1
|
$Compiler = 'f77'; |
|
523
|
|
|
|
|
|
|
} |
|
524
|
1
|
|
|
|
|
2
|
print "$Pkg: Compiler: $Compiler\n"; |
|
525
|
|
|
|
|
|
|
|
|
526
|
1
|
50
|
|
|
|
2
|
if (defined( $F77config{$system}{$compiler}{Cflags} )) { |
|
527
|
0
|
|
|
|
|
0
|
$Cflags = get $F77config{$system}{$compiler}{Cflags} ; |
|
528
|
|
|
|
|
|
|
} else { |
|
529
|
1
|
|
|
|
|
3
|
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
|
|
|
|
|
1
|
$Cflags = ''; |
|
535
|
|
|
|
|
|
|
} |
|
536
|
|
|
|
|
|
|
|
|
537
|
1
|
|
|
|
|
983
|
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 |
|
548
|
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
Returns a list of F77 runtime libraries. |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
$fortranlibs = ExtUtils::F77->runtime; |
|
552
|
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=item * B |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
Returns TRUE only if runtime libraries have been found successfully. |
|
556
|
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=item * B |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
Returns true if F77 names have trailing underscores. |
|
560
|
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
=item * B |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
Returns command to execute the compiler (e.g. 'f77'). |
|
564
|
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=item * B |
|
566
|
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
Returns compiler flags. |
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=item * B |
|
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
|
|
|
0
|
1
|
0
|
sub runtime { return $Runtime; } |
|
580
|
0
|
|
|
0
|
1
|
0
|
sub runtimeok { return $RuntimeOK; } |
|
581
|
0
|
|
|
0
|
1
|
0
|
sub trail_ { return $Trail_; } |
|
582
|
0
|
|
|
0
|
1
|
0
|
sub compiler { return $Compiler; } |
|
583
|
0
|
|
|
0
|
1
|
0
|
sub cflags { return $Cflags; } |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
### Minor internal utility routines ### |
|
586
|
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
# Get hash entry, evaluating code references |
|
588
|
|
|
|
|
|
|
|
|
589
|
3
|
50
|
|
3
|
0
|
7
|
sub get { ref($_[0]) eq "CODE" ? &{$_[0]} : $_[0] }; |
|
|
0
|
|
|
|
|
0
|
|
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
# Test if any files exist matching glob |
|
592
|
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
sub any_exists { |
|
594
|
0
|
|
|
0
|
0
|
0
|
my @glob = glob(shift); |
|
595
|
0
|
|
|
|
|
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
|
|
|
0
|
0
|
0
|
print "$Pkg: Scanning for $_[0]\n"; |
|
602
|
0
|
|
|
|
|
0
|
my @glob = glob(shift); |
|
603
|
0
|
|
|
|
|
0
|
my %n=(); |
|
604
|
0
|
|
|
|
|
0
|
for (@glob) { |
|
605
|
|
|
|
|
|
|
#print "Found $_\n"; |
|
606
|
0
|
0
|
|
|
|
0
|
if ( m|/SC(\d)\.(\d)/?.*$| ) { |
|
607
|
0
|
|
|
|
|
0
|
$n{$_} = $1 *100 + $2 * 10; |
|
608
|
|
|
|
|
|
|
} |
|
609
|
0
|
0
|
|
|
|
0
|
if ( m|/SC(\d)\.(\d)\.(\d)/?.*$| ) { |
|
610
|
0
|
|
|
|
|
0
|
$n{$_} = $1 *100 + $2 * 10 + $3; |
|
611
|
|
|
|
|
|
|
} |
|
612
|
|
|
|
|
|
|
} |
|
613
|
0
|
|
|
|
|
0
|
my @sorted_dirs = grep {-f "$_/libF77.a"} sort {$n{$a} <=> $n{$b}} @glob; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
614
|
|
|
|
|
|
|
|
|
615
|
0
|
|
|
|
|
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
|
|
|
0
|
0
|
0
|
print "$Pkg: Validating $_[0] "; |
|
622
|
0
|
|
|
|
|
0
|
my @args = split(' ',shift()); |
|
623
|
0
|
|
|
|
|
0
|
my $pat; |
|
624
|
0
|
|
|
|
|
0
|
my $ret = 1; |
|
625
|
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
# Create list of directories to search (with common defaults) |
|
627
|
|
|
|
|
|
|
|
|
628
|
0
|
|
|
|
|
0
|
my @path = (); |
|
629
|
0
|
|
|
|
|
0
|
for (@args, "/usr/lib", "/lib") { |
|
630
|
0
|
0
|
0
|
|
|
0
|
push @path, $1 if /^-L(.+)$/ && -d $1; |
|
631
|
|
|
|
|
|
|
} |
|
632
|
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
# Search directories |
|
634
|
|
|
|
|
|
|
|
|
635
|
0
|
|
|
|
|
0
|
for (@args) { |
|
636
|
0
|
0
|
|
|
|
0
|
next if /^-L/; |
|
637
|
0
|
0
|
|
|
|
0
|
next if $_ eq "-lm"; # Ignore this common guy |
|
638
|
0
|
0
|
|
|
|
0
|
if (/^-l(.+)$/) { |
|
639
|
0
|
|
|
|
|
0
|
$pat = join(" ", map {$_."/lib".$1.".*"} @path); # Join dirs + file |
|
|
0
|
|
|
|
|
0
|
|
|
640
|
|
|
|
|
|
|
#print "Checking for $pat\n"; |
|
641
|
0
|
0
|
|
|
|
0
|
unless (any_exists($pat)) { |
|
642
|
0
|
|
|
|
|
0
|
print "\n$Pkg: Unable to find library $_" ; |
|
643
|
0
|
|
|
|
|
0
|
$ret = 0; |
|
644
|
|
|
|
|
|
|
} |
|
645
|
|
|
|
|
|
|
} |
|
646
|
|
|
|
|
|
|
} |
|
647
|
0
|
0
|
|
|
|
0
|
print $ret ? "[ok]\n" : "\n"; |
|
648
|
0
|
|
|
|
|
0
|
return $ret; |
|
649
|
|
|
|
|
|
|
} |
|
650
|
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
sub testcompiler { |
|
653
|
|
|
|
|
|
|
|
|
654
|
0
|
|
|
0
|
1
|
0
|
my $file = File::Spec->tmpdir . "/testf77$$"; |
|
655
|
0
|
|
|
|
|
0
|
$file =~ s/\\/\//g; # For Win32 |
|
656
|
|
|
|
|
|
|
|
|
657
|
0
|
|
|
|
|
0
|
my $ret; |
|
658
|
0
|
|
|
|
|
0
|
open(OUT,">$file.f"); |
|
659
|
0
|
|
|
|
|
0
|
print OUT " print *, 'Hello World'\n"; |
|
660
|
0
|
|
|
|
|
0
|
print OUT " end\n"; |
|
661
|
0
|
|
|
|
|
0
|
close(OUT); |
|
662
|
0
|
|
|
|
|
0
|
print "Compiling the test Fortran program...\n"; |
|
663
|
0
|
|
|
|
|
0
|
system "$Compiler $Cflags $file.f -o ${file}_exe"; |
|
664
|
0
|
|
|
|
|
0
|
print "Executing the test program...\n"; |
|
665
|
0
|
0
|
|
|
|
0
|
if (`${file}_exe` ne " Hello World\n") { |
|
666
|
0
|
|
|
|
|
0
|
print "Test of Fortran Compiler FAILED. \n"; |
|
667
|
0
|
|
|
|
|
0
|
print "Do not know how to compile Fortran on your system\n"; |
|
668
|
0
|
|
|
|
|
0
|
$ret=0; |
|
669
|
|
|
|
|
|
|
} |
|
670
|
|
|
|
|
|
|
else{ |
|
671
|
0
|
|
|
|
|
0
|
print "Congratulations you seem to have a working f77!\n"; |
|
672
|
0
|
|
|
|
|
0
|
$ret=1; |
|
673
|
|
|
|
|
|
|
} |
|
674
|
0
|
0
|
|
|
|
0
|
unlink("${file}_exe"); unlink("$file.f"); unlink("$file.o") if -e "$file.o"; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
675
|
0
|
|
|
|
|
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
|
|
|
0
|
0
|
0
|
my $flibs = shift; # Fortran libs |
|
687
|
0
|
|
|
|
|
0
|
my $isgcc = $Config{'cc'} eq "$gcc"; |
|
688
|
0
|
0
|
0
|
|
|
0
|
if (!$isgcc && $^O ne 'VMS') { |
|
689
|
0
|
|
|
|
|
0
|
print "Checking for gcc in disguise:\n"; |
|
690
|
0
|
0
|
|
|
|
0
|
$isgcc = 1 if $Config{gccversion}; |
|
691
|
0
|
|
|
|
|
0
|
my $string; |
|
692
|
0
|
0
|
|
|
|
0
|
if ($isgcc) { |
|
693
|
0
|
|
|
|
|
0
|
$string = "Compiler is gcc version $Config{gccversion}"; |
|
694
|
0
|
0
|
|
|
|
0
|
$string .= "\n" unless $string =~ /\n$/; |
|
695
|
|
|
|
|
|
|
} else { |
|
696
|
0
|
|
|
|
|
0
|
$string = "Not gcc\n"; |
|
697
|
|
|
|
|
|
|
} |
|
698
|
0
|
|
|
|
|
0
|
print $string; |
|
699
|
|
|
|
|
|
|
} |
|
700
|
0
|
0
|
0
|
|
|
0
|
if ($isgcc or ($flibs =~ /-lg2c/) or ($flibs =~ /-lf2c/) ) { |
|
|
|
|
0
|
|
|
|
|
|
701
|
|
|
|
|
|
|
# Don't link to libgcc on MS Windows iff we're using gfortran. |
|
702
|
0
|
0
|
0
|
|
|
0
|
unless($fallback_compiler eq 'GFortran' && $^O =~ /MSWin/i) { |
|
703
|
0
|
|
|
|
|
0
|
$gccdir = `$gcc -m32 -print-libgcc-file-name`; chomp $gccdir; |
|
|
0
|
|
|
|
|
0
|
|
|
704
|
0
|
|
|
|
|
0
|
$gccdir =~ s/\/libgcc.a//; |
|
705
|
0
|
|
|
|
|
0
|
return " -L$gccdir -lgcc"; |
|
706
|
|
|
|
|
|
|
}else{ |
|
707
|
0
|
|
|
|
|
0
|
return ""; |
|
708
|
|
|
|
|
|
|
} |
|
709
|
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
}else{ |
|
711
|
0
|
|
|
|
|
0
|
return ""; |
|
712
|
|
|
|
|
|
|
} |
|
713
|
|
|
|
|
|
|
} |
|
714
|
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
# Try and find a program in the users PATH |
|
716
|
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
sub find_in_path { |
|
718
|
5
|
|
|
5
|
0
|
7
|
my @names = @_; |
|
719
|
5
|
|
|
|
|
4
|
my @path; |
|
720
|
5
|
50
|
|
|
|
7
|
if ($^O =~ /mswin32/i) { |
|
721
|
0
|
|
|
|
|
0
|
for(@names) { $_ .= '.exe'} |
|
|
0
|
|
|
|
|
0
|
|
|
722
|
0
|
|
|
|
|
0
|
@path = split(";", $ENV{PATH}); |
|
723
|
|
|
|
|
|
|
} |
|
724
|
5
|
|
|
|
|
13
|
else {@path = split(":",$ENV{PATH})} |
|
725
|
5
|
|
|
|
|
4
|
my ($name,$dir); |
|
726
|
5
|
|
|
|
|
3
|
for $name (@names) { |
|
727
|
19
|
50
|
|
|
|
25
|
return $name if exists $CACHE{$name}; |
|
728
|
19
|
|
|
|
|
11
|
for $dir (@path) { |
|
729
|
133
|
50
|
|
|
|
829
|
if (-x $dir."/$name") { |
|
730
|
0
|
|
|
|
|
0
|
print "Found compiler $name\n"; |
|
731
|
0
|
|
|
|
|
0
|
$CACHE{$name}++; |
|
732
|
0
|
|
|
|
|
0
|
return $name; |
|
733
|
|
|
|
|
|
|
} |
|
734
|
|
|
|
|
|
|
} |
|
735
|
|
|
|
|
|
|
} |
|
736
|
5
|
50
|
|
|
|
11
|
return '' if $^O eq 'VMS'; |
|
737
|
5
|
|
|
|
|
12
|
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
|
50
|
|
2
|
0
|
3
|
return () if $^O =~ /MSWin32/i; # Unneeded for MinGW, emits warnings if allowed to proceed. |
|
745
|
2
|
|
|
|
|
4
|
my @try = @_; |
|
746
|
2
|
|
|
|
|
3
|
my $compiler = find_in_path( @try ); |
|
747
|
|
|
|
|
|
|
# all the compilers and their libraries |
|
748
|
2
|
|
|
|
|
8
|
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
|
50
|
|
|
|
9
|
return () unless defined $compiler; |
|
756
|
0
|
|
|
|
|
|
my @libs = @{$complibs{$compiler}}; |
|
|
0
|
|
|
|
|
|
|
|
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
|
0
|
0
|
|
|
|
if (defined $dir && $dir ne "lib$test.a") { |
|
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
|
0
|
0
|
|
|
|
if (defined $dir && $dir ne "lib$test.so") { |
|
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+)/; |
|
|
0
|
|
|
|
|
|
|
|
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
|
0
|
0
|
|
|
|
if ( $Config{osname} =~ /darwin/ && $Config{osvers} >= 14 |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
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; # Return true |
|
806
|
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
|