Welcome to the Linux Foundation Forum!

What is the difference between compiling at the directory level and compiling a module?

I am currently in Lesson 10: Kernel and Driver Building, Loading and Dependencies and I tried changing the option CONFIG_USB driver as module (the module name is usbcore) and then changing drivers/usb/core/usb.c by adding pr_info(...) in usb_init().

After that, I tried compiling at the directory level with command:

make drivers/usb/core/

and do make modules_install, rmmod usbcore (assumming usbcore already loaded previously), modprobe usbcore, but the message is not in dmesg.

And then, I tried compiling the module with command:

make M=drivers/usb/core

and do make modules_install, rmmod usbcore (assumming usbcore already loaded previously), modprobe usbcore, and the message appear in dmesg.

So I am curious, what is the difference between compiling at the directory level and compiling a module, even though we use the same path?

Another information is that I am using virtual machine to try things out, in case there's some difference whether using virtual machine or actual machine.

Thank you.

Categories

Upcoming Training