Skip to content

Commit a2a45eb

Browse files
committed
kbuild: make wrapper Makefile more convenient for external modules
When Kbuild starts building in a separate output directory, it generates a wrapper Makefile, allowing you to invoke 'make' from the output directory. This commit makes it more convenient, so you can invoke 'make' without M= or MO=. First, you need to build external modules in a separate directory: $ make M=/path/to/module/source/dir MO=/path/to/module/build/dir Once the wrapper Makefile is generated in /path/to/module/build/dir, you can proceed as follows: $ cd /path/to/module/build/dir $ make Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nicolas Schier <[email protected]>
1 parent 822b11a commit a2a45eb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,20 @@ ifdef building_out_of_srctree
642642
# At the same time when output Makefile generated, generate .gitignore to
643643
# ignore whole output directory
644644

645+
ifdef KBUILD_EXTMOD
646+
print_env_for_makefile = \
647+
echo "export KBUILD_OUTPUT = $(objtree)"; \
648+
echo "export KBUILD_EXTMOD = $(realpath $(srcroot))" ; \
649+
echo "export KBUILD_EXTMOD_OUTPUT = $(CURDIR)"
650+
else
651+
print_env_for_makefile = \
652+
echo "export KBUILD_OUTPUT = $(CURDIR)"
653+
endif
654+
645655
quiet_cmd_makefile = GEN Makefile
646656
cmd_makefile = { \
647657
echo "\# Automatically generated by $(abs_srctree)/Makefile: don't edit"; \
648-
echo "export KBUILD_OUTPUT = $(CURDIR)"; \
658+
$(print_env_for_makefile); \
649659
echo "include $(abs_srctree)/Makefile"; \
650660
} > Makefile
651661

0 commit comments

Comments
 (0)