github.com/hwaf/hwaf@v0.0.0-20140814122253-5465f73b20f1/py-hwaftools/orch/rootsys.py (about) 1 #!/usr/bin/env python 2 ''' 3 Reproduce some root.cern.ch stuff 4 ''' 5 import os 6 import re 7 from . import util 8 9 arch_desc = [ 10 ("aix*", "aix5"), 11 ("osf1.*:alpha:.*", "alphacxx6"), 12 ("freebsd.*:.*:[789].*", "freebsd7"), 13 ("freebsd.*:.*:6.*", "freebsd5"), 14 ("freebsd.*:.*:5.*", "freebsd5"), 15 ("freebsd.*:.*:4.*", "freebsd4"), 16 ("freebsd.*:.*:.*", "freebsd"), 17 ("hp-ux:ia64:.*", "hpuxia64acc"), 18 ("hp-ux:.*:.*", "hpuxacc"), 19 ("hurd.*:.*:.*", "hurddeb"), 20 ("linux:ia64:.*", "linuxia64gcc"), 21 ("linux:x86_64:.*", "linuxx8664gcc"), 22 ("linux:alpha:.*", "linuxalphagcc"), 23 ("linux:arm.*:.*", "linuxarm"), 24 ("linux:hppa.*:.*", "linux"), 25 ("linux:mips:.*", "linuxmips"), 26 ("linux:sparc.*:.*", "linux"), 27 ("linux:parisc.*:.*", "linuxhppa"), 28 ("linux:ppc64.*:.*", "linuxppc64gcc"), 29 ("linux:ppc.*:.*", "linuxppcgcc"), 30 ("linux:i.*86:.*", "linux"), 31 ("linux:s39.*:.*", "linux"), 32 ("openbsd.*:.*:.*", "openbsd"), 33 ("lynx:.*:.*", "lynxos"), 34 ("darwin:power.*:.*", "macosx"), 35 ("darwin:.*86.*:.*", "macosx"), 36 ("irix.*:sgi.*:.*", "sgicc"), 37 ("sunos:sun.*:6.*", "solarisCC5"), 38 ("sunos:sun.*:5.*", "solarisCC5"), 39 ("sunos:sun.*:4.*", "solaris"), 40 ("sunos:i86pc:5.*", "solarisCC5"), 41 ("cygwin_.*:.*86:.*", "win32"), 42 ("cygwin_.*:pentium:.*", "win32"), 43 ("cygwin_.*:ia64", "win32"), 44 ("mingw32_.*:.*86:.*", "win32"), 45 ] 46 47 def arch(uname = None): 48 ''' 49 Should match the output of "root-config --arch" 50 ''' 51 if not uname: 52 uname = os.uname() 53 arch = uname[0].lower() 54 55 if arch.lower() in ['darwin']: 56 # root cmake does this on Darwin 57 if os.path.exists('/usr/sbin/sysctl'): 58 out = util.check_output('/usr/sbin/sysctl machdep.cpu.extfeatures'.split()) 59 if '64' in out: # seems like an awful thing to match on 60 return 'macosx64' 61 else: 62 return 'macosx' 63 64 rele = uname[2].lower() 65 chip = uname[4].lower() 66 acr = '%s:%s:%s' % (arch,chip,rele) 67 for check,answer in arch_desc: 68 if re.search(check, acr): 69 return answer 70 #print 'Failed: "%s" <--> "%s". Not yours: "%s"' % (check, acr, answer) 71 return None 72 73