/[gentoo-x86]/eclass/kernel-2.eclass
Gentoo

Diff of /eclass/kernel-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.260 Revision 1.268
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.260 2011/08/29 01:28:10 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.268 2011/12/02 02:37:50 vapier Exp $
4 4
5# Description: kernel.eclass rewrite for a clean base regarding the 2.6 5# Description: kernel.eclass rewrite for a clean base regarding the 2.6
6# series of kernel with back-compatibility for 2.4 6# series of kernel with back-compatibility for 2.4
7# 7#
8# Original author: John Mylchreest <johnm@gentoo.org> 8# Original author: John Mylchreest <johnm@gentoo.org>
81if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then 81if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
82 export CTARGET=${CATEGORY/cross-} 82 export CTARGET=${CATEGORY/cross-}
83fi 83fi
84 84
85HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}" 85HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
86[[ -z ${LICENSE} ]] && \
87 LICENSE="GPL-2" 86: ${LICENSE:="GPL-2"}
88 87
89# This is the latest KV_PATCH of the deblob tool available from the 88# This is the latest KV_PATCH of the deblob tool available from the
90# libre-sources upstream. If you bump this, you MUST regenerate the Manifests 89# libre-sources upstream. If you bump this, you MUST regenerate the Manifests
91# for ALL kernel-2 consumer packages where deblob is available. 90# for ALL kernel-2 consumer packages where deblob is available.
92[[ -z ${DEBLOB_MAX_VERSION} ]] && DEBLOB_MAX_VERSION=38 91: ${DEBLOB_MAX_VERSION:=38}
93 92
94# No need to run scanelf/strip on kernel sources/headers (bug #134453). 93# No need to run scanelf/strip on kernel sources/headers (bug #134453).
95RESTRICT="binchecks strip" 94RESTRICT="binchecks strip"
96 95
97# set LINUX_HOSTCFLAGS if not already set 96# set LINUX_HOSTCFLAGS if not already set
98[[ -z ${LINUX_HOSTCFLAGS} ]] && \
99 LINUX_HOSTCFLAGS="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include" 97: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"}
100 98
101# debugging functions 99# debugging functions
102#============================================================== 100#==============================================================
103# this function exists only to help debug kernel-2.eclass 101# this function exists only to help debug kernel-2.eclass
104# if you are adding new functionality in, put a call to it 102# if you are adding new functionality in, put a call to it
116handle_genpatches() { 114handle_genpatches() {
117 local tarball 115 local tarball
118 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1 116 [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
119 117
120 debug-print "Inside handle_genpatches" 118 debug-print "Inside handle_genpatches"
121 local oldifs=${IFS}
122 export IFS="."
123 local OKV_ARRAY=( $OKV ) 119 local OKV_ARRAY
124 export IFS=${oldifs} 120 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
125 121
126 # for > 3.0 kernels, handle genpatches tarball name 122 # for > 3.0 kernels, handle genpatches tarball name
127 # genpatches for 3.0 and 3.0.1 might be named 123 # genpatches for 3.0 and 3.0.1 might be named
128 # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2 124 # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2
129 # respectively. Handle this. 125 # respectively. Handle this.
170 OKV=${OKV/-r*} 166 OKV=${OKV/-r*}
171 OKV=${OKV/_p*} 167 OKV=${OKV/_p*}
172 168
173 KV_MAJOR=$(get_version_component_range 1 ${OKV}) 169 KV_MAJOR=$(get_version_component_range 1 ${OKV})
174 # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1) 170 # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1)
175 local oldifs=${IFS}
176 export IFS="."
177 local OKV_ARRAY=( $OKV ) 171 local OKV_ARRAY
178 export IFS=${oldifs} 172 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
179 173
180 # if KV_MAJOR >= 3, then we have no more KV_MINOR 174 # if KV_MAJOR >= 3, then we have no more KV_MINOR
181 #if [[ ${KV_MAJOR} -lt 3 ]]; then 175 #if [[ ${KV_MAJOR} -lt 3 ]]; then
182 if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then 176 if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
183 KV_MINOR=$(get_version_component_range 2 ${OKV}) 177 KV_MINOR=$(get_version_component_range 2 ${OKV})
229 # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}" 223 # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}"
230 [[ -n "${K_LONGTERM}" ]] && 224 [[ -n "${K_LONGTERM}" ]] &&
231 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}" 225 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
232 else 226 else
233 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0" 227 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
234 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}" 228 #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
229 if [[ ${KV_MAJOR} -ge 3 ]]; then
230 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
231 else
232 KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
233 fi
234
235 [[ -n "${K_LONGTERM}" ]] && 235 [[ -n "${K_LONGTERM}" ]] &&
236 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
236 KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}" 237 #KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
237 fi 238 fi
238 239
239 debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}" 240 debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
240 241
241 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then 242 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
495 496
496 # Since we should NOT honour KBUILD_OUTPUT in headers 497 # Since we should NOT honour KBUILD_OUTPUT in headers
497 # lets unset it here. 498 # lets unset it here.
498 unset KBUILD_OUTPUT 499 unset KBUILD_OUTPUT
499 500
500 if [[ ${CTARGET} = ${CHOST} ]]; then
501 SLOT="0" 501 SLOT="0"
502 else
503 SLOT="${CTARGET}"
504 fi
505else 502else
506 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 503 eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
507 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\"" 504 die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
508fi 505fi
509 506
567} 564}
568 565
569universal_unpack() { 566universal_unpack() {
570 debug-print "Inside universal_unpack" 567 debug-print "Inside universal_unpack"
571 568
572 local oldifs=${IFS}
573 export IFS="."
574 local OKV_ARRAY=( $OKV ) 569 local OKV_ARRAY
575 export IFS=${oldifs} 570 IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
576 571
577 cd "${WORKDIR}" 572 cd "${WORKDIR}"
578 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then 573 if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
579 unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2 574 unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2
580 else 575 else
1127 done 1122 done
1128 fi 1123 fi
1129 done 1124 done
1130} 1125}
1131 1126
1132# sparc nastiness
1133#==============================================================
1134# This script generates the files in /usr/include/asm for sparc systems
1135# during installation of sys-kernel/linux-headers.
1136# Will no longer be needed when full 64 bit support is used on sparc64
1137# systems.
1138#
1139# Shamefully ripped from Debian
1140# ----------------------------------------------------------------------
1141
1142# Idea borrowed from RedHat's kernel package
1143
1144# This is gonna get replaced by something in multilib.eclass soon...
1145# --eradicator
1146generate_sparc_asm() {
1147 local name
1148
1149 cd $1 || die
1150 mkdir asm
1151
1152 for h in `( ls asm-sparc; ls asm-sparc64 ) | grep '\.h$' | sort -u`; do
1153 name="$(echo $h | tr a-z. A-Z_)"
1154 # common header
1155 echo "/* All asm/ files are generated and point to the corresponding
1156 * file in asm-sparc or asm-sparc64.
1157 */
1158
1159#ifndef __SPARCSTUB__${name}__
1160#define __SPARCSTUB__${name}__
1161" > asm/${h}
1162
1163 # common for sparc and sparc64
1164 if [ -f asm-sparc/$h -a -f asm-sparc64/$h ]; then
1165 echo "#ifdef __arch64__
1166#include <asm-sparc64/$h>
1167#else
1168#include <asm-sparc/$h>
1169#endif
1170" >> asm/${h}
1171
1172 # sparc only
1173 elif [ -f asm-sparc/$h ]; then
1174echo "#ifndef __arch64__
1175#include <asm-sparc/$h>
1176#endif
1177" >> asm/${h}
1178
1179 # sparc64 only
1180 else
1181echo "#ifdef __arch64__
1182#include <asm-sparc64/$h>
1183#endif
1184" >> asm/${h}
1185 fi
1186
1187 # common footer
1188 echo "#endif /* !__SPARCSTUB__${name}__ */" >> asm/${h}
1189 done
1190 return 0
1191}
1192
1193headers___fix() { 1127headers___fix() {
1194 # Voodoo to partially fix broken upstream headers. 1128 # Voodoo to partially fix broken upstream headers.
1195 # note: do not put inline/asm/volatile together (breaks "inline asm volatile") 1129 # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
1196 sed -i \ 1130 sed -i \
1197 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \ 1131 -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
1278 [[ ${ETYPE} == sources ]] && postinst_sources 1212 [[ ${ETYPE} == sources ]] && postinst_sources
1279} 1213}
1280 1214
1281kernel-2_pkg_setup() { 1215kernel-2_pkg_setup() {
1282 if kernel_is 2 4; then 1216 if kernel_is 2 4; then
1283 if [ "$( gcc-major-version )" -eq "4" ] ; then 1217 if [[ $(gcc-major-version) -ge 4 ]] ; then
1284 echo 1218 echo
1285 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!" 1219 ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
1286 ewarn "Either switch to another gcc-version (via gcc-config) or use a" 1220 ewarn "Either switch to another gcc-version (via gcc-config) or use a"
1287 ewarn "newer kernel that supports gcc-4." 1221 ewarn "newer kernel that supports gcc-4."
1288 echo 1222 echo
1297 [[ ${ETYPE} == headers ]] && setup_headers 1231 [[ ${ETYPE} == headers ]] && setup_headers
1298 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..." 1232 [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
1299} 1233}
1300 1234
1301kernel-2_pkg_postrm() { 1235kernel-2_pkg_postrm() {
1236 # This warning only makes sense for kernel sources.
1237 [[ ${ETYPE} == headers ]] && return 0
1302 echo 1238 echo
1303 ewarn "Note: Even though you have successfully unmerged " 1239 ewarn "Note: Even though you have successfully unmerged "
1304 ewarn "your kernel package, directories in kernel source location: " 1240 ewarn "your kernel package, directories in kernel source location: "
1305 ewarn "${ROOT}usr/src/linux-${KV_FULL}" 1241 ewarn "${ROOT}usr/src/linux-${KV_FULL}"
1306 ewarn "with modified files will remain behind. By design, package managers" 1242 ewarn "with modified files will remain behind. By design, package managers"
1307 ewarn "will not remove these modified files and the directories they reside in." 1243 ewarn "will not remove these modified files and the directories they reside in."
1308 echo 1244 echo
1309} 1245}
1310

Legend:
Removed from v.1.260  
changed lines
  Added in v.1.268

  ViewVC Help
Powered by ViewVC 1.1.20