- Allow building individual source files

- Allow direct specification of the kernel build tree.
This commit is contained in:
Jeffrey Townsend
2017-01-01 18:02:19 +00:00
parent 9150307d4d
commit f6f9cdc99a

View File

@@ -5,17 +5,51 @@ set -e
# kmodbuild.sh kernel-packages module-directories platform-name
#
function build_module
#
# build <kernel-package> <module-directory> <platform-install-subdir>
#
function build
{
KERNEL=`onlpm --find-dir $1 mbuilds`
BUILD_DIR=`mktemp -d`
cp -R $2/* "$BUILD_DIR"
if [ -d $1 ]; then
KERNEL=$1
else
KERNEL=`onlpm --find-dir $1 mbuilds`
fi
BUILD_DIR=$2
INSTALL_DIR=$3
make -C $KERNEL M=$BUILD_DIR modules
make -C $KERNEL M=$BUILD_DIR INSTALL_MOD_PATH=`pwd` INSTALL_MOD_DIR="$3" modules_install
}
#
# build_directory <kernel-package> <module-directory> <install-subdir>
#
function build_directory
{
BUILD_DIR=`mktemp -d`
cp -R $2/* "$BUILD_DIR"
build $1 $BUILD_DIR $3
}
#
# build_source <kernel-package> <source-file> <install-subdir>
#
function build_source
{
BUILD_DIR=`mktemp -d`
cp $2 $BUILD_DIR
src=$(basename $2)
obj=${src%.c}.o
echo "obj-m := $obj" >> $BUILD_DIR/Kbuild
build $1 $BUILD_DIR $3
}
for kernel in $1; do
for module in $2; do
build_module $kernel $module $3
if [ -d $module ]; then
build_directory $kernel $module $3
else
build_source $kernel $module $3
fi
done
done