diff options
Diffstat (limited to 'meta/conf/distro/include/tcmode-external-sourcery.inc')
-rw-r--r-- | meta/conf/distro/include/tcmode-external-sourcery.inc | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/meta/conf/distro/include/tcmode-external-sourcery.inc b/meta/conf/distro/include/tcmode-external-sourcery.inc new file mode 100644 index 0000000000..79fef25bd0 --- /dev/null +++ b/meta/conf/distro/include/tcmode-external-sourcery.inc | |||
@@ -0,0 +1,118 @@ | |||
1 | # | ||
2 | # Configuration to use external Sourcery G++ toolchain | ||
3 | # | ||
4 | |||
5 | EXTERNAL_TOOLCHAIN ?= "/usr/local/csl/${TARGET_ARCH}" | ||
6 | |||
7 | TOOLCHAIN_PATH_ADD = "${EXTERNAL_TOOLCHAIN}/bin:" | ||
8 | PATH =. "${TOOLCHAIN_PATH_ADD}" | ||
9 | |||
10 | CSL_TARGET_SYS_powerpc ?= "powerpc-linux-gnu" | ||
11 | CSL_TARGET_SYS_powerpc64 ?= "powerpc-linux-gnu" | ||
12 | CSL_TARGET_SYS_arm ?= "arm-none-linux-gnueabi" | ||
13 | CSL_TARGET_SYS_mips ?= "mips-linux-gnu" | ||
14 | CSL_TARGET_SYS_mipsel ?= "mips-linux-gnu" | ||
15 | CSL_TARGET_SYS_mips64 ?= "mips-linux-gnu" | ||
16 | CSL_TARGET_SYS_i686 ?= "i686-pc-linux-gnu" | ||
17 | CSL_TARGET_SYS_i586 ?= "i686-pc-linux-gnu" | ||
18 | CSL_TARGET_SYS = "${TARGET_SYS}" | ||
19 | |||
20 | TARGET_PREFIX = "${CSL_TARGET_SYS}-" | ||
21 | |||
22 | PREFERRED_PROVIDER_linux-libc-headers = "external-sourcery-toolchain" | ||
23 | PREFERRED_PROVIDER_linux-libc-headers-dev = "external-sourcery-toolchain" | ||
24 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc = "external-sourcery-toolchain" | ||
25 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-initial = "external-sourcery-toolchain" | ||
26 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc-intermediate = "external-sourcery-toolchain" | ||
27 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++ = "external-sourcery-toolchain" | ||
28 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils = "external-sourcery-toolchain" | ||
29 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}libc-for-gcc = "external-sourcery-toolchain" | ||
30 | PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs = "external-sourcery-toolchain" | ||
31 | PREFERRED_PROVIDER_libgcc = "external-sourcery-toolchain" | ||
32 | PREFERRED_PROVIDER_virtual/libc = "external-sourcery-toolchain" | ||
33 | PREFERRED_PROVIDER_virtual/libintl = "external-sourcery-toolchain" | ||
34 | PREFERRED_PROVIDER_virtual/libiconv = "external-sourcery-toolchain" | ||
35 | PREFERRED_PROVIDER_glibc-thread-db = "external-sourcery-toolchain" | ||
36 | PREFERRED_PROVIDER_virtual/linux-libc-headers = "external-sourcery-toolchain" | ||
37 | PREFERRED_PROVIDER_gdbserver ??= "external-sourcery-toolchain" | ||
38 | |||
39 | # No need to re-compile the locale files | ||
40 | GLIBC_INTERNAL_USE_BINARY_LOCALE = "precompiled" | ||
41 | ENABLE_BINARY_LOCALE_GENERATION = "" | ||
42 | |||
43 | TOOLCHAIN_OPTIONS = " --sysroot=${STAGING_DIR_HOST}" | ||
44 | |||
45 | # Translate to CodeSourcery's names for their optimized files in the toolchain | ||
46 | def csl_target_core(d): | ||
47 | coredata = { | ||
48 | 'armv7a-vfp-neon': 'armv7-a-neon', | ||
49 | 'i586': 'sgxx-glibc', | ||
50 | 'i686': 'sgxx-glibc', | ||
51 | 'core2': 'sgxx-glibc', | ||
52 | 'mips': 'mips32', | ||
53 | 'mipsel': 'el', | ||
54 | 'powerpc-nf': 'nof', | ||
55 | 'ppce500': 'te500v1', | ||
56 | 'ppce500mc': 'te500mc', | ||
57 | 'ppce500v2': 'te500v2', | ||
58 | 'ppce600': 'te600' | ||
59 | } | ||
60 | return coredata.get(d.getVar('TUNE_PKGARCH', True), '') | ||
61 | |||
62 | CSL_TARGET_CORE ?= "${@csl_target_core(d)}" | ||
63 | |||
64 | # Unfortunately, the CSL ia32 toolchain has non-prefixed binaries in its | ||
65 | # bindir (e.g. gcc, ld). To avoid this messing up our build, we avoid adding | ||
66 | # this bindir to our PATH, and instead add symlinks to the prefixed binaries | ||
67 | # to our staging toolchain bindir. | ||
68 | |||
69 | python toolchain_metadata_setup () { | ||
70 | if not isinstance(e, bb.event.ConfigParsed): | ||
71 | return | ||
72 | |||
73 | d = e.data | ||
74 | |||
75 | l = d.createCopy() | ||
76 | l.finalize() | ||
77 | if os.path.exists(bb.data.expand('${EXTERNAL_TOOLCHAIN}/bin/gcc', l)): | ||
78 | d.setVar('TOOLCHAIN_PATH_ADD', '') | ||
79 | } | ||
80 | addhandler toolchain_metadata_setup | ||
81 | |||
82 | python toolchain_setup () { | ||
83 | if not isinstance(e, bb.event.BuildStarted): | ||
84 | return | ||
85 | |||
86 | d = e.data | ||
87 | |||
88 | if not d.getVar('TOOLCHAIN_PATH_ADD', True): | ||
89 | populate_toolchain_links(d) | ||
90 | } | ||
91 | addhandler toolchain_setup | ||
92 | |||
93 | def populate_toolchain_links(d): | ||
94 | import errno | ||
95 | import os | ||
96 | from glob import glob | ||
97 | |||
98 | d = d.createCopy() | ||
99 | d.finalize() | ||
100 | |||
101 | pattern = d.expand('${EXTERNAL_TOOLCHAIN}/bin/${TARGET_PREFIX}*') | ||
102 | files = glob(pattern) | ||
103 | if not files: | ||
104 | bb.fatal("Unable to populate toolchain binary symlinks in %s" % pattern) | ||
105 | |||
106 | bindir = d.getVar('STAGING_BINDIR_TOOLCHAIN', True) | ||
107 | bb.mkdirhier(bindir) | ||
108 | for f in files: | ||
109 | base = os.path.basename(f) | ||
110 | newpath = os.path.join(bindir, base) | ||
111 | try: | ||
112 | os.symlink(f, newpath) | ||
113 | except OSError as exc: | ||
114 | if exc.errno == errno.EEXIST: | ||
115 | break | ||
116 | bb.fatal("Unable to populate toolchain binary symlink for %s: %s" % (newpath, exc)) | ||
117 | |||
118 | require conf/distro/include/csl-versions.inc | ||