From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuJWi-0003pb-3r for qemu-devel@nongnu.org; Tue, 10 Jun 2014 06:43:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuJWZ-00060l-3B for qemu-devel@nongnu.org; Tue, 10 Jun 2014 06:43:36 -0400 Received: from mail-we0-x22e.google.com ([2a00:1450:400c:c03::22e]:54347) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuJWY-00060h-SW for qemu-devel@nongnu.org; Tue, 10 Jun 2014 06:43:27 -0400 Received: by mail-we0-f174.google.com with SMTP id k48so7167323wev.19 for ; Tue, 10 Jun 2014 03:43:25 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5396E08B.8000203@redhat.com> Date: Tue, 10 Jun 2014 12:40:11 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1402379781-844-1-git-send-email-pbonzini@redhat.com> <1402379781-844-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1402379781-844-7-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL 6/8] rules.mak: Rewrite unnest-vars List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Fam Zheng Il 10/06/2014 07:56, Paolo Bonzini ha scritto: > + $(foreach v,$(filter %-m,$2), > + # All .o found in *-m variables are single object modules, create .mo > + # for them > + $(foreach o,$(filter %.o,$($v)), > + $(eval $(o:%.o=%.mo)-objs := $o)) > + # Now unify .o in -m variable to .mo > + $(eval $v := $($v:%.o=%.mo)) > + > + $(eval modules: $($v:%.mo=%$(DSOSUF))) > + $(eval modules-m += $($v)) > + > + # For non-module build, add -m to -y > + $(if $(CONFIG_MODULES),,$(eval $(patsubst %-m,%-y,$v) += $($v)))) Peter spotted a few problems here. This needs to be + $(if $(CONFIG_MODULES), + $(eval modules: $($v:%.mo=%$(DSOSUF))) + $(eval $(patsubst %-m,%-y,$v) += $(call expand-objs, $($v))))) There are two changes: 1) You must not build modules if they are disabled 2) Because the .mo file has no dependencies, you need expand-objs. (In fact we should just stop using .mo files except as an artificial construct in Makefile.objs). > + > + # Post-process all the unnested vars > + $(foreach v,$2, > + $(foreach o, $(filter %.mo,$($v)), > + # Find all the .mo objects in variables and add dependency rules > + # according to .mo-objs. Report error if not set > + $(if $($o-objs), > + $(eval $(o:%.mo=%$(DSOSUF)): $($o-objs)), > + $(error $o added in $v but $o-objs is not set)) > + # Pass the .mo-cflags along to member objects > + $(if $($o-cflags), > + $(foreach p,$($o-objs), > + $(eval $p-cflags := $($o-cflags))))) Finally, this should be a +=. I'll send an updated pull request. Paolo > + $(shell mkdir -p ./ $(sort $(dir $($v)))) > + # Include all the .d files > + $(eval -include $(addsuffix *.d, $(sort $(dir $($v))))) > + $(eval $v := $(filter-out %/,$($v)))) > endef >