glibc-external.bb 8.6 KB

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