17

I am very new to Linux device drivers.

In Makefile what is obj-m?

What is the difference between obj-m and obj-m+?

jww
  • 97,681
  • 90
  • 411
  • 885
Prashanth
  • 301
  • 1
  • 2
  • 5
  • 3
    The target is called `obj-m`, the way to assign something to it may be `=`, `+=`, `:=`. This is syntax of `make` language. So, I recommend to read documentation about `make` first. https://www.gnu.org/software/make/manual/make.html#Setting – 0andriy Sep 08 '19 at 09:08
  • 1
    From the Linux kernel documentation for [obj-m](https://www.kernel.org/doc/html/latest/kbuild/makefiles.html#loadable-module-goals-obj-m): "$(obj-m) specifies object files that are built as kernel modules.". There isn't an `obj-m+`. The `+` is part of the `+=` operator to append to a variable. It can also be used to append subdirectories which will be entered recursively. – Ian Abbott Sep 09 '19 at 14:53

1 Answers1

15

"obj-m := .o"

The kbuild system in kernel will build mod_name.o from mod_name.c After linking these files will get kernel module mod_name.ko.

The above line can be put in either a "Kbuild" file or a "Makefile."

When the module is built from multiple sources, an additional line is needed listing the files:

<module_name>-y := <src1>.o <src2>.o ...

For detailed info about this you can refer here

user12045319
  • 166
  • 1
  • 2