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:
103
configure
vendored
103
configure
vendored
@@ -4,103 +4,14 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||
#
|
||||
|
||||
MODULE_FILE=test_mod.c
|
||||
OBJ_MOD=test_mod.o
|
||||
KERN_VER=`uname -r`
|
||||
PWD=`pwd`
|
||||
NPROC=`nproc`
|
||||
DEFINE_FILE=modules/generated_defines.h
|
||||
SCRIPTPATH=`dirname $0`
|
||||
SCRIPTPATH=`realpath $SCRIPTPATH`
|
||||
|
||||
CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf`
|
||||
|
||||
add_define() {
|
||||
echo -n "#define " >> $DEFINE_FILE
|
||||
for arg in "$@"; do
|
||||
echo -e "$arg" >> $DEFINE_FILE
|
||||
done
|
||||
}
|
||||
rm -f $SCRIPTPATH/modules/generated_defines.h
|
||||
|
||||
add_function() {
|
||||
for arg in "$@"; do
|
||||
echo -e "$arg" >> $DEFINE_FILE
|
||||
done
|
||||
}
|
||||
|
||||
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 /lib/modules/$KERN_VER/build M=$PWD modules\
|
||||
obj-m=$OBJ_MOD -j$NPROC &> /dev/null
|
||||
|
||||
local ret=$?
|
||||
if [ $ret -eq 0 ]; then
|
||||
make -j$NPROC -C /lib/modules/$KERN_VER/build M=$PWD clean\
|
||||
obj-m=test.o &> /dev/null
|
||||
fi
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
kernel_not_supp_fail() {
|
||||
echo "Current kernel is not supported!"
|
||||
rm $DEFINE_FILE
|
||||
exit 1
|
||||
}
|
||||
|
||||
rm -f $DEFINE_FILE
|
||||
|
||||
compile_module "part_round_stats(1, 1)" "linux/genhd.h"
|
||||
if [ $? -eq 0 ]; then
|
||||
add_define "CAS_PART_ROUND_STATS(q, cpu, part) part_round_stats(cpu, part)"
|
||||
else
|
||||
compile_module "part_round_stats(NULL, 1, 1)" "linux/genhd.h"
|
||||
if [ $? -eq 0 ]; then
|
||||
add_define "CAS_PART_ROUND_STATS(q, cpu, part)\\"\
|
||||
"\tpart_round_stats(q, cpu, part)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
compile_module "part_inc_in_flight(1, 1)" "linux/genhd.h"
|
||||
if [ $? -eq 0 ]; then
|
||||
add_define "CAS_PART_INC_IN_FLIGHT(q, cpu, part)\\"\
|
||||
"\tpart_inc_in_flight(cpu, part)"
|
||||
else
|
||||
compile_module "part_inc_in_flight(NULL, 1, 1)" "linux/genhd.h"
|
||||
if [ $? -eq 0 ]; then
|
||||
add_define "CAS_PART_INC_IN_FLIGHT(q, cpu, part)\\"\
|
||||
"\tpart_inc_in_flight(q, cpu, part)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
compile_module "part_dec_in_flight(1, 1)" "linux/genhd.h"
|
||||
if [ $? -eq 0 ]; then
|
||||
add_define "CAS_PART_DEC_IN_FLIGHT(q, cpu, part)\\"\
|
||||
"\tpart_dec_in_flight(cpu, part)"
|
||||
else
|
||||
compile_module "part_dec_in_flight(NULL, 1, 1)" "linux/genhd.h"
|
||||
if [ $? -eq 0 ]; then
|
||||
add_define "CAS_PART_DEC_IN_FLIGHT(q, cpu, part)\\"\
|
||||
"\tpart_dec_in_flight(q, cpu, part)"
|
||||
fi
|
||||
fi
|
||||
for file in $CONFIG_FILES; do
|
||||
/bin/bash $file
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user