Driver porting: compiling external modules
Posted Apr 13, 2007 22:04 UTC (Fri) by ffo
Parent article: Driver porting: compiling external modules
The information is misleading as far as I can judge by the number of posts. Here is my contribution.
If your module is made of f1.c f2.c and f3.c then your Makefile should look like:
module-objs := f1.o f2.o f3.o
you will be able to load your module by insmod ./module.ko.
Note that module.o is NOT associated to any .c, it is just the product name of the compilation.
Now to take other names, misleading ones...
If your module is made of interceptor.c frame.c and packet.c then your Makefile should look like:
module-objs := interceptor.o frame.o packet.o
interceptor_module-objs := interceptor.o frame.o packet.o
if your Makefile is
interceptpr-objs := interceptor.o frame.o packet.o
it will report a circular depdendency and not compile interceptor.c
interceptor-objs := frame.o packet.o
it will NOT compile interceptor.c, produce an interceptor.ko (bad), emit some warnings about undefined references. Trying to load it by insmod will produce errors about unresolved stuff.
Again, the name after obj-m does NOT correspond to any .c but to the name of the .ko you want to obtain from make. The fact that it is named with a .o extension is very misleading... it should have been .ko IHMO.
This may sound obvious for the kernel development community, but for newbies like me, this is way different!
to post comments)