18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci# 38c2ecf20Sopenharmony_ci# Build userspace programs for the target system 48c2ecf20Sopenharmony_ci# 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci# Executables compiled from a single .c file 78c2ecf20Sopenharmony_ciuser-csingle := $(foreach m, $(userprogs), $(if $($(m)-objs),,$(m))) 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci# Executables linked based on several .o files 108c2ecf20Sopenharmony_ciuser-cmulti := $(foreach m, $(userprogs), $(if $($(m)-objs),$(m))) 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci# Objects compiled from .c files 138c2ecf20Sopenharmony_ciuser-cobjs := $(sort $(foreach m, $(userprogs), $($(m)-objs))) 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciuser-csingle := $(addprefix $(obj)/, $(user-csingle)) 168c2ecf20Sopenharmony_ciuser-cmulti := $(addprefix $(obj)/, $(user-cmulti)) 178c2ecf20Sopenharmony_ciuser-cobjs := $(addprefix $(obj)/, $(user-cobjs)) 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ciuser_ccflags = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \ 208c2ecf20Sopenharmony_ci $($(target-stem)-userccflags) 218c2ecf20Sopenharmony_ciuser_ldflags = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags) 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci# Create an executable from a single .c file 248c2ecf20Sopenharmony_ciquiet_cmd_user_cc_c = CC [U] $@ 258c2ecf20Sopenharmony_ci cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \ 268c2ecf20Sopenharmony_ci $($(target-stem)-userldlibs) 278c2ecf20Sopenharmony_ci$(user-csingle): $(obj)/%: $(src)/%.c FORCE 288c2ecf20Sopenharmony_ci $(call if_changed_dep,user_cc_c) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci# Link an executable based on list of .o files 318c2ecf20Sopenharmony_ciquiet_cmd_user_ld = LD [U] $@ 328c2ecf20Sopenharmony_ci cmd_user_ld = $(CC) $(user_ldflags) -o $@ \ 338c2ecf20Sopenharmony_ci $(addprefix $(obj)/, $($(target-stem)-objs)) \ 348c2ecf20Sopenharmony_ci $($(target-stem)-userldlibs) 358c2ecf20Sopenharmony_ci$(user-cmulti): FORCE 368c2ecf20Sopenharmony_ci $(call if_changed,user_ld) 378c2ecf20Sopenharmony_ci$(call multi_depend, $(user-cmulti), , -objs) 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci# Create .o file from a .c file 408c2ecf20Sopenharmony_ciquiet_cmd_user_cc_o_c = CC [U] $@ 418c2ecf20Sopenharmony_ci cmd_user_cc_o_c = $(CC) $(user_ccflags) -c -o $@ $< 428c2ecf20Sopenharmony_ci$(user-cobjs): $(obj)/%.o: $(src)/%.c FORCE 438c2ecf20Sopenharmony_ci $(call if_changed_dep,user_cc_o_c) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_citargets += $(user-csingle) $(user-cmulti) $(user-cobjs) 46