Skip to content

Commit 9da0763

Browse files
committed
kbuild: Use relative path when building in a subdir of the source tree
When doing make O=<subdir>, use '..' to refer to the source tree. This allows for more readable compiler messages, and, more importantly, it sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter. Acked-by: Sam Ravnborg <[email protected]> Signed-off-by: Michal Marek <[email protected]>
1 parent 890676c commit 9da0763

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
@@ -149,7 +149,17 @@ else
149149
_all: modules
150150
endif
151151

152-
srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),.)
152+
ifeq ($(KBUILD_SRC),)
153+
# building in the source tree
154+
srctree := .
155+
else
156+
ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
157+
# building in a subdirectory of the source tree
158+
srctree := ..
159+
else
160+
srctree := $(KBUILD_SRC)
161+
endif
162+
endif
153163
objtree := .
154164
src := $(srctree)
155165
obj := $(objtree)

0 commit comments

Comments
 (0)