blob: 8e9013824450cedeabcee31feda70b4511890ae3 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001SUMMARY = "VirtualBox Linux Guest Drivers"
2SECTION = "core"
3LICENSE = "GPL-3.0-only"
4LIC_FILES_CHKSUM = "file://${WORKDIR}/${VBOX_NAME}/COPYING;md5=fff5fe1c81dd6dc3d522e7862e44881e"
5
6DEPENDS = "virtual/kernel"
7
8inherit module kernel-module-split
9
10COMPATIBLE_MACHINE = "(qemux86|qemux86-64)"
11
12VBOX_NAME = "VirtualBox-${PV}"
13
14SRC_URI = "http://download.virtualbox.org/virtualbox/${PV}/${VBOX_NAME}.tar.bz2 \
15 file://Makefile.utils \
Andrew Geissler220dafd2023-10-04 10:18:08 -050016 file://0001-vbox_fb-fix-kernel-v6.5-build.patch \
Andrew Geissler517393d2023-01-13 08:55:19 -060017"
18
Patrick Williams2a254922023-08-11 09:48:11 -050019SRC_URI[sha256sum] = "0b1e6d8b7f87d017c7fae37f80586acff04f799ffc1d51e995954d6415dee371"
Andrew Geissler517393d2023-01-13 08:55:19 -060020
21S ?= "${WORKDIR}/vbox_module"
22S:task-patch = "${WORKDIR}/${VBOX_NAME}"
23
24export VBOX_KBUILD_TARGET_ARCH="${ARCH}"
25export VBOX_KBUILD_TARGET_ARCH:x86-64="amd64"
26
27EXTRA_OEMAKE += "KERN_DIR='${WORKDIR}/${KERNEL_VERSION}/build' KBUILD_VERBOSE=1"
28
29# otherwise 5.2.22 builds just vboxguest
30MAKE_TARGETS = "all"
31
32addtask export_sources after do_patch before do_configure
33do_export_sources[depends] += "virtual/kernel:do_shared_workdir"
34
35do_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
56do_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
64do_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
73module_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
81do_install:append() {
82 install -d ${D}${base_sbindir}
83 install -m 755 ${S}/utils/mount.vboxsf ${D}${base_sbindir}
84}
85
86PACKAGES += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo"
87RRECOMMENDS:${PN} += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo"
88
89FILES:${PN} = "${base_sbindir}"
90
91# autoload if installed
92KERNEL_MODULE_AUTOLOAD += "vboxguest vboxsf vboxvideo"