summaryrefslogtreecommitdiff
blob: da920f74bf40b12d6266ada4193df4964c526ca8 (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-kernel/linux26-headers/linux26-headers-2.6.8.1-r3.ebuild,v 1.2 2005/01/11 07:13:28 eradicator Exp $

# What's in this kernel ?  ninja juice ! :D

# INCLUDED:
# 1) linux sources from kernel.org

ETYPE="headers"
inherit kernel eutils toolchain-funcs

OKV="${PV/_/-}"
KV="${OKV}"
EXTRAVERSION=""

DESCRIPTION="Linux ${OKV} headers from kernel.org"
HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/"
SRC_URI="mirror://kernel/linux/kernel/v2.6/linux-${OKV}.tar.bz2
	mirror://gentoo/linux-2.6.8.1-sh-headers.patch.bz2"

LICENSE="GPL-2"
#KEYWORDS="~alpha amd64 arm hppa ia64 ~ppc ppc64 ~s390 ~sparc sh x86"
# Just amd64 fixes over -r2
KEYWORDS="~amd64"
IUSE=""

if [[ ${CTARGET} = ${CHOST} ]] ; then
	DEPEND="!virtual/os-headers"
	PROVIDE="virtual/kernel virtual/os-headers"
	SLOT="0"
else
	SLOT="${CTARGET}"
fi

S=${WORKDIR}/linux-${OKV}

headers___fix() {
	sed -i \
		-e "s/\([ "$'\t'"]\)u8\([ "$'\t'"]\)/\1__u8\2/g;" \
		-e "s/\([ "$'\t'"]\)u16\([ "$'\t'"]\)/\1__u16\2/g;" \
		-e "s/\([ "$'\t'"]\)u32\([ "$'\t'"]\)/\1__u32\2/g;" \
		-e "s/\([ "$'\t'"]\)u64\([ "$'\t'"]\)/\1__u64\2/g;" \
		"$@"
}

pkg_setup() {
	# Archs which have their own separate header packages, add a check here
	# and redirect the user to them
	case $(tc-arch ${CTARGET}) in
		mips)
			eerror "These headers are not appropriate for your architecture."
			eerror "Please use sys-kernel/mips-headers instead."
			die
		;;
	esac
}

src_unpack() {
	unpack ${A}
	cd ${S}
	epatch ${WORKDIR}/linux-2.6.8.1-sh-headers.patch

	# Do Stuff
	kernel_universal_unpack

	# User-space patches for various things
	epatch ${FILESDIR}/${PN}-2.6.0-sysctl_h-compat.patch
	epatch ${FILESDIR}/${PN}-2.6.0-fb.patch
	epatch ${FILESDIR}/${PN}-2.6.7-generic-arm-prepare.patch
	epatch ${FILESDIR}/${P}-strict-ansi-fix.patch
	epatch ${FILESDIR}/${P}-appCompat.patch
	epatch ${FILESDIR}/${P}-sparc-glibcsafe.patch
	epatch ${FILESDIR}/${PN}-soundcard-ppc64.patch
	epatch ${FILESDIR}/${P}-arm-float.patch
	epatch ${FILESDIR}/${P}-parisc-syscall.patch

	# Fixes ... all the mv magic is to keep sed from dumping 
	# ugly warnings about how it can't work on a directory.
	cd "${S}"/include
	mv asm-ia64/sn asm-ppc64/iSeries .
	headers___fix asm-ia64/*
	mv sn asm-ia64/
	headers___fix asm-ppc64/*
	mv iSeries asm-ppc64/
	headers___fix asm-ppc64/iSeries/*
}

src_compile() {
	# autoconf.h isnt generated unless it already exists. plus, we have
	# no guarantee that any headers are installed on the system...
	[ -f "${ROOT}"/usr/include/linux/autoconf.h ] \
		|| touch include/linux/autoconf.h

	# Kernel ARCH != portage ARCH
	local KARCH=$(tc-arch-kernel ${CTARGET})

	# When cross-compiling, we need to set the CROSS_COMPILE var properly
	local xmakeopts=
	if [[ ${CTARGET} != ${CHOST} ]] ; then
		xmakeopts="CROSS_COMPILE=${CTARGET}-"
	elif type -p ${CHOST}-ar ; then
		xmakeopts="CROSS_COMPILE=${CHOST}-"
	fi
	xmakeopts="${xmakeopts} ARCH=${KARCH}"

	# if there arent any installed headers, then there also isnt an asm
	# symlink in /usr/include/, and make defconfig will fail, so we have
	# to force an include path with $S.
	local HOSTCFLAGS="-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -I${S}/include/"

	ln -sf ${S}/include/asm-${KARCH} ${S}/include/asm
	make defconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed"
	make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
}

src_install() {
	# Do normal src_install stuff
	kernel_src_install

	# Sorry, but this multilib includes stuff NEEDS to be abstracted better...
	# I'll do it soon... --eradicator

	# If this is sparc, then we need to place asm_offsets.h in the proper location(s)
	if [ "${PROFILE_ARCH}" = "sparc64" -o "${PROFILE_ARCH}" = "sparc64-multilib" ] ; then
		# We don't need the asm dir, generate-asm-sparc will take care of this
		rm -Rf ${D}/${LINUX_INCDIR}/asm

		# We do need empty directories, though...
		dodir ${LINUX_INCDIR}/asm
		dodir ${LINUX_INCDIR}/asm-sparc
		dodir ${LINUX_INCDIR}/asm-sparc64

		# Copy asm-sparc and asm-sparc64
		cp -ax ${S}/include/asm-sparc/* ${D}/${LINUX_INCDIR}/asm-sparc
		cp -ax ${S}/include/asm-sparc64/* ${D}/${LINUX_INCDIR}/asm-sparc64

		# Check if generate-asm-sparc exists
		if [ -a "${FILESDIR}/generate-asm-sparc" ]; then
			# Copy generate-asm-sparc into the sandox
			cp ${FILESDIR}/generate-asm-sparc ${WORKDIR}/generate-asm-sparc

			# Just in case generate-asm-sparc isn't executable, make it so
			if [ ! -x "${WORKDIR}/generate-asm-sparc" ]; then
				chmod +x ${WORKDIR}/generate-asm-sparc
			fi

			# Generate asm for sparc systems
			${WORKDIR}/generate-asm-sparc ${D}/${LINUX_INCDIR}
		else
			eerror "${FILESDIR}/generate-asm-sparc doesn't exist!"
			die
		fi
	fi

	# If this is sparc, then we need to place asm_offsets.h in the proper location(s)
	if [ "${ARCH}" = "amd64" ]; then
		# We don't need the asm dir, generate-asm-sparc will take care of this
		rm -Rf ${D}/${LINUX_INCDIR}/asm

		# We do need empty directories, though...
		dodir ${LINUX_INCDIR}/asm
		dodir ${LINUX_INCDIR}/asm-i386
		dodir ${LINUX_INCDIR}/asm-x86_64

		cp -ax ${S}/include/asm-i386/* ${D}/${LINUX_INCDIR}/asm-i386
		cp -ax ${S}/include/asm-x86_64/* ${D}/${LINUX_INCDIR}/asm-x86_64

		# Check if generate-asm-amd64 exists
		if [ -a "${FILESDIR}/generate-asm-amd64" ]; then
			# Copy generate-asm-amd64 into the sandox
			cp ${FILESDIR}/generate-asm-amd64 ${WORKDIR}/generate-asm-amd64

			# Just in case generate-asm-amd64 isn't executable, make it so
			if [ ! -x "${WORKDIR}/generate-asm-amd64" ]; then
				chmod +x ${WORKDIR}/generate-asm-amd64
			fi

			# Generate asm for sparc systems
			${WORKDIR}/generate-asm-amd64 ${D}/${LINUX_INCDIR}
		else
			eerror "${FILESDIR}/generate-asm-amd64 doesn't exist!"
			die
		fi
	fi

	# If this is 2.5 or 2.6 headers, then we need asm-generic too
	if [ "`KV_to_int ${OKV}`" -ge "`KV_to_int 2.6.0`" ]; then
		dodir ${LINUX_INCDIR}/asm-generic
		cp -ax ${S}/include/asm-generic/* ${D}/${LINUX_INCDIR}/asm-generic
	fi
}

pkg_preinst() {
	kernel_pkg_preinst
}

pkg_postinst() {
	kernel_pkg_postinst

	einfo "Kernel headers are usually only used when recompiling glibc, as such, following the installation"
	einfo "of newer headers, it is advised that you re-merge glibc as follows:"
	einfo "emerge glibc"
	einfo "Failure to do so will cause glibc to not make use of newer features present in the updated kernel"
	einfo "headers."
}