(file) Return to moreconfigure.pl CVS log (file) (dir) Up to [Development] / JSOC

  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           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 arta  1.1 
 34           $hasicc = 0;
 35           $hasifort = 0;
 36           $hasgcc = 0;
 37           $hasgfort = 0;
 38           
 39           if (defined($outfile))
 40           {
 41               # Try icc
 42 arta  1.2     $ans = `icc -V 2>&1`;      
 43 arta  1.1 
 44 arta  1.2     if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
 45 arta  1.1     {
 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 arta  1.2         if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
 60 arta  1.1         {
 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 arta  1.2     if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
 74 arta  1.1     {
 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 arta  1.2         if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
 89 arta  1.1         {
 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 arta  1.7         print "Fatal error: Acceptable C compiler not found! You will be unable to build the DRMS library.\n";
106 arta  1.1     }
107               elsif ($hasicc)
108               {
109 rick  1.4         print OUTFILE "JSOC_AUTOCOMPILER = icc\n";
110 arta  1.1     }
111               else
112               {
113 rick  1.4         print OUTFILE "JSOC_AUTOCOMPILER = gcc\n";
114 arta  1.1     }
115           
116               if (!$hasifort && !$hasgfort)
117               {
118 arta  1.7         print "Warning: Acceptable Fortran compiler not found! Fortran interface will not be built, and you will be unable to build Fortran modules.\n";
119 arta  1.1     }
120               elsif ($hasifort)
121               {
122 rick  1.4         print OUTFILE "JSOC_AUTOFCOMPILER = ifort\n";
123 arta  1.1     }
124               else
125               {
126 rick  1.4         print OUTFILE "JSOC_AUTOFCOMPILER = gfortran\n";
127 arta  1.1     }
128           
129 arta  1.8     # 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 arta  1.1     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           }

Karen Tian
Powered by
ViewCVS 0.9.4