waf-samba.bbclass 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # waf is a build system which is used by samba related project.
  2. # Obtain details from https://wiki.samba.org/index.php/Waf
  3. #
  4. inherit qemu python3native
  5. DEPENDS += "qemu-native libxslt-native docbook-xsl-stylesheets-native python3"
  6. CONFIGUREOPTS = " --prefix=${prefix} \
  7. --bindir=${bindir} \
  8. --sbindir=${sbindir} \
  9. --libexecdir=${libexecdir} \
  10. --datadir=${datadir} \
  11. --sysconfdir=${sysconfdir} \
  12. --sharedstatedir=${sharedstatedir} \
  13. --localstatedir=${localstatedir} \
  14. --libdir=${libdir} \
  15. --includedir=${includedir} \
  16. --oldincludedir=${oldincludedir} \
  17. --infodir=${infodir} \
  18. --mandir=${mandir} \
  19. ${PACKAGECONFIG_CONFARGS} \
  20. "
  21. # avoids build breaks when using no-static-libs.inc
  22. DISABLE_STATIC = ""
  23. def get_waf_parallel_make(d):
  24. pm = d.getVar('PARALLEL_MAKE')
  25. if pm:
  26. # look for '-j' and throw other options (e.g. '-l') away
  27. # because they might have different meaning in bjam
  28. pm = pm.split()
  29. while pm:
  30. opt = pm.pop(0)
  31. if opt == '-j':
  32. v = pm.pop(0)
  33. elif opt.startswith('-j'):
  34. v = opt[2:].strip()
  35. else:
  36. continue
  37. v = min(64, int(v))
  38. return '-j' + str(v)
  39. return ""
  40. # Three methods for waf cross compile:
  41. # 1. answers:
  42. # Only --cross-answers - try the cross-answers file, and if
  43. # there's no corresponding answer, add to the file and mark
  44. # the configure process as unfinished.
  45. # 2. exec:
  46. # Only --cross-execute - get the answer from cross-execute,
  47. # an emulator (qemu) is used to run cross-compiled binaries.
  48. # 3. both:
  49. # (notes: not supported in lower version of some packages,
  50. # please check buildtools/wafsamba/samba_cross.py in the
  51. # package source)
  52. # Try the cross-answers file first, and if there is no
  53. # corresponding answer, use cross-execute to get an answer,
  54. # and add that answer to the file.
  55. #
  56. # The first one is preferred since it may fail with 2 or 3 if
  57. # the target board is not suported by qemu, but we can use 2 or 3
  58. # to help generate the cross answer when adding new board support.
  59. CROSS_METHOD ?= "answer"
  60. do_configure() {
  61. # Prepare the cross-answers file
  62. WAF_CROSS_ANSWERS_PATH="${THISDIR}/../../files/waf-cross-answers"
  63. CROSS_ANSWERS="${B}/cross-answers-${TARGET_ARCH}.txt"
  64. if [ -e ${CROSS_ANSWERS} ]; then
  65. rm -f ${CROSS_ANSWERS}
  66. fi
  67. echo 'Checking uname machine type: "${TARGET_ARCH}"' >> ${CROSS_ANSWERS}
  68. echo 'Checking uname release type: "${OLDEST_KERNEL}"' >> ${CROSS_ANSWERS}
  69. cat ${WAF_CROSS_ANSWERS_PATH}/cross-answers-${TARGET_ARCH}.txt >> ${CROSS_ANSWERS}
  70. qemu_binary="${@qemu_target_binary(d)}"
  71. if [ "${qemu_binary}" = "qemu-allarch" ]; then
  72. qemu_binary="qemuwrapper"
  73. fi
  74. libdir_qemu="${STAGING_DIR_HOST}/${libdir}"
  75. base_libdir_qemu="${STAGING_DIR_HOST}/${base_libdir}"
  76. CROSS_EXEC="${qemu_binary} \
  77. ${QEMU_OPTIONS} \
  78. -L ${STAGING_DIR_HOST} \
  79. -E LD_LIBRARY_PATH=${libdir_qemu}:${base_libdir_qemu}"
  80. export BUILD_ARCH=${BUILD_ARCH}
  81. export HOST_ARCH=${HOST_ARCH}
  82. export STAGING_LIBDIR=${STAGING_LIBDIR}
  83. export STAGING_INCDIR=${STAGING_INCDIR}
  84. export PYTHONPATH=${STAGING_DIR_HOST}${PYTHON_SITEPACKAGES_DIR}
  85. CONFIG_CMD="./configure ${CONFIGUREOPTS} ${EXTRA_OECONF} --cross-compile"
  86. if [ "${CROSS_METHOD}" = "answer" ]; then
  87. ${CONFIG_CMD} --cross-answers="${CROSS_ANSWERS}"
  88. elif [ "${CROSS_METHOD}" = "exec" ]; then
  89. ${CONFIG_CMD} --cross-exec="${CROSS_EXEC}"
  90. elif [ "${CROSS_METHOD}" = "both" ]; then
  91. ${CONFIG_CMD} --cross-answers="${CROSS_ANSWERS}" --cross-exec="${CROSS_EXEC}"
  92. else
  93. echo "ERROR: ${CROSS_METHOD} is not valid for cross-compile!"
  94. exit 1
  95. fi
  96. }
  97. do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
  98. do_compile () {
  99. python3 ./buildtools/bin/waf ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)}
  100. }
  101. do_install() {
  102. oe_runmake install DESTDIR=${D}
  103. }