Skip to content

Commit 85569d1

Browse files
committed
kbuild: sort hostprogs before passing it to ifneq
The conditional: ifneq ($(hostprogs),) ... is evaluated to true if $(hostprogs) does not contain any word but whitespace characters. ifneq ($(strip $(hostprogs)),) ... is a safe way to avoid interpreting whitespace as a non-empty value, but I'd rather want to use the side-effect of $(sort ...) to do the equivalent. $(sort ...) is used in scripts/Makefile.host in order to drop duplication in $(hostprogs). It is also useful to strip excessive spaces. Move $(sort ...) before evaluating the ifneq. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 42640b1 commit 85569d1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

scripts/Makefile.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ include $(kbuild-file)
4545

4646
include scripts/Makefile.lib
4747

48-
# Do not include hostprogs rules unless needed
48+
# Do not include hostprogs rules unless needed.
49+
# $(sort ...) is used here to remove duplicated words and excessive spaces.
50+
hostprogs := $(sort $(hostprogs))
4951
ifneq ($(hostprogs),)
5052
include scripts/Makefile.host
5153
endif
5254

5355
# Do not include userprogs rules unless needed.
56+
# $(sort ...) is used here to remove duplicated words and excessive spaces.
5457
userprogs := $(sort $(userprogs))
5558
ifneq ($(userprogs),)
5659
include scripts/Makefile.userprogs

scripts/Makefile.host

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,22 @@ $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
3838
# Will compile qconf as a C++ program, and menu as a C program.
3939
# They are linked as C++ code to the executable qconf
4040

41-
__hostprogs := $(sort $(hostprogs))
42-
4341
# C code
4442
# Executables compiled from a single .c file
45-
host-csingle := $(foreach m,$(__hostprogs), \
43+
host-csingle := $(foreach m,$(hostprogs), \
4644
$(if $($(m)-objs)$($(m)-cxxobjs),,$(m)))
4745

4846
# C executables linked based on several .o files
49-
host-cmulti := $(foreach m,$(__hostprogs),\
47+
host-cmulti := $(foreach m,$(hostprogs),\
5048
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
5149

5250
# Object (.o) files compiled from .c files
53-
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
51+
host-cobjs := $(sort $(foreach m,$(hostprogs),$($(m)-objs)))
5452

5553
# C++ code
5654
# C++ executables compiled from at least one .cc file
5755
# and zero or more .c files
58-
host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m)))
56+
host-cxxmulti := $(foreach m,$(hostprogs),$(if $($(m)-cxxobjs),$(m)))
5957

6058
# C++ Object (.o) files compiled from .cc files
6159
host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))

0 commit comments

Comments
 (0)