From f6f9cdc99a57dc8b08a4c8f426d17c02d205878c Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 1 Jan 2017 18:02:19 +0000 Subject: [PATCH] - Allow building individual source files - Allow direct specification of the kernel build tree. --- tools/scripts/kmodbuild.sh | 44 +++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/tools/scripts/kmodbuild.sh b/tools/scripts/kmodbuild.sh index 36d801cd..0e5890ec 100755 --- a/tools/scripts/kmodbuild.sh +++ b/tools/scripts/kmodbuild.sh @@ -5,17 +5,51 @@ set -e # kmodbuild.sh kernel-packages module-directories platform-name # -function build_module +# +# build +# +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 +# +function build_directory +{ + BUILD_DIR=`mktemp -d` + cp -R $2/* "$BUILD_DIR" + build $1 $BUILD_DIR $3 +} + +# +# build_source +# +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