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') |
| 35 | os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR') |
| 36 | kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS') |
| 37 | if kbuild_extra_symbols: |
| 38 | os.environ['KBUILD_EXTRA_SYMBOLS'] = kbuild_extra_symbols |
| 39 | else: |
| 40 | os.environ['KBUILD_EXTRA_SYMBOLS'] = '' |
| 41 | } |
| 42 | |
| 43 | module_do_compile() { |
| 44 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS |
| 45 | oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \ |
| 46 | KERNEL_VERSION=${KERNEL_VERSION} \ |
| 47 | CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ |
| 48 | AR="${KERNEL_AR}" \ |
| 49 | O=${STAGING_KERNEL_BUILDDIR} \ |
| 50 | KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \ |
| 51 | ${MAKE_TARGETS} |
| 52 | } |
| 53 | |
| 54 | module_do_install() { |
| 55 | unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS |
| 56 | oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \ |
| 57 | INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \ |
| 58 | CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ |
| 59 | O=${STAGING_KERNEL_BUILDDIR} \ |
| 60 | ${MODULES_INSTALL_TARGET} |
| 61 | |
| 62 | if [ ! -e "${B}/${MODULES_MODULE_SYMVERS_LOCATION}/Module.symvers" ] ; then |
| 63 | bbwarn "Module.symvers not found in ${B}/${MODULES_MODULE_SYMVERS_LOCATION}" |
| 64 | bbwarn "Please consider setting MODULES_MODULE_SYMVERS_LOCATION to a" |
| 65 | bbwarn "directory below B to get correct inter-module dependencies" |
| 66 | else |
| 67 | install -Dm0644 "${B}/${MODULES_MODULE_SYMVERS_LOCATION}"/Module.symvers ${D}${includedir}/${BPN}/Module.symvers |
| 68 | # Module.symvers contains absolute path to the build directory. |
| 69 | # While it doesn't actually seem to matter which path is specified, |
| 70 | # clear them out to avoid confusion |
| 71 | sed -e 's:${B}/::g' -i ${D}${includedir}/${BPN}/Module.symvers |
| 72 | fi |
| 73 | } |
| 74 | |
| 75 | EXPORT_FUNCTIONS do_compile do_install |
| 76 | |
| 77 | # add all splitted modules to PN RDEPENDS, PN can be empty now |
| 78 | KERNEL_MODULES_META_PACKAGE = "${PN}" |
| 79 | FILES:${PN} = "" |
| 80 | ALLOW_EMPTY:${PN} = "1" |