ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/moreconfigure.pl
Revision: 1.12
Committed: Wed Feb 2 19:49:16 2011 UTC (12 years, 7 months ago) by arta
Content type: text/plain
Branch: MAIN
CVS Tags: NetDRMS_Ver_6-4, NetDRMS_Ver_6-2, NetDRMS_Ver_6-3, NetDRMS_Ver_6-0, NetDRMS_Ver_6-1, Ver_6-0, Ver_6-1, Ver_6-2, Ver_6-3, Ver_6-4, NetDRMS_Ver_2-7, Ver_5-14, Ver_5-13, Ver_LATEST, NetDRMS_Ver_LATEST, NetDRMS_Ver_9-9, NetDRMS_Ver_8-0, NetDRMS_Ver_8-1, NetDRMS_Ver_2-6, Ver_DRMSLATEST, Ver_8-0, Ver_8-1, Ver_7-1, Ver_7-0, NetDRMS_Ver_7-1, NetDRMS_Ver_7-0
Changes since 1.11: +18 -3 lines
Log Message:
Source configure and make changes that allow users to checkout NetDRMS plus specified proj directories.

File Contents

# Content
1 #!/usr/bin/perl -w
2
3 # Determine which compilers are installed; then set make variables to indicate that
4 # 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 use constant ICCMAJOR => 9;
8 use constant ICCMINOR => 0;
9 use constant IFORTMAJOR => 9;
10 use constant IFORTMINOR => 0;
11 use constant GCCMAJOR => 3;
12 use constant GCCMINOR => 0;
13 use constant GFORTMAJOR => 4;
14 use constant GFORTMINOR => 2;
15
16 my($arg);
17 my($pos);
18 my($outdir);
19 my($outfile);
20 my($customdefsfile);
21 my($major);
22 my($minor);
23 my($hasicc);
24 my($hasifort);
25 my($hasgcc);
26 my($hasgfort);
27 my($skipautocomp);
28 my($line);
29
30 while ($arg = shift(@ARGV))
31 {
32 if (($pos = index($arg, "-d", 0)) == 0)
33 {
34 $outdir = substr($arg, 2);
35 }
36 elsif (($pos = index($arg, "-f", 0)) == 0)
37 {
38 $outfile = substr($arg, 2);
39 }
40 elsif (($pos = index($arg, "-c", 0)) == 0)
41 {
42 $customdefsfile = substr($arg, 2);
43 }
44 }
45
46 $outfile = "$outdir/$outfile";
47
48 $hasicc = 0;
49 $hasifort = 0;
50 $hasgcc = 0;
51 $hasgfort = 0;
52 $skipautocomp = 0;
53
54 if (defined($outdir) && defined($outfile))
55 {
56 # 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
75 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
89 if (IsVersion($major, $minor, ICCMAJOR, ICCMINOR))
90 {
91 $hasicc = 1;
92 }
93 }
94
95 # 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 $major = $1;
102 $minor = $2;
103
104 if (IsVersion($major, $minor, GCCMAJOR, GCCMINOR))
105 {
106 $hasgcc = 1;
107 }
108 }
109 }
110
111 # 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
118 if (IsVersion($major, $minor, IFORTMAJOR, IFORTMINOR))
119 {
120 $hasifort = 1;
121 }
122 }
123
124 # 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 $major = $1;
131 $minor = $2;
132
133 if (IsVersion($major, $minor, GFORTMAJOR, GFORTMINOR))
134 {
135 $hasgfort = 1;
136 }
137 }
138 }
139 }
140
141 open(OUTFILE, ">>$outfile") || die "Couldn't open file $outfile for writing.\n";
142
143 # Error messages
144 if (!$skipautocomp)
145 {
146 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
159 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 }
172
173 # 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 # Set DEFAULT values for Stanford-specific (if running at Stanford) make variables.
179 if (-e "configsdp.txt")
180 {
181 my($line);
182 my($parse);
183
184 if (open(SUFLAG, "<configsdp.txt"))
185 {
186
187 $parse = 0;
188
189 while (defined($line = <SUFLAG>))
190 {
191 chomp($line);
192
193 if ($line =~ /^__LIBS__/)
194 {
195 $parse = 1;
196 next;
197 }
198 elsif ($parse && $line =~ /^__END__/)
199 {
200 last;
201 }
202
203 if ($parse && $line !~ /^#/ && $line =~ /\S+/)
204 {
205 print OUTFILE "$line\n";
206 }
207 }
208
209 close(SUFLAG);
210 }
211 }
212
213 close(OUTFILE);
214 }
215
216 sub IsVersion
217 {
218 my($maj1) = $_[0];
219 my($min1) = $_[1];
220 my($maj2) = $_[2];
221 my($min2) = $_[3];
222
223 my($res) = 0;
224
225 if ($maj1 > $maj2 || ($maj1 == $maj2 && $min1 >= $min2))
226 {
227 $res = 1;
228 }
229
230 return $res;
231 }