blob: ed7b5222692daa183a78f01555e3e2ae14111995 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001DEPENDS += "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)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500122 uclibc_cfg('ssp', distro_features, 'UCLIBC_BUILD_SSP', cnf, rem)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500123 uclibc_cfg('argp', distro_features, 'UCLIBC_HAS_ARGP', cnf, rem)
124 uclibc_cfg('libc-posix-clang-wchar', distro_features,'UCLIBC_HAS_WCHAR', cnf, rem)
125 return "\n".join(cnf), "\n".join(rem)
126# X, Y = ${@features_to_uclibc_settings(d)}
127# unfortunately doesn't seem to work with bitbake, workaround:
128def features_to_uclibc_conf(d):
129 cnf, rem = features_to_uclibc_settings(d)
130 return cnf
131def features_to_uclibc_del(d):
132 cnf, rem = features_to_uclibc_settings(d)
133 return rem
134
135# returns all the elements from the src uri that are .cfg files
136def find_cfgs(d):
137 sources=src_patches(d, True)
138 sources_list=[]
139 for s in sources:
140 if s.endswith('.cfg'):
141 sources_list.append(s)
142
143 return sources_list