summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/uclibc/uclibc-config.inc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/uclibc/uclibc-config.inc')
-rw-r--r--meta/recipes-core/uclibc/uclibc-config.inc142
1 files changed, 142 insertions, 0 deletions
diff --git a/meta/recipes-core/uclibc/uclibc-config.inc b/meta/recipes-core/uclibc/uclibc-config.inc
new file mode 100644
index 0000000000..8b9e41c64d
--- /dev/null
+++ b/meta/recipes-core/uclibc/uclibc-config.inc
@@ -0,0 +1,142 @@
1DEPENDS += "kern-tools-native"
2inherit cml1
3#
4# Set the ARCH environment variable for uClibc compilation.
5# Return value must match one of the architectures known to uClibc:
6# libc/sysdeps/*/*
7#
8
9valid_archs = "\
10alpha \
11arm \
12avr32 \
13bfin \
14c6x \
15cris \
16e1 \
17frv \
18h8300 \
19hppa \
20i386 \
21i960 \
22ia64 \
23m68k \
24microblaze \
25mips \
26nios \
27nios2 \
28powerpc \
29sh \
30sh64 \
31sparc \
32v850 \
33vax \
34x86_64 \
35xtensa \
36"
37def map_uclibc_arch(a, d):
38 """Return the uClibc architecture for the given TARGET_ARCH."""
39 import re
40
41 valid_archs = d.getVar('valid_archs', True).split()
42
43 if re.match('^(arm|sa110).*', a):
44 return 'arm'
45 elif re.match('^(i.86|athlon)$', a):
46 return 'i386'
47 elif re.match('^mips.*', a):
48 return 'mips'
49 elif re.match('^parisc.*', a):
50 return 'hppa'
51 elif re.match('^ppc.*', a):
52 return 'powerpc'
53 elif re.match('^s390.*', a):
54 return 's390'
55 elif re.match('^sh.*', a):
56 return 'sh'
57 elif re.match('^(sun|sparc).*', a):
58 return 'sparc'
59 elif re.match('^xtensa.*', a):
60 return 'xtensa'
61 elif a in valid_archs:
62 return a
63 else:
64 bb.error("cannot map '%s' to a uClibc architecture" % a)
65
66export UCLIBC_ARCH = "${@map_uclibc_arch(d.getVar('TARGET_ARCH', True), d)}"
67
68def map_uclibc_abi(o, d):
69 """Return the uClibc ABI for the given TARGET_OS."""
70 import re
71
72 arch = d.getVar('TARGET_ARCH', True)
73 if map_uclibc_arch(d.getVar('TARGET_ARCH', True), d) == "arm":
74 if re.match('.*eabi$', o):
75 return 'ARM_EABI'
76 else:
77 return 'ARM_OABI'
78 # FIXME: This is inaccurate! Handle o32, n32, n64
79 elif re.match('^mips.*64$', arch):
80 return 'MIPS_N64_ABI'
81 elif re.match('^mips.*', arch):
82 return 'MIPS_O32_ABI'
83 return ""
84
85export UCLIBC_ABI = "${@map_uclibc_abi(d.getVar('TARGET_OS', True), d)}"
86
87def map_uclibc_endian(a, d):
88 """Return the uClibc endianess for the given TARGET_ARCH."""
89 import re
90
91 # Always BE
92 if re.match('^(avr32|e1|frv|(parisc|hppa)|m68k|microblaze|powerpc.*|(sparc|sun).*)$', a):
93 return 'BIG'
94 # Possibly BE
95 elif re.match('^(((arm|sa110).*eb)|h8300.*eb|(parisc|hppa).*eb|mips|mips64|sh.*eb|xtensa.*eb)$', a):
96 return 'BIG'
97 return 'LITTLE'
98
99export UCLIBC_ENDIAN = "${@map_uclibc_endian(d.getVar('TARGET_ARCH', True), d)}"
100
101# internal helper
102def uclibc_cfg(feature, features, tokens, cnf, rem):
103 if type(tokens) == type(""):
104 tokens = [tokens]
105 rem.extend(['/^[# ]*' + token + '[ =]/d' for token in tokens])
106 if type(features) == type([]) and feature in features:
107 cnf.extend([token + '=y' for token in tokens])
108 else:
109 cnf.extend(['# ' + token + ' is not set' for token in tokens])
110
111# Map distro features to config settings
112def features_to_uclibc_settings(d):
113 cnf, rem = ([], [])
114 distro_features = d.getVar('DISTRO_FEATURES', True).split()
115 uclibc_cfg('ipv4', distro_features, 'UCLIBC_HAS_IPV4', cnf, rem)
116 uclibc_cfg('ipv6', distro_features, 'UCLIBC_HAS_IPV6', cnf, rem)
117 uclibc_cfg('largefile', distro_features, 'UCLIBC_HAS_LFS', cnf, rem)
118 uclibc_cfg('nls', distro_features, 'UCLIBC_HAS_LOCALE', cnf, rem)
119 uclibc_cfg('thumb-interwork', distro_features,'USE_BX', cnf, rem)
120 uclibc_cfg('xattr', distro_features, 'UCLIBC_HAS_XATTR', cnf, rem)
121 uclibc_cfg('ssp', distro_features, 'UCLIBC_HAS_SSP', cnf, rem)
122 uclibc_cfg('argp', distro_features, 'UCLIBC_HAS_ARGP', cnf, rem)
123 uclibc_cfg('libc-posix-clang-wchar', distro_features,'UCLIBC_HAS_WCHAR', cnf, rem)
124 return "\n".join(cnf), "\n".join(rem)
125# X, Y = ${@features_to_uclibc_settings(d)}
126# unfortunately doesn't seem to work with bitbake, workaround:
127def features_to_uclibc_conf(d):
128 cnf, rem = features_to_uclibc_settings(d)
129 return cnf
130def features_to_uclibc_del(d):
131 cnf, rem = features_to_uclibc_settings(d)
132 return rem
133
134# returns all the elements from the src uri that are .cfg files
135def find_cfgs(d):
136 sources=src_patches(d, True)
137 sources_list=[]
138 for s in sources:
139 if s.endswith('.cfg'):
140 sources_list.append(s)
141
142 return sources_list