From patchwork Sun Jul 6 08:02:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 4489431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F4CC9F26C for ; Sun, 6 Jul 2014 08:06:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3B5A2021A for ; Sun, 6 Jul 2014 08:06:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9A322020A for ; Sun, 6 Jul 2014 08:06:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X3hPe-0007Gt-B7; Sun, 06 Jul 2014 08:03:06 +0000 Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X3hPb-0007Ef-3w for linux-arm-kernel@lists.infradead.org; Sun, 06 Jul 2014 08:03:03 +0000 Received: by mail-la0-f42.google.com with SMTP id pn19so2067526lab.15 for ; Sun, 06 Jul 2014 01:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; bh=Ao1RWwwYeV3ex6TCN795ybtRO/srSaWq3Mv7Z56OJgQ=; b=da+lxlxNkjJ04eoLxwrOV+SlYNtlF2Jqo2Mil6dfruydkFaMtgLmmz6IuITJlRauom BLppaEgdi1S5V9/n6THMRx2M3sfac9VwLfUiqDlf2YA6/BGa29yyh/t+NUZBUCAZsAXj 74Ytkbx76e/wo5NkfsSTm8YDemP5mDzsMyoPQfGH40J8cI0YwkrzUlCtbiKCVYMCNV2v thP8fl4MBA7ZmdV3PkrR61vQjsPNQ+09nSq1bedlvngvaQ/vpTigtPMDecw03KCOAjqk 79xjK8c/LN5UuLgNpNaVVt5uBPAd9NEzxbnbgakFM5zsDDLKkXAvgrbgqHms53AHgoKS skWQ== X-Received: by 10.112.156.199 with SMTP id wg7mr16562678lbb.1.1404633759914; Sun, 06 Jul 2014 01:02:39 -0700 (PDT) Received: from localhost (95-25-124-72.broadband.corbina.ru. [95.25.124.72]) by mx.google.com with ESMTPSA id h2sm17412932lam.47.2014.07.06.01.02.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Jul 2014 01:02:38 -0700 (PDT) Subject: [PATCH] kconfig: store default ARCH in .config From: Konstantin Khlebnikov To: Michal Marek , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Date: Sun, 06 Jul 2014 12:02:34 +0400 Message-ID: <20140706080234.19520.96704.stgit@zurg> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140706_010303_369237_37CF01A1 X-CRM114-Status: GOOD ( 14.38 ) X-Spam-Score: -0.8 (/) Cc: Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes cross-compilation configuration fully statefull. Default ARCH is stored in .config as CONFIG_DEFAULT_ARCH. After initial configuration specifying ARCH= is no longer required. To avoid recursion it is read directly from .config using scritps/config because include/config/auto.conf is not yet included at this point. Signed-off-by: Konstantin Khlebnikov --- Documentation/kbuild/makefiles.txt | 2 ++ Makefile | 19 ++++++++++++++----- init/Kconfig | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index c600e2f..ced3e42 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1394,6 +1394,8 @@ The top Makefile exports the following variables: make ARCH=m68k ... + Default $(ARCH) is stored in .config as CONFIG_DEFAULT_ARCH, + so overriding is required only for initial configuration. INSTALL_PATH diff --git a/Makefile b/Makefile index 50fb690..76fcd9f 100644 --- a/Makefile +++ b/Makefile @@ -171,6 +171,8 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) export srctree objtree VPATH +KCONFIG_CONFIG ?= .config +export KCONFIG_CONFIG # SUBARCH tells the usermode build what the underlying arch is. That is set # first, and if a usermode build is happening, the "ARCH=um" on the command @@ -193,7 +195,18 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # ARCH can be set during invocation of make: # make ARCH=ia64 # Another way is to have ARCH set in the environment. -# The default ARCH is the host where make is executed. +# If CONFIG_DEFAULT_ARCH is in .config its value is used as default ARCH, +# otherwise the host where make is executed. + +ifndef ARCH + ARCH := $(shell test -e $(KBUILD_OUTPUT)$(KCONFIG_CONFIG) && \ + $(srctree)/scripts/config \ + --file $(KBUILD_OUTPUT)$(KCONFIG_CONFIG) \ + --state "DEFAULT_ARCH") +ifeq ($(filter-out undef,$(ARCH)),) + ARCH := $(SUBARCH) +endif +endif # CROSS_COMPILE specify the prefix used for all executables used # during compilation. Only gcc and related bin-utils executables @@ -205,7 +218,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # "make" in the configured kernel build directory always uses that. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -ARCH ?= $(SUBARCH) CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) # Architecture as present in compile.h @@ -244,9 +256,6 @@ endif # Where to locate arch specific headers hdr-arch := $(SRCARCH) -KCONFIG_CONFIG ?= .config -export KCONFIG_CONFIG - # SHELL used by kbuild CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ diff --git a/init/Kconfig b/init/Kconfig index 9d76b99..3d58cb7 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2,6 +2,10 @@ config ARCH string option env="ARCH" +config DEFAULT_ARCH + string + default ARCH + config KERNELVERSION string option env="KERNELVERSION"