How to build an external module in a specified directory?

Shiyao Ma i at introo.me
Tue Jan 3 02:32:06 EST 2017


Hi Alexander,


Looking at that Makefile:

# 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
ifdef SUBDIRS
  KBUILD_EXTMOD ?= $(SUBDIRS)
endif

ifeq ("$(origin M)", "command line")
  KBUILD_EXTMOD := $(M)
endif


So specifying KBUILD_EXTMOD or M is the same thing, which tells KBUILD the directory that the Makefile for the module is in.
And by default, KBUILD will build the module in KBUILD_EXTMOD.

What I want is tell KBUILD to build the modules in a specified directory.



Regards.





On Jan 2, 2017, 20:30 +0800, Alexander Kapshuk <alexander.kapshuk at gmail.com>, wrote:
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170103/0f2aedab/attachment.html 


More information about the Kernelnewbies mailing list