Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0-only
0002 #
0003 # Build userspace programs for the target system
0004 #
0005 
0006 # Executables compiled from a single .c file
0007 user-csingle    := $(foreach m, $(userprogs), $(if $($(m)-objs),,$(m)))
0008 
0009 # Executables linked based on several .o files
0010 user-cmulti     := $(foreach m, $(userprogs), $(if $($(m)-objs),$(m)))
0011 
0012 # Objects compiled from .c files
0013 user-cobjs      := $(sort $(foreach m, $(userprogs), $($(m)-objs)))
0014 
0015 user-csingle    := $(addprefix $(obj)/, $(user-csingle))
0016 user-cmulti     := $(addprefix $(obj)/, $(user-cmulti))
0017 user-cobjs      := $(addprefix $(obj)/, $(user-cobjs))
0018 
0019 user_ccflags    = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \
0020                         $($(target-stem)-userccflags)
0021 user_ldflags    = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags)
0022 
0023 # Create an executable from a single .c file
0024 quiet_cmd_user_cc_c = CC [U]  $@
0025       cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \
0026                       $($(target-stem)-userldlibs)
0027 $(user-csingle): $(obj)/%: $(src)/%.c FORCE
0028         $(call if_changed_dep,user_cc_c)
0029 
0030 # Link an executable based on list of .o files
0031 quiet_cmd_user_ld = LD [U]  $@
0032       cmd_user_ld = $(CC) $(user_ldflags) -o $@ \
0033                     $(addprefix $(obj)/, $($(target-stem)-objs)) \
0034                     $($(target-stem)-userldlibs)
0035 $(user-cmulti): FORCE
0036         $(call if_changed,user_ld)
0037 $(call multi_depend, $(user-cmulti), , -objs)
0038 
0039 # Create .o file from a .c file
0040 quiet_cmd_user_cc_o_c = CC [U]  $@
0041       cmd_user_cc_o_c = $(CC) $(user_ccflags) -c -o $@ $<
0042 $(user-cobjs): $(obj)/%.o: $(src)/%.c FORCE
0043         $(call if_changed_dep,user_cc_o_c)
0044 
0045 targets += $(user-csingle) $(user-cmulti) $(user-cobjs)