diff options
author | Masahiro Yamada <yamada.m@jp.panasonic.com> | 2014-09-09 07:02:24 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2014-10-01 16:44:21 -0400 |
commit | aa55c8e2f7a395dfc9e67fc6637321e19ce9bfe1 (patch) | |
tree | 23fc4ca0d100904325701042b95ec406802e7daa /Makefile | |
parent | 745a254322c898dadf019342cd7140f7867d2d0f (diff) |
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>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 60 |
1 files changed, 29 insertions, 31 deletions
@@ -95,34 +95,6 @@ endif | |||
95 | 95 | ||
96 | export quiet Q KBUILD_VERBOSE | 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 | # kbuild supports saving output files in a separate directory. | 98 | # kbuild supports saving output files in a separate directory. |
127 | # To locate output files in a separate directory two syntaxes are supported. | 99 | # To locate output files in a separate directory two syntaxes are supported. |
128 | # In both cases the working directory must be the root of the kernel src. | 100 | # In both cases the working directory must be the root of the kernel src. |
@@ -138,7 +110,6 @@ endif | |||
138 | # The O= assignment takes precedence over the KBUILD_OUTPUT environment | 110 | # The O= assignment takes precedence over the KBUILD_OUTPUT environment |
139 | # variable. | 111 | # variable. |
140 | 112 | ||
141 | |||
142 | # KBUILD_SRC is set on invocation of make in OBJ directory | 113 | # KBUILD_SRC is set on invocation of make in OBJ directory |
143 | # KBUILD_SRC is not intended to be used by the regular user (for now) | 114 | # KBUILD_SRC is not intended to be used by the regular user (for now) |
144 | ifeq ($(KBUILD_SRC),) | 115 | ifeq ($(KBUILD_SRC),) |
@@ -172,8 +143,7 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make | |||
172 | 143 | ||
173 | sub-make: FORCE | 144 | sub-make: FORCE |
174 | $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ | 145 | $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ |
175 | KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ | 146 | -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) |
176 | $(filter-out _all sub-make,$(MAKECMDGOALS)) | ||
177 | 147 | ||
178 | # Leave processing to above invocation of make | 148 | # Leave processing to above invocation of make |
179 | skip-makefile := 1 | 149 | skip-makefile := 1 |
@@ -188,6 +158,34 @@ ifeq ($(skip-makefile),) | |||
188 | # so that IDEs/editors are able to understand relative filenames. | 158 | # so that IDEs/editors are able to understand relative filenames. |
189 | MAKEFLAGS += --no-print-directory | 159 | MAKEFLAGS += --no-print-directory |
190 | 160 | ||
161 | # Call a source code checker (by default, "sparse") as part of the | ||
162 | # C compilation. | ||
163 | # | ||
164 | # Use 'make C=1' to enable checking of only re-compiled files. | ||
165 | # Use 'make C=2' to enable checking of *all* source files, regardless | ||
166 | # of whether they are re-compiled or not. | ||
167 | # | ||
168 | # See the file "Documentation/sparse.txt" for more details, including | ||
169 | # where to get the "sparse" utility. | ||
170 | |||
171 | ifeq ("$(origin C)", "command line") | ||
172 | KBUILD_CHECKSRC = $(C) | ||
173 | endif | ||
174 | ifndef KBUILD_CHECKSRC | ||
175 | KBUILD_CHECKSRC = 0 | ||
176 | endif | ||
177 | |||
178 | # Use make M=dir to specify directory of external module to build | ||
179 | # Old syntax make ... SUBDIRS=$PWD is still supported | ||
180 | # Setting the environment variable KBUILD_EXTMOD take precedence | ||
181 | ifdef SUBDIRS | ||
182 | KBUILD_EXTMOD ?= $(SUBDIRS) | ||
183 | endif | ||
184 | |||
185 | ifeq ("$(origin M)", "command line") | ||
186 | KBUILD_EXTMOD := $(M) | ||
187 | endif | ||
188 | |||
191 | # If building an external module we do not care about the all: rule | 189 | # If building an external module we do not care about the all: rule |
192 | # but instead _all depend on modules | 190 | # but instead _all depend on modules |
193 | PHONY += all | 191 | PHONY += all |