blob: 91f5ae0e0f1a8dcbd217b25f881dd466a47c22d5 [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 \
16"
17
18SRC_URI[sha256sum] = "58951f7d1bcda836c5e50ca0a6b13f0e61a07a904f476526a831df3d9bfe5b17"
19
20S ?= "${WORKDIR}/vbox_module"
21S:task-patch = "${WORKDIR}/${VBOX_NAME}"
22
23export VBOX_KBUILD_TARGET_ARCH="${ARCH}"
24export VBOX_KBUILD_TARGET_ARCH:x86-64="amd64"
25
26EXTRA_OEMAKE += "KERN_DIR='${WORKDIR}/${KERNEL_VERSION}/build' KBUILD_VERBOSE=1"
27
28# otherwise 5.2.22 builds just vboxguest
29MAKE_TARGETS = "all"
30
31addtask export_sources after do_patch before do_configure
32do_export_sources[depends] += "virtual/kernel:do_shared_workdir"
33
34do_export_sources() {
35 mkdir -p "${S}"
36 ${WORKDIR}/${VBOX_NAME}/src/VBox/Additions/linux/export_modules.sh ${T}/vbox_modules.tar.gz
37 tar -C "${S}" -xzf ${T}/vbox_modules.tar.gz
38
39 # add a mount utility to use shared folder from VBox Addition Source Code
40 mkdir -p "${S}/utils"
41 install ${WORKDIR}/${VBOX_NAME}/src/VBox/Additions/linux/sharedfolders/mount.vboxsf.c ${S}/utils
42 install ${WORKDIR}/${VBOX_NAME}/src/VBox/Additions/linux/sharedfolders/vbsfmount.c ${S}/utils
43 install ${S}/../Makefile.utils ${S}/utils/Makefile
44
45 # some kernel versions have issues with stdarg.h and compatibility with
46 # the sysroot and libc-headers/uapi. If we include the file directly from
47 # the kernel source (STAGING_KERNEL_DIR) we get conflicting types on many
48 # structures, due to kernel .h files being found before libc .h files.
49 # if we grab just this one file from the source, and put it into our
50 # file structure, everything holds together
51 mkdir -p ${S}/vboxsf/include/linux
52 install ${STAGING_KERNEL_DIR}/include/linux/stdarg.h ${S}/vboxsf/include/linux
53}
54
55do_configure:prepend() {
56 # 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.
57 # 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.
58 mkdir -p ${WORKDIR}/${KERNEL_VERSION}
59 ln -snf ${STAGING_KERNEL_DIR} ${WORKDIR}/${KERNEL_VERSION}/build
60}
61
62# compile and install mount utility
63do_compile() {
64 oe_runmake all
65 oe_runmake 'LD=${CC}' 'EXTRA_CFLAGS=-I${STAGING_KERNEL_BUILDDIR}/include/' 'LDFLAGS=${LDFLAGS}' -C ${S}/utils
66 if ! [ -e vboxguest.ko -a -e vboxsf.ko -a -e vboxvideo.ko ] ; then
67 echo "ERROR: One of vbox*.ko modules wasn't built"
68 exit 1
69 fi
70}
71
72module_do_install() {
73 MODULE_DIR=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/misc
74 install -d $MODULE_DIR
75 install -m 644 vboxguest.ko $MODULE_DIR
76 install -m 644 vboxsf.ko $MODULE_DIR
77 install -m 644 vboxvideo.ko $MODULE_DIR
78}
79
80do_install:append() {
81 install -d ${D}${base_sbindir}
82 install -m 755 ${S}/utils/mount.vboxsf ${D}${base_sbindir}
83}
84
85PACKAGES += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo"
86RRECOMMENDS:${PN} += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo"
87
88FILES:${PN} = "${base_sbindir}"
89
90# autoload if installed
91KERNEL_MODULE_AUTOLOAD += "vboxguest vboxsf vboxvideo"