I have a Makefile that compiles two Linux kernel modules (mod1.c
and mod2.c
).
obj-m = mod1.o mod2.o
KDIR=/lib/modules/$(shell uname -r)/build/
PWD=$(shell pwd)
# build the modules
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
#cleanup
clean:
rm -rf *.ko *.o *.mod* .*.cmd modules.order Module.symvers .tmp_versions
This works fine to build both kernel modules when I run make
, but I would like to be able to specify which module to build. For example, make mod1
to compile mod1.c
and make mod2
to compile mod2.c
.
The thing that I am unsure of is how to handle obj-m
. Otherwise, specifying which program to compile is well described online.