]> git.itanic.dy.fi Git - linux-stable/commitdiff
kbuild: support 'userldlibs' syntax
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 31 Oct 2023 18:11:57 +0000 (03:11 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 1 Nov 2023 14:26:01 +0000 (23:26 +0900)
This syntax is useful to specify libraries linked to all userspace
programs in the Makefile.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Documentation/kbuild/makefiles.rst
scripts/Makefile.userprogs

index d88d4f0f4f8951473ce08456545e56e272e4c17f..e9299971220a0cb54611984387c26b4e94b6cac4 100644 (file)
@@ -937,6 +937,10 @@ Example::
   # net/bpfilter/Makefile
   bpfilter_umh-userldflags += -static
 
+To specify libraries linked to a userspace program, you can use
+``<executable>-userldlibs``. The ``userldlibs`` syntax specifies libraries
+linked to all userspace programs created in the current Makefile.
+
 When linking bpfilter_umh, it will be passed the extra option -static.
 
 From command line, :ref:`USERCFLAGS and USERLDFLAGS <userkbuildflags>` will also be used.
index fb415297337ab9be7fbea6861ead52e96ff4ba66..f3a7e1ef3753b54303718fae97f4b3c9d4eac07c 100644 (file)
@@ -19,19 +19,19 @@ user-cobjs  := $(addprefix $(obj)/, $(user-cobjs))
 user_ccflags   = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \
                        $($(target-stem)-userccflags)
 user_ldflags   = $(KBUILD_USERLDFLAGS) $(userldflags) $($(target-stem)-userldflags)
+user_ldlibs    = $(userldlibs) $($(target-stem)-userldlibs)
 
 # Create an executable from a single .c file
 quiet_cmd_user_cc_c = CC [U]  $@
       cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \
-                     $($(target-stem)-userldlibs)
+                     $(user_ldlibs)
 $(user-csingle): $(obj)/%: $(src)/%.c FORCE
        $(call if_changed_dep,user_cc_c)
 
 # Link an executable based on list of .o files
 quiet_cmd_user_ld = LD [U]  $@
       cmd_user_ld = $(CC) $(user_ldflags) -o $@ \
-                   $(addprefix $(obj)/, $($(target-stem)-objs)) \
-                   $($(target-stem)-userldlibs)
+                   $(addprefix $(obj)/, $($(target-stem)-objs)) $(user_ldlibs)
 $(user-cmulti): FORCE
        $(call if_changed,user_ld)
 $(call multi_depend, $(user-cmulti), , -objs)