Compile multiple modules with a single makefile

Henrique Rodrigues henriquesilvar at gmail.com
Fri Apr 26 14:11:09 EDT 2013


Hi all,

I have the one .c source file that I want to create multiple kernel modules
out of it by setting macros using the makefile.

The idea is that if -DMODULE1 is set, I'll build module1.ko and if
-DMODULE2 is set, I'll build module 2.

Does anyone know how to do this? I created the following makefile:

...
module1: override obj-m := module1.o
module1: EXTRA_CFLAGS += -DMODULE1

module1:
$(MAKE) -C $(KDIR) M=$(PWD) modules

module2: override obj-m := module2.o
module2: EXTRA_CFLAGS += -DMODULE2

module2:
$(MAKE) -C $(KDIR) M=$(PWD) modules
...

But it isn't working as I expected. Anyone with kernel build system
experience knows the answer for that?

Thanks,
-- 
Henrique Rodrigues
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130426/f6a84f26/attachment.html 


More information about the Kernelnewbies mailing list