binconfig.bbclass 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. FILES:${PN}-dev += "${bindir}/*-config"
  7. # The namespaces can clash here hence the two step replace
  8. def get_binconfig_mangle(d):
  9. s = "-e ''"
  10. if not bb.data.inherits_class('native', d):
  11. optional_quote = r"\(\"\?\)"
  12. s += " -e 's:=%s${base_libdir}:=\\1OEBASELIBDIR:;'" % optional_quote
  13. s += " -e 's:=%s${libdir}:=\\1OELIBDIR:;'" % optional_quote
  14. s += " -e 's:=%s${includedir}:=\\1OEINCDIR:;'" % optional_quote
  15. s += " -e 's:=%s${datadir}:=\\1OEDATADIR:'" % optional_quote
  16. s += " -e 's:=%s${prefix}/:=\\1OEPREFIX/:'" % optional_quote
  17. s += " -e 's:=%s${exec_prefix}/:=\\1OEEXECPREFIX/:'" % optional_quote
  18. s += " -e 's:-L${libdir}:-LOELIBDIR:;'"
  19. s += " -e 's:-I${includedir}:-IOEINCDIR:;'"
  20. s += " -e 's:-L${WORKDIR}:-LOELIBDIR:'"
  21. s += " -e 's:-I${WORKDIR}:-IOEINCDIR:'"
  22. s += " -e 's:OEBASELIBDIR:${STAGING_BASELIBDIR}:;'"
  23. s += " -e 's:OELIBDIR:${STAGING_LIBDIR}:;'"
  24. s += " -e 's:OEINCDIR:${STAGING_INCDIR}:;'"
  25. s += " -e 's:OEDATADIR:${STAGING_DATADIR}:'"
  26. s += " -e 's:OEPREFIX:${STAGING_DIR_HOST}${prefix}:'"
  27. s += " -e 's:OEEXECPREFIX:${STAGING_DIR_HOST}${exec_prefix}:'"
  28. if d.getVar("OE_BINCONFIG_EXTRA_MANGLE", False):
  29. s += d.getVar("OE_BINCONFIG_EXTRA_MANGLE")
  30. return s
  31. BINCONFIG_GLOB ?= "*-config"
  32. PACKAGE_PREPROCESS_FUNCS += "binconfig_package_preprocess"
  33. binconfig_package_preprocess () {
  34. for config in `find ${PKGD} -type f -name '${BINCONFIG_GLOB}'`; do
  35. sed -i \
  36. -e 's:${STAGING_BASELIBDIR}:${base_libdir}:g;' \
  37. -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
  38. -e 's:${STAGING_INCDIR}:${includedir}:g;' \
  39. -e 's:${STAGING_DATADIR}:${datadir}:' \
  40. -e 's:${STAGING_DIR_HOST}${prefix}:${prefix}:' \
  41. $config
  42. done
  43. }
  44. SYSROOT_PREPROCESS_FUNCS += "binconfig_sysroot_preprocess"
  45. binconfig_sysroot_preprocess () {
  46. for config in `find ${S} -type f -name '${BINCONFIG_GLOB}'` `find ${B} -type f -name '${BINCONFIG_GLOB}'`; do
  47. configname=`basename $config`
  48. install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}
  49. sed ${@get_binconfig_mangle(d)} $config > ${SYSROOT_DESTDIR}${bindir_crossscripts}/$configname
  50. chmod u+x ${SYSROOT_DESTDIR}${bindir_crossscripts}/$configname
  51. done
  52. }