Makefile: Speed up parallel build

Parallel build is extremely slow when using vars (O, I,
PLATFORM_DIR+PLATFORM). And all this is because the variables are
calculated continuously, with the simultaneous invocation of
the $(shell ...). So use "Simply expanded variables" to
calculate value and call $(shell ...) just once.

Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260924060133.294142-1-fido_max@inbox.ru
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Maxim Kochetkov authored and Anup Patel committed 2026-10-27 13:34:29 +05:30
1 parent a0531af7ad
commit 113d719547
1 file changed
+7 -7
+7 -7
View File
@@ -22,18 +22,18 @@ endif
# Find out source, build, and install directories
src_dir=$(CURDIR)
ifdef O
build_dir=$(shell $(READLINK) -f $(O))
build_dir:=$(shell $(READLINK) -f $(O))
else
build_dir=$(CURDIR)/build
build_dir:=$(CURDIR)/build
endif
ifeq ($(build_dir),$(CURDIR))
$(error Build directory is same as source directory.)
endif
install_root_dir_default=$(CURDIR)/install
ifdef I
install_root_dir=$(shell $(READLINK) -f $(I))
install_root_dir:=$(shell $(READLINK) -f $(I))
else
install_root_dir=$(install_root_dir_default)/usr
install_root_dir:=$(install_root_dir_default)/usr
endif
ifeq ($(install_root_dir),$(CURDIR))
$(error Install root directory is same as source directory.)
@@ -42,12 +42,12 @@ ifeq ($(install_root_dir),$(build_dir))
$(error Install root directory is same as build directory.)
endif
ifdef PLATFORM_DIR
platform_dir_path=$(shell $(READLINK) -f $(PLATFORM_DIR))
platform_dir_path:=$(shell $(READLINK) -f $(PLATFORM_DIR))
ifdef PLATFORM
platform_parent_dir=$(platform_dir_path)
else
PLATFORM=$(shell basename $(platform_dir_path))
platform_parent_dir=$(shell realpath ${platform_dir_path}/..)
PLATFORM:=$(shell basename $(platform_dir_path))
platform_parent_dir:=$(shell realpath ${platform_dir_path}/..)
endif
else
platform_parent_dir=$(src_dir)/platform