Replace vpermpd with vpermilpd
[platform/upstream/openblas.git] / f_check
diff --git a/f_check b/f_check
index 90ae2fe..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,12 +27,13 @@ $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",
              "pgf95", "pgf90", "pgf77",
+             "flang",
               "ifort");
 
 OUTER:
@@ -37,6 +41,7 @@ OUTER:
         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;
        }
     }
@@ -145,7 +155,7 @@ if ($compiler eq "") {
        if ($compiler =~ /ifort/) {
            $vendor = INTEL;
            $bu       = "_";
-           $openmp = "-openmp";
+           $openmp = "-fopenmp";
        }
 
        if ($compiler =~ /pathf/) {
@@ -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,7 +220,7 @@ if ($compiler eq "") {
     }
 }
 
-$data = `which $compiler > /dev/null 2> /dev/null`;
+$data = `which $compiler_bin > /dev/null 2> /dev/null`;
 
 if (!$?) {
 
@@ -217,9 +233,18 @@ if (!$?) {
        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 ($?);
     }
@@ -229,6 +254,10 @@ if (!$?) {
        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`;
@@ -263,29 +292,27 @@ 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 . " " ;
        }
 
@@ -294,7 +321,6 @@ if ($link ne "") {
            && ($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";