1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 #EGIT_BRANCH="vblank-rework"
8 EGIT_TREE="3d08d380643784dcef30a8d416957e6fe2dd1450"
9 EGIT_REPO_URI="git://anongit.freedesktop.org/git/mesa/drm"
11 inherit eutils x11 linux-mod autotools git
13 IUSE="kernel_linux kernel_FreeBSD"
15 # Make sure Portage does _NOT_ strip symbols. We will do it later and make sure
16 # that only we only strip stuff that are safe to strip ...
17 # Tests require user intervention (see bug #236845)
22 DESCRIPTION="Nouveau DRM Kernel Modules for X11"
23 HOMEPAGE="http://dri.sf.net"
28 KEYWORDS="~amd64 ~x86"
30 DEPEND="kernel_linux? ( virtual/linux-sources )
31 kernel_FreeBSD? ( sys-freebsd/freebsd-sources
32 sys-freebsd/freebsd-mk-defs )
37 # Setup the kernel's stuff.
40 # Set video cards to build for.
43 # Determine which -core dir we build in.
50 # Substitute new directory under /lib/modules/${KV_FULL}
52 sed -i -e "s:/kernel/drivers/char/drm:/${PN}:g" Makefile
54 cp "${S}"/tests/*.c ${SRC_BUILD}
59 eautoreconf -v --install
63 # Building the programs. These are useful for developers and getting info from DRI and DRM.
65 # libdrm objects are needed for drmstat.
69 emake || die "libdrm build failed."
71 einfo "Building DRM in ${SRC_BUILD}..."
73 einfo "DRM build finished".
77 einfo "Installing DRM..."
82 dodoc "${S}/linux-core/README.drm"
84 dobin ../tests/dristat || die dobin failed
85 dobin ../tests/drmstat || die dobin failed
89 if use video_cards_sis
91 einfo "SiS direct rendering only works on 300 series chipsets."
92 einfo "SiS framebuffer also needs to be enabled in the kernel."
95 if use video_cards_mach64
97 einfo "The Mach64 DRI driver is insecure."
98 einfo "Malicious clients can write to system memory."
99 einfo "For more information, see:"
100 einfo "http://dri.freedesktop.org/wiki/ATIMach64."
106 # Functions used above are defined below:
109 if use kernel_FreeBSD
111 K_RV=${CHOST/*-freebsd/}
112 elif use kernel_linux
118 eerror "Upstream support for 2.4 kernels has been removed, so this package will no"
119 eerror "longer support them."
120 die "Please use in-kernel DRM or switch to a 2.6 kernel."
123 linux_chkconfig_builtin "DRM" && \
124 die "Please disable or modularize DRM in the kernel config. (CONFIG_DRM = n or m)"
127 ERROR_AGP="AGP support is not enabled in your kernel config (CONFIG_AGP)"
133 VIDCARDS="${VIDCARDS} nouveau.${KV_OBJ}"
136 get_drm_build_dir() {
137 if use kernel_FreeBSD
139 SRC_BUILD="${S}/bsd-core"
142 SRC_BUILD="${S}/linux-core"
147 # Handle exclusions based on the following...
148 # All trees (0**), Standard only (1**), Others (none right now)
149 # 2.4 vs. 2.6 kernels
152 kernel_is 2 6 && mv -f "${PATCHDIR}"/*kernel-2.4* "${EXCLUDED}"
155 # There is only one tree being maintained now. No numeric exclusions need
156 # to be done based on DRM tree.
160 convert_to_m "${SRC_BUILD}"/Makefile
163 src_unpack_freebsd() {
164 # Link in freebsd kernel.
165 ln -s "/usr/src/sys-${K_RV}" "${WORKDIR}/sys"
166 # SUBDIR variable gets to all Makefiles, we need it only in the main one.
167 SUBDIRS=${VIDCARDS//.ko}
168 sed -i -e "s:SUBDIR\ =.*:SUBDIR\ =\ drm ${SUBDIRS}:" "${SRC_BUILD}"/Makefile
172 if use kernel_linux; then
174 elif use kernel_FreeBSD
184 elif use kernel_FreeBSD
194 elif use kernel_FreeBSD
200 src_compile_linux() {
201 # remove leading and trailing space
202 VIDCARDS="${VIDCARDS% }"
203 VIDCARDS="${VIDCARDS# }"
205 check_modules_supported
207 for i in drm.${KV_OBJ} ${VIDCARDS}; do
208 MODULE_NAMES="${MODULE_NAMES} ${i/.${KV_OBJ}}(${PN}:${SRC_BUILD})"
209 i=$(echo ${i} | tr '[:lower:]' '[:upper:]')
210 eval MODULESD_${i}_ENABLED="yes"
213 # This now uses an M= build system. Makefile does most of the work.
216 BUILD_TARGETS="modules"
217 BUILD_PARAMS="DRM_MODULES='${VIDCARDS}' LINUXDIR='${KERNEL_DIR}' M='${SRC_BUILD}'"
218 ECONF_PARAMS='' S="${SRC_BUILD}" linux-mod_src_compile
220 if linux_chkconfig_present DRM
222 ewarn "Please disable in-kernel DRM support to use this package."
226 src_compile_freebsd() {
228 # Environment CFLAGS overwrite kernel CFLAGS which is bad.
229 local svcflags=${CFLAGS}; local svldflags=${LDFLAGS}
230 unset CFLAGS; unset LDFLAGS
234 SYSDIR="${WORKDIR}/sys" \
235 KMODDIR="/boot/modules" \
236 || die "pmake failed."
237 export CFLAGS=${svcflags}; export LDFLAGS=${svldflags}
240 # -D_POSIX_SOURCE skips the definition of several stuff we need
241 # for these two to compile
242 sed -i -e "s/-D_POSIX_SOURCE//" Makefile
243 emake dristat || die "Building dristat failed."
244 emake drmstat || die "Building drmstat failed."
245 # Move these where the linux stuff expects them
246 mv dristat drmstat ${SRC_BUILD}
250 eerror "Portage could not build the DRM modules. If you see an ACCESS DENIED error,"
251 eerror "this could mean that you were using an unsupported kernel build system."
252 eerror "Only 2.6 kernels at least as new as 2.6.6 are supported."
253 die "Unable to build DRM modules."
256 src_install_linux() {
257 linux-mod_src_install
259 # Strip binaries, leaving /lib/modules untouched (bug #24415)
260 strip_bins \/lib\/modules
263 src_install_freebsd() {
265 dodir "/boot/modules"
271 KMODDIR="/boot/modules" \
272 || die "Install failed."
278 linux-mod_pkg_postinst