summaryrefslogtreecommitdiff
blob: f5ec63d1823f3200681ed4e8aab71db42a7b555e (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
181
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dialup/misdn/misdn-1.1.2.ebuild,v 1.4 2007/05/16 17:11:50 genstef Exp $

inherit eutils linux-mod

MY_P=mISDN-${PV//./_}
DESCRIPTION="mISDN is the new ISDN stack of the linux kernel 2.6."
HOMEPAGE="http://www.misdn.org/"
SRC_URI="http://www.misdn.org/downloads/releases/${MY_P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64 ~ppc"

# list of echo canceller use flags,
# first active in this list is selected (=order does matter)
MISDN_EC_FLAGS="ecmg2 eckb1 ecmark2"

# list of card modules
MISDN_MODULES=("avmfritz" "hfcpci" "hfcmulti" "hfcsusb" "hfcsmini" "xhfc" "sedlfax" "w6692pci" "netjetpci")
MISDN_KCONFIG=("AVM_FRITZ" "HFCPCI" "HFCMULTI" "HFCUSB" "HFCMINI" "XHFC" "SPEEDFAX" "W6692" "NETJET")

IUSE="ecaggressive ${MISDN_EC_FLAGS}"
for i in ${MISDN_MODULES[@]}; do IUSE="${IUSE} misdn_cards_${i}"; done

RDEPEND=">=net-dialup/capi4k-utils-20050718
	sys-devel/bc"

S=${WORKDIR}/${MY_P}/drivers/isdn/hardware/mISDN

### Begin: Helper functions

select_echo_cancel() {
	local myEC=""
	for x in ${MISDN_EC_FLAGS}; do
		if use ${x}; then
			myEC=$(echo "${x}" | sed -e "s:^ec\(.*\):\U\1\E:")
			break;
		fi
	done
	echo ${myEC}
}

dsp_enable() {
	local i
	for i in "${@}"; do
		sed -i -e "s:.*\(#include.*dsp_${i}\):\1:m" dsp.h
	done
}

dsp_disable() {
	local i
	for i in "${@}"; do
		sed -i -e "s:.*\(#include.*dsp_${i}\)://\1:m" dsp.h
	done
}

### End: Helper functions

pkg_setup() {
	local numec=0

	CONFIG_CHECK="ISDN_CAPI ISDN_CAPI_CAPI20 ISDN_CAPI_CAPIFS_BOOL"
	linux-mod_pkg_setup
	MODULE_NAMES="mISDN_capi(net:) mISDN_dtmf(net:) mISDN_l1(net:)
	mISDN_x25dte(net:) l3udss1(net:) mISDN_core(net:) mISDN_isac(net:)
	mISDN_l2(net:) mISDN_dsp(net:)"
	BUILD_PARAMS="-C ${KV_DIR} SUBDIRS=${S} MINCLUDES=${WORKDIR}/${MY_P}/include CONFIG_MISDN_DRV=m CONFIG_MISDN_DSP=y"
	BUILD_TARGETS="modules"
	#I4LmISDN(net:) does not compile :( CONFIG_I4L_CAPI_LAYER=m
	# the i4l->capi simulation seems to be only for kernel 2.4

	# check if multiple echo cancellers have been selected
	for x in ${MISDN_EC_FLAGS}; do
		use ${x} && : $((numec++))
	done
	if [[ ${numec} -gt 1 ]]; then
		# multiple flags are active, only the first in the ZAP_EC_FLAGS list
		# will be used, make sure the user knows about this
		ewarn
		ewarn "Multiple echo canceller flags are active but only one will be used!"
		ewarn "Selected: $(select_echo_cancel)"
	fi

	# Check existence of user selected cards
	if [ -n "${MISDN_CARDS}" ]; then
		for USERCARD in ${MISDN_CARDS} ; do
			for ((CARD=0; CARD < ${#MISDN_MODULES[*]}; CARD++)); do
				if [ "${USERCARD}" = "${MISDN_MODULES[CARD]}" ]; then
					MODULE_NAMES="${MODULE_NAMES} ${MISDN_MODULES[CARD]}(net:)"
					#[ "sedlfax" = "${MISDN_MODULES[CARD]}" ] && MODULE_NAMES="${MODULE_NAMES} faxl3(net:)"
					BUILD_PARAMS="${BUILD_PARAMS} CONFIG_MISDN_${MISDN_KCONFIG[CARD]}=y"
					continue 2
				fi
			done
			die "Module ${USERCARD} not present in ${P}"
		done
	else
		elog
		elog "You can control the modules which are built with the variable"
		elog "MISDN_CARDS which should contain a blank separated list"
		elog "of a selection from the following cards:"
		elog "   ${MISDN_MODULES[*]}"
		elog
		ewarn "I give you the chance of hitting Ctrl-C and make the necessary"
		ewarn "adjustments in /etc/make.conf."

		# enable everything
		for ((CARD=0; CARD < ${#MISDN_MODULES[*]}; CARD++)); do
			MODULE_NAMES="${MODULE_NAMES} ${MISDN_MODULES[CARD]}(net:)"
			#[ "sedlfax" = "${MISDN_MODULES[CARD]}" ] && MODULE_NAMES="${MODULE_NAMES} faxl3(net:)"
			BUILD_PARAMS="${BUILD_PARAMS} CONFIG_MISDN_${MISDN_KCONFIG[CARD]}=y"
		done
	fi
}

src_unpack() {
	unpack ${A}

	cd "${S}"
	if use ecaggressive; then
		sed -i -e "s:.*#define \(AGGRESSIVE_SUPPRESSOR\):#define \1:m" dsp.h
	fi

	case "$(select_echo_cancel)" in
		MG2)
			dsp_enable  mg2ec
			dsp_disable kb1ec mec2
			;;
		KB1)
			dsp_enable  kb1ec
			dsp_disable mg2ec mec2
			;;
		MARK2)
			dsp_enable  mec2
			dsp_disable mg2ec kb1ec
			;;
	esac
}

src_install() {
	linux-mod_src_install

	insinto /usr/include/linux
	doins "${WORKDIR}/${MY_P}/"include/linux/*.h

	dodir /etc/udev/rules.d
	echo 'KERNEL=="obj-*", NAME="mISDN", GROUP="dialout", MODE="0660"' \
		> "${D}/etc/udev/rules.d/53-${PN}.rules"

	insinto /etc/modules.d
	newins "${WORKDIR}/${MY_P}/"mISDN.modprobe.d ${PN}

	sed -i -e "s:USER=.*:USER=root:" \
		-e "s:GROUP=.*:GROUP=dialout:" "${WORKDIR}/${MY_P}/"misdn-init
	dosbin "${WORKDIR}/${MY_P}/"misdn-init

	dodoc Kconfig.v2.6
	dodoc "${FILESDIR}/README.hfcmulti" "${WORKDIR}/${MY_P}/"README.misdn-init
}

pkg_preinst() {
	if [ -e "${ROOT}"/etc/misdn-init.conf ]; then
		cp "${ROOT}"/etc/misdn-init.conf "${D}"/etc
	else
		sed -i -e "s:/etc/misdn-init.conf:${D}\0:" "${D}"/usr/sbin/misdn-init
		"${D}"/usr/sbin/misdn-init config
		sed -i -e "s:${D}/etc/misdn-init.conf:/etc/misdn-init.conf:" "${D}"/usr/sbin/misdn-init
	fi
}

pkg_postinst() {
	linux-mod_pkg_postinst

	ewarn
	ewarn "This driver is still under heavy development"
	ewarn "Please report ebuild related bugs / wishes to http://bugs.gentoo.org"
	ewarn "Please report driver bugs to the mISDN mailing-list:"
	ewarn "    https://www.isdn4linux.de/mailman/listinfo/isdn4linux"
}