Revert "Merge pull request #5323 from scivision/pgiflang"

This reverts commit 9cd89f55fca0933dd2897ac7470c5827d939e0ac, reversing
changes made to 60969d99d33001317c569a9b37d3b9efae08d387.
diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py
index 4cb7ebf..5de0e59 100644
--- a/mesonbuild/compilers/__init__.py
+++ b/mesonbuild/compilers/__init__.py
@@ -69,8 +69,6 @@
     'IntelCCompiler',
     'IntelCPPCompiler',
     'IntelFortranCompiler',
-    'IntelClCCompiler',
-    'IntelClCPPCompiler',
     'JavaCompiler',
     'LLVMDCompiler',
     'MonoCompiler',
@@ -132,7 +130,6 @@
     GnuCCompiler,
     ElbrusCCompiler,
     IntelCCompiler,
-    IntelClCCompiler,
     PGICCompiler,
     CcrxCCompiler,
     VisualStudioCCompiler,
@@ -146,7 +143,6 @@
     GnuCPPCompiler,
     ElbrusCPPCompiler,
     IntelCPPCompiler,
-    IntelClCPPCompiler,
     PGICPPCompiler,
     CcrxCPPCompiler,
     VisualStudioCPPCompiler,
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 1aeb637..07d18d8 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -1331,9 +1331,9 @@
 
 
 class PGICCompiler(PGICompiler, CCompiler):
-    def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs):
+    def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
         CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
-        PGICompiler.__init__(self, compiler_type)
+        PGICompiler.__init__(self, CompilerType.PGI_STANDARD)
 
 
 class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler):
@@ -1729,12 +1729,6 @@
         self.id = 'clang-cl'
 
 
-class IntelClCCompiler(VisualStudioCCompiler):
-    def __init__(self, exelist, version, is_cross, exe_wrap, target):
-        super().__init__(exelist, version, is_cross, exe_wrap, target)
-        self.id = 'intel'
-
-
 class ArmCCompiler(ArmCompiler, CCompiler):
     def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs):
         CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 2f3c7b7..b03458a 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1413,20 +1413,18 @@
     CCRX_WIN = 40
 
     PGI_STANDARD = 50
-    PGI_OSX = 51
-    PGI_WIN = 52
 
     @property
     def is_standard_compiler(self):
-        return self.name in ('GCC_STANDARD', 'CLANG_STANDARD', 'ICC_STANDARD', 'PGI_STANDARD')
+        return self.name in ('GCC_STANDARD', 'CLANG_STANDARD', 'ICC_STANDARD')
 
     @property
     def is_osx_compiler(self):
-        return self.name in ('GCC_OSX', 'CLANG_OSX', 'ICC_OSX', 'PGI_OSX')
+        return self.name in ('GCC_OSX', 'CLANG_OSX', 'ICC_OSX')
 
     @property
     def is_windows_compiler(self):
-        return self.name in ('GCC_MINGW', 'GCC_CYGWIN', 'CLANG_MINGW', 'ICC_WIN', 'ARM_WIN', 'CCRX_WIN', 'PGI_WIN')
+        return self.name in ('GCC_MINGW', 'GCC_CYGWIN', 'CLANG_MINGW', 'ICC_WIN', 'ARM_WIN', 'CCRX_WIN')
 
 
 def get_macos_dylib_install_name(prefix, shlib_name, suffix, soversion):
@@ -1708,7 +1706,7 @@
 
 
 class PGICompiler:
-    def __init__(self, compiler_type):
+    def __init__(self, compiler_type=None):
         self.id = 'pgi'
         self.compiler_type = compiler_type
 
@@ -1724,11 +1722,6 @@
     def get_no_warn_args(self) -> List[str]:
         return ['-silent']
 
-    def get_pic_args(self) -> List[str]:
-        if self.compiler_type.is_osx_compiler or self.compiler_type.is_windows_compiler:
-            return [] # PGI -fPIC is Linux only.
-        return ['-fPIC']
-
     def openmp_flags(self) -> List[str]:
         return ['-mp']
 
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index a089a5b..6b30a94 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -19,7 +19,7 @@
 from .. import mlog
 from ..mesonlib import MesonException, version_compare
 
-from .c import CCompiler, VisualStudioCCompiler, ClangClCCompiler, IntelClCCompiler
+from .c import CCompiler, VisualStudioCCompiler, ClangClCCompiler
 from .compilers import (
     gnu_winlibs,
     msvc_winlibs,
@@ -256,9 +256,9 @@
 
 
 class PGICPPCompiler(PGICompiler, CPPCompiler):
-    def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs):
+    def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwargs):
         CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs)
-        PGICompiler.__init__(self, compiler_type)
+        PGICompiler.__init__(self, CompilerType.PGI_STANDARD)
 
 
 class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler):
@@ -436,13 +436,6 @@
         VisualStudioCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, target)
         self.id = 'clang-cl'
 
-
-class IntelClCPPCompiler(VisualStudioCPPCompiler, IntelClCCompiler):
-    def __init__(self, exelist, version, is_cross, exe_wrap, target):
-        VisualStudioCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, target)
-        self.id = 'intel'
-
-
 class ArmCPPCompiler(ArmCompiler, CPPCompiler):
     def __init__(self, exelist, version, compiler_type, is_cross, exe_wrap=None, **kwargs):
         CPPCompiler.__init__(self, exelist, version, is_cross, exe_wrap, **kwargs)
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index b4eb327..79de71c 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -422,9 +422,9 @@
 
 
 class PGIFortranCompiler(PGICompiler, FortranCompiler):
-    def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwags):
+    def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags):
         FortranCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwags)
-        PGICompiler.__init__(self, compiler_type)
+        PGICompiler.__init__(self, CompilerType.PGI_STANDARD)
 
     def language_stdlib_only_link_flags(self) -> List[str]:
         return ['-lpgf90rtl', '-lpgf90', '-lpgf90_rpm1', '-lpgf902',
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 462672e..e7bf576 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -12,13 +12,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import os, platform, re, sys, shlex, shutil, subprocess, typing
+import configparser, os, platform, re, sys, shlex, shutil, subprocess
+import typing
 
 from . import coredata
 from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker
 from . import mesonlib
 from .mesonlib import (
-    MesonException, EnvironmentException, MachineChoice, Popen_safe,
+    MesonException, EnvironmentException, MachineChoice, PerMachine, Popen_safe,
 )
 from . import mlog
 
@@ -38,6 +39,7 @@
     is_source,
 )
 from .compilers import (
+    Compiler,
     ArmCCompiler,
     ArmCPPCompiler,
     ArmclangCCompiler,
@@ -61,8 +63,6 @@
     IntelCCompiler,
     IntelCPPCompiler,
     IntelFortranCompiler,
-    IntelClCCompiler,
-    IntelClCPPCompiler,
     JavaCompiler,
     MonoCompiler,
     CudaCompiler,
@@ -458,13 +458,11 @@
 
         # List of potential compilers.
         if mesonlib.is_windows():
-            # Intel C and C++ compiler is icl on Windows, but icc and icpc elsewhere.
-            self.default_c = ['cl', 'cc', 'gcc', 'clang', 'clang-cl', 'pgcc', 'icl']
-            # There is currently no pgc++ for Windows, only for  Mac and Linux.
-            self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl', 'icl']
+            self.default_c = ['cl', 'cc', 'gcc', 'clang', 'clang-cl', 'pgcc']
+            self.default_cpp = ['cl', 'c++', 'g++', 'clang++', 'clang-cl', 'pgc++']
         else:
-            self.default_c = ['cc', 'gcc', 'clang', 'pgcc', 'icc']
-            self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++', 'icpc']
+            self.default_c = ['cc', 'gcc', 'clang', 'pgcc']
+            self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++']
         if mesonlib.is_windows():
             self.default_cs = ['csc', 'mcs']
         else:
@@ -472,7 +470,7 @@
         self.default_objc = ['cc']
         self.default_objcpp = ['c++']
         self.default_d = ['ldc2', 'ldc', 'gdc', 'dmd']
-        self.default_fortran = ['gfortran', 'flang', 'pgfortran', 'ifort', 'g95']
+        self.default_fortran = ['gfortran', 'g95', 'f95', 'f90', 'f77', 'ifort', 'pgfortran']
         self.default_java = ['javac']
         self.default_cuda = ['nvcc']
         self.default_rust = ['rustc']
@@ -681,7 +679,6 @@
                 arg = '-v'
             else:
                 arg = '--version'
-
             try:
                 p, out, err = Popen_safe(compiler + [arg])
             except OSError as e:
@@ -690,11 +687,6 @@
 
             if 'ccrx' in compiler[0]:
                 out = err
-            if 'icl' in compiler[0]:
-                # https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-alphabetical-list-of-compiler-options
-                # https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-logo
-                # most consistent way for ICL is to just let compiler error and tell version
-                out = err
 
             full_version = out.split('\n', 1)[0]
             version = search_version(out)
@@ -780,29 +772,19 @@
                     target = 'x86'
                 cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler
                 return cls(compiler, version, is_cross, exe_wrap, target)
-
             if 'PGI Compilers' in out:
-                if mesonlib.for_darwin(is_cross, self):
-                    compiler_type = CompilerType.PGI_OSX
-                elif mesonlib.for_windows(is_cross, self):
-                    compiler_type = CompilerType.PGI_WIN
-                else:
-                    compiler_type = CompilerType.PGI_STANDARD
                 cls = PGICCompiler if lang == 'c' else PGICPPCompiler
-                return cls(ccache + compiler, version, compiler_type, is_cross, exe_wrap)
+                return cls(ccache + compiler, version, is_cross, exe_wrap)
             if '(ICC)' in out:
                 if mesonlib.for_darwin(want_cross, self):
                     compiler_type = CompilerType.ICC_OSX
                 elif mesonlib.for_windows(want_cross, self):
-                    raise EnvironmentException('At the time of authoring, there was no ICC for Windows')
+                    # TODO: fix ICC on Windows
+                    compiler_type = CompilerType.ICC_WIN
                 else:
                     compiler_type = CompilerType.ICC_STANDARD
                 cls = IntelCCompiler if lang == 'c' else IntelCPPCompiler
                 return cls(ccache + compiler, version, compiler_type, is_cross, exe_wrap, full_version=full_version)
-            if out.startswith('Intel(R) C++') and mesonlib.for_windows(want_cross, self):
-                cls = IntelClCCompiler if lang == 'c' else IntelClCPPCompiler
-                target = 'x64' if 'Intel(R) 64 Compiler' in out else 'x86'
-                return cls(compiler, version, is_cross, exe_wrap, target)
             if 'ARM' in out:
                 compiler_type = CompilerType.ARM_WIN
                 cls = ArmCCompiler if lang == 'c' else ArmCPPCompiler
@@ -867,13 +849,6 @@
                     popen_exceptions[' '.join(compiler + [arg])] = e
                     continue
 
-                if mesonlib.for_windows(is_cross, self):
-                    if 'ifort' in compiler[0]:
-                        # https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-alphabetical-list-of-compiler-options
-                        # https://software.intel.com/en-us/fortran-compiler-developer-guide-and-reference-logo
-                        # most consistent way for ICL is to just let compiler error and tell version
-                        out = err
-
                 version = search_version(out)
                 full_version = out.split('\n', 1)[0]
 
@@ -904,20 +879,14 @@
                     version = search_version(err)
                     return SunFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version)
 
-                if 'ifort (IFORT)' in out or out.startswith('Intel(R) Visual Fortran'):
+                if 'ifort (IFORT)' in out:
                     return IntelFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version)
 
                 if 'PathScale EKOPath(tm)' in err:
                     return PathScaleFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version)
 
                 if 'PGI Compilers' in out:
-                    if mesonlib.for_darwin(is_cross, self):
-                        compiler_type = CompilerType.PGI_OSX
-                    elif mesonlib.for_windows(is_cross, self):
-                        compiler_type = CompilerType.PGI_WIN
-                    else:
-                        compiler_type = CompilerType.PGI_STANDARD
-                    return PGIFortranCompiler(compiler, version, compiler_type, is_cross, exe_wrap, full_version=full_version)
+                    return PGIFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version)
 
                 if 'flang' in out or 'clang' in out:
                     return FlangFortranCompiler(compiler, version, is_cross, exe_wrap, full_version=full_version)
@@ -1073,8 +1042,7 @@
         # up to date language version at time (2016).
         if exelist is not None:
             if os.path.basename(exelist[-1]).startswith(('ldmd', 'gdmd')):
-                raise EnvironmentException('Meson does not support {} as it is only a DMD frontend for another compiler.'
-                                           'Please provide a valid value for DC or unset it so that Meson can resolve the compiler by itself.'.format(exelist[-1]))
+                    raise EnvironmentException('Meson doesn\'t support %s as it\'s only a DMD frontend for another compiler. Please provide a valid value for DC or unset it so that Meson can resolve the compiler by itself.' % exelist[-1])
         else:
             for d in self.default_d:
                 if shutil.which(d):