Skip to content

Commit

Permalink
kbuild: unexport abs_srctree and abs_objtree
Browse files Browse the repository at this point in the history
Commit 25b146c ("kbuild: allow Kbuild to start from any directory")
exported abs_srctree and abs_objtree to avoid recomputation after the
sub-make. However, this approach turned out to be fragile.

Commit 5fa94ce ("kbuild: set correct abs_srctree and abs_objtree
for package builds") moved them above "ifneq ($(sub_make_done),1)",
eliminating the need for exporting them.

These are only needed in the top Makefile. If an absolute path is
required in sub-directories, you can use $(abspath ) or $(realpath )
as needed.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
  • Loading branch information
masahir0y committed Mar 10, 2024
1 parent 75b5ab1 commit e2bad14
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ __all:
# prepare rule.

this-makefile := $(lastword $(MAKEFILE_LIST))
export abs_srctree := $(realpath $(dir $(this-makefile)))
export abs_objtree := $(CURDIR)
abs_srctree := $(realpath $(dir $(this-makefile)))
abs_objtree := $(CURDIR)

ifneq ($(sub_make_done),1)

Expand Down
4 changes: 2 additions & 2 deletions rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ rustdoc: rustdoc-core rustdoc-macros rustdoc-compiler_builtins \
-e 's:rust-logo-[0-9a-f]+\.svg:logo.svg:g' \
-e 's:favicon-[0-9a-f]+\.svg:logo.svg:g' \
-e 's:<link rel="alternate icon" type="image/png" href="[/.]+/static\.files/favicon-(16x16|32x32)-[0-9a-f]+\.png">::g' \
-e 's:<a href="srctree/([^"]+)">:<a href="$(abs_srctree)/\1">:g'
-e 's:<a href="srctree/([^"]+)">:<a href="$(realpath $(srctree))/\1">:g'
$(Q)for f in $(rustdoc_output)/static.files/rustdoc-*.css; do \
echo ".logo-container > img { object-fit: contain; }" >> $$f; done

Expand Down Expand Up @@ -413,7 +413,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
rust-analyzer:
$(Q)$(srctree)/scripts/generate_rust_analyzer.py \
--cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
$(abs_srctree) $(abs_objtree) \
$(realpath $(srctree)) $(realpath $(objtree)) \
$(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json

Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile.package
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ snap-pkg:
mkdir $(objtree)/snap
$(MAKE) clean
sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
s@SRCTREE@$(abs_srctree)@" \
s@SRCTREE@$(realpath $(srctree))@" \
$(srctree)/scripts/package/snapcraft.template > \
$(objtree)/snap/snapcraft.yaml
cd $(objtree)/snap && \
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Most of this file is copied from tools/lib/traceevent/Makefile

RM ?= rm
srctree = $(abs_srctree)
srctree := $(realpath $(srctree))

VERSION_SCRIPT := libbpf.map
LIBBPF_VERSION := $(shell \
Expand Down

0 comments on commit e2bad14

Please sign in to comment.