Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: handle C=... and M=... after entering into build directory

This commit avoids processing C=... and M=... twice
when O=... is also given.

Besides, we can also remove KBUILD_EXTMOD="$(KBUILD_EXTMOD)"
in the sub-make target.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Peter Foley <pefoley2@pefoley.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>

authored by

Masahiro Yamada and committed by
Michal Marek
aa55c8e2 745a2543

+29 -31
+29 -31
Makefile
··· 95 95 96 96 export quiet Q KBUILD_VERBOSE 97 97 98 - # Call a source code checker (by default, "sparse") as part of the 99 - # C compilation. 100 - # 101 - # Use 'make C=1' to enable checking of only re-compiled files. 102 - # Use 'make C=2' to enable checking of *all* source files, regardless 103 - # of whether they are re-compiled or not. 104 - # 105 - # See the file "Documentation/sparse.txt" for more details, including 106 - # where to get the "sparse" utility. 107 - 108 - ifeq ("$(origin C)", "command line") 109 - KBUILD_CHECKSRC = $(C) 110 - endif 111 - ifndef KBUILD_CHECKSRC 112 - KBUILD_CHECKSRC = 0 113 - endif 114 - 115 - # Use make M=dir to specify directory of external module to build 116 - # Old syntax make ... SUBDIRS=$PWD is still supported 117 - # Setting the environment variable KBUILD_EXTMOD take precedence 118 - ifdef SUBDIRS 119 - KBUILD_EXTMOD ?= $(SUBDIRS) 120 - endif 121 - 122 - ifeq ("$(origin M)", "command line") 123 - KBUILD_EXTMOD := $(M) 124 - endif 125 - 126 98 # kbuild supports saving output files in a separate directory. 127 99 # To locate output files in a separate directory two syntaxes are supported. 128 100 # In both cases the working directory must be the root of the kernel src. ··· 109 137 # 110 138 # The O= assignment takes precedence over the KBUILD_OUTPUT environment 111 139 # variable. 112 - 113 140 114 141 # KBUILD_SRC is set on invocation of make in OBJ directory 115 142 # KBUILD_SRC is not intended to be used by the regular user (for now) ··· 143 172 144 173 sub-make: FORCE 145 174 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ 146 - KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ 147 - $(filter-out _all sub-make,$(MAKECMDGOALS)) 175 + -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 148 176 149 177 # Leave processing to above invocation of make 150 178 skip-makefile := 1 ··· 157 187 # but we want to display it when entering to the output directory 158 188 # so that IDEs/editors are able to understand relative filenames. 159 189 MAKEFLAGS += --no-print-directory 190 + 191 + # Call a source code checker (by default, "sparse") as part of the 192 + # C compilation. 193 + # 194 + # Use 'make C=1' to enable checking of only re-compiled files. 195 + # Use 'make C=2' to enable checking of *all* source files, regardless 196 + # of whether they are re-compiled or not. 197 + # 198 + # See the file "Documentation/sparse.txt" for more details, including 199 + # where to get the "sparse" utility. 200 + 201 + ifeq ("$(origin C)", "command line") 202 + KBUILD_CHECKSRC = $(C) 203 + endif 204 + ifndef KBUILD_CHECKSRC 205 + KBUILD_CHECKSRC = 0 206 + endif 207 + 208 + # Use make M=dir to specify directory of external module to build 209 + # Old syntax make ... SUBDIRS=$PWD is still supported 210 + # Setting the environment variable KBUILD_EXTMOD take precedence 211 + ifdef SUBDIRS 212 + KBUILD_EXTMOD ?= $(SUBDIRS) 213 + endif 214 + 215 + ifeq ("$(origin M)", "command line") 216 + KBUILD_EXTMOD := $(M) 217 + endif 160 218 161 219 # If building an external module we do not care about the all: rule 162 220 # but instead _all depend on modules