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