blob: b3b852be5f68d80bc9d3345a58b4ff8ed4e90bc1 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7inherit module-base kernel-module-split pkgconfig
8
9EXTRA_OEMAKE += "KERNEL_SRC=${STAGING_KERNEL_DIR}"
10
11MODULES_INSTALL_TARGET ?= "modules_install"
12MODULES_MODULE_SYMVERS_LOCATION ?= ""
13
14python __anonymous () {
15 depends = d.getVar('DEPENDS')
16 extra_symbols = []
17 for dep in depends.split():
18 if dep.startswith("kernel-module-"):
19 extra_symbols.append("${STAGING_INCDIR}/" + dep + "/Module.symvers")
20 d.setVar('KBUILD_EXTRA_SYMBOLS', " ".join(extra_symbols))
21}
22
23python do_devshell:prepend () {
24 os.environ['CFLAGS'] = ''
25 os.environ['CPPFLAGS'] = ''
26 os.environ['CXXFLAGS'] = ''
27 os.environ['LDFLAGS'] = ''
28
29 os.environ['KERNEL_PATH'] = d.getVar('STAGING_KERNEL_DIR')
30 os.environ['KERNEL_SRC'] = d.getVar('STAGING_KERNEL_DIR')
31 os.environ['KERNEL_VERSION'] = d.getVar('KERNEL_VERSION')
32 os.environ['CC'] = d.getVar('KERNEL_CC')
33 os.environ['LD'] = d.getVar('KERNEL_LD')
34 os.environ['AR'] = d.getVar('KERNEL_AR')
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060035 os.environ['OBJCOPY'] = d.getVar('KERNEL_OBJCOPY')
Patrick Williams92b42cb2022-09-03 06:53:57 -050036 os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
37 kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
38 if kbuild_extra_symbols:
39 os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols
40 else:
41 os.environ['KBUILD_EXTRA_SYMBOLS'] = ''
42}
43
44module_do_compile() {
45 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
46 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \
47 KERNEL_VERSION=${KERNEL_VERSION} \
48 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060049 AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
Patrick Williams92b42cb2022-09-03 06:53:57 -050050 O=${STAGING_KERNEL_BUILDDIR} \
51 KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
52 ${MAKE_TARGETS}
53}
54
55module_do_install() {
56 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
57 oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \
58 INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060059 CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" \
Patrick Williams92b42cb2022-09-03 06:53:57 -050060 O=${STAGING_KERNEL_BUILDDIR} \
61 ${MODULES_INSTALL_TARGET}
62
63 if [ ! -e "${B}/${MODULES_MODULE_SYMVERS_LOCATION}/Module.symvers" ] ; then
64 bbwarn "Module.symvers not found in ${B}/${MODULES_MODULE_SYMVERS_LOCATION}"
65 bbwarn "Please consider setting MODULES_MODULE_SYMVERS_LOCATION to a"
66 bbwarn "directory below B to get correct inter-module dependencies"
67 else
68 install -Dm0644 "${B}/${MODULES_MODULE_SYMVERS_LOCATION}"/Module.symvers ${D}${includedir}/${BPN}/Module.symvers
69 # Module.symvers contains absolute path to the build directory.
70 # While it doesn't actually seem to matter which path is specified,
71 # clear them out to avoid confusion
72 sed -e 's:${B}/::g' -i ${D}${includedir}/${BPN}/Module.symvers
73 fi
74}
75
76EXPORT_FUNCTIONS do_compile do_install
77
78# add all splitted modules to PN RDEPENDS, PN can be empty now
79KERNEL_MODULES_META_PACKAGE = "${PN}"
80FILES:${PN} = ""
81ALLOW_EMPTY:${PN} = "1"