Lines 8-24
Link Here
|
8 |
# This eclass differs from kmod.eclass because it doesn't require modules |
8 |
# This eclass differs from kmod.eclass because it doesn't require modules |
9 |
# to be added to the kernel source tree first. |
9 |
# to be added to the kernel source tree first. |
10 |
|
10 |
|
|
|
11 |
# Variables you can use to change behavior |
12 |
# |
13 |
# KERNEL_MOD_SOURCES - space seperated list of source to unpack in |
14 |
# kernel-mod_src_unpack() if you don't want ${A} unpacked. |
15 |
# |
16 |
# KERNEL_MOD_KOUTPUT_PATCH - Patch to apply in src_unpack() if a seperate output |
17 |
# directory is detected. |
18 |
# |
19 |
# KERNEL_MOD_SYMLINK_PATCH - Patch to fix 2.6 compilation if KV_OUTPUT is |
20 |
# /usr/src/linux on a 2.5 kernel and the build |
21 |
# directory with symlink method is being used. |
22 |
|
23 |
inherit eutils |
24 |
|
11 |
ECLASS=kernel-mod |
25 |
ECLASS=kernel-mod |
12 |
INHERITED="$INHERITED $ECLASS" |
26 |
|
13 |
S=${WORKDIR}/${P} |
27 |
S=${WORKDIR}/${P} |
14 |
DESCRIPTION="Based on the $ECLASS eclass" |
28 |
DESCRIPTION="Based on the $ECLASS eclass" |
15 |
|
29 |
|
16 |
SRC_URI="${SRC_URI:-unknown - please fix me!!}" |
30 |
SRC_URI="${SRC_URI:-unknown - please fix me!!}" |
17 |
KERNEL_DIR="${KERNEL_DIR:-/usr/src/linux}" |
31 |
KERNEL_DIR="${KERNEL_DIR:-/usr/src/linux}" |
18 |
|
32 |
|
|
|
33 |
|
19 |
kernel-mod_getmakefilevar () |
34 |
kernel-mod_getmakefilevar () |
20 |
{ |
35 |
{ |
21 |
grep $1 $2 | head -n 1 | cut -d = -f 2- | awk '{ print $1 }' |
36 |
grep $1 $2 | head -n 1 | grep -v ":=" | cut -d = -f 2- | awk '{ print $1 }' |
22 |
} |
37 |
} |
23 |
|
38 |
|
24 |
kernel-mod_getversion () |
39 |
kernel-mod_getversion () |
Lines 61-66
Link Here
|
61 |
|
76 |
|
62 |
KV_MK_VERSION_FULL="$KV_MK_MAJOR.$KV_MK_MINOR.$KV_MK_PATCH$KV_MK_TYPE" |
77 |
KV_MK_VERSION_FULL="$KV_MK_MAJOR.$KV_MK_MINOR.$KV_MK_PATCH$KV_MK_TYPE" |
63 |
|
78 |
|
|
|
79 |
KV_MK_OUTPUT="`kernel-mod_getmakefilevar ^KBUILD_OUTPUT $KV_MK_FILE`" |
80 |
|
64 |
if [ "$KV_MK_VERSION_FULL" != "$KV_DIR_VERSION_FULL" ]; then |
81 |
if [ "$KV_MK_VERSION_FULL" != "$KV_DIR_VERSION_FULL" ]; then |
65 |
ewarn |
82 |
ewarn |
66 |
ewarn "The kernel Makefile says that this is a $KV_MK_VERSION_FULL kernel" |
83 |
ewarn "The kernel Makefile says that this is a $KV_MK_VERSION_FULL kernel" |
Lines 82-88
Link Here
|
82 |
KV_PATCH="$KV_MK_PATCH" |
99 |
KV_PATCH="$KV_MK_PATCH" |
83 |
KV_TYPE="$KV_MK_TYPE" |
100 |
KV_TYPE="$KV_MK_TYPE" |
84 |
|
101 |
|
|
|
102 |
# if we found an output location, use that. otherwise use KERNEL_DIR. |
103 |
if [ ! -z "${KV_MK_OUTPUT}" ] |
104 |
then |
105 |
KV_OUTPUT="$KV_MK_OUTPUT" |
106 |
else |
107 |
KV_OUTPUT="$KERNEL_DIR" |
108 |
fi |
109 |
|
110 |
if [ "${KV_MINOR}" -gt "4" ] |
111 |
then |
112 |
KV_OBJ="ko" |
113 |
else |
114 |
KV_OBJ="o" |
115 |
fi |
116 |
|
117 |
if [ "${KV_MINOR}" -gt 4 ] && [ "${KV_OUTPUT}" = "/usr/src/linux" ] |
118 |
then |
119 |
KV_BUILD="${T}/kernel-build" |
120 |
else |
121 |
KV_BUILD="/usr/src/linux" |
122 |
fi |
123 |
|
85 |
einfo "Building for Linux ${KV_VERSION_FULL} found in ${KERNEL_DIR}" |
124 |
einfo "Building for Linux ${KV_VERSION_FULL} found in ${KERNEL_DIR}" |
|
|
125 |
|
126 |
if [ "${KV_MINOR}" -gt "4" ] |
127 |
then |
128 |
einfo "which outputs to ${KV_OUTPUT}" |
129 |
|
130 |
# Warn them if they aren't using a different output directory |
131 |
if [ "${KV_OUTPUT}" = "/usr/src/linux" ]; then |
132 |
ewarn "By not using the kernel's ability to output to an alternative" |
133 |
ewarn "directory, some external module builds may fail." |
134 |
ewarn "See <insert link to user doc here>" |
135 |
fi |
136 |
fi |
86 |
} |
137 |
} |
87 |
|
138 |
|
88 |
kernel-mod_checkzlibinflate_configured () |
139 |
kernel-mod_checkzlibinflate_configured () |
Lines 151-161
Link Here
|
151 |
die "Kernel doesn't include zlib support" |
202 |
die "Kernel doesn't include zlib support" |
152 |
} |
203 |
} |
153 |
|
204 |
|
|
|
205 |
kernel-mod_prepare_builddir() |
206 |
{ |
207 |
einfo "Creating temporary build directory:" |
208 |
einfo "\t${KV_BUILD}" |
209 |
einfo "using files in:" |
210 |
einfo "\t${KV_OUTPUT}" |
211 |
|
212 |
mkdir -p ${KV_BUILD} |
213 |
cd ${KV_BUILD} |
214 |
for link in ${KV_OUTPUT}/.config \ |
215 |
${KV_OUTPUT}/.version \ |
216 |
${KV_OUTPUT}/.tmp_versions \ |
217 |
${KV_OUTPUT}/*; |
218 |
do |
219 |
ln -s "${link}" . |
220 |
done |
221 |
} |
222 |
|
223 |
kernel-mod_do_buildpatches() |
224 |
{ |
225 |
cd ${S} |
226 |
if [ "${KV_OUTPUT}" = "/usr/src/linux" ]; then |
227 |
# Patch as needed |
228 |
if [ -n "${KERNEL_MOD_SYMLINK_PATCH}" ]; then |
229 |
EPATCH_SINGLE_MESSAGE="Patching to fix 2.6 module compilation" \ |
230 |
epatch "${KERNEL_MOD_SYMLINK_PATCH}" |
231 |
fi |
232 |
elif [ -n "${KERNEL_MOD_KOUTPUT_PATCH}" ]; then |
233 |
EPATCH_SINGLE_MESSAGE="Patching to enable koutput compatibility" \ |
234 |
epatch ${KERNEL_MOD_KOUTPUT_PATCH} |
235 |
fi |
236 |
} |
237 |
|
238 |
kernel-mod_src_unpack () |
239 |
{ |
240 |
check_KV |
241 |
kernel-mod_getversion |
242 |
|
243 |
# KERNEL_MOD_SOURCES is used if you don't want to unpack just ${A} |
244 |
# It can be set to "none" if you need to unpack things by hand |
245 |
# (like the nvidia-kernel ebuild). If set to "none", you'll have |
246 |
# to do any patching by hand as ${S} won't be around yet! |
247 |
# You can just call kernel-mod_do_buildpatches after unpacking ${S} |
248 |
# if need be. |
249 |
if [ -z "${KERNEL_MOD_SOURCES}" ] |
250 |
then |
251 |
unpack ${A} |
252 |
elif [ "${KERNEL_MOD_SOURCES}" != "none" ] |
253 |
then |
254 |
unpack ${KERNEL_MOD_SOURCES} |
255 |
fi |
256 |
|
257 |
if [ "${KV_MINOR}" -gt 4 ] |
258 |
then |
259 |
if [ "${KV_OUTPUT}" = "/usr/src/linux" ] |
260 |
then |
261 |
kernel-mod_prepare_builddir |
262 |
fi |
263 |
|
264 |
if [ "${KERNEL_MOD_SOURCES}" != "none" ]; then |
265 |
kernel-mod_do_buildpatches |
266 |
fi |
267 |
fi |
268 |
} |
269 |
|
154 |
kernel-mod_src_compile () |
270 |
kernel-mod_src_compile () |
155 |
{ |
271 |
{ |
156 |
emake KERNEL_DIR=${KERNEL_DIR} || die |
272 |
emake KERNEL_DIR=${KERNEL_DIR} || die |
157 |
} |
273 |
} |
158 |
|
274 |
|
|
|
275 |
kernel-mod_pkg_postinst() |
276 |
{ |
277 |
depmod -a |
278 |
} |
279 |
|
159 |
kernel-mod_is_2_4_kernel() { |
280 |
kernel-mod_is_2_4_kernel() { |
160 |
kernel-mod_getversion |
281 |
kernel-mod_getversion |
161 |
|
282 |
|
Lines 189-192
Link Here
|
189 |
fi |
310 |
fi |
190 |
} |
311 |
} |
191 |
|
312 |
|
192 |
EXPORT_FUNCTIONS src_compile |
313 |
EXPORT_FUNCTIONS src_unpack src_compile pkg_postinst |