[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 2/4] build-sys: allow object-specific libraries
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [RFC PATCH 2/4] build-sys: allow object-specific libraries to be used to link executables |
Date: |
Tue, 18 Jun 2013 21:34:02 +0400 |
When linking final executables consiting of various object files foo.o,
one may define foo.libs variable to hold libraries needed to be linked
with foo.o.
This way, we may specify dependencies inside the makefile fragments
where corresponding objects are defined.
Signed-off-by: Michael Tokarev <address@hidden>
---
rules.mak | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/rules.mak b/rules.mak
index a6bb4f1..69764b9 100644
--- a/rules.mak
+++ b/rules.mak
@@ -22,10 +22,14 @@ QEMU_INCLUDES += -I$(<D) -I$(@D)
%.o: %.rc
$(call quiet-command,$(WINDRES) -I. -o $@ $<," RC $(TARGET_DIR)$@")
+# check all .o files and extract any object-specific .libs
+# we remove leading ../ in case the build is done in a subdir.
+extract-libs = $(strip $(foreach o, $(patsubst ../%, %, $(filter %.o, $1)),
$($(o:%.o=%.libs))))
+
ifeq ($(LIBTOOL),)
LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
$(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
- $(LIBS)," LINK $(TARGET_DIR)$@")
+ $(LIBS) $(call extract-libs, $1)," LINK $(TARGET_DIR)$@")
else
LIBTOOL += $(if $(V),,--quiet)
%.lo: %.c
@@ -41,7 +45,7 @@ LINK = $(call quiet-command,\
$(sort $(filter %.o, $1)) $(filter-out %.o, $1) \
$(if $(filter %.lo %.la,$^),$(version-lobj-y),$(version-obj-y)) \
$(if $(filter %.lo %.la,$^),$(LIBTOOLFLAGS)) \
- $(LIBS),$(if $(filter %.lo %.la,$^),"lt LINK ", " LINK
")"$(TARGET_DIR)$@")
+ $(LIBS) $(call extract-libs, $1),$(if $(filter %.lo %.la,$^),"lt LINK
", " LINK ")"$(TARGET_DIR)$@")
endif
%.asm: %.S
--
1.7.10.4
- [Qemu-devel] [RFC PATCH 0/4] per-object libraries, Michael Tokarev, 2013/06/18
- [Qemu-devel] [RFC PATCH 2/4] build-sys: allow object-specific libraries to be used to link executables,
Michael Tokarev <=
- [Qemu-devel] [RFC PATCH 1/4] build-sys: strip leading ./ from $(obj), Michael Tokarev, 2013/06/18
- [Qemu-devel] [RFC PATCH 3/4] build-sys: allow per-object foo.cflags variables, Michael Tokarev, 2013/06/18
- [Qemu-devel] [RFC PATCH 4/4] build-sys: move -lcurl out of libs and specify it for curl.o, Michael Tokarev, 2013/06/18
- Re: [Qemu-devel] [RFC PATCH 0/4] per-object libraries, Michael Tokarev, 2013/06/18
- Re: [Qemu-devel] [RFC PATCH 0/4] per-object libraries, Stefan Hajnoczi, 2013/06/19
- Re: [Qemu-devel] [RFC PATCH 0/4] per-object libraries, Paolo Bonzini, 2013/06/19