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