I have working kernel module which I install manually with insmod/modprobe command as learnt by reading book. however I was wondering if there is way to do it automatically after compiling - So basically how to automate insmod/modprobe command ?
My modprobe has a dependent file thread_module.o as well
My make file so far
obj-m := wakeup_counter.o
obj-m += thread_module.o
$INSTALL_MOD_PATH = /lib/modules/2.6.32-5-amd64/
all:
make -C /lib/modules/2.6.32-5-amd64/build M=$(PWD) modules
install:
make $(INSTALL_MOD_PATH) =/build modules_install
clean:
make -C /lib/modules/2.6.32-5-amd64/build M=$(PWD) modules
output after running : make install
root@xyz:/home/xyz/Desktop/Drivers/symbols# make install
make -C /lib/modules/2.6.32-5-amd64/build M=/home/xyz/Desktop/Drivers/symbols modules_install
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-5-amd64'
INSTALL /home/xyz/Desktop/Drivers/symbols/thread_module.ko
INSTALL /home/xyz/Desktop/Drivers/symbols/wakeup_counter.ko
DEPMOD 2.6.32-5-amd64
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-5-amd64'
Edit: After going through comments and https://www.kernel.org/doc/Documentation/kbuild/modules.txt I tried to add install command but I dont see any modules in the build path - Also at high level I get what we write in cmd prompt we type in Makefile but if someone can give an example it would help me to understand with nice base case to refer.
make install
command. Just create "install" target in your makefile and place all needed actions in its recipes. - Tsyvarevmake … modules_install
from it. - 0andriy