summaryrefslogtreecommitdiff
blob: 29ae458f0eca9f852ae2b493a65a58a3769d7eb2 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# 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.9-r2.ebuild,v 1.3 2004/08/15 02:47:00 dragonheart Exp $

inherit kmod 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="${KV}"
KEYWORDS="~x86"
IUSE="alsa usb"

DEPEND="virtual/libc
	alsa? ( media-libs/alsa-lib )
	virtual/os-headers"

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

src_unpack() {

	ewarn "This ebuild is sensive to use flags (usb, alsa)."
	ewarn "Please select approprately based on your hardware."
	ewarn "use -usb if you have a PCI modem"

	# Unpack and set some variables
	kmod_src_unpack

	cd ${S}
	epatch ${FILESDIR}/${P}-makefile-fixup.patch
}

src_compile() {

	#[ -d ${KV_OUTPUT} ] || die "Build kernel ${KV_VERSION_FULL} first"

	export KERNEL_OUTPUT_DIR=${S}/workdir

	if is_kernel 2 5 || is_kernel 2 6
	then
		unset ARCH
	fi

	if use alsa
	then
		export SUPPORT_ALSA=1
	else
		export SUPPORT_ALSA=0
	fi

	mkdir ${S}/workdir

	emake -C ${S} \
		KERNEL_VER=${KV_VERSION_FULL} \
		KERNEL_DIR=${KV_OUTPUT} \
		KERNEL_INCLUDES=/usr/include/linux \
		all || die "Failed to compile driver"

}

#src_test() {
#	cd modem
#	emake modem_test
#	./modem_test || die "failed modem test"
#
#	if use usb
#	then
#	# USB modem test
#	else
#	# PCI modem test
#	fi
#}

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

	mv ${D}/usr/sbin/modem_test ${D}/usr/sbin/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}
	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} KERNELRELEASE=1 KERNEL_VER=${KV_VERSION_FULL} install-devices
	fi

	dodir /etc/hotplug

	#if [ -r ${ROOT}/etc/hotplug/blacklist ]
	#then
	#	cp ${ROOT}/etc/hotplug/blacklist ${D}/etc/hotplug/
	#fi

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

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"

	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
}