From patchwork Mon Sep 1 07:16:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 4817201 Return-Path: X-Original-To: patchwork-linux-kbuild@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 C55409F2ED for ; Mon, 1 Sep 2014 07:17:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E508020149 for ; Mon, 1 Sep 2014 07:17:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02819200F4 for ; Mon, 1 Sep 2014 07:17:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752629AbaIAHQw (ORCPT ); Mon, 1 Sep 2014 03:16:52 -0400 Received: from mail-la0-f52.google.com ([209.85.215.52]:34412 "EHLO mail-la0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752614AbaIAHQv (ORCPT ); Mon, 1 Sep 2014 03:16:51 -0400 Received: by mail-la0-f52.google.com with SMTP id ty20so5625520lab.11 for ; Mon, 01 Sep 2014 00:16:48 -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:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=a7D9JOP7yQbQ0naFbckOL+Ya8GSoxNO98qmBXDP/90U=; b=jI0xuKuwEfu0/HmmFFtYPxwcrKGuZ2vq0KW/rst+15iH1ezE3y8Z2f0DFwoXvYsOvx AJ8FXGu9A+9us1nmGME1Ykp4XfwEhH1IaXZbdPaIal2mWLW4Phl3/gi4wqngz0FfCx4+ GLsCblm70g2lIOzKQVXUJW3tM9tOMU2ibY6ErJc/voOVNwcTjIZ35ll748C29B/X3S0s I2a7jjJfwXbbIsu+S3XCiXc2kPmJkAau/05vNbN1YuMMPy3xbTH4JSfj11MUAgbH6+4P RWrOO8WanGDH9bu5I/fXv9PwIk0CjBaOtzKjrFaL/dA3nWuGaUoHP120rIQ80y99tjCE 2yTQ== X-Received: by 10.112.217.2 with SMTP id ou2mr695512lbc.101.1409555808840; Mon, 01 Sep 2014 00:16:48 -0700 (PDT) Received: from localhost (37-145-28-45.broadband.corbina.ru. [37.145.28.45]) by mx.google.com with ESMTPSA id k9sm17680lbj.4.2014.09.01.00.16.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Sep 2014 00:16:48 -0700 (PDT) Subject: [PATCH v2 3/4] kconfig: get target architecture from config file From: Konstantin Khlebnikov To: Michal Marek , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Cc: Paul Bolle , Geert Uytterhoeven Date: Mon, 01 Sep 2014 11:16:36 +0400 Message-ID: <20140901071636.28909.74871.stgit@zurg> In-Reply-To: <20140901065916.28909.35097.stgit@zurg> References: <20140901065916.28909.35097.stgit@zurg> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 kernel cross-compilation little bit easier. After initial configuration no special environment variables are required because default ARCH is saved in .config file: # make ARCH=arm defconfig # make menuconfig # make To solve chicken and egg problem ARCH is read directly from config file. Signed-off-by: Konstantin Khlebnikov --- Documentation/kbuild/makefiles.txt | 3 ++- Makefile | 15 ++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 764f599..92cf95b 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1365,7 +1365,8 @@ The top Makefile exports the following variables: "arm", or "sparc". Some kbuild Makefiles test $(ARCH) to determine which files to compile. - By default, the top Makefile sets $(ARCH) to be the same as the + By default $(ARCH) is set by option CONFIG_ARCH in .config, + default for it is set by top Makefile to be the same as the host system architecture. For a cross build, a user may override the value of $(ARCH) on the command line: diff --git a/Makefile b/Makefile index 2893d7f..f648405 100644 --- a/Makefile +++ b/Makefile @@ -220,6 +220,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 @@ -242,7 +244,14 @@ 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. +# Usually default value is saved in .config as CONFIG_ARCH. +# If this option is undefined or config file does not exist +# ARCH is set to the host where make is executed. +ifndef ARCH + ARCH := $(shell $(srctree)/scripts/config \ + --file $(KBUILD_OUTPUT)$(KCONFIG_CONFIG) \ + --if-undef "$(SUBARCH)" --state "ARCH") +endif # CROSS_COMPILE specify the prefix used for all executables used # during compilation. Only gcc and related bin-utils executables @@ -254,7 +263,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 @@ -293,9 +301,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; \