blob: a09ec3ed1e19c94ada42d64a86d2389dcdfddeb6 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001inherit module-base kernel-module-split pkgconfig
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003EXTRA_OEMAKE += "KERNEL_SRC=${STAGING_KERNEL_DIR}"
4
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05005MODULES_INSTALL_TARGET ?= "modules_install"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05006MODULES_MODULE_SYMVERS_LOCATION ?= ""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05007
Patrick Williamsc0f7c042017-02-23 20:41:17 -06008python __anonymous () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009 depends = d.getVar('DEPENDS')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060010 extra_symbols = []
11 for dep in depends.split():
12 if dep.startswith("kernel-module-"):
13 extra_symbols.append("${STAGING_INCDIR}/" + dep + "/Module.symvers")
14 d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
15}
16
Patrick Williams213cb262021-08-07 19:21:33 -050017python do_devshell:prepend () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018 os.environ['CFLAGS'] = ''
19 os.environ['CPPFLAGS'] = ''
20 os.environ['CXXFLAGS'] = ''
21 os.environ['LDFLAGS'] = ''
22
23 os.environ['KERNEL_PATH'] = d.getVar('STAGING_KERNEL_DIR')
24 os.environ['KERNEL_SRC'] = d.getVar('STAGING_KERNEL_DIR')
25 os.environ['KERNEL_VERSION'] = d.getVar('KERNEL_VERSION')
26 os.environ['CC'] = d.getVar('KERNEL_CC')
27 os.environ['LD'] = d.getVar('KERNEL_LD')
28 os.environ['AR'] = d.getVar('KERNEL_AR')
29 os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
30 kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
31 if kbuild_extra_symbols:
32 os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols
33 else:
34 os.environ['KBUILD_EXTRA_SYMBOLS'] = ''
35}
36
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037module_do_compile() {
38 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
39 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \
40 KERNEL_VERSION=${KERNEL_VERSION} \
41 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
42 AR="${KERNEL_AR}" \
43 O=${STAGING_KERNEL_BUILDDIR} \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044 KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045 ${MAKE_TARGETS}
46}
47
48module_do_install() {
49 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \
Brad Bishop19323692019-04-05 15:28:33 -040051 INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
53 O=${STAGING_KERNEL_BUILDDIR} \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050054 ${MODULES_INSTALL_TARGET}
Patrick Williamsc0f7c042017-02-23 20:41:17 -060055
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056 if [ ! -e "${B}/${MODULES_MODULE_SYMVERS_LOCATION}/Module.symvers" ] ; then
57 bbwarn "Module.symvers not found in ${B}/${MODULES_MODULE_SYMVERS_LOCATION}"
58 bbwarn "Please consider setting MODULES_MODULE_SYMVERS_LOCATION to a"
59 bbwarn "directory below B to get correct inter-module dependencies"
60 else
61 install -Dm0644 "${B}/${MODULES_MODULE_SYMVERS_LOCATION}"/Module.symvers ${D}${includedir}/${BPN}/Module.symvers
62 # Module.symvers contains absolute path to the build directory.
63 # While it doesn't actually seem to matter which path is specified,
64 # clear them out to avoid confusion
65 sed -e 's:${B}/::g' -i ${D}${includedir}/${BPN}/Module.symvers
66 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067}
68
69EXPORT_FUNCTIONS do_compile do_install
70
71# add all splitted modules to PN RDEPENDS, PN can be empty now
72KERNEL_MODULES_META_PACKAGE = "${PN}"
Patrick Williams213cb262021-08-07 19:21:33 -050073FILES:${PN} = ""
74ALLOW_EMPTY:${PN} = "1"