configure: Add get_define() helper function
Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
parent
51dc893fc1
commit
a4610f96cc
@ -20,10 +20,10 @@ add_function() {
|
||||
printf "%s\n" $1 >> $DEFINE_FILE
|
||||
}
|
||||
|
||||
compile_module(){
|
||||
if [ $# -gt 2 ]
|
||||
__compile_module(){
|
||||
if [ $# -gt 1 ]
|
||||
then
|
||||
i=3
|
||||
i=2
|
||||
while [ "$i" -le "$#" ]; do
|
||||
INCLUDE+=$(echo -e "\n#include <${!i}>\\n")
|
||||
i=$((i + 1))
|
||||
@ -32,9 +32,6 @@ compile_module(){
|
||||
INCLUDE=""
|
||||
fi
|
||||
|
||||
config_file=$1
|
||||
test_module_dir=$SCRIPTPATH/configure.d/${config_file}_dir
|
||||
test_module_log=$SCRIPTPATH/configure.d/.${config_file}.log
|
||||
test_module_file=$test_module_dir/test_mod.c
|
||||
test_module_obj=$test_module_dir/test_mod.o
|
||||
|
||||
@ -48,7 +45,7 @@ compile_module(){
|
||||
$INCLUDE
|
||||
|
||||
int init_module(void) {
|
||||
$2
|
||||
$1
|
||||
return 0;
|
||||
}
|
||||
void cleanup_module(void) {};
|
||||
@ -56,10 +53,21 @@ compile_module(){
|
||||
EOF
|
||||
#######################################
|
||||
|
||||
echo "### $2 ###" >> $test_module_log
|
||||
echo "### $1 ###" >> $test_module_log
|
||||
|
||||
make -C $test_module_dir KERNEL_DIR=${KERNEL_DIR} &>> $test_module_log
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
compile_module(){
|
||||
config_file=$1
|
||||
shift
|
||||
|
||||
test_module_dir=$SCRIPTPATH/configure.d/${config_file}_dir
|
||||
test_module_log=$SCRIPTPATH/configure.d/.${config_file}.log
|
||||
|
||||
__compile_module $@
|
||||
local ret=$?
|
||||
|
||||
rm -Rf $test_module_dir
|
||||
@ -72,6 +80,31 @@ compile_module(){
|
||||
return $ret
|
||||
}
|
||||
|
||||
get_define(){
|
||||
config_file=$1
|
||||
define_name=$2
|
||||
include=$3
|
||||
test_module_dir=$SCRIPTPATH/configure.d/${config_file}_dir
|
||||
test_module_log=$SCRIPTPATH/configure.d/.${config_file}.log
|
||||
|
||||
read -r -d '' CODE << EOM
|
||||
#define XSTR(x) STR(x)
|
||||
#define STR(x) #x
|
||||
#pragma message "$define_name " XSTR($define_name)
|
||||
EOM
|
||||
|
||||
__compile_module "$CODE" "$include"
|
||||
|
||||
rm -Rf $test_module_dir
|
||||
|
||||
grep -Pom 1 "note:.*$define_name .*" $test_module_log | cut -d' ' -f 5- | tr -d '"'
|
||||
local ret=$?
|
||||
|
||||
rm -f $test_module_log
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
kernel_not_supp_fail() {
|
||||
echo "Current kernel is not supported!"
|
||||
rm $DEFINE_FILE
|
||||
|
Loading…
Reference in New Issue
Block a user