| 1 | |
|---|
| 2 | # -*- python -*- |
|---|
| 3 | |
|---|
| 4 | # This file holds default configuration file for SoCLib. You should |
|---|
| 5 | # not change it. You'd rather create or change file located in |
|---|
| 6 | # ~/.soclib/global.conf. See at end of file to see what files |
|---|
| 7 | # are included form here. |
|---|
| 8 | |
|---|
| 9 | import os |
|---|
| 10 | import os.path |
|---|
| 11 | |
|---|
| 12 | # Paths where modules are looked for: |
|---|
| 13 | for p in [ |
|---|
| 14 | 'soclib/communication', |
|---|
| 15 | 'soclib/lib', |
|---|
| 16 | 'soclib/module', |
|---|
| 17 | 'soclib/iss', |
|---|
| 18 | os.getcwd(), |
|---|
| 19 | ]: |
|---|
| 20 | # Relative paths are from soclib root directory |
|---|
| 21 | config.addDescPath(p) |
|---|
| 22 | |
|---|
| 23 | def _platform(): |
|---|
| 24 | """ |
|---|
| 25 | Retrieves platform information and make it look-like systemc's |
|---|
| 26 | lib-xxx thing. |
|---|
| 27 | """ |
|---|
| 28 | import os |
|---|
| 29 | |
|---|
| 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 |
|---|
| 38 | |
|---|
| 39 | def _suffix(triple): |
|---|
| 40 | '''SystemC lib directory suffix oracle, kindly contributed by |
|---|
| 41 | Philipp A. Hartmann''' |
|---|
| 42 | from fnmatch import fnmatch |
|---|
| 43 | for pattern, value in ( |
|---|
| 44 | ("sparc-sun-solaris*", 'gccsparcOS5'), |
|---|
| 45 | ("x86_64*linux*", 'linux64' ), |
|---|
| 46 | ("*linux*", 'linux' ), |
|---|
| 47 | ("i?86-apple-macosx*", 'macosx' ), |
|---|
| 48 | ("powerpc-apple-macosx*", 'macosx' ), |
|---|
| 49 | ("x86_64*freebsd*", 'freebsd64' ), |
|---|
| 50 | ("amd64*freebsd*", 'freebsd64' ), |
|---|
| 51 | ("*freebsd*", 'freebsd' ), |
|---|
| 52 | ("*cygwin*", 'cygwin' ), |
|---|
| 53 | ("*mingw*", 'mingw' ), |
|---|
| 54 | ("*hpux11*", 'gcchpux11' ), |
|---|
| 55 | ): |
|---|
| 56 | if fnmatch(triple, pattern): |
|---|
| 57 | return value |
|---|
| 58 | return None |
|---|
| 59 | |
|---|
| 60 | def _machine_triple(): |
|---|
| 61 | '''triple like the one produced by config.guess''' |
|---|
| 62 | import subprocess |
|---|
| 63 | try: |
|---|
| 64 | proc = subprocess.Popen(['gcc', '-dumpmachine'], shell = False, stdout = subprocess.PIPE) |
|---|
| 65 | out, err = proc.communicate() |
|---|
| 66 | except: |
|---|
| 67 | out = '' |
|---|
| 68 | return out |
|---|
| 69 | |
|---|
| 70 | return _suffix(_machine_triple()) or _guess_directory() or '' |
|---|
| 71 | |
|---|
| 72 | config.systemc = Library( |
|---|
| 73 | name = 'systemc', |
|---|
| 74 | vendor = 'OSCI', |
|---|
| 75 | libdir = '%(dir)s/lib-%(os)s', |
|---|
| 76 | includedir = '%(dir)s/include', |
|---|
| 77 | libs = ['-L%(libdir)s', '-lsystemc', '-lpthread'], |
|---|
| 78 | cflags = ['-I%(dir)s/include'], |
|---|
| 79 | dir = "${SYSTEMC}", |
|---|
| 80 | os = _platform(), |
|---|
| 81 | ) |
|---|
| 82 | |
|---|
| 83 | config.toolchain = Toolchain( |
|---|
| 84 | tool_CC = 'gcc', |
|---|
| 85 | tool_CXX = 'g++', |
|---|
| 86 | tool_CC_LINKER = 'gcc', |
|---|
| 87 | tool_CXX_LINKER = 'g++', |
|---|
| 88 | tool_LD = 'ld', |
|---|
| 89 | obj_ext = 'o', |
|---|
| 90 | lib_ext = 'a', |
|---|
| 91 | |
|---|
| 92 | prefix = '', |
|---|
| 93 | vflags = [], |
|---|
| 94 | cflags = ['-Wall', '-Wno-pmf-conversions', '-DSOCLIB', |
|---|
| 95 | '-include', 'sys/types.h', '-include', 'inttypes.h', |
|---|
| 96 | '-I'+config.path+'/soclib/lib/include', |
|---|
| 97 | ], |
|---|
| 98 | libs = ['-lpthread'], |
|---|
| 99 | always_include = [], |
|---|
| 100 | release_cflags = ['-O2', '-DSOCLIB_MODE_RELEASE'], |
|---|
| 101 | release_libs = [], |
|---|
| 102 | prof_cflags = ['-pg', '-DSOCLIB_MODE_PROFILE'], |
|---|
| 103 | prof_libs = ['-pg'], |
|---|
| 104 | debug_cflags = ['-ggdb', '-DSOCLIB_MODE_DEBUG'], |
|---|
| 105 | debug_libs = [], |
|---|
| 106 | max_processes = 1, |
|---|
| 107 | ) |
|---|
| 108 | |
|---|
| 109 | config.build_env = BuildEnv( |
|---|
| 110 | libraries = [config.systemc], |
|---|
| 111 | toolchain = config.toolchain, |
|---|
| 112 | repos = "/tmp/build/sc", |
|---|
| 113 | cache_file = "%(repos)s/soclib_cc.cache", |
|---|
| 114 | sd_ignore_regexp = None, |
|---|
| 115 | ) |
|---|
| 116 | |
|---|
| 117 | config.set_default("build_env") |
|---|
| 118 | |
|---|
| 119 | # Included files: |
|---|
| 120 | for p in [ |
|---|
| 121 | os.path.join(config.path, "utils/conf/soclib.conf"), |
|---|
| 122 | os.path.expanduser("~/.soclib/global.conf"), |
|---|
| 123 | "soclib.conf", |
|---|
| 124 | ]: |
|---|
| 125 | include(p, ignore_if_absent = True) |
|---|