blob: 1632c3c60ee7dc73ea6250336c77576bbbc061b4 [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#
4inherit qemu pythonnative
Patrick Williamsb48b7b42016-08-17 15:04:38 -05005
6DEPENDS += "qemu-native libxslt-native docbook-xsl-stylesheets-native python"
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} \
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}
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 Bishop316dfdd2018-06-25 12:45:53 -0400112do_compile[progress] = "outof:^\[\s*(\d+)/\s*(\d+)\]\s+"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500113do_compile () {
Brad Bishop316dfdd2018-06-25 12:45:53 -0400114 python ./buildtools/bin/waf ${@oe.utils.parallel_make_argument(d, '-j%d', limit=64)}
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500115}
116
117do_install() {
118 oe_runmake install DESTDIR=${D}
119}