Added configure script
Signed-off-by: Michal Rakowski <michal.rakowski@intel.com>
This commit is contained in:
parent
80f8e617e3
commit
61e2af80bc
68
configure
vendored
Executable file
68
configure
vendored
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright(c) 2012-2019 Intel Corporation
|
||||
# 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
|
||||
|
||||
|
||||
add_define() {
|
||||
echo -n "#define " >> $DEFINE_FILE
|
||||
for arg in "$@"; do
|
||||
echo -e "$arg" >> $DEFINE_FILE
|
||||
done
|
||||
}
|
||||
|
||||
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
|
@ -47,7 +47,7 @@ default: $(VERSION_FILE) sync
|
||||
|
||||
clean:
|
||||
cd $(KERNEL_DIR) && make M=$(PWD) clean
|
||||
|
||||
rm $(PWD)/generated_defines.h
|
||||
distclean: clean distsync
|
||||
|
||||
install:
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include <linux/nmi.h>
|
||||
#include <linux/ratelimit.h>
|
||||
|
||||
#include "generated_defines.h"
|
||||
|
||||
#ifdef CONFIG_SLAB
|
||||
#include <linux/slab_def.h>
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user