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

Contents of /eclass/kernel-mod.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (show annotations) (download)
Mon Nov 30 04:19:36 2009 UTC (4 years, 8 months ago) by abcd
Branch: MAIN
CVS Tags: HEAD
Changes since 1.16: +1 -1 lines
FILE REMOVED
Remove eclasses that have been marked as deprecated for >=2 years; schedule other deprecated eclasses for removal

1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/kernel-mod.eclass,v 1.16 2009/02/23 05:51:14 vapier Exp $
4
5 # !!!!!!!!!!
6 #
7 # BEWARE: DO NOT USE. THIS ECLASS IS DEPRECATED AND BROKEN. DO NOT USE.
8 # Use linux-mod.eclass and/or linux-info.eclass instead. --brix
9 #
10 # !!!!!!!!!!
11
12 # This eclass provides help for compiling external kernel modules from
13 # source.
14 #
15 # This eclass differs from kmod.eclass because it doesn't require modules
16 # to be added to the kernel source tree first.
17
18 DESCRIPTION="Based on the $ECLASS eclass"
19
20 SRC_URI="${SRC_URI:-unknown - please fix me!!}"
21 KERNEL_DIR="${KERNEL_DIR:-/usr/src/linux}"
22
23 kernel-mod_getmakefilevar() {
24 grep $1 $2 | head -n 1 | cut -d = -f 2- | awk '{ print $1 }'
25 }
26
27 kernel-mod_getversion() {
28 # yes, this is horrible, but it is effective
29 #
30 # KV_DIR contains the real directory name of the directory containing
31 # the Linux kernel that we are going to compile against
32
33 if [ -h ${KERNEL_DIR} ] ; then
34 einfo "${KERNEL_DIR} is a symbolic link"
35 einfo "Determining the real directory of the Linux kernel source code"
36 KV_DIR="`ls -ld --full-time ${KERNEL_DIR} | awk '{ print $11 }'`"
37 elif [ -d ${KERNEL_DIR} ] ; then
38 einfo "${KERNEL_DIR} is a real directory"
39 KV_DIR="`ls -ld --full-time ${KERNEL_DIR} | awk '{ print $9 }'`"
40 else
41 eerror "Directory '${KERNEL_DIR}' cannot be found"
42 die
43 fi
44 KV_DIR="`basename $KV_DIR`"
45
46 # now, we need to break that down into versions
47
48 KV_DIR_VERSION_FULL="`echo $KV_DIR | cut -f 2- -d -`"
49
50 KV_DIR_MAJOR="`echo $KV_DIR_VERSION_FULL | cut -f 1 -d .`"
51 KV_DIR_MINOR="`echo $KV_DIR_VERSION_FULL | cut -f 2 -d .`"
52 KV_DIR_PATCH="`echo $KV_DIR_VERSION_FULL | cut -f 3 -d . | cut -f 3 -d -`"
53 KV_DIR_TYPE="`echo $KV_DIR_VERSION_FULL | cut -f 2- -d -`"
54
55 # sanity check - do the settings in the kernel's makefile match
56 # the directory that the kernel src is stored in?
57
58 KV_MK_FILE="${KERNEL_DIR}/Makefile"
59 KV_MK_MAJOR="`kernel-mod_getmakefilevar VERSION $KV_MK_FILE`"
60 KV_MK_MINOR="`kernel-mod_getmakefilevar PATCHLEVEL $KV_MK_FILE`"
61 KV_MK_PATCH="`kernel-mod_getmakefilevar SUBLEVEL $KV_MK_FILE`"
62 KV_MK_TYPE="`kernel-mod_getmakefilevar EXTRAVERSION $KV_MK_FILE`"
63
64 KV_MK_VERSION_FULL="$KV_MK_MAJOR.$KV_MK_MINOR.$KV_MK_PATCH$KV_MK_TYPE"
65
66 if [ "$KV_MK_VERSION_FULL" != "$KV_DIR_VERSION_FULL" ]; then
67 ewarn
68 ewarn "The kernel Makefile says that this is a $KV_MK_VERSION_FULL kernel"
69 ewarn "but the source is in a directory for a $KV_DIR_VERSION_FULL kernel."
70 ewarn
71 ewarn "This goes against the recommended Gentoo naming convention."
72 ewarn "Please rename your source directory to 'linux-${KV_MK_VERSION_FULL}'"
73 ewarn
74 fi
75
76 # these variables can be used by ebuilds to determine whether they
77 # will work with the targetted kernel or not
78 #
79 # do not rely on any of the variables above being available
80
81 KV_VERSION_FULL="$KV_MK_VERSION_FULL"
82 KV_MAJOR="$KV_MK_MAJOR"
83 KV_MINOR="$KV_MK_MINOR"
84 KV_PATCH="$KV_MK_PATCH"
85 KV_TYPE="$KV_MK_TYPE"
86
87 einfo "Building for Linux ${KV_VERSION_FULL} found in ${KERNEL_DIR}"
88 }
89
90 kernel-mod_configoption_present() {
91 [ -e "${KERNEL_DIR}/.config" ] || die "kernel has not been configured yet"
92
93 if egrep "^CONFIG_${1}=[ym]" ${ROOT}/usr/src/linux/.config >/dev/null
94 then
95 return 0
96 else
97 return 1
98 fi
99 }
100
101 kernel-mod_configoption_module() {
102 [ -e "${KERNEL_DIR}/.config" ] || die "kernel has not been configured yet"
103
104 if egrep "^CONFIG_${1}=[m]" ${ROOT}/usr/src/linux/.config >/dev/null
105 then
106 return 0
107 else
108 return 1
109 fi
110 }
111
112 kernel-mod_configoption_builtin() {
113 [ -e "${KERNEL_DIR}/.config" ] || die "kernel has not been configured yet"
114
115 if egrep "^CONFIG_${1}=[y]" ${ROOT}/usr/src/linux/.config >/dev/null
116 then
117 return 0
118 else
119 return 1
120 fi
121 }
122
123 kernel-mod_modules_supported() {
124 kernel-mod_configoption_builtin "MODULES"
125 }
126
127 kernel-mod_check_modules_supported() {
128 if ! kernel-mod_modules_supported
129 then
130 eerror "Your current kernel does not support loading external modules."
131 eerror "Please enable \"Loadable module support\" (CONFIG_MODULES) in your kernel config."
132 die "kernel does not support loading modules"
133 fi
134 }
135
136 kernel-mod_checkzlibinflate_configured() {
137 einfo "Checking for status of CONFIG_ZLIB_INFLATE support in your kernel"
138
139 . ${KERNEL_DIR}/.config || die "kernel has not been configured yet"
140 [ "$CONFIG_ZLIB_INFLATE" != "y" ] && kernel-mod_badconfig_zlib
141 [ "$CONFIG_ZLIB_DEFLATE" != "y" ] && kernel-mod_badconfig_zlib
142
143 # bug #27882 - zlib routines are only linked into the kernel
144 # if something compiled into the kernel calls them
145 #
146 # plus, for the cloop module, it appears that there's no way
147 # to get cloop.o to include a static zlib if CONFIG_MODVERSIONS
148 # is on
149
150 # get the line numbers of the lines that default CONFIG_ZLIB_INFLATE
151 # to 'y'
152
153 local LINENO_START
154 local LINENO_END
155 local SYMBOLS
156 local x
157
158 LINENO_END="`grep -n 'CONFIG_ZLIB_INFLATE y' ${KERNEL_DIR}/lib/Config.in | cut -d : -f 1`"
159 LINENO_START="`head -n $LINENO_END ${KERNEL_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1`"
160 (( LINENO_AMOUNT = $LINENO_END - $LINENO_START ))
161 (( LINENO_END = $LINENO_END - 1 ))
162
163 SYMBOLS="`head -n $LINENO_END ${KERNEL_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;'`"
164
165 # okay, now we have a list of symbols
166 # we need to check each one in turn, to see whether it is set or not
167
168 for x in $SYMBOLS ; do
169 if [ "${!x}" = "y" ]; then
170 # we have a winner!
171 einfo "${x} ensures zlib is linked into your kernel - excellent"
172 return 0
173 fi
174 done
175
176 # if we get to here, the kernel config needs changing
177 #
178 # I have made this an error, because otherwise this warning will
179 # scroll off the top of the screen and be lost
180
181 eerror
182 eerror "This kernel module requires ZLIB library support."
183 eerror "You have enabled zlib support in your kernel, but haven't enabled"
184 eerror "enabled any option that will ensure that zlib is linked into your"
185 eerror "kernel."
186 eerror
187 eerror "Please ensure that you enable at least one of these options:"
188 eerror
189
190 for x in $SYMBOLS ; do
191 eerror " * $x"
192 done
193
194 eerror
195 eerror "Please remember to recompile and install your kernel, and reboot"
196 eerror "into your new kernel before attempting to load this kernel module."
197
198 die "Kernel doesn't include zlib support"
199 }
200
201 kernel-mod_src_compile() {
202 emake KERNEL_DIR=${KERNEL_DIR} || die
203 }
204
205 kernel-mod_is_2_4_kernel() {
206 kernel-mod_getversion
207
208 if [ "${KV_MAJOR}" -eq 2 -a "${KV_MINOR}" -eq 4 ]
209 then
210 return 0
211 else
212 return 1
213 fi
214 }
215
216 kernel-mod_is_2_5_kernel() {
217 kernel-mod_getversion
218
219 if [ "${KV_MAJOR}" -eq 2 -a "${KV_MINOR}" -eq 5 ]
220 then
221 return 0
222 else
223 return 1
224 fi
225 }
226
227 kernel-mod_is_2_6_kernel() {
228 kernel-mod_getversion
229
230 if [ "${KV_MAJOR}" -eq 2 -a "${KV_MINOR}" -eq 6 ]
231 then
232 return 0
233 else
234 return 1
235 fi
236 }
237
238 EXPORT_FUNCTIONS src_compile

  ViewVC Help
Powered by ViewVC 1.1.20