History

kbuild: support 'userldlibs' syntax

This syntax is useful to specify libraries linked to all userspace programs in the Makefile.

Masahiro Yamada committed 3 years ago

Commit 5f56cb01 parent 1bfaa372 files · +7 −3Browse files

Unified · Split

2 files
  1. Documentation/kbuild/makefiles.rst +4 −0
  2. scripts/Makefile.userprogs +3 −3
Documentation/kbuild/makefiles.rst+4−0
@@ -937,6 +937,10 @@ Example:: · 936 unmodified lines
937 # net/bpfilter/Makefile937 # net/bpfilter/Makefile
938 bpfilter_umh-userldflags += -static938 bpfilter_umh-userldflags += -static
939 939
940To specify libraries linked to a userspace program, you can use
941``<executable>-userldlibs``. The ``userldlibs`` syntax specifies libraries
942linked to all userspace programs created in the current Makefile.
943
940When linking bpfilter_umh, it will be passed the extra option -static.944When linking bpfilter_umh, it will be passed the extra option -static.
941 945
942From command line, :ref:`USERCFLAGS and USERLDFLAGS <userkbuildflags>` will also be used.946From command line, :ref:`USERCFLAGS and USERLDFLAGS <userkbuildflags>` will also be used.
scripts/Makefile.userprogs+3−3
@@ -19,19 +19,19 @@ user-cobjs := $(addprefix $(obj)/, $(user-cobjs)) · 18 unmodified lines
19user_ccflags = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \19user_ccflags = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \
20 $($(target-stem)-userccflags)20 $($(target-stem)-userccflags)
21user_ldflags = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags)21user_ldflags = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags)
22user_ldlibs = $(userldlibs) $($(target-stem)-userldlibs)
22 23
23# Create an executable from a single .c file24# Create an executable from a single .c file
24quiet_cmd_user_cc_c = CC [U] $@25quiet_cmd_user_cc_c = CC [U] $@
25 cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \26 cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \
26 $($(target-stem)-userldlibs)27 $(user_ldlibs)
27$(user-csingle): $(obj)/%: $(src)/%.c FORCE28$(user-csingle): $(obj)/%: $(src)/%.c FORCE
28 $(call if_changed_dep,user_cc_c)29 $(call if_changed_dep,user_cc_c)
29 30
30# Link an executable based on list of .o files31# Link an executable based on list of .o files
31quiet_cmd_user_ld = LD [U] $@32quiet_cmd_user_ld = LD [U] $@
32 cmd_user_ld = $(CC) $(user_ldflags) -o $@ \33 cmd_user_ld = $(CC) $(user_ldflags) -o $@ \
33 $(addprefix $(obj)/, $($(target-stem)-objs)) \34 $(addprefix $(obj)/, $($(target-stem)-objs)) $(user_ldlibs)
34 $($(target-stem)-userldlibs)
35$(user-cmulti): FORCE35$(user-cmulti): FORCE
36 $(call if_changed,user_ld)36 $(call if_changed,user_ld)
37$(call multi_depend, $(user-cmulti), , -objs)37$(call multi_depend, $(user-cmulti), , -objs)