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