[PATCH 2/3] [kbuild] Possibility to sanely link against off-directory .so

From: Petr Baudis
Date: Sun Dec 11 2005 - 19:46:07 EST


This patch introduces two special variables which make it actually possible
to link something against .so being built in another directory. The
variable $(<foo>-linkobjs) allows the user to specify additional objects
to link <foo> against, while not creating any dependencies of <foo> on the
objects.

I need this in order to link scripts/lxdialog/liblxdialog.so from
scripts/kconfig (I'll be able to build that lib thanks to the previous
patch and the actual change to make it a library will follow in the next
patch).

On 6 Nov 2002 Sam Ravnborg <sam@xxxxxxxxxxxx> disputed this approach,
saying that such an extra complexity will bog the whole kernel build, but
this involves only the host tools build and there I think the extra penalty
is negligible. Also, .so has two users instead of a single one now, so it's
not that easy to use his suggested approach to offload the functionality to
the leaf makefiles.

Signed-off-by: Petr Baudis <pasky@xxxxxxx>
---

scripts/Makefile.host | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index ff1b54d..1161f4c 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -34,7 +34,12 @@
# 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).
+# to it later). To link the library from another directory, do:
+# hostprogs-y := mconf
+# mconf-objs := mconf.o
+# mconf-linkobjs := ../lxdialog/liblxdialog.so
+# This will prevent kbuild from trying to build ../lxdialog/liblxdialog.so
+# from scripts/kconfig nor make mconf depend on it.

__hostprogs := $(sort $(hostprogs-y)$(hostprogs-m))

@@ -116,6 +121,7 @@ $(host-csingle): %: %.c FORCE
quiet_cmd_host-cmulti = HOSTLD $@
cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
$(addprefix $(obj)/,$($(@F)-objs)) \
+ $(addprefix $(obj)/,$($(@F)-linkobjs)) \
$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE
$(call if_changed,host-cmulti)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/