Replace vpermpd with vpermilpd
[platform/upstream/openblas.git] / f_check
diff --git a/f_check b/f_check
index 86f1fa6..b05db85 100644 (file)
--- a/f_check
+++ b/f_check
@@ -1,13 +1,15 @@
 #!/usr/bin/perl
 
+$hostos   = `uname -s | sed -e s/\-.*//`;    chop($hostos);
+
 #
 # 1. Not specified
 #   1.1 Automatically detect, then check compiler
-#   1.2 If no fortran compiler is detected, g77 is default with NOFORTRAN definition
+#   1.2 If no fortran compiler is detected, gfortran is default with NOFORTRAN definition
 # 2. Specified
 #   2.1 If path is correct, check compiler
 #   2.2 If path is not correct, but still valid compiler name, force setting
-#     2.2.2 Path is not correct, invalid compiler name, then g77 is default with NOFORTRAN definition
+#     2.2.2 Path is not correct, invalid compiler name, then gfortran is default with NOFORTRAN definition
 #
 
 $makefile = shift(@ARGV);
@@ -16,6 +18,7 @@ $config   = shift(@ARGV);
 $nofortran = 0;
 
 $compiler = join(" ", @ARGV);
+$compiler_bin = shift(@ARGV);
 
 # f77 is too ambiguous
 $compiler = "" if $compiler eq "f77";
@@ -24,19 +27,21 @@ $compiler = "" if $compiler eq "f77";
 
 if ($compiler eq "") {
 
-    @lists = ("g77", "g95", "gfortran", "frt", "fort", "openf90", "openf95",
+    @lists = ("gfortran", "g95", "frt", "fort", "openf90", "openf95",
              "sunf77", "sunf90", "sunf95",
-              "xlf95", "xlf90", "xlf", 
-              "ppuf77", "ppuf95", "ppuf90", "ppuxlf", 
-             "pathf90", "pathf95", 
+              "xlf95", "xlf90", "xlf",
+              "ppuf77", "ppuf95", "ppuf90", "ppuxlf",
+             "pathf90", "pathf95",
              "pgf95", "pgf90", "pgf77",
+             "flang",
               "ifort");
-    
+
 OUTER:
     foreach $lists (@lists) {
         foreach $path (@path) {
             if (-x $path . "/" . $lists) {
                 $compiler = $lists;
+                $compiler_bin = $lists;
                 last OUTER;
             }
         }
@@ -47,13 +52,13 @@ OUTER:
 if ($compiler eq "") {
 
     $nofortran = 1;
-    $compiler = "g77";
-    $vendor = G77;
+    $compiler = "gfortran";
+    $vendor = GFORTRAN;
     $bu       = "_";
 
 } else {
 
-    $data = `which $compiler > /dev/null 2> /dev/null`;
+    $data = `which $compiler_bin > /dev/null 2> /dev/null`;
     $vendor = "";
 
     if (!$?) {
@@ -74,8 +79,13 @@ if ($compiler eq "") {
                $vendor = GFORTRAN;
                $openmp = "-fopenmp";
            } else {
-               $vendor = G77;
-               $openmp = "";
+               if ($compiler =~ /flang/) {
+                   $vendor = FLANG;
+                   $openmp = "-fopenmp";
+               } else {
+                   $vendor = G77;
+                   $openmp = "";
+               }
            }
 
        }
@@ -87,7 +97,7 @@ if ($compiler eq "") {
 
        if ($data =~ /Intel/) {
            $vendor = INTEL;
-           $openmp = "-openmp";
+           $openmp = "-fopenmp";
        }
 
         if ($data =~ /Sun Fortran/) {
@@ -110,14 +120,14 @@ if ($compiler eq "") {
            $openmp = "-mp";
        }
 
-       if ($data =~ /IBM/) {
+       if ($data =~ /IBM XL/) {
            $vendor = IBM;
            $openmp = "-openmp";
        }
 
-       # for embeded underscore name, e.g. zho_ge, it may append 2 underscores.
+       # for embedded underscore name, e.g. zho_ge, it may append 2 underscores.
        $data = `$compiler -O2 -S ftest3.f > /dev/null 2>&1 && cat ftest3.s && rm -f ftest3.s`;
-       if ($data =~ /zho_ge__/) {
+       if ($data =~ / zho_ge__/) {
            $need2bu       = 1;
        }
     }
@@ -129,43 +139,43 @@ if ($compiler eq "") {
            $bu       = "_";
            $openmp = "";
        }
-       
+
        if ($compiler =~ /g95/) {
            $vendor = G95;
            $bu       = "_";
            $openmp = "";
        }
-       
+
        if ($compiler =~ /gfortran/) {
            $vendor = GFORTRAN;
            $bu       = "_";
            $openmp = "-fopenmp";
        }
-       
+
        if ($compiler =~ /ifort/) {
            $vendor = INTEL;
            $bu       = "_";
-           $openmp = "-openmp";
+           $openmp = "-fopenmp";
        }
-       
+
        if ($compiler =~ /pathf/) {
            $vendor = PATHSCALE;
            $bu       = "_";
            $openmp = "-mp";
        }
-       
+
        if ($compiler =~ /pgf/) {
            $vendor = PGI;
            $bu       = "_";
            $openmp = "-mp";
        }
-       
+
        if ($compiler =~ /ftn/) {
            $vendor = PGI;
            $bu       = "_";
            $openmp = "-openmp";
        }
-       
+
        if ($compiler =~ /frt/) {
            $vendor = FUJITSU;
            $bu       = "_";
@@ -177,12 +187,12 @@ if ($compiler eq "") {
            $bu       = "_";
            $openmp = "-xopenmp=parallel";
        }
-       
+
        if ($compiler =~ /ppuf/) {
            $vendor = IBM;
            $openmp = "-openmp";
        }
-       
+
        if ($compiler =~ /xlf/) {
            $vendor = IBM;
            $openmp = "-openmp";
@@ -193,10 +203,16 @@ if ($compiler eq "") {
            $openmp = "-mp";
        }
 
+       if ($compiler =~ /flang/) {
+           $vendor = FLANG;
+           $bu     = "_";
+           $openmp = "-fopenmp";
+       }
+
        if ($vendor eq "") {
            $nofortran = 1;
-           $compiler = "g77";
-           $vendor = G77;
+           $compiler = "gfortran";
+           $vendor = GFORTRAN;
            $bu       = "_";
            $openmp = "";
        }
@@ -204,43 +220,56 @@ if ($compiler eq "") {
     }
 }
 
-$data = `which $compiler > /dev/null 2> /dev/null`;
+$data = `which $compiler_bin > /dev/null 2> /dev/null`;
 
 if (!$?) {
 
     $binary = $ENV{"BINARY"};
-    
+
     $openmp = "" if $ENV{USE_OPENMP} != 1;
-    
+
     if ($binary == 32) {
        $link = `$compiler $openmp -m32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
        if ($?) {
            $link = `$compiler $openmp -q32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
        }
+        # for AIX
+       if ($?) {
+           $link = `$compiler $openmp -maix32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
+       }
        #For gfortran MIPS
        if ($?) {
-           $link = `$compiler $openmp -mabi=n32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
+    $mips_data = `$compiler_bin -E -dM - < /dev/null`;
+    if ($mips_data =~ /_MIPS_ISA_MIPS64/) {
+        $link = `$compiler $openmp -mabi=n32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
+    } else {
+        $link = `$compiler $openmp -mabi=32 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
+    }
        }
        $binary = "" if ($?);
     }
-    
+
     if ($binary == 64) {
        $link = `$compiler $openmp -m64 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
        if ($?) {
            $link = `$compiler $openmp -q64 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
        }
+        # for AIX
+       if ($?) {
+           $link = `$compiler $openmp -maix64 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
+       }
        #For gfortran MIPS
        if ($?) {
            $link = `$compiler $openmp -mabi=64 -v ftest2.f 2>&1 && rm -f a.out a.exe`;
        }
        $binary = "" if ($?);
     }
-    
+
     if ($binary eq "") {
        $link = `$compiler $openmp -v ftest2.f 2>&1 && rm -f a.out a.exe`;
     }
 }
-    
+
 $linker_L = "";
 $linker_l = "";
 $linker_a = "";
@@ -263,38 +292,35 @@ if ($link ne "") {
            && ($flags !~ /^-LIST:/)
            && ($flags !~ /^-LANG:/)
            ) {
-           if ($vendor eq "PGI") {
-               $flags =~ s/lib$/libso/;
-           }
            $linker_L .= $flags . " ";
        }
-    
+
        if ($flags =~ /^\-Y/) {
+           next if ($hostos eq 'SunOS');
            $linker_L .= "-Wl,". $flags . " ";
-           }
-       
+        }
+
+       if ($flags =~ /^\--exclude-libs/) {
+           $linker_L .= "-Wl,". $flags . " ";
+           $flags="";
+       }
+
+
        if ($flags =~ /^\-rpath\@/) {
            $flags =~ s/\@/\,/g;
-           if ($vendor eq "PGI") {
-               $flags =~ s/lib$/libso/;
-           }
            $linker_L .= "-Wl,". $flags . " " ;
        }
 
        if ($flags =~ /^\-rpath-link\@/) {
            $flags =~ s/\@/\,/g;
-           if ($vendor eq "PGI") {
-               $flags =~ s/lib$/libso/;
-           }
            $linker_L .= "-Wl,". $flags . " " ;
        }
-       
+
        if (
-           ($flags =~ /^\-l/) 
+           ($flags =~ /^\-l/)
            && ($flags !~ /gfortranbegin/)
            && ($flags !~ /frtbegin/)
            && ($flags !~ /pathfstart/)
-           && ($flags !~ /numa/)
            && ($flags !~ /crt[0-9]/)
            && ($flags !~ /gcc/)
            && ($flags !~ /user32/)
@@ -315,6 +341,10 @@ if ($vendor eq "INTEL"){
     $linker_a .= "-lgfortran"
 }
 
+if ($vendor eq "FLANG"){
+    $linker_a .= "-lflang"
+}
+
 open(MAKEFILE, ">> $makefile") || die "Can't append $makefile";
 open(CONFFILE, ">> $config"  ) || die "Can't append $config";