Building multiple .ko files from a single module

Kristof Provost kristof at sigsegv.be
Tue Apr 9 09:04:49 EDT 2013


On 2013-04-09 17:03:14 (+0530), Sankar P <sankar.curiosity at gmail.com> wrote:
> I have some source files: a.c b.c c.c etc. Now I need to generate a
> few .ko files such as, 1.ko, 2.ko, 3.ko etc.
> <SNIP>
> For example, consider the following association between source files
> and the .ko files.
> 
> a.c a.h common.c common.h => 1.ko
> b.c b.h common.c common.h => 2.ko
> 

The following (untested!) should do the trick:
obj-$(CONFIG_MYMOD) += mymod_a.o mymod_b.o
mymod_a-objs += a.o common.o
mymod_b-objs += b.o common.o

I'd probably recommend creating three modules though: a, b and common.

Regards,
Kristof




More information about the Kernelnewbies mailing list