glibc-external.bb 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. SRC_URI = "\
  2. file://SUPPORTED \
  3. file://makedbs.sh \
  4. file://nscd.init;subdir=${REL_S}/nscd \
  5. file://nscd.conf;subdir=${REL_S}/nscd \
  6. file://nscd.service;subdir=${REL_S}/nscd \
  7. "
  8. # For makedbs.sh
  9. FILESPATH .= ":${COREBASE}/meta/recipes-core/glibc/glibc"
  10. REL_S = "${@os.path.relpath('${S}', '${WORKDIR}')}"
  11. require recipes-core/glibc/glibc-common.inc
  12. inherit external-toolchain
  13. require recipes-external/glibc/glibc-external-version.inc
  14. DEPENDS = "virtual/${TARGET_PREFIX}binutils"
  15. PROVIDES += "glibc \
  16. virtual/libc \
  17. virtual/libintl \
  18. virtual/libiconv \
  19. linux-libc-headers \
  20. linux-libc-headers-dev"
  21. def get_external_libc_license(d):
  22. if (d.getVar('TCMODE', True).startswith('external') and
  23. d.getVar('EXTERNAL_TOOLCHAIN', True)):
  24. errnosearch = os.path.join(d.getVar('includedir', True), 'errno.h')
  25. found = oe.external.find_sysroot_files([errnosearch], d)
  26. if found:
  27. errno_paths = found[0]
  28. if errno_paths:
  29. with open(errno_paths[0], 'rU') as f:
  30. text = f.read()
  31. lictext = """ The GNU C Library is free software; you can redistribute it and/or
  32. modify it under the terms of the GNU Lesser General Public
  33. License as published by the Free Software Foundation; either
  34. version 2.1 of the License, or (at your option) any later version."""
  35. if lictext in text:
  36. return 'LGPL-2.1-or-later'
  37. return 'UNKNOWN'
  38. LICENSE:tcmode-external := "${@get_external_libc_license(d)}"
  39. require recipes-external/glibc/glibc-sysroot-setup.inc
  40. require recipes-external/glibc/glibc-package-adjusted.inc
  41. FILES_MIRRORS .= "\
  42. ${base_sbindir}/|/usr/bin/ \n\
  43. ${base_sbindir}/|/usr/${baselib}/bin/ \n\
  44. ${sbindir}/|/usr/bin/ \n\
  45. ${sbindir}/|/usr/${baselib}/bin/ \n\
  46. "
  47. python do_install () {
  48. bb.build.exec_func('external_toolchain_do_install', d)
  49. bb.build.exec_func('glibc_external_do_install_extra', d)
  50. if not bb.utils.contains('EXTERNAL_TOOLCHAIN_FEATURES', 'locale-utf8-is-default', True, False, d):
  51. bb.build.exec_func('adjust_locale_names', d)
  52. # sentinel
  53. }
  54. python adjust_locale_names () {
  55. """Align locale charset names with glibc-locale expectations."""
  56. # Read in supported locales and associated encodings
  57. supported = {}
  58. with open(oe.path.join(d.getVar('WORKDIR', True), "SUPPORTED")) as f:
  59. for line in f.readlines():
  60. try:
  61. locale, charset = line.rstrip().split()
  62. except ValueError:
  63. continue
  64. supported[locale] = charset
  65. # GLIBC_GENERATE_LOCALES var specifies which locales to be generated. empty or "all" means all locales
  66. to_generate = d.getVar('GLIBC_GENERATE_LOCALES', True)
  67. if not to_generate or to_generate == 'all':
  68. to_generate = supported.keys()
  69. else:
  70. to_generate = to_generate.split()
  71. for locale in to_generate:
  72. if locale not in supported:
  73. if '.' in locale:
  74. charset = locale.split('.')[1]
  75. else:
  76. charset = 'UTF-8'
  77. bb.warn("Unsupported locale '%s', assuming encoding '%s'" % (locale, charset))
  78. supported[locale] = charset
  79. localedir = oe.path.join(d.getVar('D', True), d.getVar('localedir', True))
  80. for locale in to_generate:
  81. if '.' not in locale:
  82. continue
  83. locale, charset = locale.split('.', 1)
  84. if '-' not in charset:
  85. continue
  86. oe_name = locale + '.' + charset.lower()
  87. existing_name = locale + '.' + charset.lower().replace('-', '')
  88. this_localedir = oe.path.join(localedir, existing_name)
  89. if os.path.exists(this_localedir):
  90. bb.debug(1, '%s -> %s' % (this_localedir, oe.path.join(localedir, oe_name)))
  91. os.rename(this_localedir, oe.path.join(localedir, oe_name))
  92. }
  93. glibc_external_do_install_extra () {
  94. mkdir -p ${D}${sysconfdir}
  95. touch ${D}${sysconfdir}/ld.so.conf
  96. if [ ! -e ${D}${libdir}/libc.so ]; then
  97. bbfatal "Unable to locate installed libc.so file (${libdir}/libc.so)." \
  98. "This may mean that your external toolchain uses a different" \
  99. "multi-lib setup than your machine configuration"
  100. fi
  101. if [ "${GLIBC_INTERNAL_USE_BINARY_LOCALE}" != "precompiled" ]; then
  102. rm -rf ${D}${localedir}
  103. fi
  104. # Work around localedef failures for non-precompiled
  105. for locale in bo_CN bo_IN; do
  106. if [ -e "${D}${datadir}/i18n/locales/$locale" ]; then
  107. sed -i -e '/^name_fmt\s/s/""/"???"/' "${D}${datadir}/i18n/locales/$locale"
  108. if grep -q '^name_fmt.*""' "${D}${datadir}/i18n/locales/$locale"; then
  109. bbfatal "sed did not fix $locale"
  110. fi
  111. fi
  112. done
  113. # Avoid bash dependency
  114. if [ -e "${D}${bindir}/ldd" ]; then
  115. sed -e '1s#bash#sh#; s#$"#"#g' -i "${D}${bindir}/ldd"
  116. fi
  117. if [ -e "${D}${bindir}/tzselect" ]; then
  118. sed -e '1s#bash#sh#' -i "${D}${bindir}/tzselect"
  119. fi
  120. }
  121. bberror:task-install () {
  122. # Silence any errors from oe_multilib_header, as we don't care about
  123. # missing multilib headers, as the oe-core glibc version isn't necessarily
  124. # the same as our own.
  125. :
  126. }
  127. EXTERNAL_EXTRA_FILES += "\
  128. ${bindir}/mtrace ${bindir}/xtrace ${bindir}/sotruss \
  129. ${datadir}/i18n \
  130. ${libdir}/gconv \
  131. ${@'${localedir}' if d.getVar('GLIBC_INTERNAL_USE_BINARY_LOCALE', True) == 'precompiled' else ''} \
  132. "
  133. # These files are picked up out of the sysroot by glibc-locale, so we don't
  134. # need to keep them around ourselves.
  135. do_install_locale:append() {
  136. rm -rf ${D}${localedir}
  137. }
  138. python () {
  139. # Undo the do_install:append which joined shell to python
  140. install = d.getVar('do_install', False)
  141. python, shell = install.split('# sentinel', 1)
  142. d.setVar('do_install_glibc', shell)
  143. d.setVarFlag('do_install_glibc', 'func', '1')
  144. new_install = python + '\n bb.build.exec_func("do_install_glibc", d)\n'
  145. d.setVar('do_install', new_install.replace('\t', ' '))
  146. # Ensure that we pick up just libm, not all libs that start with m
  147. baselibs = d.getVar('libc_baselibs', False)
  148. baselibs = baselibs.replace('${base_libdir}/libm*.so.*', '${base_libdir}/libm.so.* ${base_libdir}/libmvec.so.*')
  149. baselibs = baselibs.replace('${base_libdir}/libnsl*.so.* ${base_libdir}/libnsl-*.so', '')
  150. print(baselibs)
  151. d.setVar('libc_baselibs', baselibs)
  152. }
  153. # Default pattern is too greedy
  154. FILES:${PN}-utils = "\
  155. ${bindir}/gencat \
  156. ${bindir}/getconf \
  157. ${bindir}/getent \
  158. ${bindir}/iconv \
  159. ${sbindir}/iconvconfig \
  160. ${bindir}/lddlibc4 \
  161. ${bindir}/locale \
  162. ${bindir}/makedb \
  163. ${bindir}/pcprofiledump \
  164. ${bindir}/pldd \
  165. ${bindir}/sprof \
  166. "
  167. FILES:${PN}-doc += "${infodir}/libc.info*"
  168. # Extract for use by do_install_locale
  169. FILES:${PN} += "\
  170. ${bindir}/localedef \
  171. ${libdir}/gconv \
  172. ${libdir}/locale \
  173. ${datadir}/locale \
  174. ${datadir}/i18n \
  175. ${prefix}/lib64xthead/lp64d \
  176. "
  177. FILES:${PN}-dev:remove := "${datadir}/aclocal"
  178. FILES:${PN}-dev:remove = "/lib/*.o"
  179. FILES:${PN}-dev += "${libdir}/*crt*.o"
  180. linux_include_subdirs = "asm asm-generic bits drm linux mtd rdma sound video"
  181. FILES:${PN}-dev += "${@' '.join('${includedir}/%s' % d for d in '${linux_include_subdirs}'.split())}"
  182. # Already multilib headers for oe sdks
  183. libc_baselibs_dev += "\
  184. ${includedir}/fpu_control-*.h \
  185. ${includedir}/ieee754-*.h \
  186. "
  187. libc_baselibs_dev += "${@' '.join('${libdir}/' + os.path.basename(l.replace('${SOLIBS}', '${SOLIBSDEV}')) for l in '${libc_baselibs}'.replace('${base_libdir}/ld*${SOLIBS}', '').split() if l.endswith('${SOLIBS}'))}"
  188. FILES:${PN}-staticdev = "\
  189. ${@'${libc_baselibs_dev}'.replace('${SOLIBSDEV}', '.a')} \
  190. ${libdir}/libg.a \
  191. ${libdir}/libieee.a \
  192. ${libdir}/libmcheck.a \
  193. "
  194. FILES:${PN}-dev += "\
  195. ${libc_baselibs_dev} \
  196. ${libdir}/libcidn${SOLIBSDEV} \
  197. ${libdir}/libthread_db${SOLIBSDEV} \
  198. ${libdir}/libpthread${SOLIBSDEV} \
  199. "
  200. libc_headers_file = "${@bb.utils.which('${FILESPATH}', 'libc.headers')}"
  201. FILES:${PN}-dev += "\
  202. ${@' '.join('${includedir}/' + f.rstrip() for f in oe.utils.read_file('${libc_headers_file}').splitlines())} \
  203. ${includedir}/fpu_control.h \
  204. ${includedir}/stdc-predef.h \
  205. ${includedir}/uchar.h \
  206. ${includedir}/features-time64.h \
  207. "
  208. FILES:${PN}-dev[file-checksums] += "${libc_headers_file}:True"
  209. # glibc's utils need libgcc
  210. do_package[depends] += "${MLPREFIX}libgcc:do_packagedata"
  211. do_package_write_ipk[depends] += "${MLPREFIX}libgcc:do_packagedata"
  212. do_package_write_deb[depends] += "${MLPREFIX}libgcc:do_packagedata"
  213. do_package_write_rpm[depends] += "${MLPREFIX}libgcc:do_packagedata"
  214. # glibc may need libssp for -fstack-protector builds
  215. do_packagedata[depends] += "gcc-runtime:do_packagedata"
  216. python do_package:append() {
  217. bb.utils.mkdirhier(pkgdest + '/' + pn + '/lib64xthead')
  218. os.symlink("../lib", pkgdest + '/' + pn + '/lib64xthead/lp64d')
  219. }
  220. # We don't need linux-libc-headers
  221. LINUX_LIBC_RDEP_REMOVE ?= "linux-libc-headers-dev"
  222. RDEPENDS:${PN}-dev:remove = "${LINUX_LIBC_RDEP_REMOVE}"
  223. # FILES:${PN}-dev:remove = "${base_libdir}/*_nonshared.a ${libdir}/*_nonshared.a"
  224. # FILES:${PN}-dev += "${libdir}/libc_nonshared.a ${libdir}/libpthread_nonshared.a ${libdir}/libmvec_nonshared.a"