How to build an external module in a specified directory?

Alexander Kapshuk alexander.kapshuk at gmail.com
Mon Jan 2 07:29:50 EST 2017


On Mon, Jan 2, 2017 at 1:39 PM, Shiyao Ma <i at introo.me> wrote:
> Hi,
>
> When building an external module, for example, given this command,
> all:
>     $(MAKE) -C $(KDIR) M=$$PWD
>
> It will build the ko file in the $PWD.
>
> How to specify a location for the .ko files?
>
>
> Regards.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

Perhaps KBUILD_EXTMOD is what you're looking for.

/path/to/kernel/sources/Makefile:183,185
# Use make M=dir to specify directory of external module to build
# Old syntax make ... SUBDIRS=$PWD is still supported
# Setting the environment variable KBUILD_EXTMOD take precedence



More information about the Kernelnewbies mailing list