Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a kernel module from several source files which one of them has the same name as the module

Is it possible to build a kernel module from several source files which one of them has the same name as the module?

For example: I want to build "mymodule.ko" with the following source files:
mymodule.c
mymodule_func.c

This makefile doesn't work:

#Makefile obj-m += mymodule.o mymodule-objs := mymodule.o mymodule_func.o 

thanks

like image 763
Adrien Avatar asked Nov 28 '12 13:11

Adrien


People also ask

What is the name of the kernel module?

In computing, a loadable kernel module (LKM) is an object file that contains code to extend the running kernel, or so-called base kernel, of an operating system. LKMs are typically used to add support for new hardware (as device drivers) and/or filesystems, or for adding system calls.

Which of the following command is used if you have built in modules and want to use this method to install a kernel?

Look at modprobe(8) which is the linux command to install a module into the kernel.

Which command builds the kernel module dependency file?

depmod(Dependency Modules) command is used to generate a list of dependency description of kernel modules and its associated map files. This analyzes the kernel modules in the directory /lib/modules/kernel-release and creates a “Makefile”-like dependency file named modules.


Video Answer


1 Answers

I found a solution, I placed my source file in a sub folder:

Makefile
src/mymodule.c
src/mymodule_func.c

#Makefile obj-m += mymodule.o mymodule-objs := ./src/mymodule.o ./src/mymodule_func.o  all:     make -C $(KERNEL_PATH) M=$(PWD) modules  clean:     make -C $(KERNEL_PATH) M=$(PWD) clean 
like image 114
Adrien Avatar answered Sep 23 '22 00:09

Adrien