Ticket #68: built-in.conf.2.diff

File built-in.conf.2.diff, 2.2 KB (added by Nicolas Pouillon, 14 years ago)

Second attempt

  • lib/python/soclib_cc/config/built-in.conf

     
    2525    Retrieves platform information and make it look-like systemc's
    2626    lib-xxx thing.
    2727    """
    28     import sys
    29     pf = sys.platform
     28    import os
    3029
    31     # Strip numeric suffix from platform name
    32     while pf[-1] in "0123456789":
    33         pf = pf[:-1]
     30    def _guess_directory():
     31        systemc = os.getenv('SYSTEMC')
     32        if systemc:
     33            candidates = filter(lambda x:x.startswith('lib-'),
     34                                os.listdir(systemc))
     35            if len(candidates) == 1:
     36                return candidates[0][4:]
     37        return None
    3438
    35     if pf == 'darwin': pf = 'macosx'
    36     return pf
     39    def _suffix(triple):
     40        '''SystemC lib directory suffix oracle'''
     41        from fnmatch import fnmatch
     42        for pattern, value in (
     43            ("sparc-sun-solaris*",    'gccsparcOS5'),
     44            ("x86_64*linux*",         'linux64'    ),
     45            ("*linux*",               'linux'      ),
     46            ("i?86-apple-macosx*",    'macosx'     ),
     47            ("powerpc-apple-macosx*", 'macosx'     ),
     48            ("x86_64*freebsd*",       'freebsd64'  ),
     49            ("amd64*freebsd*",        'freebsd64'  ),
     50            ("*freebsd*",             'freebsd'    ),
     51            ("*cygwin*",              'cygwin'     ),
     52            ("*mingw*",               'mingw'      ),
     53            ("*hpux11*",              'gcchpux11'  ),
     54            ):
     55            if fnmatch(triple, pattern):
     56                return value
     57        return None
    3758
     59    def _machine_triple():
     60        '''triple like the one produced by config.guess'''
     61        import subprocess
     62        try:
     63            proc = subprocess.Popen(['gcc', '-dumpmachine'], shell = False, stdout = subprocess.PIPE)
     64            out, err = proc.communicate()
     65        except:
     66            out = ''
     67        return out
     68
     69    return _suffix(_machine_triple()) or _guess_directory() or ''
     70
    3871config.systemc = Library(
    3972    name = 'systemc',
    4073    vendor = 'OSCI',