ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/moreconfigure.pl
Revision: 1.9
Committed: Wed Oct 14 17:07:41 2009 UTC (13 years, 11 months ago) by arta
Content type: text/plain
Branch: MAIN
CVS Tags: NetDRMS_Ver_2-2, NetDRMS_Ver_2-3, Ver_5-7, Ver_5-6, NetDRMS_Ver_2-1, Ver_5-9, Ver_5-8, NetDRMS_Ver_2-0
Changes since 1.8: +0 -33 lines
Log Message:
Move machine-type-guessing code from moreconfigure.pl (which implies that youd have to run configure everytime you want to build on a new machine) to a script, getmachinetype.pl, which is then called directly for make. This is used to get the default third-party-lib locations

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 "JSOC_AUTOCOMPILER = icc\n";
110 }
111 else
112 {
113 print OUTFILE "JSOC_AUTOCOMPILER = 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 "JSOC_AUTOFCOMPILER = ifort\n";
123 }
124 else
125 {
126 print OUTFILE "JSOC_AUTOFCOMPILER = gfortran\n";
127 }
128
129 # Set DEFAULT values for Stanford-specific (if running at Stanford) make variables.
130 if (-e "suflag.txt")
131 {
132 my($line);
133
134 if (open(SUFLAG, "<suflag.txt"))
135 {
136 while (defined($line = <SUFLAG>))
137 {
138 chomp($line);
139 if ($line !~ /^#/ && $line =~ /\S+/)
140 {
141 print OUTFILE "$line\n";
142 }
143 }
144
145 close(SUFLAG);
146 }
147 }
148
149 close(OUTFILE);
150 }
151
152 sub IsVersion
153 {
154 my($maj1) = $_[0];
155 my($min1) = $_[1];
156 my($maj2) = $_[2];
157 my($min2) = $_[3];
158
159 my($res) = 0;
160
161 if ($maj1 > $maj2 || ($maj1 == $maj2 && $min1 >= $min2))
162 {
163 $res = 1;
164 }
165
166 return $res;
167 }