Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | inherit module-base kernel-module-split pkgconfig |
| 8 | |
| 9 | EXTRA_OEMAKE += "KERNEL_SRC=${STAGING_KERNEL_DIR}" |
| 10 | |
| 11 | MODULES_INSTALL_TARGET ?= "modules_install" |
| 12 | MODULES_MODULE_SYMVERS_LOCATION ?= "" |
| 13 | |
| 14 | python __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 | |
| 23 | python 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 Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame^] | 35 | os.environ['OBJCOPY'] = d.getVar('KERNEL_OBJCOPY') |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 36 | 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 | |
| 44 | module_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 Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame^] | 49 | AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 50 | O=${STAGING_KERNEL_BUILDDIR} \ |
| 51 | KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \ |
| 52 | ${MAKE_TARGETS} |
| 53 | } |
| 54 | |
| 55 | module_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 Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame^] | 59 | CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 60 | 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 | |
| 76 | EXPORT_FUNCTIONS do_compile do_install |
| 77 | |
| 78 | # add all splitted modules to PN RDEPENDS, PN can be empty now |
| 79 | KERNEL_MODULES_META_PACKAGE = "${PN}" |
| 80 | FILES:${PN} = "" |
| 81 | ALLOW_EMPTY:${PN} = "1" |