summaryrefslogtreecommitdiff
blob: 244a71c1fdf5e5a5152a82aea0dfdf10c73e109b (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
156
# 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.8.ebuild,v 1.2 2004/06/24 22:32:43 agriffis Exp $

inherit kmod

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

DEPEND="virtual/glibc
	alsa? ( media-libs/alsa-lib )
	sys-kernel/config-kernel"

RDEPEND="${DEPEND}"

S="${WORKDIR}/${P}"

KMOD_SOURCES="${P}.tar.gz"

src_unpack() {
	kmod_src_unpack
	cd ${S}
	epatch ${FILESDIR}/${P}-makefile-fixup.patch
	epatch ${FILESDIR}/${P}-udev.patch
}

src_compile() {

	[ -d /lib/modules/${KERNEL_VER/linux-/}/build ] || die "Build kernel ${KERNEL_VER} first"

	unset ARCH


	mkdir ${S}/workdir

	emake MODVERDIR=${T}/.tmp_versions O=${S}/workdir \
		KERNEL_VER=${KERNEL_VER/linux-/} \
		drivers || die "Failed to compile driver"

	cd modem;
	if use alsa;
	then
		emake SUPPORT_ALSA=1 MODVERDIR=${T}/.tmp_versions O=${S}/workdir \
			KERNEL_VER=${KERNEL_VER/linux-/} \
			|| die 'Alsa support failed, try USE="-alsa"'
	else
		emake MODVERDIR=${T}/.tmp_versions O=${S}/workdir \
			KERNEL_VER=${KERNEL_VER/linux-/} \
			 || die "Could not compile"
	fi
}

src_test() {
	cd modem
	emake modem_test
	./modem_test || die "failed modem test"

}

src_install() {
	unset ARCH
	emake DESTDIR=${D} KERNEL_VER=${KERNEL_VER/linux-/} install-drivers \
		|| die "driver install failed"

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

	dodoc COPYING Changes README README.1st

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

	# 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}
	elif [ -e ${ROOT}/dev/.udev ] ; then
	# udev
		# FIX Symlink
		dodir /etc/udev/rules.d/
		echo 'KERNEL="slamr", NAME="slamr0", SYMLINK="modem"' > \
			 ${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
	# simple raw devs
		dodir /dev
		cd ${D}/dev
		ebegin "Creating /dev/slamr* devices"
		local C="0"
		while [ "${C}" -lt "4" ]
		do
			if [ ! -c ${ROOT}/dev/slamr${C} ]
			then
				mknod ${D}/dev/slamr${C} c 212 ${C}
			#	doco suggests that the slmodemd creates these
			#	ln -s slamr${C} ttySL${C}
			fi
			if [ ! -c ${ROOT}/dev/slamr${C} ]
			then
				mknod ${D}/dev/slusb${C} c 213 ${C}
			#TODO usb or slamr (AMR/CNR/PCI) version for symlinks???
			#	ln -s sl${C} ttySL${C}
			fi

			C="`expr $C + 1`"
		done
		eend 0
		ln -s ttySL0 modem
	fi

}

pkg_postinst() {
	kmod_pkg_postinst

	#depmod -a

	# 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"

	if use alsa;
	then
		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
}