Skip to content

Commit 5fa94ce

Browse files
committed
kbuild: set correct abs_srctree and abs_objtree for package builds
When you run 'make rpm-pkg', the rpmbuild tool builds the kernel in rpmbuild/BUILD, but $(abs_srctree) and $(abs_objtree) point to the directory path where make was started, not the kernel is actually being built. The same applies to 'make snap-pkg'. Fix it. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 71025b8 commit 5fa94ce

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ __all:
3838
# descending is started. They are now explicitly listed as the
3939
# prepare rule.
4040

41+
this-makefile := $(lastword $(MAKEFILE_LIST))
42+
export abs_srctree := $(realpath $(dir $(this-makefile)))
43+
export abs_objtree := $(CURDIR)
44+
4145
ifneq ($(sub_make_done),1)
4246

4347
# Do not use make's built-in rules and variables
@@ -185,8 +189,6 @@ $(if $(abs_objtree),, \
185189

186190
# $(realpath ...) resolves symlinks
187191
abs_objtree := $(realpath $(abs_objtree))
188-
else
189-
abs_objtree := $(CURDIR)
190192
endif # ifneq ($(KBUILD_OUTPUT),)
191193

192194
ifeq ($(abs_objtree),$(CURDIR))
@@ -196,9 +198,6 @@ else
196198
need-sub-make := 1
197199
endif
198200

199-
this-makefile := $(lastword $(MAKEFILE_LIST))
200-
abs_srctree := $(realpath $(dir $(this-makefile)))
201-
202201
ifneq ($(words $(subst :, ,$(abs_srctree))), 1)
203202
$(error source directory cannot contain spaces or colons)
204203
endif
@@ -211,7 +210,6 @@ need-sub-make := 1
211210
$(this-makefile): ;
212211
endif
213212

214-
export abs_srctree abs_objtree
215213
export sub_make_done := 1
216214

217215
ifeq ($(need-sub-make),1)

0 commit comments

Comments
 (0)