ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/moreconfigure.pl
Revision: 1.10
Committed: Sun Aug 29 04:43:24 2010 UTC (13 years ago) by arta
Content type: text/plain
Branch: MAIN
CVS Tags: NetDRMS_Ver_2-4, NetDRMS_Ver_2-5, Ver_5-12, Ver_5-11, Ver_5-10
Changes since 1.9: +9 -4 lines
Log Message:
Various random changes to make code build on icc/gcc/ia32/x86_64

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($outfile);
19 my($major);
20 my($minor);
21 my($hasicc);
22 my($hasifort);
23 my($hasgcc);
24 my($hasgfort);
25
26 while ($arg = shift(@ARGV))
27 {
28 if (($pos = index($arg, "-f", 0)) == 0)
29 {
30 $outfile = substr($arg, 2);
31 }
32 }
33
34 $hasicc = 0;
35 $hasifort = 0;
36 $hasgcc = 0;
37 $hasgfort = 0;
38
39 if (defined($outfile))
40 {
41 # Try icc
42 $ans = `icc -V 2>&1`;
43
44 if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
45 {
46 $major = $1;
47 $minor = $2;
48
49 if (IsVersion($major, $minor, ICCMAJOR, ICCMINOR))
50 {
51 $hasicc = 1;
52 }
53 }
54
55 # Try gcc
56 if (!$hasicc)
57 {
58 $ans = `gcc -v 2>&1`;
59 if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
60 {
61 $major = $1;
62 $minor = $2;
63
64 if (IsVersion($major, $minor, GCCMAJOR, GCCMINOR))
65 {
66 $hasgcc = 1;
67 }
68 }
69 }
70
71 # Try ifort
72 $ans = `ifort -V 2>&1`;
73 if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
74 {
75 $major = $1;
76 $minor = $2;
77
78 if (IsVersion($major, $minor, IFORTMAJOR, IFORTMINOR))
79 {
80 $hasifort = 1;
81 }
82 }
83
84 # Try gfortran
85 if (!$hasifort)
86 {
87 $ans = `gfortran -v 2>&1`;
88 if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
89 {
90 $major = $1;
91 $minor = $2;
92
93 if (IsVersion($major, $minor, GFORTMAJOR, GFORTMINOR))
94 {
95 $hasgfort = 1;
96 }
97 }
98 }
99
100 open(OUTFILE, ">>$outfile") || die "Couldn't open file $outfile for writing.\n";
101
102 # Error messages
103 if (!$hasicc && !$hasgcc)
104 {
105 print "Fatal error: Acceptable C compiler not found! You will be unable to build the DRMS library.\n";
106 }
107 elsif ($hasicc)
108 {
109 print OUTFILE "COMPILER = icc\n";
110 }
111 else
112 {
113 print OUTFILE "COMPILER = gcc\n";
114 }
115
116 if (!$hasifort && !$hasgfort)
117 {
118 print "Warning: Acceptable Fortran compiler not found! Fortran interface will not be built, and you will be unable to build Fortran modules.\n";
119 }
120 elsif ($hasifort)
121 {
122 print OUTFILE "FCOMPILER = ifort\n";
123 }
124 else
125 {
126 print OUTFILE "FCOMPILER = gfortran\n";
127 }
128
129 # Print out env var override logic - otherwise we lose this logic in make_basic.mk
130 # as the include of custom.mk comes after this logic in make_basic.mk
131 print OUTFILE "ifneq (\$(JSOC_COMPILER),)\n COMPILER = \$(JSOC_COMPILER)\nendif\n";
132 print OUTFILE "ifneq (\$(JSOC_FCOMPILER),)\n FCOMPILER = \$(JSOC_FCOMPILER)\nendif\n\n";
133
134 # Set DEFAULT values for Stanford-specific (if running at Stanford) make variables.
135 if (-e "suflag.txt")
136 {
137 my($line);
138
139 if (open(SUFLAG, "<suflag.txt"))
140 {
141 while (defined($line = <SUFLAG>))
142 {
143 chomp($line);
144 if ($line !~ /^#/ && $line =~ /\S+/)
145 {
146 print OUTFILE "$line\n";
147 }
148 }
149
150 close(SUFLAG);
151 }
152 }
153
154 close(OUTFILE);
155 }
156
157 sub IsVersion
158 {
159 my($maj1) = $_[0];
160 my($min1) = $_[1];
161 my($maj2) = $_[2];
162 my($min2) = $_[3];
163
164 my($res) = 0;
165
166 if ($maj1 > $maj2 || ($maj1 == $maj2 && $min1 >= $min2))
167 {
168 $res = 1;
169 }
170
171 return $res;
172 }