vortex86sx: we use sisfb which gives 2D acceleration
[vuplus_openembedded] / packages / eglibc / eglibc-package.bbclass
1 #
2 # For now, we will skip building of a gcc package if it is a uclibc one
3 # and our build is not a uclibc one, and we skip a eglibc one if our build
4 # is a uclibc build.
5 #
6 # See the note in gcc/gcc_3.4.0.oe
7 #
8
9 python __anonymous () {
10     import bb, re
11     uc_os = (re.match('.*uclibc*', bb.data.getVar('TARGET_OS', d, 1)) != None)
12     if uc_os:
13         raise bb.parse.SkipPackage("incompatible with target %s" %
14                                    bb.data.getVar('TARGET_OS', d, 1))
15 }
16
17
18 # Binary locales are generated at build time if ENABLE_BINARY_LOCALE_GENERATION
19 # is set. The idea is to avoid running localedef on the target (at first boot)
20 # to decrease initial boot time and avoid localedef being killed by the OOM
21 # killer which used to effectively break i18n on machines with < 128MB RAM.
22
23 # default to disabled until qemu works for everyone
24 ENABLE_BINARY_LOCALE_GENERATION ?= "0"
25
26 # BINARY_LOCALE_ARCHES is a space separated list of regular expressions
27 BINARY_LOCALE_ARCHES ?= "arm.*"
28
29 PACKAGES = "eglibc-dbg eglibc catchsegv sln nscd ldd localedef eglibc-utils eglibc-dev eglibc-doc eglibc-locale libsegfault eglibc-extra-nss eglibc-thread-db eglibc-pcprofile"
30 PACKAGES_DYNAMIC = "glibc-gconv-* glibc-charmap-* glibc-localedata-* glibc-binary-localedata-* eglibc-gconv-* eglibc-charmap-* eglibc-localedata-* eglibc-binary-localedata-* locale-base-*"
31
32 RPROVIDES_eglibc = "glibc"
33 RPROVIDES_eglibc-utils = "glibc-utils"
34 RPROVIDES_eglibc-dev = "glibc-dev"
35 RPROVIDES_eglibc-doc = "glibc-doc"
36 RPROVIDES_eglibc-locale = "glibc-locale"
37 RPROVIDES_eglibc-extra-nss = "glibc-extra-nss"
38 RPROVIDES_eglibc-thread-db = "glibc-thread-db"
39 RPROVIDES_eglibc-pcprofile = "glibc-pcprofile"
40 RPROVIDES_eglibc-dbg = "glibc-dbg"
41
42 libc_baselibs = "/lib/libc* /lib/libm* /lib/ld* /lib/libpthread* /lib/libresolv* /lib/librt* /lib/libutil* /lib/libnsl* /lib/libnss_files* /lib/libnss_compat* /lib/libnss_dns* /lib/libdl* /lib/libanl* /lib/libBrokenLocale*"
43
44 FILES_${PN} = "${sysconfdir} ${libc_baselibs} /sbin/ldconfig ${libexecdir}/* ${datadir}/zoneinfo"
45 FILES_ldd = "${bindir}/ldd"
46 FILES_libsegfault = "/lib/libSegFault*"
47 FILES_eglibc-extra-nss = "/lib/libnss*"
48 FILES_sln = "/sbin/sln"
49 FILES_eglibc-dev_append = " ${libdir}/*.o ${bindir}/rpcgen"
50 FILES_nscd = "${sbindir}/nscd*"
51 FILES_eglibc-utils = "${bindir}/* ${sbindir}/*"
52 FILES_eglibc-gconv = "${libdir}/gconv/*"
53 FILES_${PN}-dbg += "${libexecdir}/*/.debug ${libdir}/gconv/.debug"
54 FILES_catchsegv = "${bindir}/catchsegv"
55 RDEPENDS_catchsegv = "libsegfault"
56 FILES_eglibc-pcprofile = "/lib/libpcprofile.so"
57 FILES_eglibc-thread-db = "/lib/libthread_db*"
58 FILES_localedef = "${bindir}/localedef"
59 RPROVIDES_eglibc-dev += "libc-dev"
60
61 DESCRIPTION_sln = "eglibc: create symbolic links between files"
62 DESCRIPTION_nscd = "eglibc: name service cache daemon for passwd, group, and hosts"
63 DESCRIPTION_eglibc-extra-nss = "eglibc: nis, nisplus and hesiod search services"
64 DESCRIPTION_ldd = "eglibc: print shared library dependencies"
65 DESCRIPTION_localedef = "eglibc: compile locale definition files"
66 DESCRIPTION_eglibc-utils = "eglibc: misc utilities like iconf, local, gencat, tzselect, rpcinfo, ..."
67
68 def get_eglibc_fpu_setting(bb, d):
69     if bb.data.getVar('TARGET_FPU', d, 1) in [ 'soft' ]:
70         return "--without-fp"
71     return ""
72
73 EXTRA_OECONF += "${@get_eglibc_fpu_setting(bb, d)}"
74
75 OVERRIDES_append = ":${TARGET_ARCH}-${TARGET_OS}"
76
77 do_install() {
78         oe_runmake install_root=${D} install
79         for r in ${rpcsvc}; do
80                 h=`echo $r|sed -e's,\.x$,.h,'`
81                 install -m 0644 ${S}/sunrpc/rpcsvc/$h ${D}/${includedir}/rpcsvc/
82         done
83         install -m 0644 ${WORKDIR}/etc/ld.so.conf ${D}/${sysconfdir}/
84         install -d ${D}${libdir}/locale
85         make -f ${WORKDIR}/generate-supported.mk IN="${S}/localedata/SUPPORTED" OUT="${WORKDIR}/SUPPORTED"
86         # get rid of some broken files...
87         for i in ${GLIBC_BROKEN_LOCALES}; do
88                 grep -v $i ${WORKDIR}/SUPPORTED > ${WORKDIR}/SUPPORTED.tmp
89                 mv ${WORKDIR}/SUPPORTED.tmp ${WORKDIR}/SUPPORTED
90         done
91         rm -f ${D}/etc/rpc
92         rm -f ${D}${includedir}/scsi/sg.h
93         rm -f ${D}${includedir}/scsi/scsi_ioctl.h
94         rm -f ${D}${includedir}/scsi/scsi.h
95 }
96
97 TMP_LOCALE="/tmp/locale${libdir}/locale"
98
99 locale_base_postinst() {
100 #!/bin/sh
101
102 if [ "x$D" != "x" ]; then
103   exit 1
104 fi
105
106 rm -rf ${TMP_LOCALE}
107 mkdir -p ${TMP_LOCALE}
108 if [ -f ${libdir}/locale/locale-archive ]; then
109         cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
110 fi
111 localedef --inputfile=${datadir}/i18n/locales/%s --charmap=%s --prefix=/tmp/locale %s
112 mkdir -p ${libdir}/locale/
113 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
114 rm -rf ${TMP_LOCALE}
115 }
116
117 locale_base_postrm() {
118 #!/bin/sh
119
120 rm -rf ${TMP_LOCALE}
121 mkdir -p ${TMP_LOCALE}
122 if [ -f ${libdir}/locale/locale-archive ]; then
123         cp ${libdir}/locale/locale-archive ${TMP_LOCALE}/
124 fi
125 localedef --delete-from-archive --inputfile=${datadir}/locales/%s --charmap=%s --prefix=/tmp/locale %s
126 mv ${TMP_LOCALE}/locale-archive ${libdir}/locale/
127 rm -rf ${TMP_LOCALE}
128 }
129
130 python __anonymous () {
131     enabled = bb.data.getVar("ENABLE_BINARY_LOCALE_GENERATION", d, 1)
132
133     if enabled and int(enabled):
134         import re
135
136         target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
137         binary_arches = bb.data.getVar("BINARY_LOCALE_ARCHES", d, 1) or ""
138
139         for regexp in binary_arches.split(" "):
140             r = re.compile(regexp)
141
142             if r.match(target_arch):
143                 depends = bb.data.getVar("DEPENDS", d, 1)
144                 depends = "%s qemu-native" % depends
145                 bb.data.setVar("DEPENDS", depends, d)
146                 bb.data.setVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", "1", d)
147                 break
148 }
149
150 do_prep_locale_tree() {
151         treedir=${WORKDIR}/locale-tree
152         rm -rf $treedir
153         mkdir -p $treedir/bin $treedir/lib $treedir/${datadir} $treedir/${libdir}/locale
154         cp -pPR ${D}${datadir}/i18n $treedir/${datadir}/i18n
155         # unzip to avoid parsing errors
156         for i in $treedir/${datadir}/i18n/charmaps/*gz; do 
157                 gunzip $i
158         done
159         ls ${D}/lib/* | xargs -iBLAH cp -pPR BLAH $treedir/lib
160         if [ -f ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* ]; then
161                 cp -pPR ${CROSS_DIR}/${TARGET_SYS}/lib/libgcc_s.* $treedir/lib
162         fi
163         install -m 0755 ${D}${bindir}/localedef $treedir/bin
164 }
165
166 do_collect_bins_from_locale_tree() {
167         treedir=${WORKDIR}/locale-tree
168
169         mkdir -p ${D}${libdir}
170         cp -pPR $treedir/${libdir}/locale ${D}${libdir}
171 }
172
173 python package_do_split_gconvs () {
174         import os, re
175         if (bb.data.getVar('PACKAGE_NO_GCONV', d, 1) == '1'):
176                 bb.note("package requested not splitting gconvs")
177                 return
178
179         if not bb.data.getVar('PACKAGES', d, 1):
180                 return
181
182         libdir = bb.data.getVar('libdir', d, 1)
183         if not libdir:
184                 bb.error("libdir not defined")
185                 return
186         datadir = bb.data.getVar('datadir', d, 1)
187         if not datadir:
188                 bb.error("datadir not defined")
189                 return
190
191         gconv_libdir = base_path_join(libdir, "gconv")
192         charmap_dir = base_path_join(datadir, "i18n", "charmaps")
193         locales_dir = base_path_join(datadir, "i18n", "locales")
194         binary_locales_dir = base_path_join(libdir, "locale")
195
196         def calc_gconv_deps(fn, pkg, file_regex, output_pattern, group):
197                 deps = []
198                 f = open(fn, "r")
199                 c_re = re.compile('^copy "(.*)"')
200                 i_re = re.compile('^include "(\w+)".*')
201                 for l in f.readlines():
202                         m = c_re.match(l) or i_re.match(l)
203                         if m:
204                                 dp = legitimize_package_name('eglibc-gconv-%s' % m.group(1))
205                                 if not dp in deps:
206                                         deps.append(dp)
207                 f.close()
208                 if deps != []:
209                         bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
210                 bb.data.setVar('RPROVIDES_%s' % pkg, 'glibc-gconv-%s' % group.lower(), d)
211
212         do_split_packages(d, gconv_libdir, file_regex='^(.*)\.so$', output_pattern='eglibc-gconv-%s', description='gconv module for character set %s', hook=calc_gconv_deps, extra_depends='eglibc-gconv')
213
214         def calc_charmap_deps(fn, pkg, file_regex, output_pattern, group):
215                 deps = []
216                 f = open(fn, "r")
217                 c_re = re.compile('^copy "(.*)"')
218                 i_re = re.compile('^include "(\w+)".*')
219                 for l in f.readlines():
220                         m = c_re.match(l) or i_re.match(l)
221                         if m:
222                                 dp = legitimize_package_name('eglibc-charmap-%s' % m.group(1))
223                                 if not dp in deps:
224                                         deps.append(dp)
225                 f.close()
226                 if deps != []:
227                         bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
228                 bb.data.setVar('RPROVIDES_%s' % pkg, 'glibc-charmap-%s' % group.lower(), d)
229
230         do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern='eglibc-charmap-%s', description='character map for %s encoding', hook=calc_charmap_deps, extra_depends='')
231
232         def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
233                 deps = []
234                 f = open(fn, "r")
235                 c_re = re.compile('^copy "(.*)"')
236                 i_re = re.compile('^include "(\w+)".*')
237                 for l in f.readlines():
238                         m = c_re.match(l) or i_re.match(l)
239                         if m:
240                                 dp = legitimize_package_name('eglibc-localedata-%s' % m.group(1))
241                                 if not dp in deps:
242                                         deps.append(dp)
243                 f.close()
244                 if deps != []:
245                         bb.data.setVar('RDEPENDS_%s' % pkg, " ".join(deps), d)
246                 bb.data.setVar('RPROVIDES_%s' % pkg, 'glibc-localedata-%s' % group.lower(), d)
247
248         do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern='eglibc-localedata-%s', description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
249         bb.data.setVar('PACKAGES', bb.data.getVar('PACKAGES', d) + ' eglibc-gconv', d)
250
251         supported = bb.data.getVar('GLIBC_GENERATE_LOCALES', d, 1)
252         if not supported or supported == "all":
253             f = open(base_path_join(bb.data.getVar('WORKDIR', d, 1), "SUPPORTED"), "r")
254             supported = f.readlines()
255             f.close()
256         else:
257             supported = supported.split()
258             supported = map(lambda s:s.replace(".", " ") + "\n", supported)
259
260         dot_re = re.compile("(.*)\.(.*)")
261
262         # Collate the locales by base and encoding
263         encodings = {}
264         for l in supported:
265                 l = l[:-1]
266                 (locale, charset) = l.split(" ")
267                 m = dot_re.match(locale)
268                 if m:
269                         locale = m.group(1)
270                 if not encodings.has_key(locale):
271                         encodings[locale] = []
272                 encodings[locale].append(charset)
273
274         def output_locale_source(name, locale, encoding):
275                 pkgname = 'locale-base-' + legitimize_package_name(name)
276
277                 bb.data.setVar('RDEPENDS_%s' % pkgname, 'localedef eglibc-localedata-%s eglibc-charmap-%s' % (legitimize_package_name(locale), legitimize_package_name(encoding)), d)
278                 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
279                 m = re.match("(.*)_(.*)", name)
280                 if m:
281                         rprovides += ' virtual-locale-%s' % m.group(1)
282                 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
283                 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
284                 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
285                 bb.data.setVar('pkg_postinst_%s' % pkgname, bb.data.getVar('locale_base_postinst', d, 1) % (locale, encoding, locale), d)
286                 bb.data.setVar('pkg_postrm_%s' % pkgname, bb.data.getVar('locale_base_postrm', d, 1) % (locale, encoding, locale), d)
287
288         def output_locale_binary(name, locale, encoding):
289                 target_arch = bb.data.getVar("TARGET_ARCH", d, 1)
290                 qemu = "qemu-%s -r 2.6.16" % target_arch
291                 pkgname = 'locale-base-' + legitimize_package_name(name)
292                 m = re.match("(.*)\.(.*)", name)
293                 if m:
294                         eglibc_name = "%s.%s" % (m.group(1), m.group(2).lower().replace("-",""))
295                 else:
296                         eglibc_name = name
297                 bb.data.setVar('RDEPENDS_%s' % pkgname, legitimize_package_name('eglibc-binary-localedata-%s' % eglibc_name), d)
298                 bb.data.setVar('RPROVIDES_%s' % pkgname, 'glibc-binary-localedata-%s' % eglibc_name, d)
299                 rprovides = 'virtual-locale-%s' % legitimize_package_name(name)
300                 m = re.match("(.*)_(.*)", name)
301                 if m:
302                         rprovides += ' virtual-locale-%s' % m.group(1)
303                 bb.data.setVar('RPROVIDES_%s' % pkgname, rprovides, d)
304                 bb.data.setVar('ALLOW_EMPTY_%s' % pkgname, '1', d)
305                 bb.data.setVar('PACKAGES', '%s %s' % (pkgname, bb.data.getVar('PACKAGES', d, 1)), d)
306
307                 treedir = base_path_join(bb.data.getVar("WORKDIR", d, 1), "locale-tree")
308                 path = bb.data.getVar("PATH", d, 1)
309                 i18npath = base_path_join(treedir, datadir, "i18n")
310
311                 localedef_opts = "--force --old-style --no-archive --prefix=%s --inputfile=%s/i18n/locales/%s --charmap=%s %s" % (treedir, datadir, locale, encoding, name)
312                 cmd = "PATH=\"%s\" I18NPATH=\"%s\" %s -L %s %s/bin/localedef %s" % (path, i18npath, qemu, treedir, treedir, localedef_opts)
313                 bb.note("generating locale %s (%s)" % (locale, encoding))
314                 if os.system(cmd):
315                         raise bb.build.FuncFailed("localedef returned an error (command was %s)." % cmd)
316
317         def output_locale(name, locale, encoding):
318                 use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
319                 if use_bin:
320                         output_locale_binary(name, locale, encoding)
321                 else:
322                         output_locale_source(name, locale, encoding)
323
324         use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
325         if use_bin:
326                 bb.note("preparing tree for binary locale generation")
327                 bb.build.exec_func("do_prep_locale_tree", d)
328
329         # Reshuffle names so that UTF-8 is preferred over other encodings
330         non_utf8 = []
331         for l in encodings.keys():
332                 if len(encodings[l]) == 1:
333                         output_locale(l, l, encodings[l][0])
334                         if encodings[l][0] != "UTF-8":
335                                 non_utf8.append(l)
336                 else:
337                         if "UTF-8" in encodings[l]:
338                                 output_locale(l, l, "UTF-8")
339                                 encodings[l].remove("UTF-8")
340                         else:
341                                 non_utf8.append(l)
342                         for e in encodings[l]:
343                                 output_locale('%s.%s' % (l, e), l, e)
344
345         if non_utf8 != []:
346                 bb.note("the following locales are supported only in legacy encodings:")
347                 bb.note("  " + " ".join(non_utf8))
348
349         use_bin = bb.data.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE", d, 1)
350         if use_bin:
351                 bb.note("collecting binary locales from locale tree")
352                 bb.build.exec_func("do_collect_bins_from_locale_tree", d)
353                 do_split_packages(d, binary_locales_dir, file_regex='(.*)', output_pattern='eglibc-binary-localedata-%s', description='binary locale definition for %s', extra_depends='', allow_dirs=True)
354         else:
355                 bb.note("generation of binary locales disabled. this may break i18n!")
356
357 }
358
359 # We want to do this indirection so that we can safely 'return'
360 # from the called function even though we're prepending
361 python populate_packages_prepend () {
362         if bb.data.getVar('DEBIAN_NAMES', d, 1):
363                 bb.data.setVar('PKG_eglibc', 'libc6', d)
364                 bb.data.setVar('PKG_eglibc-dev', 'libc6-dev', d)
365         bb.build.exec_func('package_do_split_gconvs', d)
366 }