@@ -100,6 +100,36 @@ endif
100100
101101export quiet Q KBUILD_VERBOSE
102102
103+ # Call a source code checker (by default, "sparse") as part of the
104+ # C compilation.
105+ #
106+ # Use 'make C=1' to enable checking of only re-compiled files.
107+ # Use 'make C=2' to enable checking of *all* source files, regardless
108+ # of whether they are re-compiled or not.
109+ #
110+ # See the file "Documentation/dev-tools/sparse.rst" for more details,
111+ # including where to get the "sparse" utility.
112+
113+ ifeq ("$(origin C ) ", "command line")
114+ KBUILD_CHECKSRC = $(C )
115+ endif
116+ ifndef KBUILD_CHECKSRC
117+ KBUILD_CHECKSRC = 0
118+ endif
119+
120+ export KBUILD_CHECKSRC
121+
122+ # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
123+ # directory of external module to build. Setting M= takes precedence.
124+ ifeq ("$(origin M ) ", "command line")
125+ KBUILD_EXTMOD := $(M )
126+ endif
127+
128+ $(if $(word 2, $(KBUILD_EXTMOD)), \
129+ $(error building multiple external modules is not supported))
130+
131+ export KBUILD_EXTMOD
132+
103133# Kbuild will save output files in the current working directory.
104134# This does not need to match to the root of the kernel source tree.
105135#
@@ -194,36 +224,6 @@ ifeq ($(need-sub-make),)
194224# so that IDEs/editors are able to understand relative filenames.
195225MAKEFLAGS += --no-print-directory
196226
197- # Call a source code checker (by default, "sparse") as part of the
198- # C compilation.
199- #
200- # Use 'make C=1' to enable checking of only re-compiled files.
201- # Use 'make C=2' to enable checking of *all* source files, regardless
202- # of whether they are re-compiled or not.
203- #
204- # See the file "Documentation/dev-tools/sparse.rst" for more details,
205- # including where to get the "sparse" utility.
206-
207- ifeq ("$(origin C ) ", "command line")
208- KBUILD_CHECKSRC = $(C )
209- endif
210- ifndef KBUILD_CHECKSRC
211- KBUILD_CHECKSRC = 0
212- endif
213-
214- # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
215- # directory of external module to build. Setting M= takes precedence.
216- ifeq ("$(origin M ) ", "command line")
217- KBUILD_EXTMOD := $(M )
218- endif
219-
220- $(if $(word 2, $(KBUILD_EXTMOD)), \
221- $(error building multiple external modules is not supported))
222-
223- export KBUILD_CHECKSRC KBUILD_EXTMOD
224-
225- extmod-prefix = $(if $(KBUILD_EXTMOD ) ,$(KBUILD_EXTMOD ) /)
226-
227227ifeq ($(abs_srctree ) ,$(abs_objtree ) )
228228 # building in the source tree
229229 srctree := .
@@ -1093,6 +1093,7 @@ endif # CONFIG_BPF
10931093
10941094PHONY += prepare0
10951095
1096+ extmod-prefix = $(if $(KBUILD_EXTMOD ) ,$(KBUILD_EXTMOD ) /)
10961097export MODORDER := $(extmod-prefix ) modules.order
10971098export MODULES_NSDEPS := $(extmod-prefix ) modules.nsdeps
10981099
0 commit comments