summaryrefslogtreecommitdiff
blob: 2c33c0bab4d8c76d0d59de922bbef1a4f7beb2f2 (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
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-wireless/ndiswrapper/ndiswrapper-0.12-r3.ebuild,v 1.1 2004/12/28 17:02:06 cardoe Exp $

CONFIG_CHECK="!4KSTACKS"

inherit linux-info

DESCRIPTION="Wrapper for using Windows drivers for some wireless cards"
HOMEPAGE="http://ndiswrapper.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${PN}-${PV}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="x86"

IUSE="debug"
DEPEND="sys-apps/pciutils"
S=${WORKDIR}/${PN}-${PV}

src_unpack() {
	unpack ${A}

	SWS=`grep '# CONFIG_SOFTWARE_SUSPEND2 is not set' ${ROOT}/usr/src/linux/.config`

	if [ -n "${SWS}" ]
	then
		eerror "You have a kernel patched with Software Suspend 2 (swsusp2)"
		eerror "but don't have it enabled. You must remove the patch or"
		eerror "enable Software Suspend 2 (swsusp2)."
		eerror "http://bugs.gentoo.org/show_bug.cgi?id=74864"
		die "Fix your kernel"
	fi

	# Fix path to kernel and KVERS
	sed -i -e "s:^KSRC.*:KSRC=${ROOT}/usr/src/linux:" \
		-e "s:^KVERS.*:KVERS=${KV_MAJOR}${KV_MINOR}:" \
		${S}/driver/Makefile

	if [ ${KV_MINOR} -gt 5 ] && [ ${KV_PATCH} -gt 5 ]
	then
		sed -i 's:SUBDIRS=:M=:g' ${S}/driver/Makefile
	fi
}

src_compile() {
	# Unset ARCH for 2.5/2.6 kernel compiles
	if [ ${KV_MINOR} -gt 4 ] ; then
		unset ARCH
	fi

	# Enable verbose debugging information
	use debug && export DEBUG=3

	emake || die "Compile Failed!"
}

src_install() {
	if [ ${KV_MINOR} -gt 4 ]
	then
		MOD_SUFFIX="ko"
	else
		MOD_SUFFIX="o"
	fi

	dosbin ${S}/utils/ndiswrapper
	dosbin ${S}/utils/ndiswrapper-buginfo

	dodoc ${S}/README ${S}/INSTALL ${S}/AUTHORS ${S}/ChangeLog
	doman ${S}/ndiswrapper.8

	insinto /lib/modules/${KV}/misc
	doins ${S}/driver/ndiswrapper.${MOD_SUFFIX}

	into /
	dosbin ${S}/utils/loadndisdriver

	insinto /etc/modules.d
	newins ${FILESDIR}/${PN}-0.9-modules.d ndiswrapper

	dodir /etc/ndiswrapper
}

pkg_postinst() {
	echo
	einfo "Checking kernel module dependencies"
	test -r "${ROOT}/usr/src/linux/System.map" && \
		depmod -ae -F "${ROOT}/usr/src/linux/System.map" -b "${ROOT}" -r ${KV}
	echo
	einfo "ndiswrapper requires .inf and .sys files from a Windows(tm) driver"
	einfo "to function. Download these to /root for example, then"
	einfo "run 'ndiswrapper -i /root/foo.inf'. After that you can delete them."
	einfo "They will be copied to the proper location."
	einfo "Once done, please run 'update-modules'."
	einfo
	einfo "As of release 0.9, you no longer have to call 'loadndiswrapper'"
	einfo "explicitly.  The module will handle it automatically."
	einfo
	einfo "check http://ndiswrapper.sf.net/supported_chipsets.html for drivers"
	I=`lspci -n | egrep 'Class (0280|0200):' |  cut -d' ' -f4`
	einfo "Look for the following on that page for your driver:"
	einfo ${I}
	einfo
	einfo "Please have a look at http://ndiswrapper.sourceforge.net/wiki/"
	einfo "for the FAQ, HowTos, Tips, Configuration, and installation"
	einfo "information."
	echo
}

pkg_config() {
	ewarn "New versions of ndiswrapper do not require you to run config"

	if [ ! -f "/etc/modules.d/ndiswrapper" ] ; then
		eerror "/etc/modules.d/ndiswrapper not found. Please re-emerge"
		eerror "${PN} to have this file installed, then re-run this script."
		die "Driver configuration file not found!"
	fi
}