summaryrefslogtreecommitdiff
blob: 15d0987f5b144f32248b872476a39f93ee7b670c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-video/ati-drivers/ati-drivers-3.7.6.ebuild,v 1.3 2004/03/12 02:55:57 mr_bones_ Exp $

IUSE="qt kde gnome"

inherit eutils rpm

DESCRIPTION="Ati precompiled drivers for r350, r300, r250 and r200 chipsets"
HOMEPAGE="http://www.ati.com"
SRC_URI="http://www2.ati.com/drivers/linux/fglrx-4.3.0-${PV}.i386.rpm"
SLOT="${KV}"
LICENSE="ATI"
KEYWORDS="-* ~x86"

DEPEND=">=virtual/linux-sources-2.4
	app-arch/rpm2targz
	>=x11-base/xfree-4.3.0"

RDEPEND=">=x11-base/xfree-4.3.0"

ATIBIN="${D}/opt/ati/bin"
RESTRICT="nostrip"

src_unpack() {
	local OLDBIN="/usr/X11R6/bin"

	cd ${WORKDIR}
	rpm_src_unpack

	cd ${WORKDIR}/lib/modules/fglrx/build_mod

	if [ "`echo ${KV}|grep 2.6`" ]
	then
		epatch ${FILESDIR}/fglrx-2.6-vmalloc-vmaddr.patch
	fi
}

pkg_setup(){
	check_KV || \
		die "Please ensure /usr/src/linux points to your kernel symlink!"
}

src_compile() {
	local GENTOO_ARCH=

	einfo "Building the DRM module..."
	cd ${WORKDIR}/lib/modules/fglrx/build_mod
	if [ "${KV}" != "${KV/2\.6}" ]
	then
		GENTOO_ARCH=${ARCH}
		unset ARCH
	    addwrite "/usr/src/${FK}"
	    cp 2.6.x/Makefile .
		export _POSIX2_VERSION="199209"
		make -C /usr/src/linux SUBDIRS="`pwd`" modules || \
			ewarn "DRM module not built"
	    ARCH=${GENTOO_ARCH}
	else
		export _POSIX2_VERSION="199209"
		# That is the dirty way to avoid the id -u check
		sed -e 's:`id -u`:0:' \
			-e 's:`uname -r`:${KV}:' \
			-i make.sh
		chmod +x make.sh
		./make.sh || die "DRM module not built"
	fi

	# Removing unused stuff
	rm -rf ${WORKDIR}/usr/X11R6/bin/{*.bz2,fgl_glxgears}
}

pkg_preinst() {
	# Clean the dinamic libGL stuff's home to ensure
	# we don't have stale libs floating around ...
	if [ -d "${ROOT}/usr/lib/opengl/ati" ]
	then
		rm -rf ${ROOT}/usr/lib/opengl/ati/*
	fi
}

src_install() {
	local ATI_ROOT="/usr/lib/opengl/ati"

	cd ${WORKDIR}

	# DRM module
	insinto /lib/modules/${KV}/video
	if [ "${KV}" != "${KV/2\.6}" ]
	then
		doins ${WORKDIR}/lib/modules/fglrx/build_mod/fglrx.ko
	else
		doins ${WORKDIR}/lib/modules/fglrx/build_mod/fglrx.o
	fi

	# OpenGL libs
	exeinto ${ATI_ROOT}/lib
	doexe ${WORKDIR}/usr/X11R6/lib/libGL.so.1.2
	dosym libGL.so.1.2 ${ATI_ROOT}/lib/libGL.so.1
	dosym libGL.so.1.2 ${ATI_ROOT}/lib/libGL.so
	dosym libGL.so.1.2 ${ATI_ROOT}/lib/libMesaGL.so
	# This is the same as that of xfree ...
	dosym ../../xfree/lib/libGL.la ${ATI_ROOT}/lib/libGL.la

	# X and DRI driver
	exeinto /usr/X11R6/lib/modules/drivers
	doexe ${WORKDIR}/usr/X11R6/lib/modules/drivers/fglrx_drv.o
	exeinto /usr/X11R6/lib/modules/dri
	doexe ${WORKDIR}/usr/X11R6/lib/modules/dri/fglrx_dri.so
	rm -f ${WORKDIR}/usr/X11R6/lib/modules/drivers/fglrx_drv.o \
		${WORKDIR}/usr/X11R6/lib/modules/dri/fglrx_dri.so

	# Same as in xfree
	exeinto ${ATI_ROOT}/
	dosym ../xfree/include ${ATI_ROOT}/include
	dosym ../xfree/extensions ${ATI_ROOT}/extensions
	rm -f ${WORKDIR}/usr/X11R6/lib/libGL.so.1.2

	dodoc ${WORKDIR}/usr/share/doc/fglrx/LICENSE.*

	#apps
	insinto /etc/env.d
	doins ${FILESDIR}/09ati
	exeinto /opt/ati/bin
	doexe usr/X11R6/bin/*
	rm usr/X11R6/bin/*

	# Removing unused stuff
	rm -rf ${WORKDIR}/usr/{src,share}
	cp -R ${WORKDIR}/usr ${D}/
}

pkg_postinst() {
# Ebuild shouldn't do this automatically, just tell the user to do it,
# otherwise it messes up livecd/gamecd stuff ...  (drobbins, 1 May 2003)
#	if [ "${ROOT}" = "/" ]
#	then
#		/usr/sbin/opengl-update ati
#	fi

	echo
	einfo "To switch to ATI OpenGL, run \"opengl-update ati\""
	einfo "To change your XF86Config you can use the bundled \"fglrxconfig\""
	echo

	# DRM module
	update-modules
}