blob: 3b562eeaddce0622adc97cf4bc3d7ec154faa8e3 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# This class exists to provide information about the targets that
2# may be needed by other classes and/or recipes. If you add a new
3# target this will probably need to be updated.
4
5#
6# Returns information about 'what' for the named target 'target'
7# where 'target' == "<arch>-<os>"
8#
9# 'what' can be one of
10# * target: Returns the target name ("<arch>-<os>")
11# * endianess: Return "be" for big endian targets, "le" for little endian
12# * bits: Returns the bit size of the target, either "32" or "64"
13# * libc: Returns the name of the c library used by the target
14#
15# It is an error for the target not to exist.
16# If 'what' doesn't exist then an empty value is returned
17#
18def siteinfo_data(d):
19 archinfo = {
20 "allarch": "endian-little bit-32", # bogus, but better than special-casing the checks below for allarch
21 "aarch64": "endian-little bit-64 arm-common arm-64",
22 "aarch64_be": "endian-big bit-64 arm-common arm-64",
23 "arm": "endian-little bit-32 arm-common arm-32",
24 "armeb": "endian-big bit-32 arm-common arm-32",
25 "avr32": "endian-big bit-32 avr32-common",
26 "bfin": "endian-little bit-32 bfin-common",
27 "epiphany": "endian-little bit-32",
28 "i386": "endian-little bit-32 ix86-common",
29 "i486": "endian-little bit-32 ix86-common",
30 "i586": "endian-little bit-32 ix86-common",
31 "i686": "endian-little bit-32 ix86-common",
32 "ia64": "endian-little bit-64",
33 "microblaze": "endian-big bit-32 microblaze-common",
34 "microblazeeb": "endian-big bit-32 microblaze-common",
35 "microblazeel": "endian-little bit-32 microblaze-common",
36 "mips": "endian-big bit-32 mips-common",
37 "mips64": "endian-big bit-64 mips-common",
38 "mips64el": "endian-little bit-64 mips-common",
39 "mipsel": "endian-little bit-32 mips-common",
40 "powerpc": "endian-big bit-32 powerpc-common",
41 "nios2": "endian-little bit-32 nios2-common",
42 "powerpc64": "endian-big bit-64 powerpc-common",
43 "ppc": "endian-big bit-32 powerpc-common",
44 "ppc64": "endian-big bit-64 powerpc-common",
Chris Austen13f876c2015-10-12 12:12:54 -050045 "ppc64le": "endian-little bit-64 powerpc-common",
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 "sh3": "endian-little bit-32 sh-common",
47 "sh4": "endian-little bit-32 sh-common",
48 "sparc": "endian-big bit-32",
49 "viac3": "endian-little bit-32 ix86-common",
50 "x86_64": "endian-little", # bitinfo specified in targetinfo
51 }
52 osinfo = {
53 "darwin": "common-darwin",
54 "darwin9": "common-darwin",
55 "linux": "common-linux common-glibc",
56 "linux-gnu": "common-linux common-glibc",
57 "linux-gnux32": "common-linux common-glibc",
58 "linux-gnun32": "common-linux common-glibc",
59 "linux-gnueabi": "common-linux common-glibc",
60 "linux-gnuspe": "common-linux common-glibc",
61 "linux-uclibc": "common-linux common-uclibc",
62 "linux-uclibceabi": "common-linux common-uclibc",
63 "linux-uclibcspe": "common-linux common-uclibc",
64 "linux-musl": "common-linux common-musl",
65 "linux-musleabi": "common-linux common-musl",
66 "linux-muslspe": "common-linux common-musl",
67 "uclinux-uclibc": "common-uclibc",
68 "cygwin": "common-cygwin",
69 "mingw32": "common-mingw",
70 }
71 targetinfo = {
72 "aarch64-linux-gnu": "aarch64-linux",
73 "aarch64_be-linux-gnu": "aarch64_be-linux",
74 "arm-linux-gnueabi": "arm-linux",
75 "arm-linux-musleabi": "arm-linux",
76 "arm-linux-uclibceabi": "arm-linux-uclibc",
77 "armeb-linux-gnueabi": "armeb-linux",
78 "armeb-linux-uclibceabi": "armeb-linux-uclibc",
79 "armeb-linux-musleabi": "armeb-linux",
80 "mips-linux-musl": "mips-linux",
81 "mipsel-linux-musl": "mipsel-linux",
82 "mips64-linux-musl": "mips-linux",
83 "mips64el-linux-musl": "mipsel-linux",
84 "mips64-linux-gnun32": "mips-linux bit-32",
85 "mips64el-linux-gnun32": "mipsel-linux bit-32",
86 "powerpc-linux": "powerpc32-linux",
87 "powerpc-linux-musl": "powerpc-linux powerpc32-linux",
88 "powerpc-linux-uclibc": "powerpc-linux powerpc32-linux",
89 "powerpc-linux-gnuspe": "powerpc-linux powerpc32-linux",
90 "powerpc-linux-muslspe": "powerpc-linux powerpc32-linux",
91 "powerpc-linux-uclibcspe": "powerpc-linux powerpc32-linux powerpc-linux-uclibc",
92 "powerpc64-linux-gnuspe": "powerpc-linux powerpc64-linux",
93 "powerpc64-linux-muslspe": "powerpc-linux powerpc64-linux",
94 "powerpc64-linux": "powerpc-linux",
95 "x86_64-cygwin": "bit-64",
96 "x86_64-darwin": "bit-64",
97 "x86_64-darwin9": "bit-64",
98 "x86_64-linux": "bit-64",
99 "x86_64-linux-musl": "x86_64-linux bit-64",
100 "x86_64-linux-uclibc": "bit-64",
101 "x86_64-elf": "bit-64",
102 "x86_64-linux-gnu": "bit-64 x86_64-linux",
103 "x86_64-linux-gnux32": "bit-32 ix86-common x32-linux",
104 "x86_64-mingw32": "bit-64",
105 }
106
107 hostarch = d.getVar("HOST_ARCH", True)
108 hostos = d.getVar("HOST_OS", True)
109 target = "%s-%s" % (hostarch, hostos)
110
111 sitedata = []
112 if hostarch in archinfo:
113 sitedata.extend(archinfo[hostarch].split())
114 if hostos in osinfo:
115 sitedata.extend(osinfo[hostos].split())
116 if target in targetinfo:
117 sitedata.extend(targetinfo[target].split())
118 sitedata.append(target)
119 sitedata.append("common")
120
121 bb.debug(1, "SITE files %s" % sitedata);
122 return sitedata
123
124python () {
125 sitedata = set(siteinfo_data(d))
126 if "endian-little" in sitedata:
127 d.setVar("SITEINFO_ENDIANNESS", "le")
128 elif "endian-big" in sitedata:
129 d.setVar("SITEINFO_ENDIANNESS", "be")
130 else:
131 bb.error("Unable to determine endianness for architecture '%s'" %
132 d.getVar("HOST_ARCH", True))
133 bb.fatal("Please add your architecture to siteinfo.bbclass")
134
135 if "bit-32" in sitedata:
136 d.setVar("SITEINFO_BITS", "32")
137 elif "bit-64" in sitedata:
138 d.setVar("SITEINFO_BITS", "64")
139 else:
140 bb.error("Unable to determine bit size for architecture '%s'" %
141 d.getVar("HOST_ARCH", True))
142 bb.fatal("Please add your architecture to siteinfo.bbclass")
143}
144
145def siteinfo_get_files(d, no_cache = False):
146 sitedata = siteinfo_data(d)
147 sitefiles = ""
148 for path in d.getVar("BBPATH", True).split(":"):
149 for element in sitedata:
150 filename = os.path.join(path, "site", element)
151 if os.path.exists(filename):
152 sitefiles += filename + " "
153
154 if no_cache: return sitefiles
155
156 # Now check for siteconfig cache files
157 # Use the files copied to the aclocal cache generated by autotools.bbclass
158 # to avoid races
159 path_siteconfig = d.getVar('ACLOCALDIR', True)
160 if path_siteconfig and os.path.isdir(path_siteconfig):
161 for i in os.listdir(path_siteconfig):
162 if not i.endswith("_config"):
163 continue
164 filename = os.path.join(path_siteconfig, i)
165 sitefiles += filename + " "
166
167 return sitefiles
168
169#
170# Make some information available via variables
171#
172SITECONFIG_SYSROOTCACHE = "${STAGING_DATADIR}/${TARGET_SYS}_config_site.d"