glibc-external.bb 8.7 KB

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