blob: c8bf7bacf81e54eb14a3da38e88fc22a31b55876 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001# waf is a build system which is used by samba related project.
2# Obtain details from https://wiki.samba.org/index.php/Waf
Brad Bishop316dfdd2018-06-25 12:45:53 -04003#
Brad Bishop26bdd442019-08-16 17:08:17 -04004inherit qemu python3native
Patrick Williamsb48b7b42016-08-17 15:04:38 -05005
Brad Bishop26bdd442019-08-16 17:08:17 -04006DEPENDS += "qemu-native libxslt-native docbook-xsl-stylesheets-native python3"
Patrick Williamsb48b7b42016-08-17 15:04:38 -05007
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} \
Patrick Williamsddad1a12017-02-23 20:36:32 -060021 ${PACKAGECONFIG_CONFARGS} \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050022 "
23
Brad Bishop316dfdd2018-06-25 12:45:53 -040024# 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
Patrick Williamsb48b7b42016-08-17 15:04:38 -050047# 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
Brad Bishop6e60e8b2018-02-01 10:27:11 -050071 WAF_CROSS_ANSWERS_PATH="${THISDIR}/../../files/waf-cross-answers"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050072 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 Williamsb48b7b42016-08-17 15:04:38 -050093 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}
Patrick Williams39653562024-03-01 08:54:02 -060098 export PYTHONARCHDIR=${PYTHON_SITEPACKAGES_DIR}
Andrew Geissler517393d2023-01-13 08:55:19 -060099 export PYTHON_CONFIG=${STAGING_EXECPREFIXDIR}/python-target-config/python3-config
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500100
101 CONFIG_CMD="./configure ${CONFIGUREOPTS} ${EXTRA_OECONF} --cross-compile"
102 if [ "${CROSS_METHOD}" = "answer" ]; then
103 ${CONFIG_CMD} --cross-answers="${CROSS_ANSWERS}"
104 elif [ "${CROSS_METHOD}" = "exec" ]; then
105 ${CONFIG_CMD} --cross-exec="${CROSS_EXEC}"
106 elif [ "${CROSS_METHOD}" = "both" ]; then
107 ${CONFIG_CMD} --cross-answers="${CROSS_ANSWERS}" --cross-exec="${CROSS_EXEC}"
108 else
109 echo "ERROR: ${CROSS_METHOD} is not valid for cross-compile!"
110 exit 1
111 fi
112}
113
Brad Bishop316dfdd2018-06-25 12:45:53 -0400114do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500115do_compile () {
Brad Bishop26bdd442019-08-16 17:08:17 -0400116 python3 ./buildtools/bin/waf ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)}
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500117}
118
119do_install() {
120 oe_runmake install DESTDIR=${D}
121}