Extending 'configure' script

Functions and macros dependent on different kernel versions are now generated
before compilation basing on current kernel capabilities instead of hardcoding
them for specific kernels.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk
2019-05-24 09:23:13 -04:00
parent f88d78f603
commit 1e5355eba1
50 changed files with 1079 additions and 742 deletions

View File

@@ -0,0 +1,62 @@
#!/bin/bash
#
# Copyright(c) 2012-2019 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
SCRIPTPATH=`dirname $0`
SCRIPTPATH=`realpath $SCRIPTPATH`
MODULE_FILE=$SCRIPTPATH/test_mod.c
OBJ_MOD=$SCRIPTPATH/test_mod.o
KERN_VER=`uname -r`
NPROC=`nproc`
DEFINE_FILE=$SCRIPTPATH/../modules/generated_defines.h
add_define() {
printf "#define %s\n" $1 >> $DEFINE_FILE
}
add_function() {
printf "%s\n" $1 >> $DEFINE_FILE
}
compile_module(){
if [ $# -gt 1 ]
then
INCLUDE="#include <$2>"
else
INCLUDE=""
fi
############# TEST MODULE #############
cat > $MODULE_FILE <<- EOF
#include <linux/module.h>
#include <linux/kernel.h>
$INCLUDE
int init_module(void) {
$1;
return 0;
}
void cleanup_module(void) {};
EOF
#######################################
make -C $SCRIPTPATH &> /dev/null
local ret=$?
if [ $ret -eq 0 ]; then
make -C $SCRIPTPATH clean &> /dev/null
fi
return $ret
}
kernel_not_supp_fail() {
echo "Current kernel is not supported!"
rm $DEFINE_FILE
exit 1
}
IFS='?'