Commit 85569d19 authored by Masahiro Yamada's avatar Masahiro Yamada

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: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 42640b13
...@@ -45,12 +45,15 @@ include $(kbuild-file) ...@@ -45,12 +45,15 @@ include $(kbuild-file)
include scripts/Makefile.lib include scripts/Makefile.lib
# Do not include hostprogs rules unless needed # Do not include hostprogs rules unless needed.
# $(sort ...) is used here to remove duplicated words and excessive spaces.
hostprogs := $(sort $(hostprogs))
ifneq ($(hostprogs),) ifneq ($(hostprogs),)
include scripts/Makefile.host include scripts/Makefile.host
endif endif
# Do not include userprogs rules unless needed. # Do not include userprogs rules unless needed.
# $(sort ...) is used here to remove duplicated words and excessive spaces.
userprogs := $(sort $(userprogs)) userprogs := $(sort $(userprogs))
ifneq ($(userprogs),) ifneq ($(userprogs),)
include scripts/Makefile.userprogs include scripts/Makefile.userprogs
......
...@@ -38,24 +38,22 @@ $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE ...@@ -38,24 +38,22 @@ $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
# Will compile qconf as a C++ program, and menu as a C program. # Will compile qconf as a C++ program, and menu as a C program.
# They are linked as C++ code to the executable qconf # They are linked as C++ code to the executable qconf
__hostprogs := $(sort $(hostprogs))
# C code # C code
# Executables compiled from a single .c file # Executables compiled from a single .c file
host-csingle := $(foreach m,$(__hostprogs), \ host-csingle := $(foreach m,$(hostprogs), \
$(if $($(m)-objs)$($(m)-cxxobjs),,$(m))) $(if $($(m)-objs)$($(m)-cxxobjs),,$(m)))
# C executables linked based on several .o files # C executables linked based on several .o files
host-cmulti := $(foreach m,$(__hostprogs),\ host-cmulti := $(foreach m,$(hostprogs),\
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
# Object (.o) files compiled from .c files # Object (.o) files compiled from .c files
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) host-cobjs := $(sort $(foreach m,$(hostprogs),$($(m)-objs)))
# C++ code # C++ code
# C++ executables compiled from at least one .cc file # C++ executables compiled from at least one .cc file
# and zero or more .c files # and zero or more .c files
host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) host-cxxmulti := $(foreach m,$(hostprogs),$(if $($(m)-cxxobjs),$(m)))
# C++ Object (.o) files compiled from .cc files # C++ Object (.o) files compiled from .cc files
host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment