Skip to content

Commit 95fd3f8

Browse files
committed
kbuild: add a flag to force absolute path for srctree
In old days, Kbuild always used an absolute path for $(srctree). Since commit 890676c ("kbuild: Use relative path when building in the source tree"), $(srctree) is '.' when O= was not passed from the command line. Yet, using absolute paths is useful in some cases even without O=, for instance, to create a cscope file with absolute path tags. 'O=.' was known to work as a workaround to force Kbuild to use absolute paths even when you are building in the source tree. Since commit 25b146c ("kbuild: allow Kbuild to start from any directory"), Kbuild is too clever to be tricked. Even if you pass 'O=.' Kbuild notices you are building in the source tree, then use '.' for $(srctree). So, 'make O=. cscope' is no help to create absolute path tags. We cannot force one or the other according to commit e93bc1a ("Revert "kbuild: specify absolute paths for cscope""). Both of relative path and absolute path have pros and cons. This commit adds a new flag KBUILD_ABS_SRCTREE to allow users to choose the absolute path for $(srctree). 'make KBUILD_ABS_SRCTREE=1 cscope' will work as a replacement of 'make O=. cscope'. Reported-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 051f278 commit 95fd3f8

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎Documentation/kbuild/kbuild.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ The output directory is often set using "O=..." on the commandline.
183183

184184
The value can be overridden in which case the default value is ignored.
185185

186+
KBUILD_ABS_SRCTREE
187+
--------------------------------------------------
188+
Kbuild uses a relative path to point to the tree when possible. For instance,
189+
when building in the source tree, the source tree path is '.'
190+
191+
Setting this flag requests Kbuild to use absolute path to the source tree.
192+
There are some useful cases to do so, like when generating tag files with
193+
absolute path entries etc.
194+
186195
KBUILD_SIGN_PIN
187196
--------------------------------------------------
188197
This variable allows a passphrase or PIN to be passed to the sign-file

‎Makefile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ else
244244
building_out_of_srctree := 1
245245
endif
246246

247+
ifneq ($(KBUILD_ABS_SRCTREE),)
248+
srctree := $(abs_srctree)
249+
endif
250+
247251
objtree := .
248252
VPATH := $(srctree)
249253

‎scripts/tags.sh‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ ignore="$(echo "$RCS_FIND_IGNORE" | sed 's|\\||g' )"
1717
# tags and cscope files should also ignore MODVERSION *.mod.c files
1818
ignore="$ignore ( -name *.mod.c ) -prune -o"
1919

20-
# Do not use full path if we do not use O=.. builds
21-
# Use make O=. {tags|cscope}
20+
# Use make KBUILD_ABS_SRCTREE=1 {tags|cscope}
2221
# to force full paths for a non-O= build
2322
if [ "${srctree}" = "." -o -z "${srctree}" ]; then
2423
tree=

0 commit comments

Comments
 (0)