Skip to content
Advertisement

How do I specify which of two kernel modules to compile with a Makefile?

I have a Makefile that compiles two Linux kernel modules (mod1.c and mod2.c).

JavaScript

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.

Advertisement

Answer

The kernel uses variables to set kernel modules on/off:

JavaScript

You can use this as make T1=m or make test2.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement