<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
<div>Hi Alexander,</div>
<div><br /></div>
<div><br /></div>
<div>Looking at that Makefile:</div>
<div><br /></div>
<div>
<div># Use make M=dir to specify directory of external module to build</div>
<div># Old syntax make ... SUBDIRS=$PWD is still supported</div>
<div># Setting the environment variable KBUILD_EXTMOD take precedence</div>
<div>ifdef SUBDIRS</div>
<div>  KBUILD_EXTMOD ?= $(SUBDIRS)</div>
<div>endif</div>
<div><br /></div>
<div>ifeq ("$(origin M)", "command line")</div>
<div>  KBUILD_EXTMOD := $(M)</div>
<div>endif</div>
</div>
<div><br /></div>
<div><br /></div>
<div>So specifying KBUILD_EXTMOD or M is the same thing, which tells KBUILD the directory that the Makefile for the module is in.</div>
<div>And by default, KBUILD will build the module in KBUILD_EXTMOD.</div>
<div><br /></div>
<div>What I want is tell KBUILD to build the modules in a specified directory.</div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div>Regards.</div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
<div><br /></div>
</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;"><br />
On Jan 2, 2017, 20:30 +0800, Alexander Kapshuk <alexander.kapshuk@gmail.com>, wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">On Mon, Jan 2, 2017 at 1:39 PM, Shiyao Ma <i@introo.me> wrote:<br />
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">Hi,<br />
<br />
When building an external module, for example, given this command,<br />
all:<br />
$(MAKE) -C $(KDIR) M=$$PWD<br />
<br />
It will build the ko file in the $PWD.<br />
<br />
How to specify a location for the .ko files?<br />
<br />
<br />
Regards.<br />
<br />
_______________________________________________<br />
Kernelnewbies mailing list<br />
Kernelnewbies@kernelnewbies.org<br />
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies<br />
<br /></blockquote>
<br />
Perhaps KBUILD_EXTMOD is what you're looking for.<br />
<br />
/path/to/kernel/sources/Makefile:183,185<br />
# Use make M=dir to specify directory of external module to build<br />
# Old syntax make ... SUBDIRS=$PWD is still supported<br />
# Setting the environment variable KBUILD_EXTMOD take precedence<br /></blockquote>
</div>
</body>
</html>