]> Pileus Git - ~andy/sunrise/blob - x11-base/nouveau-drm/nouveau-drm-20090318.ebuild
revert commit 8129, x11-drm in portage lost nouveau support again.
[~andy/sunrise] / x11-base / nouveau-drm / nouveau-drm-20090318.ebuild
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 WANT_AUTOMAKE="1.7"
6
7 #EGIT_BRANCH="vblank-rework"
8 EGIT_TREE="3d08d380643784dcef30a8d416957e6fe2dd1450"
9 EGIT_REPO_URI="git://anongit.freedesktop.org/git/mesa/drm"
10
11 inherit eutils x11 linux-mod autotools git
12
13 IUSE="kernel_linux kernel_FreeBSD"
14
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)
18 RESTRICT="strip test"
19
20 S="${WORKDIR}/drm"
21
22 DESCRIPTION="Nouveau DRM Kernel Modules for X11"
23 HOMEPAGE="http://dri.sf.net"
24 SRC_URI=""
25
26 SLOT="0"
27 LICENSE="X11"
28 KEYWORDS="~amd64 ~x86"
29
30 DEPEND="kernel_linux? ( virtual/linux-sources )
31         kernel_FreeBSD? ( sys-freebsd/freebsd-sources
32                         sys-freebsd/freebsd-mk-defs )
33         !x11-base/x11-drm"
34 RDEPEND=""
35
36 pkg_setup() {
37         # Setup the kernel's stuff.
38         kernel_setup
39
40         # Set video cards to build for.
41         set_vidcards
42
43         # Determine which -core dir we build in.
44         get_drm_build_dir
45 }
46
47 src_unpack() {
48         git_src_unpack
49
50         # Substitute new directory under /lib/modules/${KV_FULL}
51         cd "${SRC_BUILD}"
52         sed -i -e "s:/kernel/drivers/char/drm:/${PN}:g" Makefile
53
54         cp "${S}"/tests/*.c ${SRC_BUILD}
55
56         src_unpack_os
57
58         cd "${S}"
59         eautoreconf -v --install
60 }
61
62 src_compile() {
63         # Building the programs. These are useful for developers and getting info from DRI and DRM.
64         #
65         # libdrm objects are needed for drmstat.
66         econf \
67                 --enable-static \
68                 --disable-shared
69         emake || die "libdrm build failed."
70
71         einfo "Building DRM in ${SRC_BUILD}..."
72         src_compile_os
73         einfo "DRM build finished".
74 }
75
76 src_install() {
77         einfo "Installing DRM..."
78         cd "${SRC_BUILD}"
79
80         src_install_os
81
82         dodoc "${S}/linux-core/README.drm"
83
84         dobin ../tests/dristat || die dobin failed
85         dobin ../tests/drmstat || die dobin failed
86 }
87
88 pkg_postinst() {
89         if use video_cards_sis
90         then
91                 einfo "SiS direct rendering only works on 300 series chipsets."
92                 einfo "SiS framebuffer also needs to be enabled in the kernel."
93         fi
94
95         if use video_cards_mach64
96         then
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."
101         fi
102
103         pkg_postinst_os
104 }
105
106 # Functions used above are defined below:
107
108 kernel_setup() {
109         if use kernel_FreeBSD
110         then
111                 K_RV=${CHOST/*-freebsd/}
112         elif use kernel_linux
113         then
114                 linux-mod_pkg_setup
115
116                 if kernel_is 2 4
117                 then
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."
121                 fi
122
123                 linux_chkconfig_builtin "DRM" && \
124                         die "Please disable or modularize DRM in the kernel config. (CONFIG_DRM = n or m)"
125
126                 CONFIG_CHECK="AGP"
127                 ERROR_AGP="AGP support is not enabled in your kernel config (CONFIG_AGP)"
128         fi
129 }
130
131 set_vidcards() {
132         VIDCARDS=""
133         VIDCARDS="${VIDCARDS} nouveau.${KV_OBJ}"
134 }
135
136 get_drm_build_dir() {
137         if use kernel_FreeBSD
138         then
139                 SRC_BUILD="${S}/bsd-core"
140         elif kernel_is 2 6
141         then
142                 SRC_BUILD="${S}/linux-core"
143         fi
144 }
145
146 patch_prepare() {
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
150         if use kernel_linux
151         then
152             kernel_is 2 6 && mv -f "${PATCHDIR}"/*kernel-2.4* "${EXCLUDED}"
153         fi
154
155         # There is only one tree being maintained now. No numeric exclusions need
156         # to be done based on DRM tree.
157 }
158
159 src_unpack_linux() {
160         convert_to_m "${SRC_BUILD}"/Makefile
161 }
162
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
169 }
170
171 src_unpack_os() {
172         if use kernel_linux; then
173                 src_unpack_linux
174         elif use kernel_FreeBSD
175         then
176                 src_unpack_freebsd
177         fi
178 }
179
180 src_compile_os() {
181         if use kernel_linux
182         then
183                 src_compile_linux
184         elif use kernel_FreeBSD
185         then
186                 src_compile_freebsd
187         fi
188 }
189
190 src_install_os() {
191         if use kernel_linux
192         then
193                 src_install_linux
194         elif use kernel_FreeBSD
195         then
196                 src_install_freebsd
197         fi
198 }
199
200 src_compile_linux() {
201         # remove leading and trailing space
202         VIDCARDS="${VIDCARDS% }"
203         VIDCARDS="${VIDCARDS# }"
204
205         check_modules_supported
206         MODULE_NAMES=""
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"
211         done
212
213         # This now uses an M= build system. Makefile does most of the work.
214         cd "${SRC_BUILD}"
215         unset ARCH
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
219
220         if linux_chkconfig_present DRM
221         then
222                 ewarn "Please disable in-kernel DRM support to use this package."
223         fi
224 }
225
226 src_compile_freebsd() {
227         cd "${SRC_BUILD}"
228         # Environment CFLAGS overwrite kernel CFLAGS which is bad.
229         local svcflags=${CFLAGS}; local svldflags=${LDFLAGS}
230         unset CFLAGS; unset LDFLAGS
231         MAKE=make \
232                 emake \
233                 NO_WERROR= \
234                 SYSDIR="${WORKDIR}/sys" \
235                 KMODDIR="/boot/modules" \
236                 || die "pmake failed."
237         export CFLAGS=${svcflags}; export LDFLAGS=${svldflags}
238
239         cd "${S}/tests"
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}
247 }
248
249 die_error() {
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."
254 }
255
256 src_install_linux() {
257         linux-mod_src_install
258
259         # Strip binaries, leaving /lib/modules untouched (bug #24415)
260         strip_bins \/lib\/modules
261 }
262
263 src_install_freebsd() {
264         cd "${SRC_BUILD}"
265         dodir "/boot/modules"
266         MAKE=make \
267                 emake \
268                 install \
269                 NO_WERROR= \
270                 DESTDIR="${D}" \
271                 KMODDIR="/boot/modules" \
272                 || die "Install failed."
273 }
274
275 pkg_postinst_os() {
276         if use kernel_linux
277         then
278                 linux-mod_pkg_postinst
279         fi
280 }