From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHsXp-0006x7-7g for qemu-devel@nongnu.org; Fri, 06 Sep 2013 05:41:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHsXg-000884-PA for qemu-devel@nongnu.org; Fri, 06 Sep 2013 05:41:37 -0400 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]:51051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHsXg-00087r-Hj for qemu-devel@nongnu.org; Fri, 06 Sep 2013 05:41:28 -0400 Received: by mail-ee0-f50.google.com with SMTP id d51so1480778eek.9 for ; Fri, 06 Sep 2013 02:41:27 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5229A348.3080204@redhat.com> Date: Fri, 06 Sep 2013 11:41:28 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1378376448-29036-1-git-send-email-famz@redhat.com> <1378376448-29036-2-git-send-email-famz@redhat.com> In-Reply-To: <1378376448-29036-2-git-send-email-famz@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 1/6] make.rule: fix $(obj) to a real relative path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: mjt@tls.msk.ru, qemu-devel@nongnu.org, stefanha@redhat.com Il 05/09/2013 12:20, Fam Zheng ha scritto: > Makefile.target includes rule.mak and unnested common-obj-y, then prefix > them with '../', this will ignore object specific QEMU_CFLAGS in subdir > Makefile.objs: > > $(obj)/curl.o: QEMU_CFLAGS += $(CURL_CFLAGS) > > Because $(obj) here is './block', instead of '../block'. This doesn't > hurt compiling because we basically build all .o from top Makefile, > before entering Makefile.target, but it will affact arriving per-object > libs support. > > The starting point of $(obj) is fixed before including ./Makefile.objs, > to get consistency with nested Makefile rules in target rule and > variable definition. > > Signed-off-by: Fam Zheng > --- > Makefile.target | 3 ++- > rules.mak | 6 +++--- > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/Makefile.target b/Makefile.target > index 9a49852..b35e7c1 100644 > --- a/Makefile.target > +++ b/Makefile.target > @@ -144,12 +144,13 @@ endif # CONFIG_SOFTMMU > %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) > > nested-vars += obj-y > +obj := .. > > # This resolves all nested paths, so it must come last > include $(SRC_PATH)/Makefile.objs > > all-obj-y = $(obj-y) > -all-obj-y += $(addprefix ../, $(common-obj-y)) > +all-obj-y += $(addprefix $(obj)/, $(common-obj-y)) The bug is clearly there, but I'm not sure this is correct. "obj" is the path to the object file. obj-y files are built in the target directory, thus the extra ".." should apply only to common-obj-y; $(obj-y) should not be prefixed. So perhaps you need to: 1) move the nested-vars and unnest-vars call from Makefile.objs to Makefile. also move this line: QEMU_CFLAGS+=$(GLIB_CFLAGS) which has no business in Makefile.objs. With this change, Makefile.objs is just a list, like other */Makefile.objs files. 2) remove the additional complication where common-obj-y is including block-obj-y, just add it to all-obj-y manually. 3) in Makefile.target, do this: block-obj-y = ../ common-obj-y = ../ nested-vars = obj-y block-obj-y common-obj-y dummy := $(call unnest-vars) all-obj-y = $(obj-y) $(common-obj-y) $(block-obj-y) (Can all be done in a single patch). ? > > ifndef CONFIG_HAIKU > LIBS+=-lm > diff --git a/rules.mak b/rules.mak > index 4499745..5758137 100644 > --- a/rules.mak > +++ b/rules.mak > @@ -103,7 +103,6 @@ clean: clean-timestamp > > # magic to descend into other directories > > -obj := . > old-nested-dirs := > > define push-var > @@ -119,9 +118,10 @@ endef > > define unnest-dir > $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) > -$(eval obj := $(obj)/$1) > +$(eval old-obj := $(obj)) > +$(eval obj := $(if $(obj),$(obj)/$1,$1)) > $(eval include $(SRC_PATH)/$1/Makefile.objs) > -$(eval obj := $(patsubst %/$1,%,$(obj))) > +$(eval obj := $(old-obj)) > $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) old-obj doesn't work if you have multiple levels of nesting. But you can call the variable something like obj-parent-$1 instead to solve this problem. However, please clean it up afterwards with "$(eval obj-parent-$1 := )". Paolo > endef > >