1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT
=( python2_7
)
8 inherit eutils linux-mod multilib python-single-r1 versionator toolchain-funcs
10 MY_PV
="${PV/beta/BETA}"
11 MY_PV
="${MY_PV/rc/RC}"
12 MY_P
=VirtualBox-
${MY_PV}
13 DESCRIPTION
="VirtualBox video driver"
14 HOMEPAGE
="http://www.virtualbox.org/"
15 SRC_URI
="http://download.virtualbox.org/virtualbox/${MY_PV}/${MY_P}.tar.bz2"
19 KEYWORDS
="~amd64 ~x86"
22 RDEPEND
=">=x11-base/xorg-server-1.7:=[-minimal]
23 x11-libs/libXcomposite"
25 >=dev-util/kbuild-0.1.9998_pre20131130
33 x11-proto/resourceproto
34 x11-proto/scrnsaverproto
36 x11-proto/xineramaproto
43 dri? ( x11-proto/xf86driproto
44 >=x11-libs/libdrm-2.4.5 )"
46 REQUIRED_USE
=( "${PYTHON_REQUIRED_USE}" )
49 BUILD_TARGET_ARCH
="${ARCH}"
50 S
="${WORKDIR}/${MY_P}"
51 MODULES_SRC_DIR
="${S}/src/VBox/Additions/linux/drm"
52 MODULE_NAMES
="vboxvideo(misc:${MODULES_SRC_DIR}:${MODULES_SRC_DIR})"
55 # Ugly hack to build the opengl part of the video driver
56 "${FILESDIR}/${PN}-2.2.0-enable-opengl.patch"
58 # unset useless/problematic checks in configure
59 "${FILESDIR}/${PN}-5.0.0_beta3-configure_checks.patch"
61 # prevent musl from throwing errors everywhere
62 "${FILESDIR}/${P}-remove-references-to-sys-cdefs.h.patch"
63 "${FILESDIR}/${P}-change-sys-poll.h-to-poll.h.patch"
64 "${FILESDIR}/${P}-change-sys-fcntl.h-to-fcntl.h.patch"
65 "${FILESDIR}/${P}-some-Alpine-fixes.patch"
68 QA_TEXTRELS_x86
="usr/lib/VBoxOGL.so"
71 if [ "${MERGE_TYPE}" != "binary" ]; then
72 version_is_at_least
4.9 $
(gcc-version
) || die
"Please set gcc 4.9 or higher as active in gcc-config to build ${PN}"
75 CONFIG_CHECK
="~DRM ~DRM_TTM"
77 BUILD_PARAMS
="KERN_DIR=${KV_OUT_DIR} KERNOUT=${KV_OUT_DIR}"
79 python-single-r1_pkg_setup
83 # Prepare the vboxvideo_drm Makefiles and build dir
84 eapply
"${FILESDIR}"/${P}-Makefile.module.kms.
patch
86 # Remove shipped binaries (kBuild,yasm), see bug #232775
87 rm -r kBuild
/bin tools || die
89 # Disable things unused or splitted into separate ebuilds
90 cp "${FILESDIR}/${PN}-5-localconfig" LocalConfig.kmk || die
94 # link with lazy on hardened #394757
95 sed '/^TEMPLATE_VBOXR3EXE_LDFLAGS.linux/s/$/ -Wl,-z,lazy/' \
100 # build the user-space tools, warnings are harmless
108 --with-gcc="$(tc-getCC)"
109 --with-g++="$(tc-getCXX)"
110 --target-arch=${ARCH}
111 --with-linux="${KV_OUT_DIR}"
115 "${cmd[@]}" || die
"configure failed"
117 export VBOX_GCC_OPT
="${CFLAGS} ${CPPFLAGS}"
123 Additions
/common
/VBoxGuestLib
125 Additions
/x11
/x11stubs
126 Additions
/common
/crOpenGL
127 Additions
/x11
/vboxvideo
130 # need to use the upstream build system to create necessary objects properly
131 use dri
&& targets
+=( Additions
/linux
/drm
)
133 for each
in ${targets[@]} ; do
134 pushd "${S}"/src
/VBox
/${each} $
>/dev
/null || die
136 emake TOOL_YASM_AS
=yasm \
137 VBOX_USE_SYSTEM_XORG_HEADERS
=1 \
138 KBUILD_PATH
="${S}/kBuild" \
140 popd &>/dev
/null || die
144 local objdir
="out/linux.${ARCH}/release/obj/vboxvideo_drm"
145 # We need a Makefile, so use Makefile.module.kms
146 ln -s Makefile.module.kms
"${MODULES_SRC_DIR}"/Makefile || die
147 # All of these are expected to be in $(KBUILD_EXTMOD)/ so symlink them into place
150 src
/VBox
/Runtime
/r0drv
151 src
/VBox
/Installer
/linux
/Makefile.include.
{head,foot
}er
152 out
/linux.
${ARCH}/release
/{product
,version
,revision
}-generated.h
154 for each
in ${targets[@]} ; do
155 ln -s "${S}"/${each} \
156 "${MODULES_SRC_DIR}"/${each##*/} || die
158 # see the vboxvideo_drm_SOURCES list in Makefile.kmk for the below,
159 # and replace '..' with 'dt'
161 dt
/dt
/common
/VBoxVideo
/HGSMIBase.o
162 dt
/dt
/common
/VBoxVideo
/Modesetting.o
163 dt
/dt
/common
/VBoxVideo
/VBVABase.o
164 dt
/dt
/dt
/GuestHost
/HGSMI
/HGSMICommon.o
165 dt
/dt
/dt
/GuestHost
/HGSMI
/HGSMIMemAlloc.o
166 dt
/dt
/dt
/Runtime
/common
/alloc
/heapoffset.o
168 for each
in ${targets[@]} ; do
169 ln -s "${S}"/${objdir}/${each} \
170 "${MODULES_SRC_DIR}" || die
171 ln -s "${S}"/${objdir}/${each}.dep \
172 "${MODULES_SRC_DIR}" || die
175 # Now creating the kernel modules. We must do this _after_
176 # we compiled the user-space tools as we need two of the
177 # automatically generated header files. (>=3.2.0)
178 pushd "${MODULES_SRC_DIR}" &>/dev
/null || die
179 linux-mod_src_compile
180 popd &>/dev
/null || die
186 pushd "${MODULES_SRC_DIR}" &>/dev
/null || die
187 linux-mod_src_install
188 popd &>/dev
/null || die
191 cd "${S}/out/linux.${ARCH}/release/bin/additions" || die
192 insinto
/usr
/$
(get_libdir
)/xorg
/modules
/drivers
193 newins vboxvideo_drv_system.so vboxvideo_drv.so
195 # Guest OpenGL driver
196 insinto
/usr
/$
(get_libdir
)
200 dosym
/usr
/$
(get_libdir
)/VBoxOGL.so \
201 /usr
/$
(get_libdir
)/dri
/vboxvideo_dri.so
206 elog
"You need to edit the file /etc/X11/xorg.conf and set:"
208 elog
" Driver \"vboxvideo\""
210 elog
"in the Graphics device section (Section \"Device\")"
213 elog
"To use the kernel drm video driver, please add:"
214 elog
"\"${MODULE_NAMES%(*}\" to:"
215 if has_version sys-apps
/openrc
; then
216 elog
"/etc/conf.d/modules"
218 elog
"/etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"