From patchwork Fri Dec 27 05:36:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 305389 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 634CA2C00A2 for ; Fri, 27 Dec 2013 16:46:31 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 025EE4AB3D; Fri, 27 Dec 2013 06:46:30 +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 JQXZi+PjVncF; Fri, 27 Dec 2013 06:46:29 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2315F4AACC; Fri, 27 Dec 2013 06:38:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C63464AA9F for ; Fri, 27 Dec 2013 06:38:05 +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 JcU31QthOWCM for ; Fri, 27 Dec 2013 06:38:03 +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 575F34A061 for ; Fri, 27 Dec 2013 06:36:57 +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 rBR5asdI004732; Fri, 27 Dec 2013 14:36:54 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili16) with ESMTP id rBR5asM21212; Fri, 27 Dec 2013 14:36:54 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi11) id rBR5asJR005638; Fri, 27 Dec 2013 14:36:54 +0900 Received: from poodle by lomi11.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id rBR5arDA005423; Fri, 27 Dec 2013 14:36:54 +0900 Received: from beagle.diag.org (beagle.diag.org [10.184.179.16]) by poodle (Postfix) with ESMTP id 4CBEB2743A5D; Fri, 27 Dec 2013 14:36:54 +0900 (JST) From: Masahiro Yamada To: u-boot@lists.denx.de Date: Fri, 27 Dec 2013 14:36:03 +0900 Message-Id: <1388122564-17606-36-git-send-email-yamada.m@jp.panasonic.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388122564-17606-1-git-send-email-yamada.m@jp.panasonic.com> References: <1388122564-17606-1-git-send-email-yamada.m@jp.panasonic.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v3 35/36] Kbuild: check clean source and generate Makefile for out-of-tree build 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 For out-of-tree build - Check if the source tree is clean - Create a Makefile in the output directory Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: - Newly added Makefile | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f62944c..0065239 100644 --- a/Makefile +++ b/Makefile @@ -393,6 +393,17 @@ scripts_basic: # To avoid any implicit rule to kick in, define an empty command. scripts/basic/%: scripts_basic ; +PHONY += outputmakefile +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +outputmakefile: +ifneq ($(KBUILD_SRC),) + $(Q)ln -fsn $(srctree) source + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ + $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) +endif + # To make sure we do not include .config for any of the *config targets # catch them early, and hand them over to scripts/kconfig/Makefile # It is allowed to specify more targets when calling make, including @@ -450,7 +461,7 @@ ifeq ($(config-targets),1) # KBUILD_DEFCONFIG may point out an alternative default configuration # used for 'make defconfig' -%_config:: +%_config:: outputmakefile @$(MKCONFIG) -A $(@:_config=) else @@ -926,7 +937,7 @@ $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ; # Error messages still appears in the original language PHONY += $(u-boot-dirs) -$(u-boot-dirs): depend scripts_basic +$(u-boot-dirs): depend prepare $(Q)$(MAKE) $(build)=$@ tools: $(TIMESTAMP_FILE) $(VERSION_FILE) @@ -937,19 +948,56 @@ $(filter-out tools, $(u-boot-dirs)): tools examples: $(filter-out examples, $(u-boot-dirs)) +# Things we need to do before we recursively start building the kernel +# or the modules are listed in "prepare". +# A multi level approach is used. prepareN is processed before prepareN-1. +# archprepare is used in arch Makefiles and when processed asm symlink, +# version.h and scripts_basic is processed / created. + +# Listed in dependency order +PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 + +# prepare3 is used to check if we are building in a separate output directory, +# and if so do: +# 1) Check that make has not been executed in the kernel src $(srctree) +prepare3: +ifneq ($(KBUILD_SRC),) + @$(kecho) ' Using $(srctree) as source for u-boot' + $(Q)if [ -f $(srctree)/include/config.mk ]; then \ + echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ + echo >&2 " in the '$(srctree)' directory.";\ + /bin/false; \ + fi; +endif + +# prepare2 creates a makefile if using a separate output directory +prepare2: prepare3 outputmakefile + +prepare1: prepare2 + @: + +archprepare: prepare1 scripts_basic + +prepare0: archprepare FORCE + @: + +# All the preparing.. +prepare: prepare0 + + u-boot.lds: $(LDSCRIPT) depend $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@ -nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic +nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend prepare $(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all u-boot-nand.bin: nand_spl u-boot.bin cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin -spl/u-boot-spl.bin: tools depend scripts_basic +spl/u-boot-spl.bin: tools depend prepare $(MAKE) obj=spl -f $(srctree)/spl/Makefile all -tpl/u-boot-tpl.bin: tools depend scripts_basic +tpl/u-boot-tpl.bin: tools depend prepare $(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y # Explicitly make _depend in subdirs containing multiple targets to prevent @@ -1191,7 +1239,10 @@ backup: F=`basename $(TOPDIR)` ; cd .. ; \ gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F -######################################################################### +# Dummies... +PHONY += prepare scripts +prepare: ; +scripts: ; endif #ifeq ($(config-targets),1) endif #ifeq ($(mixed-targets),1)