From patchwork Tue Sep 27 00:10:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 116504 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 94169B6F7C for ; Tue, 27 Sep 2011 10:12:20 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4CD022849A; Tue, 27 Sep 2011 02:12:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NfCd+h+Jd2Vp; Tue, 27 Sep 2011 02:12:17 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 55C7A2837C; Tue, 27 Sep 2011 02:11:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7B42028395 for ; Tue, 27 Sep 2011 02:11:39 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HO1r-g6iaUfk for ; Tue, 27 Sep 2011 02:11:38 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.67]) by theia.denx.de (Postfix) with ESMTPS id 5288F2835E for ; Tue, 27 Sep 2011 02:11:38 +0200 (CEST) Received: from hpaq5.eem.corp.google.com (hpaq5.eem.corp.google.com [172.25.149.5]) by smtp-out.google.com with ESMTP id p8R0BaFY004817; Mon, 26 Sep 2011 17:11:36 -0700 Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by hpaq5.eem.corp.google.com with ESMTP id p8R0BY4I029617; Mon, 26 Sep 2011 17:11:34 -0700 Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id A413E141219; Mon, 26 Sep 2011 17:11:31 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 26 Sep 2011 17:10:54 -0700 Message-Id: <1317082255-24247-21-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1317082255-24247-1-git-send-email-sjg@chromium.org> References: <1317082255-24247-1-git-send-email-sjg@chromium.org> X-System-Of-Record: true Subject: [U-Boot] [PATCH v3 20/21] Adjust dependency rules to permit per-file flags X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The dependency rules are currently done in a shell 'for' loop. This does not permit Makefile variables to adjust preprocessor flags as is done with normal compile flags, using the CFLAGS_path/file.o syntax. This change moves the dependency generation into the Makefile itself, and permits a CPPFLAGS_path/file.o to adjust preprocessor flags on a file or directory basis. The CPPFLAGS_... variable is also folded into CFLAGS during the build. Signed-off-by: Simon Glass --- Changes in v3: - Change U-Boot's dependency generation to permit per-file flags .gitignore | 2 +- config.mk | 7 +++++++ rules.mk | 23 ++++++++++++----------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index dbf545f..7ba0dd9 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,7 @@ # Generated files # -*.depend +*.depend* /LOG /errlog /reloc_off diff --git a/config.mk b/config.mk index e2b440d..3fa9eef 100644 --- a/config.mk +++ b/config.mk @@ -277,6 +277,13 @@ export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%)) ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR)) ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) +EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR)) +ALL_CFLAGS += $(EXTRA_CPPFLAGS) + +# The _DEP version uses the $< file target (for dependency generation) +# See rules.mk +EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \ + $(CPPFLAGS_$(BCURDIR)) $(obj)%.s: %.S $(CPP) $(ALL_AFLAGS) -o $@ $< $(obj)%.o: %.S diff --git a/rules.mk b/rules.mk index d79fcd3..56b9044 100644 --- a/rules.mk +++ b/rules.mk @@ -25,17 +25,18 @@ _depend: $(obj).depend -$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS) - @rm -f $@ - @touch $@ - @for f in $(SRCS); do \ - g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ - $(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ - done - @for f in $(HOSTSRCS); do \ - g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ - $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ - done +DEPS := $(basename $(patsubst %,$(obj).depend.%,$(SRCS))) + +$(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(HOSTSRCS) + cat /dev/null $(DEPS) >$@ + @for f in $(HOSTSRCS); do \ + g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \ + $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \ + done + +$(obj).depend.%: %.c + $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \ + -MQ $(addsuffix .o,$(basename $<)) $< >$@ $(HOSTOBJS): $(obj)%.o: %.c $(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c