summaryrefslogtreecommitdiff
blob: e83dc8eacc208963573db7319243fe06b0faea93 (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
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-apps/pcmcia-cs-drivers/pcmcia-cs-drivers-3.2.4.ebuild,v 1.8 2004/07/15 02:23:42 agriffis Exp $

inherit eutils

MY_P=${P/-drivers/}
S=${WORKDIR}/${MY_P}
DESCRIPTION="pcmcia-cs drivers"
SRC_URI="mirror://sourceforge/pcmcia-cs/${MY_P}.tar.gz
	http://airsnort.shmoo.com/${MY_P}-orinoco-patch.diff"

HOMEPAGE="http://pcmcia-cs.sourceforge.net"
DEPEND="virtual/os-headers
	>=sys-apps/sed-4"
RDEPEND=""
SLOT="0"
IUSE="apm nocardbus pnp trusted"
LICENSE="GPL-2"
KEYWORDS="x86 amd64"

# check arch for configure
if [ ${ARCH} = "x86" ] ; then
	MY_ARCH="i386"
else
	MY_ARCH="ppc"
fi

# Note: To use this ebuild, you should have the usr/src/linux symlink to
# the kernel directory that pcmcia-cs should use for configuration.

src_unpack() {
	unpack ${MY_P}.tar.gz

	cd ${S}
	epatch ${DISTDIR}/${MY_P}-orinoco-patch.diff

	cd ${S}
	mv Configure Configure.orig
	sed -e 's:usr/man:usr/share/man:g' Configure.orig > Configure
	chmod ug+x Configure
	#man pages will now install into /usr/share/man
}

src_compile() {
	local myconf
	use trusted && myconf="--trust" || myconf="--notrust"
	use apm && myconf="$myconf --apm" || myconf="$myconf --noapm"
	use pnp && myconf="$myconf --pnp" || myconf="$myconf --nopnp"
	use nocardbus &&  myconf="$myconf --nocardbus" || myconf="$myconf --cardbus"

	#use $CFLAGS for user tools, but standard kernel optimizations for the kernel modules (for compatibility)
	./Configure -n \
		--force \
		--target=${D} \
		--srctree \
		--kernel=/usr/src/linux \
		--arch="${MY_ARCH}" \
		--uflags="$CFLAGS" \
		--kflags="-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer" \
	$myconf || die "failed configuring"
	# nopnp and noapm are important, because without them the pcmcia-cs
	# tools will require a kernel with ISA PnP and/or APM support,
	# which cannot be guaranteed.  We need to make sure the tools
	# work *all* the time, not just some of the time.

	# The --srctree option tells pcmcia-cs to configure for the kernel in
	# /usr/src/linux rather than the currently-running kernel.  It's Gentoo
	# Linux policy to configure for the kernel in /usr/src/linux

	# This handles the various cardinfo guis.  If you have gtk in your USE,
	# then the gtk version will be installed.  If not, but X is in your USE,
	# then the xaw version will be installed.  Otherwise, no gui will be
	# installed.
	sed -i -e "/^HAS_FORMS/d" config.out config.mk
	sed -i -e "/^HAS_GTK/d" config.out config.mk
	sed -i -e "/^HAS_XAW/d" config.out config.mk
	sed -i -e "s/^FLIBS=\".*\"/FLIBS=\"\"/" config.out config.mk

	# patch version.h so that they won't complain that Card Services is wrong.
	if [ -n "`grep -E '^CONFIG_PCMCIA\=y' config.mk`" ]; then
		cd ${S}/include/pcmcia

		# get kernel CS_RELEASE :
		if [ -f /usr/src/linux/include/pcmcia/version.h ]; then
			KERNEL_RELEASE=`grep -E '^#define CS_RELEASE ' /usr/src/linux/include/pcmcia/version.h | awk '{print $3}'`
			KERNEL_RELEASE_CODE=`grep -E '^#define CS_RELEASE_CODE ' /usr/src/linux/include/pcmcia/version.h | awk '{print $3}'`
		else
			die "unable to find /usr/src/linux/include/pcmcia/version.h"
		fi

		# replace CS_PKG_RELEASE :
		if [ -f version.h ]; then
			sed "s|\(#define CS_PKG_RELEASE.*\)\".*\"|\1$KERNEL_RELEASE|" version.h  > version.h.new
			sed "s|\(#define CS_PKG_RELEASE_CODE.*\)0x.*|\1$KERNEL_RELEASE_CODE|" version.h.new > version.h
		fi

		cd ${S}/clients
		emake all || die "failed compiling"
		cd ${S}/wireless
		emake all || die "failed compiling"
	else
		eerror "Please enable PCMCIA in your kernel in /usr/src/linux"
		eend
	fi

}

src_install () {
	cd ${S}/clients
	make PREFIX=${D} install || die "failed installing"
	cd ${S}/wireless
	make PREFIX=${D} install || die "failed installing"
	cd ${S}/man
	make PREFIX=${D} install-man4 || die "failed installing"

	rm -f ${D}/etc/modules.conf
	rm -rf ${D}/var/lib/pcmcia
}

pkg_postinst() {
	einfo "Please note that some of these drivers are also provided by the kernel.  To use a driver installed"
	einfo "by this ebuild, you must *disable* the corresponding driver in the kernel."
}