[kbuild] Allow building of standalone .so libraries This patch allows specifying .so libraries directly in 'hostprogs-y'. I need to create a .so library not linked to anything in the scripts/lxdialog/ directory. Signed-off-by: Petr Baudis --- scripts/Makefile.host | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 2d51970..ff1b54d 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -29,6 +29,12 @@ # conf.c is compiled as a c program, and conf.o is linked together with # libkconfig.so as the executable conf. # Note: Shared libraries consisting of C++ files are not supported +# +# hostprogs-y := liblxdialog.so +# liblxdialog-objs := checklist.o util.o +# Will create a "standalone" liblxdialog.so library in the directory, +# not linked against anything (useful when you want to link something +# to it later). __hostprogs := $(sort $(hostprogs-y)$(hostprogs-m)) @@ -39,7 +45,7 @@ obj-dirs := $(strip $(sort $(filter-out # C code # Executables compiled from a single .c file -host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) +host-csingle := $(foreach m,$(__hostprogs),$(if $($(m:.so=)-objs),,$(m))) # C executables linked based on several .o files host-cmulti := $(foreach m,$(__hostprogs),\ @@ -57,8 +63,10 @@ host-cxxmulti := $(foreach m,$(__hostpro host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) # Shared libaries (only .c supported) -# Shared libraries (.so) - all .so files referenced in "xxx-objs" -host-cshlib := $(sort $(filter %.so, $(host-cobjs))) +# Shared libraries (.so) - all .so files referenced in "xxx-objs", and +# also standalone .so's referenced in hostprogs. +host-cshlib := $(sort $(filter %.so, $(host-cobjs))) \ + $(sort $(filter %.so, $(__hostprogs))) # Remove .so files from "xxx-objs" host-cobjs := $(filter-out %.so,$(host-cobjs))