glibc-external.bb 8.4 KB

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