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