blob: 5e0accb2375e3b8e07df7e57f1186d30ab940aec [file] [log] [blame]
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00001SUMMARY = "VirtualBox Linux Guest Drivers"
2SECTION = "core"
Andrew Geissler9aee5002022-03-30 16:27:02 +00003LICENSE = "GPL-2.0-only"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00004LIC_FILES_CHKSUM = "file://${WORKDIR}/${VBOX_NAME}/COPYING;md5=e197d5641bb35b29d46ca8c4bf7f2660"
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 file://0001-utils-fix-build-against-5.15-libc-headers-headers.patch \
17"
18
Andrew Geisslerd5838332022-05-27 11:33:10 -050019SRC_URI[sha256sum] = "9c3ce1829432e5b8374f950698587038f45fb0492147dc200e59edb9bb75eb49"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000020
21S ?= "${WORKDIR}/vbox_module"
22S:task-patch = "${WORKDIR}/${VBOX_NAME}"
23
24export BUILD_TARGET_ARCH="${ARCH}"
25export BUILD_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
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}
46
47do_configure:prepend() {
48 # 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.
49 # 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.
50 mkdir -p ${WORKDIR}/${KERNEL_VERSION}
51 ln -snf ${STAGING_KERNEL_DIR} ${WORKDIR}/${KERNEL_VERSION}/build
52}
53
54# compile and install mount utility
55do_compile() {
56 oe_runmake all
57 oe_runmake 'LD=${CC}' 'EXTRA_CFLAGS=-I${STAGING_KERNEL_BUILDDIR}/include/' 'LDFLAGS=${LDFLAGS}' -C ${S}/utils
58 if ! [ -e vboxguest.ko -a -e vboxsf.ko -a -e vboxvideo.ko ] ; then
59 echo "ERROR: One of vbox*.ko modules wasn't built"
60 exit 1
61 fi
62}
63
64module_do_install() {
65 MODULE_DIR=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/misc
66 install -d $MODULE_DIR
67 install -m 644 vboxguest.ko $MODULE_DIR
68 install -m 644 vboxsf.ko $MODULE_DIR
69 install -m 644 vboxvideo.ko $MODULE_DIR
70}
71
72do_install:append() {
73 install -d ${D}${base_sbindir}
74 install -m 755 ${S}/utils/mount.vboxsf ${D}${base_sbindir}
75}
76
77PACKAGES += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo"
78RRECOMMENDS:${PN} += "kernel-module-vboxguest kernel-module-vboxsf kernel-module-vboxvideo"
79
80FILES:${PN} = "${base_sbindir}"
81
82# autoload if installed
83KERNEL_MODULE_AUTOLOAD += "vboxguest vboxsf vboxvideo"