Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/distutils/fcompiler/ibm.py @ 87:2a2c65a20a8b
Add Python libs and headers
author | Chris Cannam |
---|---|
date | Wed, 25 Feb 2015 14:05:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:413a9d26189e | 87:2a2c65a20a8b |
---|---|
1 from __future__ import division, absolute_import, print_function | |
2 | |
3 import os | |
4 import re | |
5 import sys | |
6 | |
7 from numpy.distutils.fcompiler import FCompiler | |
8 from numpy.distutils.exec_command import exec_command, find_executable | |
9 from numpy.distutils.misc_util import make_temp_file | |
10 from distutils import log | |
11 | |
12 compilers = ['IBMFCompiler'] | |
13 | |
14 class IBMFCompiler(FCompiler): | |
15 compiler_type = 'ibm' | |
16 description = 'IBM XL Fortran Compiler' | |
17 version_pattern = r'(xlf\(1\)\s*|)IBM XL Fortran ((Advanced Edition |)Version |Enterprise Edition V|for AIX, V)(?P<version>[^\s*]*)' | |
18 #IBM XL Fortran Enterprise Edition V10.1 for AIX \nVersion: 10.01.0000.0004 | |
19 | |
20 executables = { | |
21 'version_cmd' : ["<F77>", "-qversion"], | |
22 'compiler_f77' : ["xlf"], | |
23 'compiler_fix' : ["xlf90", "-qfixed"], | |
24 'compiler_f90' : ["xlf90"], | |
25 'linker_so' : ["xlf95"], | |
26 'archiver' : ["ar", "-cr"], | |
27 'ranlib' : ["ranlib"] | |
28 } | |
29 | |
30 def get_version(self,*args,**kwds): | |
31 version = FCompiler.get_version(self,*args,**kwds) | |
32 | |
33 if version is None and sys.platform.startswith('aix'): | |
34 # use lslpp to find out xlf version | |
35 lslpp = find_executable('lslpp') | |
36 xlf = find_executable('xlf') | |
37 if os.path.exists(xlf) and os.path.exists(lslpp): | |
38 s, o = exec_command(lslpp + ' -Lc xlfcmp') | |
39 m = re.search('xlfcmp:(?P<version>\d+([.]\d+)+)', o) | |
40 if m: version = m.group('version') | |
41 | |
42 xlf_dir = '/etc/opt/ibmcmp/xlf' | |
43 if version is None and os.path.isdir(xlf_dir): | |
44 # linux: | |
45 # If the output of xlf does not contain version info | |
46 # (that's the case with xlf 8.1, for instance) then | |
47 # let's try another method: | |
48 l = sorted(os.listdir(xlf_dir)) | |
49 l.reverse() | |
50 l = [d for d in l if os.path.isfile(os.path.join(xlf_dir, d, 'xlf.cfg'))] | |
51 if l: | |
52 from distutils.version import LooseVersion | |
53 self.version = version = LooseVersion(l[0]) | |
54 return version | |
55 | |
56 def get_flags(self): | |
57 return ['-qextname'] | |
58 | |
59 def get_flags_debug(self): | |
60 return ['-g'] | |
61 | |
62 def get_flags_linker_so(self): | |
63 opt = [] | |
64 if sys.platform=='darwin': | |
65 opt.append('-Wl,-bundle,-flat_namespace,-undefined,suppress') | |
66 else: | |
67 opt.append('-bshared') | |
68 version = self.get_version(ok_status=[0, 40]) | |
69 if version is not None: | |
70 if sys.platform.startswith('aix'): | |
71 xlf_cfg = '/etc/xlf.cfg' | |
72 else: | |
73 xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version | |
74 fo, new_cfg = make_temp_file(suffix='_xlf.cfg') | |
75 log.info('Creating '+new_cfg) | |
76 fi = open(xlf_cfg, 'r') | |
77 crt1_match = re.compile(r'\s*crt\s*[=]\s*(?P<path>.*)/crt1.o').match | |
78 for line in fi: | |
79 m = crt1_match(line) | |
80 if m: | |
81 fo.write('crt = %s/bundle1.o\n' % (m.group('path'))) | |
82 else: | |
83 fo.write(line) | |
84 fi.close() | |
85 fo.close() | |
86 opt.append('-F'+new_cfg) | |
87 return opt | |
88 | |
89 def get_flags_opt(self): | |
90 return ['-O3'] | |
91 | |
92 if __name__ == '__main__': | |
93 log.set_verbosity(2) | |
94 compiler = IBMFCompiler() | |
95 compiler.customize() | |
96 print(compiler.get_version()) |