1 |
arta |
1.1 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
# Determine which compilers are installed; then set make variables to indicate that |
4 |
arta |
1.8 |
# Also, set DEFAULT values for Stanford-specific (if running at Stanford) make variables. |
5 |
|
|
# To override the DEFAULT Stanford values, create a config.local file. |
6 |
|
|
|
7 |
arta |
1.1 |
use constant ICCMAJOR => 9; |
8 |
|
|
use constant ICCMINOR => 0; |
9 |
|
|
use constant IFORTMAJOR => 9; |
10 |
|
|
use constant IFORTMINOR => 0; |
11 |
arta |
1.3 |
use constant GCCMAJOR => 3; |
12 |
arta |
1.1 |
use constant GCCMINOR => 0; |
13 |
|
|
use constant GFORTMAJOR => 4; |
14 |
|
|
use constant GFORTMINOR => 2; |
15 |
|
|
|
16 |
|
|
my($arg); |
17 |
|
|
my($pos); |
18 |
arta |
1.11 |
my($outdir); |
19 |
arta |
1.1 |
my($outfile); |
20 |
arta |
1.11 |
my($customdefsfile); |
21 |
arta |
1.1 |
my($major); |
22 |
|
|
my($minor); |
23 |
|
|
my($hasicc); |
24 |
|
|
my($hasifort); |
25 |
|
|
my($hasgcc); |
26 |
|
|
my($hasgfort); |
27 |
arta |
1.11 |
my($skipautocomp); |
28 |
|
|
my($line); |
29 |
arta |
1.1 |
|
30 |
|
|
while ($arg = shift(@ARGV)) |
31 |
|
|
{ |
32 |
arta |
1.11 |
if (($pos = index($arg, "-d", 0)) == 0) |
33 |
|
|
{ |
34 |
|
|
$outdir = substr($arg, 2); |
35 |
|
|
} |
36 |
|
|
elsif (($pos = index($arg, "-f", 0)) == 0) |
37 |
arta |
1.1 |
{ |
38 |
|
|
$outfile = substr($arg, 2); |
39 |
|
|
} |
40 |
arta |
1.11 |
elsif (($pos = index($arg, "-c", 0)) == 0) |
41 |
|
|
{ |
42 |
|
|
$customdefsfile = substr($arg, 2); |
43 |
|
|
} |
44 |
arta |
1.1 |
} |
45 |
|
|
|
46 |
arta |
1.11 |
$outfile = "$outdir/$outfile"; |
47 |
|
|
|
48 |
arta |
1.1 |
$hasicc = 0; |
49 |
|
|
$hasifort = 0; |
50 |
|
|
$hasgcc = 0; |
51 |
|
|
$hasgfort = 0; |
52 |
arta |
1.11 |
$skipautocomp = 0; |
53 |
arta |
1.1 |
|
54 |
arta |
1.11 |
if (defined($outdir) && defined($outfile)) |
55 |
arta |
1.1 |
{ |
56 |
arta |
1.11 |
# Check to see if user does not want to auto-configure compiler make variables |
57 |
|
|
# Read the file containing the defs (right now, customizeddefs.h for Stanford, |
58 |
|
|
# localization.h for non-Stanford). |
59 |
|
|
if (defined($customdefsfile) && -e $customdefsfile) |
60 |
|
|
{ |
61 |
|
|
if (open(DEFSFILE, "<$customdefsfile")) |
62 |
|
|
{ |
63 |
|
|
my($doautocomp) = 0; |
64 |
|
|
|
65 |
|
|
while (defined($line = <DEFSFILE>)) |
66 |
|
|
{ |
67 |
|
|
if ($line =~ /AUTOSELCOMP\s+(.+)/) |
68 |
|
|
{ |
69 |
|
|
$doautocomp = $1; |
70 |
|
|
$skipautocomp = !$doautocomp; |
71 |
|
|
last; |
72 |
|
|
} |
73 |
|
|
} |
74 |
arta |
1.1 |
|
75 |
arta |
1.11 |
close(DEFSFILE); |
76 |
|
|
} |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
if (!$skipautocomp) |
80 |
|
|
{ |
81 |
|
|
# Try icc |
82 |
|
|
$ans = `icc -V 2>&1`; |
83 |
|
|
|
84 |
|
|
if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/) |
85 |
|
|
{ |
86 |
|
|
$major = $1; |
87 |
|
|
$minor = $2; |
88 |
arta |
1.1 |
|
89 |
arta |
1.11 |
if (IsVersion($major, $minor, ICCMAJOR, ICCMINOR)) |
90 |
|
|
{ |
91 |
arta |
1.1 |
$hasicc = 1; |
92 |
arta |
1.11 |
} |
93 |
|
|
} |
94 |
arta |
1.1 |
|
95 |
arta |
1.11 |
# Try gcc |
96 |
|
|
if (!$hasicc) |
97 |
|
|
{ |
98 |
|
|
$ans = `gcc -v 2>&1`; |
99 |
|
|
if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/) |
100 |
|
|
{ |
101 |
arta |
1.1 |
$major = $1; |
102 |
|
|
$minor = $2; |
103 |
|
|
|
104 |
|
|
if (IsVersion($major, $minor, GCCMAJOR, GCCMINOR)) |
105 |
|
|
{ |
106 |
arta |
1.11 |
$hasgcc = 1; |
107 |
arta |
1.1 |
} |
108 |
arta |
1.11 |
} |
109 |
|
|
} |
110 |
arta |
1.1 |
|
111 |
arta |
1.11 |
# Try ifort |
112 |
|
|
$ans = `ifort -V 2>&1`; |
113 |
|
|
if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/) |
114 |
|
|
{ |
115 |
|
|
$major = $1; |
116 |
|
|
$minor = $2; |
117 |
arta |
1.1 |
|
118 |
arta |
1.11 |
if (IsVersion($major, $minor, IFORTMAJOR, IFORTMINOR)) |
119 |
|
|
{ |
120 |
arta |
1.1 |
$hasifort = 1; |
121 |
arta |
1.11 |
} |
122 |
|
|
} |
123 |
arta |
1.1 |
|
124 |
arta |
1.11 |
# Try gfortran |
125 |
|
|
if (!$hasifort) |
126 |
|
|
{ |
127 |
|
|
$ans = `gfortran -v 2>&1`; |
128 |
|
|
if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/) |
129 |
|
|
{ |
130 |
arta |
1.1 |
$major = $1; |
131 |
|
|
$minor = $2; |
132 |
|
|
|
133 |
|
|
if (IsVersion($major, $minor, GFORTMAJOR, GFORTMINOR)) |
134 |
|
|
{ |
135 |
arta |
1.11 |
$hasgfort = 1; |
136 |
arta |
1.1 |
} |
137 |
arta |
1.11 |
} |
138 |
|
|
} |
139 |
|
|
} |
140 |
arta |
1.1 |
|
141 |
|
|
open(OUTFILE, ">>$outfile") || die "Couldn't open file $outfile for writing.\n"; |
142 |
|
|
|
143 |
|
|
# Error messages |
144 |
arta |
1.11 |
if (!$skipautocomp) |
145 |
arta |
1.1 |
{ |
146 |
arta |
1.11 |
if (!$hasicc && !$hasgcc) |
147 |
|
|
{ |
148 |
|
|
print "Fatal error: Acceptable C compiler not found! You will be unable to build the DRMS library.\n"; |
149 |
|
|
} |
150 |
|
|
elsif ($hasicc) |
151 |
|
|
{ |
152 |
|
|
print OUTFILE "COMPILER = icc\n"; |
153 |
|
|
} |
154 |
|
|
else |
155 |
|
|
{ |
156 |
|
|
print OUTFILE "COMPILER = gcc\n"; |
157 |
|
|
} |
158 |
arta |
1.1 |
|
159 |
arta |
1.11 |
if (!$hasifort && !$hasgfort) |
160 |
|
|
{ |
161 |
|
|
print "Warning: Acceptable Fortran compiler not found! Fortran interface will not be built, and you will be unable to build Fortran modules.\n"; |
162 |
|
|
} |
163 |
|
|
elsif ($hasifort) |
164 |
|
|
{ |
165 |
|
|
print OUTFILE "FCOMPILER = ifort\n"; |
166 |
|
|
} |
167 |
|
|
else |
168 |
|
|
{ |
169 |
|
|
print OUTFILE "FCOMPILER = gfortran\n"; |
170 |
|
|
} |
171 |
arta |
1.1 |
} |
172 |
|
|
|
173 |
arta |
1.10 |
# Print out env var override logic - otherwise we lose this logic in make_basic.mk |
174 |
|
|
# as the include of custom.mk comes after this logic in make_basic.mk |
175 |
|
|
print OUTFILE "ifneq (\$(JSOC_COMPILER),)\n COMPILER = \$(JSOC_COMPILER)\nendif\n"; |
176 |
|
|
print OUTFILE "ifneq (\$(JSOC_FCOMPILER),)\n FCOMPILER = \$(JSOC_FCOMPILER)\nendif\n\n"; |
177 |
|
|
|
178 |
arta |
1.8 |
# Set DEFAULT values for Stanford-specific (if running at Stanford) make variables. |
179 |
|
|
if (-e "suflag.txt") |
180 |
|
|
{ |
181 |
|
|
my($line); |
182 |
|
|
|
183 |
|
|
if (open(SUFLAG, "<suflag.txt")) |
184 |
|
|
{ |
185 |
|
|
while (defined($line = <SUFLAG>)) |
186 |
|
|
{ |
187 |
|
|
chomp($line); |
188 |
|
|
if ($line !~ /^#/ && $line =~ /\S+/) |
189 |
|
|
{ |
190 |
|
|
print OUTFILE "$line\n"; |
191 |
|
|
} |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
close(SUFLAG); |
195 |
|
|
} |
196 |
|
|
} |
197 |
|
|
|
198 |
arta |
1.1 |
close(OUTFILE); |
199 |
|
|
} |
200 |
|
|
|
201 |
|
|
sub IsVersion |
202 |
|
|
{ |
203 |
|
|
my($maj1) = $_[0]; |
204 |
|
|
my($min1) = $_[1]; |
205 |
|
|
my($maj2) = $_[2]; |
206 |
|
|
my($min2) = $_[3]; |
207 |
|
|
|
208 |
|
|
my($res) = 0; |
209 |
|
|
|
210 |
|
|
if ($maj1 > $maj2 || ($maj1 == $maj2 && $min1 >= $min2)) |
211 |
|
|
{ |
212 |
|
|
$res = 1; |
213 |
|
|
} |
214 |
|
|
|
215 |
|
|
return $res; |
216 |
|
|
} |