|
|
# This eclass differs from kmod.eclass because it doesn't require modules | # This eclass differs from kmod.eclass because it doesn't require modules |
# to be added to the kernel source tree first. | # to be added to the kernel source tree first. |
| |
|
# Variables you can use to change behavior |
|
# |
|
# KERNEL_MOD_SOURCES - space seperated list of source to unpack in |
|
# kernel-mod_src_unpack() if you don't want ${A} unpacked. |
|
# |
|
# KERNEL_MOD_KOUTPUT_PATCH - Patch to apply in src_unpack() if a seperate output |
|
# directory is detected. |
|
# |
|
# KERNEL_MOD_SYMLINK_PATCH - Patch to fix 2.6 compilation if KV_OUTPUT is |
|
# /usr/src/linux on a 2.5 kernel and the build |
|
# directory with symlink method is being used. |
|
|
|
inherit eutils |
|
|
ECLASS=kernel-mod | ECLASS=kernel-mod |
INHERITED="$INHERITED $ECLASS" |
|
S=${WORKDIR}/${P} | S=${WORKDIR}/${P} |
DESCRIPTION="Based on the $ECLASS eclass" | DESCRIPTION="Based on the $ECLASS eclass" |
| |
SRC_URI="${SRC_URI:-unknown - please fix me!!}" | SRC_URI="${SRC_URI:-unknown - please fix me!!}" |
KERNEL_DIR="${KERNEL_DIR:-/usr/src/linux}" | KERNEL_DIR="${KERNEL_DIR:-/usr/src/linux}" |
| |
|
|
kernel-mod_getmakefilevar () | kernel-mod_getmakefilevar () |
{ | { |
grep $1 $2 | head -n 1 | cut -d = -f 2- | awk '{ print $1 }' |
grep $1 $2 | head -n 1 | grep -v ":=" | cut -d = -f 2- | awk '{ print $1 }' |
} | } |
| |
kernel-mod_getversion () | kernel-mod_getversion () |
|
|
| |
KV_MK_VERSION_FULL="$KV_MK_MAJOR.$KV_MK_MINOR.$KV_MK_PATCH$KV_MK_TYPE" | KV_MK_VERSION_FULL="$KV_MK_MAJOR.$KV_MK_MINOR.$KV_MK_PATCH$KV_MK_TYPE" |
| |
|
KV_MK_OUTPUT="`kernel-mod_getmakefilevar ^KBUILD_OUTPUT $KV_MK_FILE`" |
|
|
if [ "$KV_MK_VERSION_FULL" != "$KV_DIR_VERSION_FULL" ]; then | if [ "$KV_MK_VERSION_FULL" != "$KV_DIR_VERSION_FULL" ]; then |
ewarn | ewarn |
ewarn "The kernel Makefile says that this is a $KV_MK_VERSION_FULL kernel" | ewarn "The kernel Makefile says that this is a $KV_MK_VERSION_FULL kernel" |
|
|
KV_PATCH="$KV_MK_PATCH" | KV_PATCH="$KV_MK_PATCH" |
KV_TYPE="$KV_MK_TYPE" | KV_TYPE="$KV_MK_TYPE" |
| |
|
# if we found an output location, use that. otherwise use KERNEL_DIR. |
|
if [ ! -z "${KV_MK_OUTPUT}" ] |
|
then |
|
KV_OUTPUT="$KV_MK_OUTPUT" |
|
else |
|
KV_OUTPUT="$KERNEL_DIR" |
|
fi |
|
|
|
if [ "${KV_MINOR}" -gt "4" ] |
|
then |
|
KV_OBJ="ko" |
|
else |
|
KV_OBJ="o" |
|
fi |
|
|
|
if [ "${KV_MINOR}" -gt 4 ] && [ "${KV_OUTPUT}" = "/usr/src/linux" ] |
|
then |
|
KV_BUILD="${T}/kernel-build" |
|
else |
|
KV_BUILD="/usr/src/linux" |
|
fi |
|
|
einfo "Building for Linux ${KV_VERSION_FULL} found in ${KERNEL_DIR}" | einfo "Building for Linux ${KV_VERSION_FULL} found in ${KERNEL_DIR}" |
|
|
|
if [ "${KV_MINOR}" -gt "4" ] |
|
then |
|
einfo "which outputs to ${KV_OUTPUT}" |
|
|
|
# Warn them if they aren't using a different output directory |
|
if [ "${KV_OUTPUT}" = "/usr/src/linux" ]; then |
|
ewarn "By not using the kernel's ability to output to an alternative" |
|
ewarn "directory, some external module builds may fail." |
|
ewarn "See <insert link to user doc here>" |
|
fi |
|
fi |
} | } |
| |
kernel-mod_checkzlibinflate_configured () | kernel-mod_checkzlibinflate_configured () |
|
|
die "Kernel doesn't include zlib support" | die "Kernel doesn't include zlib support" |
} | } |
| |
|
kernel-mod_prepare_builddir() |
|
{ |
|
einfo "Creating temporary build directory:" |
|
einfo "\t${KV_BUILD}" |
|
einfo "using files in:" |
|
einfo "\t${KV_OUTPUT}" |
|
|
|
mkdir -p ${KV_BUILD} |
|
cd ${KV_BUILD} |
|
for link in ${KV_OUTPUT}/.config \ |
|
${KV_OUTPUT}/.version \ |
|
${KV_OUTPUT}/.tmp_versions \ |
|
${KV_OUTPUT}/*; |
|
do |
|
ln -s "${link}" . |
|
done |
|
} |
|
|
|
kernel-mod_do_buildpatches() |
|
{ |
|
cd ${S} |
|
if [ "${KV_OUTPUT}" = "/usr/src/linux" ]; then |
|
# Patch as needed |
|
if [ -n "${KERNEL_MOD_SYMLINK_PATCH}" ]; then |
|
EPATCH_SINGLE_MESSAGE="Patching to fix 2.6 module compilation" \ |
|
epatch "${KERNEL_MOD_SYMLINK_PATCH}" |
|
fi |
|
elif [ -n "${KERNEL_MOD_KOUTPUT_PATCH}" ]; then |
|
EPATCH_SINGLE_MESSAGE="Patching to enable koutput compatibility" \ |
|
epatch ${KERNEL_MOD_KOUTPUT_PATCH} |
|
fi |
|
} |
|
|
|
kernel-mod_src_unpack () |
|
{ |
|
check_KV |
|
kernel-mod_getversion |
|
|
|
# KERNEL_MOD_SOURCES is used if you don't want to unpack just ${A} |
|
# It can be set to "none" if you need to unpack things by hand |
|
# (like the nvidia-kernel ebuild). If set to "none", you'll have |
|
# to do any patching by hand as ${S} won't be around yet! |
|
# You can just call kernel-mod_do_buildpatches after unpacking ${S} |
|
# if need be. |
|
if [ -z "${KERNEL_MOD_SOURCES}" ] |
|
then |
|
unpack ${A} |
|
elif [ "${KERNEL_MOD_SOURCES}" != "none" ] |
|
then |
|
unpack ${KERNEL_MOD_SOURCES} |
|
fi |
|
|
|
if [ "${KV_MINOR}" -gt 4 ] |
|
then |
|
if [ "${KV_OUTPUT}" = "/usr/src/linux" ] |
|
then |
|
kernel-mod_prepare_builddir |
|
fi |
|
|
|
if [ "${KERNEL_MOD_SOURCES}" != "none" ]; then |
|
kernel-mod_do_buildpatches |
|
fi |
|
fi |
|
} |
|
|
kernel-mod_src_compile () | kernel-mod_src_compile () |
{ | { |
emake KERNEL_DIR=${KERNEL_DIR} || die | emake KERNEL_DIR=${KERNEL_DIR} || die |
} | } |
| |
|
kernel-mod_pkg_postinst() |
|
{ |
|
depmod -a |
|
} |
|
|
kernel-mod_is_2_4_kernel() { | kernel-mod_is_2_4_kernel() { |
kernel-mod_getversion | kernel-mod_getversion |
| |
|
|
fi | fi |
} | } |
| |
EXPORT_FUNCTIONS src_compile |
EXPORT_FUNCTIONS src_unpack src_compile pkg_postinst |