Simple Linux device driver program
turn on
#include<linux/module.h>
#include<linux/init.h>
int my_init(void){
printk("<1> Angus : Module Insertion is successful!");
return 0;
}
void my_cleanup(void){
printk("<1> Angus : Module unloading successful!");
}
module_init(my_init);
module_cleanup(my_cleanup);
Makefile:
obj-m:=simple.o
aoll:
make -C /usr/src/linux-headers-3.2.0-25-generic-pae/ M=$(PWD) modules
clean:
make -C /usr/src/linux-headers-3.2.0-25-generic-pae/ M=$(PWD) clean
make -C => will be changed to a directory before making make, In this path / usr / src / linux-headers-3.2.0-25-generic-pae / I have a Makefile, why is M = $ (PWD) required? what does he do where can i check $ pwd? The Makefile inside / usr / src / linux-headers-3.2.0-25-generic-pae / has an all target: modules and target modules and has a clean target. What is obj-m?
. 24 " Linux", 3- ( http://oreilly.com/openbook/linuxdrive3/book/index.html).
-C . Makefile . M = , Makefile , ($PWD) - , ).
obj-m - , , (. https://www.kernel.org/doc/Documentation/kbuild/makefiles.txt).
why is the M=$(PWD) needed ?
M= option causes that makefile to move back into your module source
directory before trying to build the modules target. This goal, in turn, refers to the list of modules found in the obj-m variable.
What is obj-m ?
The above description states that one module must be built from the file of the hello.o object. The resulting module is called hello.ko after it was created from the object file.