summaryrefslogtreecommitdiff
blob: 8fa839b111b69e3edb80a62872a90bda18f2e16d (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
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/matrox.eclass,v 1.4 2004/04/12 02:09:01 spyderous Exp $
#
# Author: Donnie Berkholz <spyderous@gentoo.org>
#
# This eclass is designed to reduce code duplication in the mtxdrivers* ebuilds.
# The only addition to mtxdrivers-pro is OpenGL stuff.

ECLASS="matrox"
INHERITED="${INHERITED} ${ECLASS}"

EXPORT_FUNCTIONS pkg_setup src_compile

HOMEPAGE="http://www.matrox.com/mga/products/parhelia/home.cfm"

LICENSE="Matrox"
SLOT="${KV}"
RESTRICT="fetch nostrip"

RDEPEND="virtual/x11
	virtual/linux-sources"

matrox_pkg_setup() {
	# Require correct /usr/src/linux
	check_KV

	# Set up X11 implementation
	X11_IMPLEM_P="$(portageq best_version "${ROOT}" virtual/x11)"
	X11_IMPLEM="${X11_IMPLEM_P%-[0-9]*}"
	X11_IMPLEM="${X11_IMPLEM##*\/}"
	einfo "X11 implementation is ${X11_IMPLEM}."

	# Force XFree86 4.3.0, 4.2.1 or 4.2.0 to be installed unless FORCE_VERSION
	# is set. Need FORCE_VERSION for 4.3.99/4.4.0 compatibility until Matrox
	# comes up with drivers (spyderous)
	if has_version "x11-base/xfree"
	then
		local INSTALLED_X="`best_version x11-base/xfree`"
		GENTOO_X_VERSION_REVISION="${INSTALLED_X/x11-base\/xfree-}"
		GENTOO_X_VERSION="${GENTOO_X_VERSION_REVISION%-*}"
		if [ "${GENTOO_X_VERSION}" -ne "4.3.0" ]
		then
			if [ "${GENTOO_X_VERSION}" -ne "4.2.1" ]
			then
				if [ "${GENTOO_X_VERSION}" -ne "4.2.0" ]
				then
					if [ -n "${FORCE_VERSION}" ]
					then
						GENTOO_X_VERSION="${FORCE_VERSION}"
					else
						die "These drivers require XFree86 4.3.0, 4.2.1 or 4.2.0. Do FORCE_VERSION=version-you-want emerge ${PN} (4.3.0, 4.2.1 or 4.2.0) to force installation."
					fi
				fi
			fi
		fi
	# xorg-x11 compatibility
	elif has_version "x11-base/xorg-x11"
	then
		if [ "${FORCE_VERSION}" -ne "4.3.0" ]
		then
			die "Set FORCE_VERSION=4.3.0 to emerge this. Use at your own risk."
		fi
		GENTOO_X_VERSION="${FORCE_VERSION}"
	fi
}

matrox_src_compile() {
	export PARHELIUX="${PWD}/src"
	cd ${S}/src/kernel/parhelia
	ln -sf ../../../kernel/mtx_parhelia.o .
	cd ..
	# Can't use emake here
	make clean
	make
}

matrox_base_src_install() {
	# Kernel Module
	dodir /lib/modules/${KV}/kernel/drivers/video; insinto /lib/modules/${KV}/kernel/drivers/video
	doins src/kernel/mtx.o

	# X Driver (2D)
	dodir /usr/X11R6/lib/modules/drivers; insinto /usr/X11R6/lib/modules/drivers
	doins xfree86/${GENTOO_X_VERSION}/mtx_drv.o
}

matrox_base_pkg_postinst() {
	if [ "${ROOT}" = "/" ]
	then
		/sbin/modules-update
	fi

	if [ ! -d /dev/video ]
	then
		if [ -f /dev/video ]
		then
			einfo "NOTE: To be able to use busmastering, you MUST have /dev/video as"
		    einfo "a directory, which means you must remove anything there first"
			einfo "(rm -f /dev/video), and mkdir /dev/video"
		else
			mkdir /dev/video
		fi
	fi
}