Skip to content

Commit 5f56cb0

Browse files
committed
kbuild: support 'userldlibs' syntax
This syntax is useful to specify libraries linked to all userspace programs in the Makefile. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 1bfaa37 commit 5f56cb0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Documentation/kbuild/makefiles.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,10 @@ Example::
937937
# net/bpfilter/Makefile
938938
bpfilter_umh-userldflags += -static
939939

940+
To specify libraries linked to a userspace program, you can use
941+
``<executable>-userldlibs``. The ``userldlibs`` syntax specifies libraries
942+
linked to all userspace programs created in the current Makefile.
943+
940944
When linking bpfilter_umh, it will be passed the extra option -static.
941945

942946
From command line, :ref:`USERCFLAGS and USERLDFLAGS <userkbuildflags>` will also be used.

scripts/Makefile.userprogs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ user-cobjs := $(addprefix $(obj)/, $(user-cobjs))
1919
user_ccflags = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \
2020
$($(target-stem)-userccflags)
2121
user_ldflags = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags)
22+
user_ldlibs = $(userldlibs) $($(target-stem)-userldlibs)
2223

2324
# Create an executable from a single .c file
2425
quiet_cmd_user_cc_c = CC [U] $@
2526
cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \
26-
$($(target-stem)-userldlibs)
27+
$(user_ldlibs)
2728
$(user-csingle): $(obj)/%: $(src)/%.c FORCE
2829
$(call if_changed_dep,user_cc_c)
2930

3031
# Link an executable based on list of .o files
3132
quiet_cmd_user_ld = LD [U] $@
3233
cmd_user_ld = $(CC) $(user_ldflags) -o $@ \
33-
$(addprefix $(obj)/, $($(target-stem)-objs)) \
34-
$($(target-stem)-userldlibs)
34+
$(addprefix $(obj)/, $($(target-stem)-objs)) $(user_ldlibs)
3535
$(user-cmulti): FORCE
3636
$(call if_changed,user_ld)
3737
$(call multi_depend, $(user-cmulti), , -objs)

0 commit comments

Comments
 (0)