Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | SUMMARY = "VirtualBox Linux Guest Drivers" |
| 2 | SECTION = "core" |
| 3 | LICENSE = "GPL-3.0-only" |
| 4 | LIC_FILES_CHKSUM = "file://${WORKDIR}/${VBOX_NAME}/COPYING;md5=fff5fe1c81dd6dc3d522e7862e44881e" |
| 5 | |
| 6 | DEPENDS = "virtual/kernel" |
| 7 | |
| 8 | inherit module kernel-module-split |
| 9 | |
| 10 | COMPATIBLE_MACHINE = "(qemux86|qemux86-64)" |
| 11 | |
| 12 | VBOX_NAME = "VirtualBox-${PV}" |
| 13 | |
| 14 | SRC_URI = "http://download.virtualbox.org/virtualbox/${PV}/${VBOX_NAME}.tar.bz2 \ |
| 15 | file://Makefile.utils \ |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 16 | file://0001-vbox_fb-fix-kernel-v6.5-build.patch \ |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 17 | " |
| 18 | |
Patrick Williams | 2a25492 | 2023-08-11 09:48:11 -0500 | [diff] [blame] | 19 | SRC_URI[sha256sum] = "0b1e6d8b7f87d017c7fae37f80586acff04f799ffc1d51e995954d6415dee371" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 20 | |
| 21 | S ?= "${WORKDIR}/vbox_module" |
| 22 | S:task-patch = "${WORKDIR}/${VBOX_NAME}" |
| 23 | |
| 24 | export VBOX_KBUILD_TARGET_ARCH="${ARCH}" |
| 25 | export VBOX_KBUILD_TARGET_ARCH:x86-64="amd64" |
| 26 | |
| 27 | EXTRA_OEMAKE += "KERN_DIR='${WORKDIR}/${KERNEL_VERSION}/build' KBUILD_VERBOSE=1" |
| 28 | |
| 29 | # otherwise 5.2.22 builds just vboxguest |
| 30 | MAKE_TARGETS = "all" |
| 31 | |
| 32 | addtask export_sources after do_patch before do_configure |
| 33 | do_export_sources[depends] += "virtual/kernel:do_shared_workdir" |
| 34 | |
| 35 | do_export_sources() { |
| 36 | mkdir -p "${S}" |
| 37 | ${WORKDIR}/${VBOX_NAME}/src/VBox/Additions/linux/export_modules.sh ${T}/vbox_modules.tar.gz |
| 38 | tar -C "${S}" -xzf ${T}/vbox_modules.tar.gz |
| 39 | |
| 40 | # add a mount utility to use shared folder from VBox Addition Source Code |
| 41 | mkdir -p "${S}/utils" |
| 42 | install ${WORKDIR}/${VBOX_NAME}/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c ${S}/utils |
| 43 | install ${WORKDIR}/${VBOX_NAME}/src/VBox/Additions/linux/sharedfolders/vbsfmount.c ${S}/utils |
| 44 | install ${S}/../Makefile.utils ${S}/utils/Makefile |
| 45 | |
| 46 | # some kernel versions have issues with stdarg.h and compatibility with |
| 47 | # the sysroot and libc-headers/uapi. If we include the file directly from |
| 48 | # the kernel source (STAGING_KERNEL_DIR) we get conflicting types on many |
| 49 | # structures, due to kernel .h files being found before libc .h files. |
| 50 | # if we grab just this one file from the source, and put it into our |
| 51 | # file structure, everything holds together |
| 52 | mkdir -p ${S}/vboxsf/include/linux |
| 53 | install ${STAGING_KERNEL_DIR}/include/linux/stdarg.h ${S}/vboxsf/include/linux |
| 54 | } |
| 55 | |
| 56 | do_configure:prepend() { |
| 57 | # vboxguestdrivers/5.2.6-r0/vbox_module/vboxguest/Makefile.include.header:99: *** The variable KERN_DIR must be a kernel build folder and end with /build without a trailing slash, or KERN_VER must be set. Stop. |
| 58 | # vboxguestdrivers/5.2.6-r0/vbox_module/vboxguest/Makefile.include.header:108: *** The kernel build folder path must end in <version>/build, or the variable KERN_VER must be set. Stop. |
| 59 | mkdir -p ${WORKDIR}/${KERNEL_VERSION} |
| 60 | ln -snf ${STAGING_KERNEL_DIR} ${WORKDIR}/${KERNEL_VERSION}/build |
| 61 | } |
| 62 | |
| 63 | # compile and install mount utility |
| 64 | do_compile() { |
| 65 | oe_runmake all |
| 66 | oe_runmake 'LD=${CC}' 'EXTRA_CFLAGS=-I${STAGING_KERNEL_BUILDDIR}/include/' 'LDFLAGS=${LDFLAGS}' -C ${S}/utils |
| 67 | if ! [ -e vboxguest.ko -a -e vboxsf.ko -a -e vboxvideo.ko ] ; then |
| 68 | echo "ERROR: One of vbox*.ko modules wasn't built" |
| 69 | exit 1 |
| 70 | fi |
| 71 | } |
| 72 | |
| 73 | module_do_install() { |
| 74 | MODULE_DIR=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/misc |
| 75 | install -d $MODULE_DIR |
| 76 | install -m 644 vboxguest.ko $MODULE_DIR |
| 77 | install -m 644 vboxsf.ko $MODULE_DIR |
| 78 | install -m 644 vboxvideo.ko $MODULE_DIR |
| 79 | } |
| 80 | |
| 81 | do_install:append() { |
| 82 | install -d ${D}${base_sbindir} |
| 83 | install -m 755 ${S}/utils/mount.vboxsf ${D}${base_sbindir} |
| 84 | } |
| 85 | |
| 86 | PACKAGES += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo" |
| 87 | RRECOMMENDS:${PN} += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo" |
| 88 | |
| 89 | FILES:${PN} = "${base_sbindir}" |
| 90 | |
| 91 | # autoload if installed |
| 92 | KERNEL_MODULE_AUTOLOAD += "vboxguest vboxsf vboxvideo" |