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