merge of '02e9149a64fb51811fbc732f21698b412dadb41b'
[vuplus_openembedded] / classes / siteinfo.bbclass
1 # 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 #
18 def get_siteinfo_list(d):
19        import bb
20
21        target = bb.data.getVar('HOST_ARCH', d, 1) + "-" + bb.data.getVar('HOST_OS', d, 1)
22
23        targetinfo = {\
24                "armeb-linux":             "endian-big bit-32 common-glibc arm-common",\
25                "armeb-linux-gnueabi":     "endian-big bit-32 common-glibc arm-common armeb-linux",\
26                "armeb-linux-uclibc":      "endian-big bit-32 common-uclibc arm-common",\
27                "armeb-linux-uclibcgnueabi": "endian-big bit-32 common-uclibc arm-common armeb-linux-uclibc",\
28                "arm-linux":               "endian-little bit-32 common-glibc arm-common",\
29                "arm-linux-gnueabi":       "endian-little bit-32 common-glibc arm-common arm-linux",\
30                "arm-linux-uclibc":        "endian-little bit-32 common-uclibc arm-common",\
31                "arm-linux-uclibcgnueabi": "endian-little bit-32 common-uclibc arm-common arm-linux-uclibc",\
32                "avr32-linux":             "endian-big bit-32 common-glibc avr32-common",\ 
33                "avr32-linux-uclibc":      "endian-big bit-32 common-uclibc avr32-common",\
34                "bfin-uclinux-uclibc":       "endian-little bit-32 common-uclibc bfin-common",\
35                "i386-linux":              "endian-little bit-32 common-glibc ix86-common",\
36                "i486-linux":              "endian-little bit-32 common-glibc ix86-common",\
37                "i586-linux":              "endian-little bit-32 common-glibc ix86-common",\
38                "i686-linux":              "endian-little bit-32 common-glibc ix86-common",\
39                "i386-linux-uclibc":       "endian-little bit-32 common-uclibc ix86-common",\
40                "i486-linux-uclibc":       "endian-little bit-32 common-uclibc ix86-common",\
41                "i586-linux-uclibc":       "endian-little bit-32 common-uclibc ix86-common",\
42                "i686-linux-uclibc":       "endian-little bit-32 common-uclibc ix86-common",\
43                "mipsel-linux":            "endian-little bit-32 common-glibc",\
44                "mipsel-linux-uclibc":     "endian-little bit-32 common-uclibc",\
45                "powerpc-darwin":          "endian-big bit-32 common-darwin",\
46                "ppc-linux":               "endian-big bit-32 common-glibc powerpc-common",\ 
47                "powerpc-linux":           "endian-big bit-32 common-glibc powerpc-common",\
48                "powerpc-linux-uclibc":    "endian-big bit-32 common-uclibc powerpc-common",\
49                "sh3-linux":               "endian-little bit-32 common-glibc sh-common",\
50                "sh4-linux":               "endian-little bit-32 common-glibc sh-common",\
51                "sh4-linux-uclibc":        "endian-little bit-32 common-uclibc sh-common",\
52                "sparc-linux":             "endian-big bit-32 common-glibc",\
53                "x86_64-linux":            "endian-little bit-64 common-glibc",\
54                "x86_64-linux-uclibc":     "endian-little bit-64 common-uclibc"}
55        if target in targetinfo:
56                info = targetinfo[target].split()
57                info.append(target)
58                info.append("common")
59                return info
60        else:
61                bb.error("Information not available for target '%s'" % target)
62
63
64 #
65 # Define which site files to use. We check for several site files and
66 # use each one that is found, based on the list returned by get_siteinfo_list()
67 #
68 # Search for the files in the following directories:
69 # 1) ${BBPATH}/site (in reverse) - app specific, then site wide
70 # 2) ${FILE_DIRNAME}/site-${PV}         - app version specific
71 #
72 def siteinfo_get_files(d):
73        import bb, os
74
75        sitefiles = ""
76
77        # Determine which site files to look for
78        sites = get_siteinfo_list(d)
79        sites.append("common");
80
81        # Check along bbpath for site files and append in reverse order so
82        # the application specific sites files are last and system site
83        # files first.
84        path_bb = bb.data.getVar('BBPATH', d, 1)
85        for p in (path_bb or "").split(':'):
86                tmp = ""
87                for i in sites:
88                        fname = os.path.join(p, 'site', i)
89                        if os.path.exists(fname):
90                                tmp += fname + " "
91                sitefiles = tmp + sitefiles;
92
93        # Now check for the applications version specific site files
94        path_pkgv = os.path.join(bb.data.getVar('FILE_DIRNAME', d, 1), "site-" + bb.data.getVar('PV', d, 1))
95        for i in sites:
96                fname = os.path.join(path_pkgv, i)
97                if os.path.exists(fname):
98                        sitefiles += fname + " "
99
100        bb.debug(1, "SITE files " + sitefiles);
101        return sitefiles
102
103 #
104 # Export CONFIG_SITE to the enviroment. The autotools will make use
105 # of this to determine where to load in variables from. This is a
106 # space seperate list of shell scripts processed in the order listed.
107 #
108 export CONFIG_SITE = "${@siteinfo_get_files(d)}"
109
110
111 def siteinfo_get_endianess(d):
112        info = get_siteinfo_list(d)
113        if 'endian-little' in info:
114               return "le"
115        elif 'endian-big' in info:
116               return "be"
117        bb.error("Site info could not determine endianess for target")
118
119 def siteinfo_get_bits(d):
120        info = get_siteinfo_list(d)
121        if 'bit-32' in info:
122               return "32"
123        elif 'bit-64' in info:
124               return "64"
125        bb.error("Site info could not determine bit size for target")
126
127 #
128 # Make some information available via variables
129 #
130 SITEINFO_ENDIANESS  = "${@siteinfo_get_endianess(d)}"
131 SITEINFO_BITS       = "${@siteinfo_get_bits(d)}"
132
133