diff options
Diffstat (limited to 'fcompiler')
-rw-r--r-- | fcompiler/__init__.py | 890 | ||||
-rw-r--r-- | fcompiler/absoft.py | 154 | ||||
-rw-r--r-- | fcompiler/compaq.py | 105 | ||||
-rw-r--r-- | fcompiler/g95.py | 51 | ||||
-rw-r--r-- | fcompiler/gnu.py | 330 | ||||
-rw-r--r-- | fcompiler/hpux.py | 44 | ||||
-rw-r--r-- | fcompiler/ibm.py | 100 | ||||
-rw-r--r-- | fcompiler/intel.py | 215 | ||||
-rw-r--r-- | fcompiler/lahey.py | 49 | ||||
-rw-r--r-- | fcompiler/mips.py | 59 | ||||
-rw-r--r-- | fcompiler/nag.py | 46 | ||||
-rw-r--r-- | fcompiler/none.py | 31 | ||||
-rw-r--r-- | fcompiler/pg.py | 45 | ||||
-rw-r--r-- | fcompiler/sun.py | 54 | ||||
-rw-r--r-- | fcompiler/vast.py | 53 |
15 files changed, 0 insertions, 2226 deletions
diff --git a/fcompiler/__init__.py b/fcompiler/__init__.py deleted file mode 100644 index ab59372b7..000000000 --- a/fcompiler/__init__.py +++ /dev/null @@ -1,890 +0,0 @@ -"""numpy.distutils.fcompiler - -Contains FCompiler, an abstract base class that defines the interface -for the numpy.distutils Fortran compiler abstraction model. -""" - -__all__ = ['FCompiler','new_fcompiler','show_fcompilers', - 'dummy_fortran_file'] - -import os -import sys -import re -import new -try: - set -except NameError: - from sets import Set as set - -from distutils.sysconfig import get_config_var, get_python_lib -from distutils.fancy_getopt import FancyGetopt -from distutils.errors import DistutilsModuleError,DistutilsArgError,\ - DistutilsExecError,CompileError,LinkError,DistutilsPlatformError -from distutils.util import split_quoted - -from numpy.distutils.ccompiler import CCompiler, gen_lib_options -from numpy.distutils import log -from numpy.distutils.misc_util import is_string, is_sequence -from numpy.distutils.environment import EnvironmentConfig -from numpy.distutils.exec_command import find_executable -from distutils.spawn import _nt_quote_args - -__metaclass__ = type - -class CompilerNotFound(Exception): - pass - -class FCompiler(CCompiler): - """ Abstract base class to define the interface that must be implemented - by real Fortran compiler classes. - - Methods that subclasses may redefine: - - find_executables(), get_version_cmd(), get_linker_so(), get_version() - get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug() - get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(), - get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(), - get_flags_arch_f90(), get_flags_debug_f90(), - get_flags_fix(), get_flags_linker_so(), get_flags_version() - - DON'T call these methods (except get_version) after - constructing a compiler instance or inside any other method. - All methods, except get_version_cmd() and get_flags_version(), may - call the get_version() method. - - After constructing a compiler instance, always call customize(dist=None) - method that finalizes compiler construction and makes the following - attributes available: - compiler_f77 - compiler_f90 - compiler_fix - linker_so - archiver - ranlib - libraries - library_dirs - """ - - # These are the environment variables and distutils keys used. - # Each configuration descripition is - # (<hook name>, <environment variable>, <key in distutils.cfg>) - # The hook names are handled by the self._environment_hook method. - # - names starting with 'self.' call methods in this class - # - names starting with 'exe.' return the key in the executables dict - # - names like'flags.YYY' return self.get_flag_YYY() - - distutils_vars = EnvironmentConfig( - noopt = (None, None, 'noopt'), - noarch = (None, None, 'noarch'), - debug = (None, None, 'debug'), - verbose = (None, None, 'verbose'), - ) - - command_vars = EnvironmentConfig( - distutils_section='config_fc', - compiler_f77 = ('exe.compiler_f77', 'F77', 'f77exec'), - compiler_f90 = ('exe.compiler_f90', 'F90', 'f90exec'), - compiler_fix = ('exe.compiler_fix', 'F90', 'f90exec'), - version_cmd = ('self.get_version_cmd', None, None), - linker_so = ('self.get_linker_so', 'LDSHARED', 'ldshared'), - linker_exe = ('self.get_linker_exe', 'LD', 'ld'), - archiver = (None, 'AR', 'ar'), - ranlib = (None, 'RANLIB', 'ranlib'), - ) - - flag_vars = EnvironmentConfig( - distutils_section='config_fc', - version = ('flags.version', None, None), - f77 = ('flags.f77', 'F77FLAGS', 'f77flags'), - f90 = ('flags.f90', 'F90FLAGS', 'f90flags'), - free = ('flags.free', 'FREEFLAGS', 'freeflags'), - fix = ('flags.fix', None, None), - opt = ('flags.opt', 'FOPT', 'opt'), - opt_f77 = ('flags.opt_f77', None, None), - opt_f90 = ('flags.opt_f90', None, None), - arch = ('flags.arch', 'FARCH', 'arch'), - arch_f77 = ('flags.arch_f77', None, None), - arch_f90 = ('flags.arch_f90', None, None), - debug = ('flags.debug', 'FDEBUG', None, None), - debug_f77 = ('flags.debug_f77', None, None), - debug_f90 = ('flags.debug_f90', None, None), - flags = ('self.get_flags', 'FFLAGS', 'fflags'), - linker_so = ('flags.linker_so', 'LDFLAGS', 'ldflags'), - linker_exe = ('flags.linker_exe', 'LDFLAGS', 'ldflags'), - ar = ('flags.ar', 'ARFLAGS', 'arflags'), - ) - - language_map = {'.f':'f77', - '.for':'f77', - '.F':'f77', # XXX: needs preprocessor - '.ftn':'f77', - '.f77':'f77', - '.f90':'f90', - '.F90':'f90', # XXX: needs preprocessor - '.f95':'f90', - } - language_order = ['f90','f77'] - - version_pattern = None - - possible_executables = [] - executables = { - 'version_cmd' : ["f77", "-v"], - 'compiler_f77' : ["f77"], - 'compiler_f90' : ["f90"], - 'compiler_fix' : ["f90", "-fixed"], - 'linker_so' : ["f90", "-shared"], - 'linker_exe' : ["f90"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : None, - } - - compile_switch = "-c" - object_switch = "-o " # Ending space matters! It will be stripped - # but if it is missing then object_switch - # will be prefixed to object file name by - # string concatenation. - library_switch = "-o " # Ditto! - - # Switch to specify where module files are created and searched - # for USE statement. Normally it is a string and also here ending - # space matters. See above. - module_dir_switch = None - - # Switch to specify where module files are searched for USE statement. - module_include_switch = '-I' - - pic_flags = [] # Flags to create position-independent code - - src_extensions = ['.for','.ftn','.f77','.f','.f90','.f95','.F','.F90'] - obj_extension = ".o" - shared_lib_extension = get_config_var('SO') # or .dll - static_lib_extension = ".a" # or .lib - static_lib_format = "lib%s%s" # or %s%s - shared_lib_format = "%s%s" - exe_extension = "" - - def __init__(self, *args, **kw): - CCompiler.__init__(self, *args, **kw) - self.distutils_vars = self.distutils_vars.clone(self._environment_hook) - self.command_vars = self.command_vars.clone(self._environment_hook) - self.flag_vars = self.flag_vars.clone(self._environment_hook) - self.executables = self.executables.copy() - for e in ['version_cmd', 'compiler_f77', 'compiler_f90', - 'compiler_fix', 'linker_so', 'linker_exe', 'archiver', - 'ranlib']: - if e not in self.executables: - self.executables[e] = None - - def __copy__(self): - obj = new.instance(self.__class__, self.__dict__) - obj.distutils_vars = obj.distutils_vars.clone(obj._environment_hook) - obj.command_vars = obj.command_vars.clone(obj._environment_hook) - obj.flag_vars = obj.flag_vars.clone(obj._environment_hook) - obj.executables = obj.executables.copy() - return obj - - # If compiler does not support compiling Fortran 90 then it can - # suggest using another compiler. For example, gnu would suggest - # gnu95 compiler type when there are F90 sources. - suggested_f90_compiler = None - - ###################################################################### - ## Methods that subclasses may redefine. But don't call these methods! - ## They are private to FCompiler class and may return unexpected - ## results if used elsewhere. So, you have been warned.. - - def find_executables(self): - """Go through the self.executables dictionary, and attempt to - find and assign appropiate executables. - - Executable names are looked for in the environment (environment - variables, the distutils.cfg, and command line), the 0th-element of - the command list, and the self.possible_executables list. - - Also, if the 0th element is "<F77>" or "<F90>", the Fortran 77 - or the Fortran 90 compiler executable is used, unless overridden - by an environment setting. - """ - exe_cache = {} - def cached_find_executable(exe): - if exe in exe_cache: - return exe_cache[exe] - fc_exe = find_executable(exe) - exe_cache[exe] = fc_exe - return fc_exe - def set_exe(exe_key, f77=None, f90=None): - cmd = self.executables.get(exe_key, None) - if not cmd: - return None - # Note that we get cmd[0] here if the environment doesn't - # have anything set - exe_from_environ = getattr(self.command_vars, exe_key) - if not exe_from_environ: - possibles = [f90, f77] + self.possible_executables - else: - possibles = [exe_from_environ] + self.possible_executables - - seen = set() - unique_possibles = [] - for e in possibles: - if e == '<F77>': - e = f77 - elif e == '<F90>': - e = f90 - if not e or e in seen: - continue - seen.add(e) - unique_possibles.append(e) - - for exe in unique_possibles: - fc_exe = cached_find_executable(exe) - if fc_exe: - cmd[0] = fc_exe - return fc_exe - return None - - f90 = set_exe('compiler_f90') - if not f90: - raise CompilerNotFound('f90') - f77 = set_exe('compiler_f77', f90=f90) - if not f77: - raise CompilerNotFound('f90') - set_exe('compiler_fix', f90=f90) - - set_exe('linker_so', f77=f77, f90=f90) - set_exe('linker_exe', f77=f77, f90=f90) - set_exe('version_cmd', f77=f77, f90=f90) - - set_exe('archiver') - set_exe('ranlib') - - def get_version_cmd(self): - """Compiler command to print out version information.""" - cmd = self.executables['version_cmd'] - if cmd: - return cmd[0] - else: - return None - - def get_linker_so(self): - """Linker command to build shared libraries.""" - cmd = self.executables['linker_so'] - if cmd: - return cmd[0] - else: - return None - - def get_linker_exe(self): - """Linker command to build shared libraries.""" - cmd = self.executables['linker_exe'] - if cmd: - return cmd[0] - else: - return None - - def get_flags(self): - """ List of flags common to all compiler types. """ - return [] + self.pic_flags - def get_flags_version(self): - """ List of compiler flags to print out version information. """ - if self.executables['version_cmd']: - return self.executables['version_cmd'][1:] - return [] - def get_flags_f77(self): - """ List of Fortran 77 specific flags. """ - if self.executables['compiler_f77']: - return self.executables['compiler_f77'][1:] - return [] - def get_flags_f90(self): - """ List of Fortran 90 specific flags. """ - if self.executables['compiler_f90']: - return self.executables['compiler_f90'][1:] - return [] - def get_flags_free(self): - """ List of Fortran 90 free format specific flags. """ - return [] - def get_flags_fix(self): - """ List of Fortran 90 fixed format specific flags. """ - if self.executables['compiler_fix']: - return self.executables['compiler_fix'][1:] - return [] - def get_flags_linker_so(self): - """ List of linker flags to build a shared library. """ - if self.executables['linker_so']: - return self.executables['linker_so'][1:] - return [] - def get_flags_linker_exe(self): - """ List of linker flags to build an executable. """ - if self.executables['linker_exe']: - return self.executables['linker_exe'][1:] - return [] - def get_flags_ar(self): - """ List of archiver flags. """ - if self.executables['archiver']: - return self.executables['archiver'][1:] - return [] - def get_flags_opt(self): - """ List of architecture independent compiler flags. """ - return [] - def get_flags_arch(self): - """ List of architecture dependent compiler flags. """ - return [] - def get_flags_debug(self): - """ List of compiler flags to compile with debugging information. """ - return [] - - get_flags_opt_f77 = get_flags_opt_f90 = get_flags_opt - get_flags_arch_f77 = get_flags_arch_f90 = get_flags_arch - get_flags_debug_f77 = get_flags_debug_f90 = get_flags_debug - - def get_libraries(self): - """ List of compiler libraries. """ - return self.libraries[:] - def get_library_dirs(self): - """ List of compiler library directories. """ - return self.library_dirs[:] - - ############################################################ - - ## Public methods: - - def customize(self, dist): - """ Customize Fortran compiler. - - This method gets Fortran compiler specific information from - (i) class definition, (ii) environment, (iii) distutils config - files, and (iv) command line. - - This method should be always called after constructing a - compiler instance. But not in __init__ because Distribution - instance is needed for (iii) and (iv). - """ - log.info('customize %s' % (self.__class__.__name__)) - self.distutils_vars.use_distribution(dist) - self.command_vars.use_distribution(dist) - self.flag_vars.use_distribution(dist) - - self.find_executables() - - noopt = self.distutils_vars.get('noopt', False) - if 0: # change to `if 1:` when making release. - # Don't use architecture dependent compiler flags: - noarch = True - else: - noarch = self.distutils_vars.get('noarch', noopt) - debug = self.distutils_vars.get('debug', False) - - f77 = self.command_vars.compiler_f77 - f90 = self.command_vars.compiler_f90 - - # Must set version_cmd before others as self.get_flags* - # methods may call self.get_version. - vers_cmd = self.command_vars.version_cmd - if vers_cmd: - vflags = self.flag_vars.version - self.set_executables(version_cmd=[vers_cmd]+vflags) - - f77flags = [] - f90flags = [] - freeflags = [] - fixflags = [] - - if f77: - f77flags = self.flag_vars.f77 - if f90: - f90flags = self.flag_vars.f90 - freeflags = self.flag_vars.free - # XXX Assuming that free format is default for f90 compiler. - fix = self.command_vars.compiler_fix - if fix: - fixflags = self.flag_vars.fix + f90flags - - oflags, aflags, dflags = [], [], [] - def to_list(flags): - if is_string(flags): - return [flags] - return flags - # examine get_flags_<tag>_<compiler> for extra flags - # only add them if the method is different from get_flags_<tag> - def get_flags(tag, flags): - # note that self.flag_vars.<tag> calls self.get_flags_<tag>() - flags.extend(to_list(getattr(self.flag_vars, tag))) - this_get = getattr(self, 'get_flags_' + tag) - for name, c, flagvar in [('f77', f77, f77flags), - ('f90', f90, f90flags), - ('f90', fix, fixflags)]: - t = '%s_%s' % (tag, name) - if c and this_get is not getattr(self, 'get_flags_' + t): - flagvar.extend(to_list(getattr(self.flag_vars, t))) - return oflags - if not noopt: - get_flags('opt', oflags) - if not noarch: - get_flags('arch', aflags) - if debug: - get_flags('debug', dflags) - - fflags = to_list(self.flag_vars.flags) + dflags + oflags + aflags - - if f77: - self.set_executables(compiler_f77=[f77]+f77flags+fflags) - if f90: - self.set_executables(compiler_f90=[f90]+freeflags+f90flags+fflags) - if fix: - self.set_executables(compiler_fix=[fix]+fixflags+fflags) - - #XXX: Do we need LDSHARED->SOSHARED, LDFLAGS->SOFLAGS - linker_so = self.command_vars.linker_so - if linker_so: - linker_so_flags = to_list(self.flag_vars.linker_so) - if sys.platform.startswith('aix'): - python_lib = get_python_lib(standard_lib=1) - ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') - python_exp = os.path.join(python_lib, 'config', 'python.exp') - linker_so = [ld_so_aix, linker_so, '-bI:'+python_exp] - else: - linker_so = [linker_so] - self.set_executables(linker_so=linker_so+linker_so_flags) - - linker_exe = self.command_vars.linker_exe - if linker_exe: - linker_exe_flags = to_list(self.flag_vars.linker_exe) - self.set_executables(linker_exe=[linker_exe]+linker_exe_flags) - - ar = self.command_vars.archiver - if ar: - arflags = to_list(self.flag_vars.ar) - self.set_executables(archiver=[ar]+arflags) - - ranlib = self.command_vars.ranlib - if ranlib: - self.set_executables(ranlib=[ranlib]) - - self.set_library_dirs(self.get_library_dirs()) - self.set_libraries(self.get_libraries()) - - def dump_properties(self): - """ Print out the attributes of a compiler instance. """ - props = [] - for key in self.executables.keys() + \ - ['version','libraries','library_dirs', - 'object_switch','compile_switch']: - if hasattr(self,key): - v = getattr(self,key) - props.append((key, None, '= '+repr(v))) - props.sort() - - pretty_printer = FancyGetopt(props) - for l in pretty_printer.generate_help("%s instance properties:" \ - % (self.__class__.__name__)): - if l[:4]==' --': - l = ' ' + l[4:] - print l - return - - ################### - - def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): - """Compile 'src' to product 'obj'.""" - src_flags = {} - if is_f_file(src) and not has_f90_header(src): - flavor = ':f77' - compiler = self.compiler_f77 - src_flags = get_f77flags(src) - elif is_free_format(src): - flavor = ':f90' - compiler = self.compiler_f90 - if compiler is None: - raise DistutilsExecError, 'f90 not supported by %s needed for %s'\ - % (self.__class__.__name__,src) - else: - flavor = ':fix' - compiler = self.compiler_fix - if compiler is None: - raise DistutilsExecError, 'f90 (fixed) not supported by %s needed for %s'\ - % (self.__class__.__name__,src) - if self.object_switch[-1]==' ': - o_args = [self.object_switch.strip(),obj] - else: - o_args = [self.object_switch.strip()+obj] - - assert self.compile_switch.strip() - s_args = [self.compile_switch, src] - - extra_flags = src_flags.get(self.compiler_type,[]) - if extra_flags: - log.info('using compile options from source: %r' \ - % ' '.join(extra_flags)) - - if os.name == 'nt': - compiler = _nt_quote_args(compiler) - command = compiler + cc_args + extra_flags + s_args + o_args \ - + extra_postargs - - display = '%s: %s' % (os.path.basename(compiler[0]) + flavor, - src) - try: - self.spawn(command,display=display) - except DistutilsExecError, msg: - raise CompileError, msg - - return - - def module_options(self, module_dirs, module_build_dir): - options = [] - if self.module_dir_switch is not None: - if self.module_dir_switch[-1]==' ': - options.extend([self.module_dir_switch.strip(),module_build_dir]) - else: - options.append(self.module_dir_switch.strip()+module_build_dir) - else: - print 'XXX: module_build_dir=%r option ignored' % (module_build_dir) - print 'XXX: Fix module_dir_switch for ',self.__class__.__name__ - if self.module_include_switch is not None: - for d in [module_build_dir]+module_dirs: - options.append('%s%s' % (self.module_include_switch, d)) - else: - print 'XXX: module_dirs=%r option ignored' % (module_dirs) - print 'XXX: Fix module_include_switch for ',self.__class__.__name__ - return options - - def library_option(self, lib): - return "-l" + lib - def library_dir_option(self, dir): - return "-L" + dir - - def link(self, target_desc, objects, - output_filename, output_dir=None, libraries=None, - library_dirs=None, runtime_library_dirs=None, - export_symbols=None, debug=0, extra_preargs=None, - extra_postargs=None, build_temp=None, target_lang=None): - objects, output_dir = self._fix_object_args(objects, output_dir) - libraries, library_dirs, runtime_library_dirs = \ - self._fix_lib_args(libraries, library_dirs, runtime_library_dirs) - - lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, - libraries) - if is_string(output_dir): - output_filename = os.path.join(output_dir, output_filename) - elif output_dir is not None: - raise TypeError, "'output_dir' must be a string or None" - - if self._need_link(objects, output_filename): - if self.library_switch[-1]==' ': - o_args = [self.library_switch.strip(),output_filename] - else: - o_args = [self.library_switch.strip()+output_filename] - - if is_string(self.objects): - ld_args = objects + [self.objects] - else: - ld_args = objects + self.objects - ld_args = ld_args + lib_opts + o_args - if debug: - ld_args[:0] = ['-g'] - if extra_preargs: - ld_args[:0] = extra_preargs - if extra_postargs: - ld_args.extend(extra_postargs) - self.mkpath(os.path.dirname(output_filename)) - if target_desc == CCompiler.EXECUTABLE: - linker = self.linker_exe[:] - else: - linker = self.linker_so[:] - if os.name == 'nt': - linker = _nt_quote_args(linker) - command = linker + ld_args - try: - self.spawn(command) - except DistutilsExecError, msg: - raise LinkError, msg - else: - log.debug("skipping %s (up-to-date)", output_filename) - return - - def _environment_hook(self, name, hook_name): - if hook_name is None: - return None - if is_string(hook_name): - if hook_name.startswith('self.'): - hook_name = hook_name[5:] - hook = getattr(self, hook_name) - return hook() - elif hook_name.startswith('exe.'): - hook_name = hook_name[4:] - var = self.executables[hook_name] - if var: - return var[0] - else: - return None - elif hook_name.startswith('flags.'): - hook_name = hook_name[6:] - hook = getattr(self, 'get_flags_' + hook_name) - return hook() - else: - return hook_name() - - ## class FCompiler - -_default_compilers = ( - # Platform mappings - ('win32', ('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')), - ('cygwin.*', ('gnu','intelv','absoft','compaqv','intelev','gnu95','g95')), - ('linux.*', ('gnu','intel','lahey','pg','absoft','nag','vast','compaq', - 'intele','intelem','gnu95','g95')), - ('darwin.*', ('nag', 'absoft', 'ibm', 'intel', 'gnu', 'gnu95', 'g95')), - ('sunos.*', ('sun','gnu','gnu95','g95')), - ('irix.*', ('mips','gnu','gnu95',)), - ('aix.*', ('ibm','gnu','gnu95',)), - # OS mappings - ('posix', ('gnu','gnu95',)), - ('nt', ('gnu','gnu95',)), - ('mac', ('gnu','gnu95',)), - ) - -fcompiler_class = None - -def load_all_fcompiler_classes(): - """Cache all the FCompiler classes found in modules in the - numpy.distutils.fcompiler package. - """ - from glob import glob - global fcompiler_class - if fcompiler_class is not None: - return - pys = os.path.join(os.path.dirname(__file__), '*.py') - fcompiler_class = {} - for fname in glob(pys): - module_name, ext = os.path.splitext(os.path.basename(fname)) - module_name = 'numpy.distutils.fcompiler.' + module_name - __import__ (module_name) - module = sys.modules[module_name] - if hasattr(module, 'compilers'): - for cname in module.compilers: - klass = getattr(module, cname) - fcompiler_class[klass.compiler_type] = (klass.compiler_type, - klass, - klass.description) - -def _find_existing_fcompiler(compiler_types, osname=None, platform=None, - requiref90=False): - from numpy.distutils.core import get_distribution - dist = get_distribution(always=True) - for compiler_type in compiler_types: - v = None - try: - c = new_fcompiler(plat=platform, compiler=compiler_type) - c.customize(dist) - v = c.get_version() - if requiref90 and c.compiler_f90 is None: - v = None - new_compiler = c.suggested_f90_compiler - if new_compiler: - log.warn('Trying %r compiler as suggested by %r ' - 'compiler for f90 support.' % (compiler, - new_compiler)) - c = new_fcompiler(plat=platform, compiler=new_compiler) - c.customize(dist) - v = c.get_version() - if v is not None: - compiler_type = new_compiler - if requiref90 and c.compiler_f90 is None: - raise ValueError('%s does not support compiling f90 codes, ' - 'skipping.' % (c.__class__.__name__)) - except DistutilsModuleError: - pass - except CompilerNotFound: - pass - if v is not None: - return compiler_type - return None - -def available_fcompilers_for_platform(osname=None, platform=None): - if osname is None: - osname = os.name - if platform is None: - platform = sys.platform - matching_compiler_types = [] - for pattern, compiler_type in _default_compilers: - if re.match(pattern, platform) or re.match(pattern, osname): - for ct in compiler_type: - if ct not in matching_compiler_types: - matching_compiler_types.append(ct) - if not matching_compiler_types: - matching_compiler_types.append('gnu') - return matching_compiler_types - -def get_default_fcompiler(osname=None, platform=None, requiref90=False): - """Determine the default Fortran compiler to use for the given - platform.""" - matching_compiler_types = available_fcompilers_for_platform(osname, - platform) - compiler_type = _find_existing_fcompiler(matching_compiler_types, - osname=osname, - platform=platform, - requiref90=requiref90) - return compiler_type - -def new_fcompiler(plat=None, - compiler=None, - verbose=0, - dry_run=0, - force=0, - requiref90=False): - """Generate an instance of some FCompiler subclass for the supplied - platform/compiler combination. - """ - load_all_fcompiler_classes() - if plat is None: - plat = os.name - if compiler is None: - compiler = get_default_fcompiler(plat, requiref90=requiref90) - try: - module_name, klass, long_description = fcompiler_class[compiler] - except KeyError: - msg = "don't know how to compile Fortran code on platform '%s'" % plat - if compiler is not None: - msg = msg + " with '%s' compiler." % compiler - msg = msg + " Supported compilers are: %s)" \ - % (','.join(fcompiler_class.keys())) - raise DistutilsPlatformError, msg - - compiler = klass(verbose=verbose, dry_run=dry_run, force=force) - return compiler - -def show_fcompilers(dist=None): - """Print list of available compilers (used by the "--help-fcompiler" - option to "config_fc"). - """ - if dist is None: - from distutils.dist import Distribution - from numpy.distutils.command.config_compiler import config_fc - dist = Distribution() - dist.script_name = os.path.basename(sys.argv[0]) - dist.script_args = ['config_fc'] + sys.argv[1:] - try: - dist.script_args.remove('--help-fcompiler') - except ValueError: - pass - dist.cmdclass['config_fc'] = config_fc - dist.parse_config_files() - dist.parse_command_line() - compilers = [] - compilers_na = [] - compilers_ni = [] - if not fcompiler_class: - load_all_fcompiler_classes() - platform_compilers = available_fcompilers_for_platform() - for compiler in platform_compilers: - v = None - log.set_verbosity(-2) - try: - c = new_fcompiler(compiler=compiler, verbose=dist.verbose) - c.customize(dist) - v = c.get_version() - except (DistutilsModuleError, CompilerNotFound): - pass - - if v is None: - compilers_na.append(("fcompiler="+compiler, None, - fcompiler_class[compiler][2])) - else: - c.dump_properties() - compilers.append(("fcompiler="+compiler, None, - fcompiler_class[compiler][2] + ' (%s)' % v)) - - compilers_ni = list(set(fcompiler_class.keys()) - set(platform_compilers)) - compilers_ni = [("fcompiler="+fc, None, fcompiler_class[fc][2]) - for fc in compilers_ni] - - compilers.sort() - compilers_na.sort() - compilers_ni.sort() - pretty_printer = FancyGetopt(compilers) - pretty_printer.print_help("Fortran compilers found:") - pretty_printer = FancyGetopt(compilers_na) - pretty_printer.print_help("Compilers available for this " - "platform, but not found:") - if compilers_ni: - pretty_printer = FancyGetopt(compilers_ni) - pretty_printer.print_help("Compilers not available on this platform:") - print "For compiler details, run 'config_fc --verbose' setup command." - -def dummy_fortran_file(): - import atexit - import tempfile - dummy_name = tempfile.mktemp()+'__dummy' - dummy = open(dummy_name+'.f','w') - dummy.write(" subroutine dummy()\n end\n") - dummy.close() - def rm_file(name=dummy_name,log_threshold=log._global_log.threshold): - save_th = log._global_log.threshold - log.set_threshold(log_threshold) - try: os.remove(name+'.f'); log.debug('removed '+name+'.f') - except OSError: pass - try: os.remove(name+'.o'); log.debug('removed '+name+'.o') - except OSError: pass - log.set_threshold(save_th) - atexit.register(rm_file) - return dummy_name - -is_f_file = re.compile(r'.*[.](for|ftn|f77|f)\Z',re.I).match -_has_f_header = re.compile(r'-[*]-\s*fortran\s*-[*]-',re.I).search -_has_f90_header = re.compile(r'-[*]-\s*f90\s*-[*]-',re.I).search -_has_fix_header = re.compile(r'-[*]-\s*fix\s*-[*]-',re.I).search -_free_f90_start = re.compile(r'[^c*!]\s*[^\s\d\t]',re.I).match - -def is_free_format(file): - """Check if file is in free format Fortran.""" - # f90 allows both fixed and free format, assuming fixed unless - # signs of free format are detected. - result = 0 - f = open(file,'r') - line = f.readline() - n = 10000 # the number of non-comment lines to scan for hints - if _has_f_header(line): - n = 0 - elif _has_f90_header(line): - n = 0 - result = 1 - while n>0 and line: - line = line.rstrip() - if line and line[0]!='!': - n -= 1 - if (line[0]!='\t' and _free_f90_start(line[:5])) or line[-1:]=='&': - result = 1 - break - line = f.readline() - f.close() - return result - -def has_f90_header(src): - f = open(src,'r') - line = f.readline() - f.close() - return _has_f90_header(line) or _has_fix_header(line) - -_f77flags_re = re.compile(r'(c|)f77flags\s*\(\s*(?P<fcname>\w+)\s*\)\s*=\s*(?P<fflags>.*)',re.I) -def get_f77flags(src): - """ - Search the first 20 lines of fortran 77 code for line pattern - `CF77FLAGS(<fcompiler type>)=<f77 flags>` - Return a dictionary {<fcompiler type>:<f77 flags>}. - """ - flags = {} - f = open(src,'r') - i = 0 - for line in f.readlines(): - i += 1 - if i>20: break - m = _f77flags_re.match(line) - if not m: continue - fcname = m.group('fcname').strip() - fflags = m.group('fflags').strip() - flags[fcname] = split_quoted(fflags) - f.close() - return flags - -if __name__ == '__main__': - show_fcompilers() diff --git a/fcompiler/absoft.py b/fcompiler/absoft.py deleted file mode 100644 index 3360c7309..000000000 --- a/fcompiler/absoft.py +++ /dev/null @@ -1,154 +0,0 @@ - -# http://www.absoft.com/literature/osxuserguide.pdf -# http://www.absoft.com/documentation.html - -# Notes: -# - when using -g77 then use -DUNDERSCORE_G77 to compile f2py -# generated extension modules (works for f2py v2.45.241_1936 and up) - -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file -from numpy.distutils.misc_util import cyg2win32 - -compilers = ['AbsoftFCompiler'] - -class AbsoftFCompiler(FCompiler): - - compiler_type = 'absoft' - description = 'Absoft Corp Fortran Compiler' - #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp' - version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\ - r' (?P<version>[^\s*,]*)(.*?Absoft Corp|)' - - # on windows: f90 -V -c dummy.f - # f90: Copyright Absoft Corporation 1994-1998 mV2; Cray Research, Inc. 1994-1996 CF90 (2.x.x.x f36t87) Version 2.3 Wed Apr 19, 2006 13:05:16 - - # samt5735(8)$ f90 -V -c dummy.f - # f90: Copyright Absoft Corporation 1994-2002; Absoft Pro FORTRAN Version 8.0 - # Note that fink installs g77 as f77, so need to use f90 for detection. - - executables = { - 'version_cmd' : ["<F90>", "-V -c %(fname)s.f -o %(fname)s.o" \ - % {'fname':cyg2win32(dummy_fortran_file())}], - 'compiler_f77' : ["f77"], - 'compiler_fix' : ["f90"], - 'compiler_f90' : ["f90"], - 'linker_so' : ["<F90>"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - - if os.name=='nt': - library_switch = '/out:' #No space after /out:! - - module_dir_switch = None - module_include_switch = '-p' - - def get_flags_linker_so(self): - if os.name=='nt': - opt = ['/dll'] - # The "-K shared" switches are being left in for pre-9.0 versions - # of Absoft though I don't think versions earlier than 9 can - # actually be used to build shared libraries. In fact, version - # 8 of Absoft doesn't recognize "-K shared" and will fail. - elif self.get_version() >= '9.0': - opt = ['-shared'] - else: - opt = ["-K","shared"] - return opt - - def library_dir_option(self, dir): - if os.name=='nt': - return ['-link','/PATH:"%s"' % (dir)] - return "-L" + dir - - def library_option(self, lib): - if os.name=='nt': - return '%s.lib' % (lib) - return "-l" + lib - - def get_library_dirs(self): - opt = FCompiler.get_library_dirs(self) - d = os.environ.get('ABSOFT') - if d: - if self.get_version() >= '10.0': - # use shared libraries, the static libraries were not compiled -fPIC - prefix = 'sh' - else: - prefix = '' - if cpu.is_64bit(): - suffix = '64' - else: - suffix = '' - opt.append(os.path.join(d, '%slib%s' % (prefix, suffix))) - return opt - - def get_libraries(self): - opt = FCompiler.get_libraries(self) - if self.get_version() >= '10.0': - opt.extend(['af90math', 'afio', 'af77math', 'U77']) - elif self.get_version() >= '8.0': - opt.extend(['f90math','fio','f77math','U77']) - else: - opt.extend(['fio','f90math','fmath','U77']) - if os.name =='nt': - opt.append('COMDLG32') - return opt - - def get_flags(self): - opt = FCompiler.get_flags(self) - if os.name != 'nt': - opt.extend(['-s']) - if self.get_version(): - if self.get_version()>='8.2': - opt.append('-fpic') - return opt - - def get_flags_f77(self): - opt = FCompiler.get_flags_f77(self) - opt.extend(['-N22','-N90','-N110']) - v = self.get_version() - if os.name == 'nt': - if v and v>='8.0': - opt.extend(['-f','-N15']) - else: - opt.append('-f') - if v: - if v<='4.6': - opt.append('-B108') - else: - # Though -N15 is undocumented, it works with - # Absoft 8.0 on Linux - opt.append('-N15') - return opt - - def get_flags_f90(self): - opt = FCompiler.get_flags_f90(self) - opt.extend(["-YCFRL=1","-YCOM_NAMES=LCS","-YCOM_PFX","-YEXT_PFX", - "-YCOM_SFX=_","-YEXT_SFX=_","-YEXT_NAMES=LCS"]) - if self.get_version(): - if self.get_version()>'4.6': - opt.extend(["-YDEALLOC=ALL"]) - return opt - - def get_flags_fix(self): - opt = FCompiler.get_flags_fix(self) - opt.extend(["-YCFRL=1","-YCOM_NAMES=LCS","-YCOM_PFX","-YEXT_PFX", - "-YCOM_SFX=_","-YEXT_SFX=_","-YEXT_NAMES=LCS"]) - opt.extend(["-f","fixed"]) - return opt - - def get_flags_opt(self): - opt = ['-O'] - return opt - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='absoft') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/compaq.py b/fcompiler/compaq.py deleted file mode 100644 index 03c8c88ac..000000000 --- a/fcompiler/compaq.py +++ /dev/null @@ -1,105 +0,0 @@ - -#http://www.compaq.com/fortran/docs/ - -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler - -compilers = ['CompaqFCompiler'] -if os.name != 'posix': - # Otherwise we'd get a false positive on posix systems with - # case-insensitive filesystems (like darwin), because we'll pick - # up /bin/df - compilers.append('CompaqVisualFCompiler') - -class CompaqFCompiler(FCompiler): - - compiler_type = 'compaq' - description = 'Compaq Fortran Compiler' - version_pattern = r'Compaq Fortran (?P<version>[^\s]*).*' - - if sys.platform[:5]=='linux': - fc_exe = 'fort' - else: - fc_exe = 'f90' - - executables = { - 'version_cmd' : ['<F90>', "-version"], - 'compiler_f77' : [fc_exe, "-f77rtl","-fixed"], - 'compiler_fix' : [fc_exe, "-fixed"], - 'compiler_f90' : [fc_exe], - 'linker_so' : ['<F90>'], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - - module_dir_switch = '-module ' # not tested - module_include_switch = '-I' - - def get_flags(self): - return ['-assume no2underscore','-nomixed_str_len_arg'] - def get_flags_debug(self): - return ['-g','-check bounds'] - def get_flags_opt(self): - return ['-O4','-align dcommons','-assume bigarrays', - '-assume nozsize','-math_library fast'] - def get_flags_arch(self): - return ['-arch host', '-tune host'] - def get_flags_linker_so(self): - if sys.platform[:5]=='linux': - return ['-shared'] - return ['-shared','-Wl,-expect_unresolved,*'] - -class CompaqVisualFCompiler(FCompiler): - - compiler_type = 'compaqv' - description = 'DIGITAL or Compaq Visual Fortran Compiler' - version_pattern = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\ - ' Version (?P<version>[^\s]*).*' - - compile_switch = '/compile_only' - object_switch = '/object:' - library_switch = '/OUT:' #No space after /OUT:! - - static_lib_extension = ".lib" - static_lib_format = "%s%s" - module_dir_switch = '/module:' - module_include_switch = '/I' - - ar_exe = 'lib.exe' - fc_exe = 'DF' - if sys.platform=='win32': - from distutils.msvccompiler import MSVCCompiler - m = MSVCCompiler() - m.initialize() - ar_exe = m.lib - - executables = { - 'version_cmd' : ['<F90>', "/what"], - 'compiler_f77' : [fc_exe, "/f77rtl","/fixed"], - 'compiler_fix' : [fc_exe, "/fixed"], - 'compiler_f90' : [fc_exe], - 'linker_so' : ['<F90>'], - 'archiver' : [ar_exe, "/OUT:"], - 'ranlib' : None - } - - def get_flags(self): - return ['/nologo','/MD','/WX','/iface=(cref,nomixed_str_len_arg)', - '/names:lowercase','/assume:underscore'] - def get_flags_opt(self): - return ['/Ox','/fast','/optimize:5','/unroll:0','/math_library:fast'] - def get_flags_arch(self): - return ['/threads'] - def get_flags_debug(self): - return ['/debug'] - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='compaq') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/g95.py b/fcompiler/g95.py deleted file mode 100644 index c3b006b13..000000000 --- a/fcompiler/g95.py +++ /dev/null @@ -1,51 +0,0 @@ -# http://g95.sourceforge.net/ - -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler - -compilers = ['G95FCompiler'] - -class G95FCompiler(FCompiler): - - compiler_type = 'g95' - description = 'G95 Fortran Compiler' - -# version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*' - # $ g95 --version - # G95 (GCC 4.0.3 (g95!) May 22 2006) - - version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95 (?P<version>.*)!\) (?P<date>.*)\).*' - # $ g95 --version - # G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006) - - executables = { - 'version_cmd' : ["<F90>", "--version"], - 'compiler_f77' : ["g95", "-ffixed-form"], - 'compiler_fix' : ["g95", "-ffixed-form"], - 'compiler_f90' : ["g95"], - 'linker_so' : ["<F90>","-shared"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - pic_flags = ['-fpic'] - module_dir_switch = '-fmod=' - module_include_switch = '-I' - - def get_flags(self): - return ['-fno-second-underscore'] - def get_flags_opt(self): - return ['-O'] - def get_flags_debug(self): - return ['-g'] - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - #compiler = new_fcompiler(compiler='g95') - compiler = G95FCompiler() - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/gnu.py b/fcompiler/gnu.py deleted file mode 100644 index 76980ae7d..000000000 --- a/fcompiler/gnu.py +++ /dev/null @@ -1,330 +0,0 @@ -import re -import os -import sys -import warnings - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler -from numpy.distutils.exec_command import exec_command -from numpy.distutils.misc_util import mingw32, msvc_runtime_library - -compilers = ['GnuFCompiler', 'Gnu95FCompiler'] - -class GnuFCompiler(FCompiler): - compiler_type = 'gnu' - description = 'GNU Fortran 77 compiler' - - def gnu_version_match(self, version_string): - """Handle the different versions of GNU fortran compilers""" - m = re.match(r'GNU Fortran', version_string) - if not m: - return None - m = re.match(r'GNU Fortran\s+95.*?([0-9-.]+)', version_string) - if m: - return ('gfortran', m.group(1)) - m = re.match(r'GNU Fortran.*?([0-9-.]+)', version_string) - if m: - v = m.group(1) - if v.startswith('0') or v.startswith('2') or v.startswith('3'): - # the '0' is for early g77's - return ('g77', v) - else: - # at some point in the 4.x series, the ' 95' was dropped - # from the version string - return ('gfortran', v) - - def version_match(self, version_string): - v = self.gnu_version_match(version_string) - if not v or v[0] != 'g77': - return None - return v[1] - - # 'g77 --version' results - # SunOS: GNU Fortran (GCC 3.2) 3.2 20020814 (release) - # Debian: GNU Fortran (GCC) 3.3.3 20040110 (prerelease) (Debian) - # GNU Fortran (GCC) 3.3.3 (Debian 20040401) - # GNU Fortran 0.5.25 20010319 (prerelease) - # Redhat: GNU Fortran (GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) - - possible_executables = ['g77', 'f77'] - executables = { - 'version_cmd' : [None, "--version"], - 'compiler_f77' : [None, "-g", "-Wall","-fno-second-underscore"], - 'compiler_f90' : None, # Use --fcompiler=gnu95 for f90 codes - 'compiler_fix' : None, - 'linker_so' : [None, "-g", "-Wall"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"], - 'linker_exe' : [None, "-g", "-Wall"] - } - module_dir_switch = None - module_include_switch = None - - # Cygwin: f771: warning: -fPIC ignored for target (all code is - # position independent) - if os.name != 'nt' and sys.platform != 'cygwin': - pic_flags = ['-fPIC'] - - # use -mno-cygwin for g77 when Python is not Cygwin-Python - if sys.platform == 'win32': - for key in ['version_cmd', 'compiler_f77', 'linker_so', 'linker_exe']: - executables[key].append('-mno-cygwin') - - g2c = 'g2c' - - suggested_f90_compiler = 'gnu95' - - #def get_linker_so(self): - # # win32 linking should be handled by standard linker - # # Darwin g77 cannot be used as a linker. - # #if re.match(r'(darwin)', sys.platform): - # # return - # return FCompiler.get_linker_so(self) - - def get_flags_linker_so(self): - opt = self.linker_so[1:] - if sys.platform=='darwin': - # MACOSX_DEPLOYMENT_TARGET must be at least 10.3. This is - # a reasonable default value even when building on 10.4 when using - # the official Python distribution and those derived from it (when - # not broken). - target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', None) - if target is None or target == '': - target = '10.3' - major, minor = target.split('.') - if int(minor) < 3: - minor = '3' - warnings.warn('Environment variable ' - 'MACOSX_DEPLOYMENT_TARGET reset to %s.%s' % (major, minor)) - os.environ['MACOSX_DEPLOYMENT_TARGET'] = '%s.%s' % (major, - minor) - - opt.extend(['-undefined', 'dynamic_lookup', '-bundle']) - else: - opt.append("-shared") - if sys.platform.startswith('sunos'): - # SunOS often has dynamically loaded symbols defined in the - # static library libg2c.a The linker doesn't like this. To - # ignore the problem, use the -mimpure-text flag. It isn't - # the safest thing, but seems to work. 'man gcc' says: - # ".. Instead of using -mimpure-text, you should compile all - # source code with -fpic or -fPIC." - opt.append('-mimpure-text') - return opt - - def get_libgcc_dir(self): - status, output = exec_command(self.compiler_f77 + - ['-print-libgcc-file-name'], - use_tee=0) - if not status: - return os.path.dirname(output) - return None - - def get_library_dirs(self): - opt = [] - if sys.platform[:5] != 'linux': - d = self.get_libgcc_dir() - if d: - # if windows and not cygwin, libg2c lies in a different folder - if sys.platform == 'win32' and not d.startswith('/usr/lib'): - d = os.path.normpath(d) - if not os.path.exists(os.path.join(d, 'libg2c.a')): - d2 = os.path.abspath(os.path.join(d, - '../../../../lib')) - if os.path.exists(os.path.join(d2, 'libg2c.a')): - opt.append(d2) - opt.append(d) - return opt - - def get_libraries(self): - opt = [] - d = self.get_libgcc_dir() - if d is not None: - g2c = self.g2c + '-pic' - f = self.static_lib_format % (g2c, self.static_lib_extension) - if not os.path.isfile(os.path.join(d,f)): - g2c = self.g2c - else: - g2c = self.g2c - - if g2c is not None: - opt.append(g2c) - if sys.platform == 'win32': - # in case want to link F77 compiled code with MSVC - opt.append('gcc') - runtime_lib = msvc_runtime_library() - if runtime_lib: - opt.append(runtime_lib) - if sys.platform == 'darwin': - opt.append('cc_dynamic') - return opt - - def get_flags_debug(self): - return ['-g'] - - def get_flags_opt(self): - if self.get_version()<='3.3.3': - # With this compiler version building Fortran BLAS/LAPACK - # with -O3 caused failures in lib.lapack heevr,syevr tests. - opt = ['-O2'] - else: - opt = ['-O3'] - opt.append('-funroll-loops') - return opt - - def get_flags_arch(self): - opt = [] - if sys.platform == 'darwin': - # Since Apple doesn't distribute a GNU Fortran compiler, we - # can't add -arch ppc or -arch i386, as only their version - # of the GNU compilers accepts those. - for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\ - '403 505 801 821 823 860'.split(): - if getattr(cpu,'is_ppc%s'%a)(): - opt.append('-mcpu='+a) - opt.append('-mtune='+a) - break - return opt - - # default march options in case we find nothing better - if cpu.is_i686(): - march_opt = '-march=i686' - elif cpu.is_i586(): - march_opt = '-march=i586' - elif cpu.is_i486(): - march_opt = '-march=i486' - elif cpu.is_i386(): - march_opt = '-march=i386' - else: - march_opt = '' - - gnu_ver = self.get_version() - - if gnu_ver >= '0.5.26': # gcc 3.0 - if cpu.is_AthlonK6(): - march_opt = '-march=k6' - elif cpu.is_AthlonK7(): - march_opt = '-march=athlon' - - if gnu_ver >= '3.1.1': - if cpu.is_AthlonK6_2(): - march_opt = '-march=k6-2' - elif cpu.is_AthlonK6_3(): - march_opt = '-march=k6-3' - elif cpu.is_AthlonMP(): - march_opt = '-march=athlon-mp' - # there's also: athlon-tbird, athlon-4, athlon-xp - elif cpu.is_Nocona(): - march_opt = '-march=nocona' - elif cpu.is_Core2(): - march_opt = '-march=nocona' - elif cpu.is_Xeon() and cpu.is_64bit(): - march_opt = '-march=nocona' - elif cpu.is_Prescott(): - march_opt = '-march=prescott' - elif cpu.is_PentiumIV(): - march_opt = '-march=pentium4' - elif cpu.is_PentiumIII(): - march_opt = '-march=pentium3' - elif cpu.is_PentiumM(): - march_opt = '-march=pentium3' - elif cpu.is_PentiumII(): - march_opt = '-march=pentium2' - - if gnu_ver >= '3.4': - if cpu.is_Opteron(): - march_opt = '-march=opteron' - elif cpu.is_Athlon64(): - march_opt = '-march=athlon64' - - if gnu_ver >= '3.4.4': - if cpu.is_PentiumM(): - march_opt = '-march=pentium-m' - # Future: - # if gnu_ver >= '4.3': - # if cpu.is_Core2(): - # march_opt = '-march=core2' - - # Note: gcc 3.2 on win32 has breakage with -march specified - if '3.1.1' <= gnu_ver <= '3.4' and sys.platform=='win32': - march_opt = '' - - if march_opt: - opt.append(march_opt) - - # other CPU flags - if gnu_ver >= '3.1.1': - if cpu.has_mmx(): opt.append('-mmmx') - if cpu.has_3dnow(): opt.append('-m3dnow') - - if gnu_ver > '3.2.2': - if cpu.has_sse2(): opt.append('-msse2') - if cpu.has_sse(): opt.append('-msse') - if gnu_ver >= '3.4': - if cpu.has_sse3(): opt.append('-msse3') - if cpu.is_Intel(): - opt.append('-fomit-frame-pointer') - if cpu.is_32bit(): - opt.append('-malign-double') - return opt - -class Gnu95FCompiler(GnuFCompiler): - compiler_type = 'gnu95' - description = 'GNU Fortran 95 compiler' - - def version_match(self, version_string): - v = self.gnu_version_match(version_string) - if not v or v[0] != 'gfortran': - return None - return v[1] - - # 'gfortran --version' results: - # XXX is the below right? - # Debian: GNU Fortran 95 (GCC 4.0.3 20051023 (prerelease) (Debian 4.0.2-3)) - # GNU Fortran 95 (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) - # OS X: GNU Fortran 95 (GCC) 4.1.0 - # GNU Fortran 95 (GCC) 4.2.0 20060218 (experimental) - # GNU Fortran (GCC) 4.3.0 20070316 (experimental) - - possible_executables = ['gfortran', 'f95'] - executables = { - 'version_cmd' : ["<F90>", "--version"], - 'compiler_f77' : [None, "-Wall", "-ffixed-form", - "-fno-second-underscore"], - 'compiler_f90' : [None, "-Wall", "-fno-second-underscore"], - 'compiler_fix' : [None, "-Wall", "-ffixed-form", - "-fno-second-underscore"], - 'linker_so' : ["<F90>", "-Wall"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"], - 'linker_exe' : [None,"-Wall"] - } - - # use -mno-cygwin flag for g77 when Python is not Cygwin-Python - if sys.platform == 'win32': - for key in ['version_cmd', 'compiler_f77', 'compiler_f90', - 'compiler_fix', 'linker_so', 'linker_exe']: - executables[key].append('-mno-cygwin') - - module_dir_switch = '-J' - module_include_switch = '-I' - - g2c = 'gfortran' - - def get_libraries(self): - opt = GnuFCompiler.get_libraries(self) - if sys.platform == 'darwin': - opt.remove('cc_dynamic') - return opt - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - #compiler = new_fcompiler(compiler='gnu') - compiler = GnuFCompiler() - compiler.customize() - print compiler.get_version() - compiler = Gnu95FCompiler() - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/hpux.py b/fcompiler/hpux.py deleted file mode 100644 index 431583600..000000000 --- a/fcompiler/hpux.py +++ /dev/null @@ -1,44 +0,0 @@ -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler - -compilers = ['HPUXFCompiler'] - -class HPUXFCompiler(FCompiler): - - compiler_type = 'hpux' - description = 'HP Fortran 90 Compiler' - version_pattern = r'HP F90 (?P<version>[^\s*,]*)' - - executables = { - 'version_cmd' : ["<F90>", "+version"], - 'compiler_f77' : ["f90"], - 'compiler_fix' : ["f90"], - 'compiler_f90' : ["f90"], - 'linker_so' : None, - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - module_dir_switch = None #XXX: fix me - module_include_switch = None #XXX: fix me - pic_flags = ['+pic=long'] - def get_flags(self): - return self.pic_flags + ['+ppu'] - def get_flags_opt(self): - return ['-O3'] - def get_libraries(self): - return ['m'] - def get_version(self, force=0, ok_status=[256,0]): - # XXX status==256 may indicate 'unrecognized option' or - # 'no input file'. So, version_cmd needs more work. - return FCompiler.get_version(self,force,ok_status) - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(10) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='hpux') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/ibm.py b/fcompiler/ibm.py deleted file mode 100644 index fd6a8e84a..000000000 --- a/fcompiler/ibm.py +++ /dev/null @@ -1,100 +0,0 @@ -import os -import re -import sys - -from numpy.distutils.fcompiler import FCompiler -from numpy.distutils.exec_command import exec_command, find_executable -from distutils import log -from distutils.sysconfig import get_python_lib - -compilers = ['IBMFCompiler'] - -class IBMFCompiler(FCompiler): - - compiler_type = 'ibm' - description = 'IBM XL Fortran Compiler' - version_pattern = r'(xlf\(1\)\s*|)IBM XL Fortran ((Advanced Edition |)Version |Enterprise Edition V)(?P<version>[^\s*]*)' - #IBM XL Fortran Enterprise Edition V10.1 for AIX \nVersion: 10.01.0000.0004 - executables = { - 'version_cmd' : ["<F77>", "-qversion"], - 'compiler_f77' : ["xlf"], - 'compiler_fix' : ["xlf90", "-qfixed"], - 'compiler_f90' : ["xlf90"], - 'linker_so' : ["xlf95"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - - def get_version(self,*args,**kwds): - version = FCompiler.get_version(self,*args,**kwds) - - if version is None and sys.platform.startswith('aix'): - # use lslpp to find out xlf version - lslpp = find_executable('lslpp') - xlf = find_executable('xlf') - if os.path.exists(xlf) and os.path.exists(lslpp): - s,o = exec_command(lslpp + ' -Lc xlfcmp') - m = re.search('xlfcmp:(?P<version>\d+([.]\d+)+)', o) - if m: version = m.group('version') - - xlf_dir = '/etc/opt/ibmcmp/xlf' - if version is None and os.path.isdir(xlf_dir): - # linux: - # If the output of xlf does not contain version info - # (that's the case with xlf 8.1, for instance) then - # let's try another method: - l = os.listdir(xlf_dir) - l.sort() - l.reverse() - l = [d for d in l if os.path.isfile(os.path.join(xlf_dir,d,'xlf.cfg'))] - if l: - from distutils.version import LooseVersion - self.version = version = LooseVersion(l[0]) - return version - - def get_flags(self): - return ['-qextname'] - - def get_flags_debug(self): - return ['-g'] - - def get_flags_linker_so(self): - opt = [] - if sys.platform=='darwin': - opt.append('-Wl,-bundle,-flat_namespace,-undefined,suppress') - else: - opt.append('-bshared') - version = self.get_version(ok_status=[0,40]) - if version is not None: - import tempfile - if sys.platform.startswith('aix'): - xlf_cfg = '/etc/xlf.cfg' - else: - xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version - new_cfg = tempfile.mktemp()+'_xlf.cfg' - log.info('Creating '+new_cfg) - fi = open(xlf_cfg,'r') - fo = open(new_cfg,'w') - crt1_match = re.compile(r'\s*crt\s*[=]\s*(?P<path>.*)/crt1.o').match - for line in fi.readlines(): - m = crt1_match(line) - if m: - fo.write('crt = %s/bundle1.o\n' % (m.group('path'))) - else: - fo.write(line) - fi.close() - fo.close() - opt.append('-F'+new_cfg) - return opt - - def get_flags_opt(self): - return ['-O5'] - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - #compiler = new_fcompiler(compiler='ibm') - compiler = IbmFCompiler() - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/intel.py b/fcompiler/intel.py deleted file mode 100644 index e8178eca9..000000000 --- a/fcompiler/intel.py +++ /dev/null @@ -1,215 +0,0 @@ -# -*- encoding: iso-8859-1 -*- -# above encoding b/c there's a non-ASCII character in the sample output -# of intele -# http://developer.intel.com/software/products/compilers/flin/ - -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.ccompiler import simple_version_match -from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file - -compilers = ['IntelFCompiler', 'IntelVisualFCompiler', - 'IntelItaniumFCompiler', 'IntelItaniumVisualFCompiler', - 'IntelEM64TFCompiler'] - -def intel_version_match(type): - # Match against the important stuff in the version string - return simple_version_match(start=r'Intel.*?Fortran.*?%s.*?Version' % (type,)) - -class IntelFCompiler(FCompiler): - - compiler_type = 'intel' - description = 'Intel Fortran Compiler for 32-bit apps' - version_match = intel_version_match('32-bit') - - - possible_executables = ['ifort', 'ifc'] - - executables = { - 'version_cmd' : ["<F77>", "-FI -V -c %(fname)s.f -o %(fname)s.o" \ - % {'fname':dummy_fortran_file()}], - 'compiler_f77' : [None,"-72","-w90","-w95"], - 'compiler_f90' : [None], - 'compiler_fix' : [None,"-FI"], - 'linker_so' : ["<F90>","-shared"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - - pic_flags = ['-KPIC'] - module_dir_switch = '-module ' # Don't remove ending space! - module_include_switch = '-I' - - def get_flags(self): - opt = self.pic_flags + ["-cm"] - return opt - - def get_flags_free(self): - return ["-FR"] - - def get_flags_opt(self): - return ['-O3','-unroll'] - - def get_flags_arch(self): - opt = [] - if cpu.has_fdiv_bug(): - opt.append('-fdiv_check') - if cpu.has_f00f_bug(): - opt.append('-0f_check') - if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII(): - opt.extend(['-tpp6']) - elif cpu.is_PentiumM(): - opt.extend(['-tpp7','-xB']) - elif cpu.is_Pentium(): - opt.append('-tpp5') - elif cpu.is_PentiumIV() or cpu.is_Xeon(): - opt.extend(['-tpp7','-xW']) - if cpu.has_mmx() and not cpu.is_Xeon(): - opt.append('-xM') - if cpu.has_sse2(): - opt.append('-arch SSE2') - elif cpu.has_sse(): - opt.append('-arch SSE') - return opt - - def get_flags_linker_so(self): - opt = FCompiler.get_flags_linker_so(self) - v = self.get_version() - if v and v >= '8.0': - opt.append('-nofor_main') - return opt - -class IntelItaniumFCompiler(IntelFCompiler): - compiler_type = 'intele' - description = 'Intel Fortran Compiler for Itanium apps' - - version_match = intel_version_match('Itanium') - -#Intel(R) Fortran Itanium(R) Compiler for Itanium(R)-based applications -#Version 9.1 Build 20060928 Package ID: l_fc_c_9.1.039 -#Copyright (C) 1985-2006 Intel Corporation. All rights reserved. -#30 DAY EVALUATION LICENSE - - possible_executables = ['ifort', 'efort', 'efc'] - - executables = { - 'version_cmd' : ['<F77>', "-FI -V -c %(fname)s.f -o %(fname)s.o" \ - % {'fname':dummy_fortran_file()}], - 'compiler_f77' : [None,"-FI","-w90","-w95"], - 'compiler_fix' : [None,"-FI"], - 'compiler_f90' : [None], - 'linker_so' : ['<F90>', "-shared"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - -class IntelEM64TFCompiler(IntelFCompiler): - compiler_type = 'intelem' - description = 'Intel Fortran Compiler for EM64T-based apps' - - version_match = intel_version_match('EM64T-based') - - possible_executables = ['ifort', 'efort', 'efc'] - - executables = { - 'version_cmd' : ['<F77>', "-FI -V -c %(fname)s.f -o %(fname)s.o" \ - % {'fname':dummy_fortran_file()}], - 'compiler_f77' : [None, "-FI", "-w90", "-w95"], - 'compiler_fix' : [None, "-FI"], - 'compiler_f90' : [None], - 'linker_so' : ['<F90>', "-shared"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - - def get_flags_arch(self): - opt = [] - if cpu.is_PentiumIV() or cpu.is_Xeon(): - opt.extend(['-tpp7', '-xW']) - return opt - -# Is there no difference in the version string between the above compilers -# and the Visual compilers? - -class IntelVisualFCompiler(FCompiler): - compiler_type = 'intelv' - description = 'Intel Visual Fortran Compiler for 32-bit apps' - - version_match = intel_version_match('32-bit') - - ar_exe = 'lib.exe' - fc_exe = 'ifl' - - executables = { - 'version_cmd' : ['<F77>', "-FI -V -c %(fname)s.f -o %(fname)s.o" \ - % {'fname':dummy_fortran_file()}], - 'compiler_f77' : [fc_exe,"-FI","-w90","-w95"], - 'compiler_fix' : [fc_exe,"-FI","-4L72","-w"], - 'compiler_f90' : [fc_exe], - 'linker_so' : ['<F90>', "-shared"], - 'archiver' : [ar_exe, "/verbose", "/OUT:"], - 'ranlib' : None - } - - compile_switch = '/c ' - object_switch = '/Fo' #No space after /Fo! - library_switch = '/OUT:' #No space after /OUT:! - module_dir_switch = '/module:' #No space after /module: - module_include_switch = '/I' - - def get_flags(self): - opt = ['/nologo','/MD','/nbs','/Qlowercase','/us'] - return opt - - def get_flags_free(self): - return ["-FR"] - - def get_flags_debug(self): - return ['/4Yb','/d2'] - - def get_flags_opt(self): - return ['/O3','/Qip','/Qipo','/Qipo_obj'] - - def get_flags_arch(self): - opt = [] - if cpu.is_PentiumPro() or cpu.is_PentiumII(): - opt.extend(['/G6','/Qaxi']) - elif cpu.is_PentiumIII(): - opt.extend(['/G6','/QaxK']) - elif cpu.is_Pentium(): - opt.append('/G5') - elif cpu.is_PentiumIV(): - opt.extend(['/G7','/QaxW']) - if cpu.has_mmx(): - opt.append('/QaxM') - return opt - -class IntelItaniumVisualFCompiler(IntelVisualFCompiler): - compiler_type = 'intelev' - description = 'Intel Visual Fortran Compiler for Itanium apps' - - version_match = intel_version_match('Itanium') - - fc_exe = 'efl' # XXX this is a wild guess - ar_exe = IntelVisualFCompiler.ar_exe - - executables = { - 'version_cmd' : ['<F77>', "-FI -V -c %(fname)s.f -o %(fname)s.o" \ - % {'fname':dummy_fortran_file()}], - 'compiler_f77' : [fc_exe,"-FI","-w90","-w95"], - 'compiler_fix' : [fc_exe,"-FI","-4L72","-w"], - 'compiler_f90' : [fc_exe], - 'linker_so' : ['<F90>',"-shared"], - 'archiver' : [ar_exe, "/verbose", "/OUT:"], - 'ranlib' : None - } - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='intel') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/lahey.py b/fcompiler/lahey.py deleted file mode 100644 index 2fef4a212..000000000 --- a/fcompiler/lahey.py +++ /dev/null @@ -1,49 +0,0 @@ -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler - -compilers = ['LaheyFCompiler'] - -class LaheyFCompiler(FCompiler): - - compiler_type = 'lahey' - description = 'Lahey/Fujitsu Fortran 95 Compiler' - version_pattern = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P<version>[^\s*]*)' - - executables = { - 'version_cmd' : ["<F90>", "--version"], - 'compiler_f77' : ["lf95", "--fix"], - 'compiler_fix' : ["lf95", "--fix"], - 'compiler_f90' : ["lf95"], - 'linker_so' : ["lf95","-shared"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - - module_dir_switch = None #XXX Fix me - module_include_switch = None #XXX Fix me - - def get_flags_opt(self): - return ['-O'] - def get_flags_debug(self): - return ['-g','--chk','--chkglobal'] - def get_library_dirs(self): - opt = [] - d = os.environ.get('LAHEY') - if d: - opt.append(os.path.join(d,'lib')) - return opt - def get_libraries(self): - opt = [] - opt.extend(['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']) - return opt - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='lahey') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/mips.py b/fcompiler/mips.py deleted file mode 100644 index 4079c6e59..000000000 --- a/fcompiler/mips.py +++ /dev/null @@ -1,59 +0,0 @@ -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler - -compilers = ['MIPSFCompiler'] - -class MIPSFCompiler(FCompiler): - - compiler_type = 'mips' - description = 'MIPSpro Fortran Compiler' - version_pattern = r'MIPSpro Compilers: Version (?P<version>[^\s*,]*)' - - executables = { - 'version_cmd' : ["<F90>", "-version"], - 'compiler_f77' : ["f77", "-f77"], - 'compiler_fix' : ["f90", "-fixedform"], - 'compiler_f90' : ["f90"], - 'linker_so' : ["f90","-shared"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : None - } - module_dir_switch = None #XXX: fix me - module_include_switch = None #XXX: fix me - pic_flags = ['-KPIC'] - - def get_flags(self): - return self.pic_flags + ['-n32'] - def get_flags_opt(self): - return ['-O3'] - def get_flags_arch(self): - opt = [] - for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split(): - if getattr(cpu,'is_IP%s'%a)(): - opt.append('-TARG:platform=IP%s' % a) - break - return opt - def get_flags_arch_f77(self): - r = None - if cpu.is_r10000(): r = 10000 - elif cpu.is_r12000(): r = 12000 - elif cpu.is_r8000(): r = 8000 - elif cpu.is_r5000(): r = 5000 - elif cpu.is_r4000(): r = 4000 - if r is not None: - return ['r%s' % (r)] - return [] - def get_flags_arch_f90(self): - r = self.get_flags_arch_f77() - if r: - r[0] = '-' + r[0] - return r - -if __name__ == '__main__': - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='mips') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/nag.py b/fcompiler/nag.py deleted file mode 100644 index 328e4074f..000000000 --- a/fcompiler/nag.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler - -compilers = ['NAGFCompiler'] - -class NAGFCompiler(FCompiler): - - compiler_type = 'nag' - description = 'NAGWare Fortran 95 Compiler' - version_pattern = r'NAGWare Fortran 95 compiler Release (?P<version>[^\s]*)' - - executables = { - 'version_cmd' : ["<F90>", "-V"], - 'compiler_f77' : ["f95", "-fixed"], - 'compiler_fix' : ["f95", "-fixed"], - 'compiler_f90' : ["f95"], - 'linker_so' : ["<F90>"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - - def get_flags_linker_so(self): - if sys.platform=='darwin': - return ['-unsharedf95','-Wl,-bundle,-flat_namespace,-undefined,suppress'] - return ["-Wl,-shared"] - def get_flags_opt(self): - return ['-O4'] - def get_flags_arch(self): - version = self.get_version() - if version < '5.1': - return ['-target=native'] - else: - return [''] - def get_flags_debug(self): - return ['-g','-gline','-g90','-nan','-C'] - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='nag') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/none.py b/fcompiler/none.py deleted file mode 100644 index e80613883..000000000 --- a/fcompiler/none.py +++ /dev/null @@ -1,31 +0,0 @@ - -from numpy.distutils.fcompiler import FCompiler - -compilers = ['NoneFCompiler'] - -class NoneFCompiler(FCompiler): - - compiler_type = 'none' - description = 'Fake Fortran compiler' - - executables = {'compiler_f77' : None, - 'compiler_f90' : None, - 'compiler_fix' : None, - 'linker_so' : None, - 'linker_exe' : None, - 'archiver' : None, - 'ranlib' : None, - 'version_cmd' : None, - } - - def find_executables(self): - pass - - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = NoneFCompiler() - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/pg.py b/fcompiler/pg.py deleted file mode 100644 index 9152bab15..000000000 --- a/fcompiler/pg.py +++ /dev/null @@ -1,45 +0,0 @@ - -# http://www.pgroup.com - -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler import FCompiler - -compilers = ['PGroupFCompiler'] - -class PGroupFCompiler(FCompiler): - - compiler_type = 'pg' - description = 'Portland Group Fortran Compiler' - version_pattern = r'\s*pg(f77|f90|hpf) (?P<version>[\d.-]+).*' - - executables = { - 'version_cmd' : ["<F77>", "-V 2>/dev/null"], - 'compiler_f77' : ["pgf77"], - 'compiler_fix' : ["pgf90", "-Mfixed"], - 'compiler_f90' : ["pgf90"], - 'linker_so' : ["pgf90","-shared","-fpic"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - pic_flags = ['-fpic'] - module_dir_switch = '-module ' - module_include_switch = '-I' - - def get_flags(self): - opt = ['-Minform=inform','-Mnosecond_underscore'] - return self.pic_flags + opt - def get_flags_opt(self): - return ['-fast'] - def get_flags_debug(self): - return ['-g'] - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='pg') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/sun.py b/fcompiler/sun.py deleted file mode 100644 index 0ff051453..000000000 --- a/fcompiler/sun.py +++ /dev/null @@ -1,54 +0,0 @@ -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.ccompiler import simple_version_match -from numpy.distutils.fcompiler import FCompiler - -compilers = ['SunFCompiler'] - -class SunFCompiler(FCompiler): - - compiler_type = 'sun' - description = 'Sun or Forte Fortran 95 Compiler' - # ex: - # f90: Sun WorkShop 6 update 2 Fortran 95 6.2 Patch 111690-10 2003/08/28 - version_match = simple_version_match( - start=r'f9[05]: (Sun|Forte|WorkShop).*Fortran 95') - - executables = { - 'version_cmd' : ["<F90>", "-V"], - 'compiler_f77' : ["f90"], - 'compiler_fix' : ["f90", "-fixed"], - 'compiler_f90' : ["f90"], - 'linker_so' : ["<F90>","-Bdynamic","-G"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - module_dir_switch = '-moddir=' - module_include_switch = '-M' - pic_flags = ['-xcode=pic32'] - - def get_flags_f77(self): - ret = ["-ftrap=%none"] - if (self.get_version() or '') >= '7': - ret.append("-f77") - else: - ret.append("-fixed") - return ret - def get_opt(self): - return ['-fast','-dalign'] - def get_arch(self): - return ['-xtarget=generic'] - def get_libraries(self): - opt = [] - opt.extend(['fsu','sunmath','mvec','f77compat']) - return opt - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='sun') - compiler.customize() - print compiler.get_version() diff --git a/fcompiler/vast.py b/fcompiler/vast.py deleted file mode 100644 index 791d1459a..000000000 --- a/fcompiler/vast.py +++ /dev/null @@ -1,53 +0,0 @@ -import os -import sys - -from numpy.distutils.cpuinfo import cpu -from numpy.distutils.fcompiler.gnu import GnuFCompiler - -compilers = ['VastFCompiler'] - -class VastFCompiler(GnuFCompiler): - - compiler_type = 'vast' - description = 'Pacific-Sierra Research Fortran 90 Compiler' - version_pattern = r'\s*Pacific-Sierra Research vf90 '\ - '(Personal|Professional)\s+(?P<version>[^\s]*)' - - # VAST f90 does not support -o with -c. So, object files are created - # to the current directory and then moved to build directory - object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile ' - - executables = { - 'version_cmd' : ["vf90", "-v"], - 'compiler_f77' : ["g77"], - 'compiler_fix' : ["f90", "-Wv,-ya"], - 'compiler_f90' : ["f90"], - 'linker_so' : ["<F90>"], - 'archiver' : ["ar", "-cr"], - 'ranlib' : ["ranlib"] - } - module_dir_switch = None #XXX Fix me - module_include_switch = None #XXX Fix me - - def get_version_cmd(self): - f90 = self.compiler_f90[0] - d, b = os.path.split(f90) - vf90 = os.path.join(d, 'v'+b) - return vf90 - - def get_flags_arch(self): - vast_version = self.get_version() - gnu = GnuFCompiler() - gnu.customize(None) - self.version = gnu.get_version() - opt = GnuFCompiler.get_flags_arch(self) - self.version = vast_version - return opt - -if __name__ == '__main__': - from distutils import log - log.set_verbosity(2) - from numpy.distutils.fcompiler import new_fcompiler - compiler = new_fcompiler(compiler='vast') - compiler.customize() - print compiler.get_version() |