xref: /OK3568_Linux_fs/yocto/meta-openembedded/meta-networking/classes/waf-samba.bbclass (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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#
4inherit qemu python3native
5
6DEPENDS += "qemu-native libxslt-native docbook-xsl-stylesheets-native python3"
7
8CONFIGUREOPTS = " --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} \
21                  ${PACKAGECONFIG_CONFARGS} \
22                "
23
24# avoids build breaks when using no-static-libs.inc
25DISABLE_STATIC = ""
26
27def 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
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.
66CROSS_METHOD ?= "answer"
67
68do_configure() {
69
70    # Prepare the cross-answers file
71    WAF_CROSS_ANSWERS_PATH="${THISDIR}/../../files/waf-cross-answers"
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
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
112do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
113do_compile () {
114    python3 ./buildtools/bin/waf ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)}
115}
116
117do_install() {
118    oe_runmake install DESTDIR=${D}
119}
120