summaryrefslogtreecommitdiff
blob: be99129d5533eee3f7602199221c1dd35a87a9eb (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
149
150
151
152
153
154
155
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dialup/slmodem/slmodem-2.9.10-r1.ebuild,v 1.4 2004/12/29 21:54:06 mrness Exp $

inherit kernel-mod eutils

DESCRIPTION="Driver for Smart Link modem"
HOMEPAGE="http://www.smlink.com/"
SRC_URI="http://www.smlink.com/main/down/${P}.tar.gz"
LICENSE="Smart-Link"
SLOT="0"
KEYWORDS="x86 -*"
IUSE="alsa usb"

DEPEND="virtual/libc
	alsa? ( media-libs/alsa-lib )
	virtual/os-headers
	>=sys-apps/sed-4"

RDEPEND="virtual/libc
	alsa? ( media-libs/alsa-lib )"

pkg_setup() {
	if [ "${KV_MAJOR}" -eq 2 -a "${KV_MINOR}" -eq 6 -a "${KV_PATCH}" -ge 10 ]; then
		eerror "This package isn't compatible with kernel versions >= 2.6.10!"
		die "unsupported kernel version"
	fi
	kernel-mod_check_modules_supported
}

src_compile() {
	if use alsa
	then
		export SUPPORT_ALSA=1
	else
		unset SUPPORT_ALSA
	fi

	# http://marc.theaimsgroup.com/?l=gentoo-dev&m=109672618708314&w=2
	kernel-mod_getversion
	if [ ${KV_MINOR} -gt 5 ] && [ ${KV_PATCH} -gt 5 ]
	then
		sed -i 's:SUBDIRS=:M=:g' drivers/Makefile
	fi

	unset ARCH

	emake \
		KERNEL_DIR="${ROOT}/usr/src/linux" \
	 	modem drivers || die "Failed to compile driver"
}

src_install() {
	if kernel-mod_is_2_6_kernel
	then
		KV_OBJ="ko"
	else
		KV_OBJ="o"
	fi

	insinto /lib/modules/${KV}/extra
	doins drivers/slamr.${KV_OBJ}
	doins drivers/slusb.${KV_OBJ}

	newsbin modem/modem_test slmodem_test
	dosbin modem/slmodemd
	dodir /var/lib/slmodem
	fowners root:dialout /var/lib/slmodem

	dodoc COPYING Changes README

	# Install /etc/{devfs,modules,init,conf}.d/slmodem files
	insinto /etc/conf.d/; newins ${FILESDIR}/${PN}-2.9.conf ${PN}
	insopts -m0755; insinto /etc/init.d/; newins ${FILESDIR}/${PN}-2.9.init ${PN}

	if use alsa
	then
		sed -i -e "s/# ALSACONF //g" ${D}/etc/conf.d/slmodem
	else
		sed -i -e "s/# NONALSACONF //g" ${D}/etc/conf.d/slmodem
		if use usb
		then
			sed -i -e "s/# USBCONF //g" ${D}/etc/conf.d/slmodem
		else
			sed -i -e "s/# PCICONF //g" ${D}/etc/conf.d/slmodem
		fi
	fi
	sed -i -e "s/ALSACONF//g" -e "s/PCICONF//g" -e "s/USBCONF//g" ${D}/etc/conf.d/slmodem


	# Make some devices if we aren't using devfs
	# If we are using devfs, restart it
	if [ -e ${ROOT}/dev/.devfsd ] ; then
	# devfs
		insinto /etc/devfs.d/; newins ${FILESDIR}/${PN}-2.9.devfs ${PN}
		insinto /etc/modules.d/; newins ${FILESDIR}/${PN}-2.9.modules ${PN}
		chmod 644 ${D}/etc/modules.d/slmodem
	elif [ -e ${ROOT}/dev/.udev ] ; then
	# udev
		# check Symlink
		dodir /etc/udev/rules.d/
		echo 'KERNEL="slamr", NAME="slamr0"' > \
			 ${D}/etc/udev/rules.d/55-${PN}.rules
		echo 'KERNEL="slusb", NAME="slusb0"' >> \
			 ${D}/etc/udev/rules.d/55-${PN}.rules
		dodir /etc/udev/permissions.d
		echo 'slamr*:root:dialout:0660' > \
			${D}/etc/udev/permissions.d/55-${PN}.permissions
	else
		make -C drivers DESTDIR=${D} KERNEL_DIR="${ROOT}/usr/src/linux" install-devices
	fi

	dodir /etc/hotplug/blacklist.d
	echo -e "slusb\nslamr\nsnd-intel8x0m" >> ${D}/etc/hotplug/blacklist.d/55-${PN}
}

pkg_postinst() {
	# Make some devices if we aren't using devfs
	# If we are using devfs, restart it
	if [ -e ${ROOT}/dev/.devfsd ]
	then
		ebegin "Restarting devfsd to reread devfs rules"
			killall -HUP devfsd
		eend 0
		einfo "modules-update to complete configuration."

	elif [ -e ${ROOT}/dev/.udev ]
	then
		ebegin "Restarting udev to reread udev rules"
			udevstart
		eend 0
	fi

	echo

	einfo "You must edit /etc/conf.d/${PN} for your configuration"

	ewarn "To avoid problems add slusb/slamr to /etc/hotplug/blacklist"

	einfo "To add slmodem to your startup - type : rc-update add slmodem default"

	if use alsa;
	then
		einfo "I hope you have already added alsa to your startup: "
		einfo "otherwise type: rc-update add alsasound boot"
		einfo
		einfo "If you need to use snd-intel8x0m from the kernel"
		einfo "compile it as a module and edit /etc/module.d/alsa"
		einfo 'to: "alias snd-card-(number) snd-intel8x0m"'
	fi

	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}
}