From patchwork Fri Nov 29 08:14:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 295169 X-Patchwork-Delegate: trini@ti.com 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 0054F2C00A6 for ; Fri, 29 Nov 2013 19:15:33 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B8F03A75AF; Fri, 29 Nov 2013 09:15:31 +0100 (CET) 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 8nCLi4c8U1kq; Fri, 29 Nov 2013 09:15:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 32D61A75B3; Fri, 29 Nov 2013 09:15:27 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A88F0A75B3 for ; Fri, 29 Nov 2013 09:15:18 +0100 (CET) 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 pkFxmhq3oTqk for ; Fri, 29 Nov 2013 09:15:12 +0100 (CET) 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.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by theia.denx.de (Postfix) with ESMTP id 5293DA75AF for ; Fri, 29 Nov 2013 09:15:05 +0100 (CET) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile11) with ESMTP id rAT8EwDN001914 for ; Fri, 29 Nov 2013 17:14:58 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili13) with ESMTP id rAT8EwJ05956 for ; Fri, 29 Nov 2013 17:14:58 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi14) id rAT8EwxZ031188; Fri, 29 Nov 2013 17:14:58 +0900 Received: from poodle by lomi14.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id rAT8Ew7C031147; Fri, 29 Nov 2013 17:14:58 +0900 Received: from beagle.diag.org (beagle.diag.org [10.184.179.16]) by poodle (Postfix) with ESMTP id 1072C2740043; Fri, 29 Nov 2013 17:14:58 +0900 (JST) From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 29 Nov 2013 17:14:56 +0900 Message-Id: <1385712896-16764-1-git-send-email-yamada.m@jp.panasonic.com> X-Mailer: git-send-email 1.8.3.2 Subject: [U-Boot] [PATCH] Makefile: Do not create empty autoconf.mk on error X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 build rules of - include/autoconf.mk.dep - include/autoconf.mk - include/spl-autoconf.mk - include/tpl-autoconf.mk were wrong. They created empty files (which are never updated) if an error occurrs during preprocessing. Signed-off-by: Masahiro Yamada --- Before this commit, Makefile created empty files such as - include/autoconf.mk - include/spl-autoconf.mk - include/tpl-autoconf.mk - include/autoconf.mk.dep on error. For example, try "make" with a wrong CROSS_COMPILE like this: $ make mrproper $ make omap4_panda_config Configuring for omap4_panda board... $ make CROSS_COMPILE=foobar- all ------ /bin/bash: foobar-gcc: command not found make[1]: *** [lib/asm-offsets.s] Error 127 Of cource, make failed. And just check include/autoconf.mk, include/spl-autoconf.mk, etc. They exist and are all empty. And then, try "make" with a correct CROSS_COMPILE: $ make CROSS_COMPILE=arm-linux-gnueabi- all make will proceed with empty include/autoconf.mk and fail. A build rule of include/autoconf.mk is absolutely wrong: $(obj)include/autoconf.mk: $(obj)include/config.h @$(XECHO) Generating $@ ; \ set -e ; \ : Extract the config macros ; \ $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \ sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ mv $@.tmp $@ This code does not work as we expect on error because it does not detect the error of $(CPP). An error usually occurrs during $(CPP), whereas sed always succeeds. ( "set -e" is also meaningless, here. ) A empty include/autoconf.mk is created on error. (And it is never updated because it is newer than include/config.h) FYI: A pipe return the exit status of the last command. For example, $ command1 | command2 returns exit status of "command2", not "command1". Makefile | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index a2fb037..21c96cb 100644 --- a/Makefile +++ b/Makefile @@ -637,36 +637,33 @@ checkdtc: # to regenerate the autoconf.mk file. $(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h @$(XECHO) Generating $@ ; \ - set -e ; \ : Generate the dependancies ; \ $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \ - -MQ $(obj)include/autoconf.mk include/common.h > $@ + -MQ $(obj)include/autoconf.mk include/common.h > $@ || \ + rm $@ $(obj)include/autoconf.mk: $(obj)include/config.h @$(XECHO) Generating $@ ; \ - set -e ; \ : Extract the config macros ; \ - $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \ - sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ - mv $@.tmp $@ + $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \ + sed -n -f tools/scripts/define2mk.sed $@.tmp > $@ || \ + rm $@.tmp # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL) $(obj)include/tpl-autoconf.mk: $(obj)include/config.h @$(XECHO) Generating $@ ; \ - set -e ; \ : Extract the config macros ; \ $(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\ - -DDO_DEPS_ONLY -dM include/common.h | \ - sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ - mv $@.tmp $@ + -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \ + sed -n -f tools/scripts/define2mk.sed $@.tmp > $@ || \ + rm $@.tmp $(obj)include/spl-autoconf.mk: $(obj)include/config.h @$(XECHO) Generating $@ ; \ - set -e ; \ : Extract the config macros ; \ - $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h | \ - sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ - mv $@.tmp $@ + $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \ + sed -n -f tools/scripts/define2mk.sed $@.tmp > $@ || \ + rm $@.tmp $(obj)include/generated/generic-asm-offsets.h: $(obj)include/autoconf.mk.dep \ $(obj)include/spl-autoconf.mk \