cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
958e1b
From ef6f26bb4a43131a7a3de4109aa9aeb145ad139a Mon Sep 17 00:00:00 2001
958e1b
From: Fam Zheng <famz@redhat.com>
958e1b
Date: Wed, 16 Jul 2014 02:20:27 -0500
958e1b
Subject: [CHANGE 27/29] rules.mak: allow per object cflags and libs
958e1b
To: rhvirt-patches@redhat.com,
958e1b
    jen@redhat.com
958e1b
958e1b
RH-Author: Fam Zheng <famz@redhat.com>
958e1b
Message-id: <1405477228-11490-4-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 59917
958e1b
O-Subject: [RHEL-7 qemu-kvm PATCH 3/4] rules.mak: allow per object cflags and libs
958e1b
Bugzilla: 1017685
958e1b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
958e1b
Adds extract-libs in LINK to expand any "per object libs", the syntax to define
958e1b
such a libs options is like:
958e1b
958e1b
        foo.o-libs := $(CURL_LIBS)
958e1b
958e1b
in block/Makefile.objs.
958e1b
958e1b
Similarly,
958e1b
958e1b
        foo.o-cflags := $(FOO_CFLAGS)
958e1b
958e1b
is also supported.
958e1b
958e1b
"foo.o" must be listed in a nested var (e.g. common-obj-y) to make the
958e1b
option variables effective.
958e1b
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
(cherry picked from commit 5c0d52bcd3aada33e274ea7dad75955f98bc2636)
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
---
958e1b
 rules.mak | 19 ++++++++++++++++---
958e1b
 1 file changed, 16 insertions(+), 3 deletions(-)
958e1b
958e1b
Signed-off-by: jen <jen@redhat.com>
958e1b
---
958e1b
 rules.mak | 19 ++++++++++++++++---
958e1b
 1 file changed, 16 insertions(+), 3 deletions(-)
958e1b
958e1b
diff --git a/rules.mak b/rules.mak
958e1b
index 0c5125d..355c275 100644
958e1b
--- a/rules.mak
958e1b
+++ b/rules.mak
958e1b
@@ -17,15 +17,17 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
958e1b
 # Same as -I$(SRC_PATH) -I., but for the nested source/object directories
958e1b
 QEMU_INCLUDES += -I$(
958e1b
 
958e1b
+extract-libs = $(strip $(foreach o,$1,$($o-libs)))
958e1b
+
958e1b
 %.o: %.c
958e1b
-	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
958e1b
+	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
958e1b
 %.o: %.rc
958e1b
 	$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
958e1b
 
958e1b
 ifeq ($(LIBTOOL),)
958e1b
 LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
958e1b
        $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
958e1b
-       $(LIBS),"  LINK  $(TARGET_DIR)$@")
958e1b
+       $(call extract-libs,$^) $(LIBS),"  LINK  $(TARGET_DIR)$@")
958e1b
 else
958e1b
 LIBTOOL += $(if $(V),,--quiet)
958e1b
 %.lo: %.c
958e1b
@@ -41,7 +43,7 @@ LINK = $(call quiet-command,\
958e1b
        $(sort $(filter %.o, $1)) $(filter-out %.o, $1) \
958e1b
        $(if $(filter %.lo %.la,$^),$(version-lobj-y),$(version-obj-y)) \
958e1b
        $(if $(filter %.lo %.la,$^),$(LIBTOOLFLAGS)) \
958e1b
-       $(LIBS),$(if $(filter %.lo %.la,$^),"lt LINK ", "  LINK  ")"$(TARGET_DIR)$@")
958e1b
+       $(call extract-libs,$^) $(LIBS),$(if $(filter %.lo %.la,$^),"lt LINK ", "  LINK  ")"$(TARGET_DIR)$@")
958e1b
 endif
958e1b
 
958e1b
 %.asm: %.S
958e1b
@@ -114,11 +116,22 @@ $(eval $1 = $(value save-$2-$1) $$(subdir-$2-$1))
958e1b
 $(eval save-$2-$1 :=)
958e1b
 endef
958e1b
 
958e1b
+define fix-obj-vars
958e1b
+$(foreach v,$($1), \
958e1b
+	$(if $($v-cflags), \
958e1b
+		$(eval $2$v-cflags := $($v-cflags)) \
958e1b
+		$(eval $v-cflags := )) \
958e1b
+	$(if $($v-libs), \
958e1b
+		$(eval $2$v-libs := $($v-libs)) \
958e1b
+		$(eval $v-libs := )))
958e1b
+endef
958e1b
+
958e1b
 define unnest-dir
958e1b
 $(foreach var,$(nested-vars),$(call push-var,$(var),$1/))
958e1b
 $(eval obj-parent-$1 := $(obj))
958e1b
 $(eval obj := $(if $(obj),$(obj)/$1,$1))
958e1b
 $(eval include $(SRC_PATH)/$1/Makefile.objs)
958e1b
+$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/)))
958e1b
 $(eval obj := $(obj-parent-$1))
958e1b
 $(eval obj-parent-$1 := )
958e1b
 $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/))
958e1b
-- 
958e1b
1.9.3
958e1b