blob: f2f0b25a2d1fcf141730930ec8dc45949860f7ad [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
Patrick Williams520786c2023-06-25 16:20:36 -050023python do_package:prepend () {
24 os.environ['STRIP'] = d.getVar('KERNEL_STRIP')
25}
26
Patrick Williams92b42cb2022-09-03 06:53:57 -050027python do_devshell:prepend () {
28 os.environ['CFLAGS'] = ''
29 os.environ['CPPFLAGS'] = ''
30 os.environ['CXXFLAGS'] = ''
31 os.environ['LDFLAGS'] = ''
32
33 os.environ['KERNEL_PATH'] = d.getVar('STAGING_KERNEL_DIR')
34 os.environ['KERNEL_SRC'] = d.getVar('STAGING_KERNEL_DIR')
35 os.environ['KERNEL_VERSION'] = d.getVar('KERNEL_VERSION')
36 os.environ['CC'] = d.getVar('KERNEL_CC')
37 os.environ['LD'] = d.getVar('KERNEL_LD')
38 os.environ['AR'] = d.getVar('KERNEL_AR')
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060039 os.environ['OBJCOPY'] = d.getVar('KERNEL_OBJCOPY')
Patrick Williams520786c2023-06-25 16:20:36 -050040 os.environ['STRIP'] = d.getVar('KERNEL_STRIP')
Patrick Williams92b42cb2022-09-03 06:53:57 -050041 os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
42 kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
43 if kbuild_extra_symbols:
44 os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols
45 else:
46 os.environ['KBUILD_EXTRA_SYMBOLS'] = ''
47}
48
49module_do_compile() {
50 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
51 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \
52 KERNEL_VERSION=${KERNEL_VERSION} \
53 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060054 AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
Patrick Williams520786c2023-06-25 16:20:36 -050055 STRIP="${KERNEL_STRIP}" \
Patrick Williams92b42cb2022-09-03 06:53:57 -050056 O=${STAGING_KERNEL_BUILDDIR} \
57 KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
58 ${MAKE_TARGETS}
59}
60
61module_do_install() {
62 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
63 oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \
64 INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060065 CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" \
Patrick Williams520786c2023-06-25 16:20:36 -050066 STRIP="${KERNEL_STRIP}" \
Patrick Williams92b42cb2022-09-03 06:53:57 -050067 O=${STAGING_KERNEL_BUILDDIR} \
68 ${MODULES_INSTALL_TARGET}
69
70 if [ ! -e "${B}/${MODULES_MODULE_SYMVERS_LOCATION}/Module.symvers" ] ; then
71 bbwarn "Module.symvers not found in ${B}/${MODULES_MODULE_SYMVERS_LOCATION}"
72 bbwarn "Please consider setting MODULES_MODULE_SYMVERS_LOCATION to a"
73 bbwarn "directory below B to get correct inter-module dependencies"
74 else
75 install -Dm0644 "${B}/${MODULES_MODULE_SYMVERS_LOCATION}"/Module.symvers ${D}${includedir}/${BPN}/Module.symvers
76 # Module.symvers contains absolute path to the build directory.
77 # While it doesn't actually seem to matter which path is specified,
78 # clear them out to avoid confusion
79 sed -e 's:${B}/::g' -i ${D}${includedir}/${BPN}/Module.symvers
80 fi
81}
82
83EXPORT_FUNCTIONS do_compile do_install
84
85# add all splitted modules to PN RDEPENDS, PN can be empty now
86KERNEL_MODULES_META_PACKAGE = "${PN}"
87FILES:${PN} = ""
88ALLOW_EMPTY:${PN} = "1"