I'm new in linux programming and I'm struggling with creation on makefile. I got 3 files: hello.c
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include "funcs.h"
int init_module(void) {
asgard();
return 0;
}
void cleanup_module(void) {
printk(KERN_INFO "Goodbye world 1.\n");
}
funcs.c
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include "funcs.h"
void asgard(void) {
printk(KERN_INFO "Asgard balordo\n");
return;
}
funcs.h
#include <linux/module.h> /* Needed by all modules */
void asgard(void);
Then the makefile:
obj-m += hello.o
hello-objs := funcs.o
first:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
all: funcs.o hello.o
gcc -o start funcs.o hello.o
funcs.o: funcs.c funcs.h
gcc -C funcs.c
hello.o: hello.c funcs.h
gcc -C hello.c
clean:
rm -f *.o
rm -f ./start
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
When I compile, everything is fine, when i call insmod ./hello.ko it's said that was impossible to insert the module. May you tell me where I'm wrong please?