]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools GNUmakefile: Move HOST_ARCH detection into common makefile
authorLiming Gao <liming.gao@intel.com>
Wed, 31 Jan 2018 11:59:56 +0000 (19:59 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 6 Feb 2018 05:44:39 +0000 (13:44 +0800)
With this change, enter single tool directory, make can pass.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/C/Makefiles/header.makefile

index e034da258cdca3c1b47aefb7365f3bba650f9985..0976973bdd7bf7d2b5c46c772821ae5610a655e3 100644 (file)
@@ -6,7 +6,7 @@
 # HOST_ARCH = ia64 or IA64 for IA64 build\r
 # HOST_ARCH = Arm or ARM for ARM build\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.    The full text of the license may be found at\r
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-HOST_ARCH ?= IA32\r
+ifndef HOST_ARCH\r
+  #\r
+  # If HOST_ARCH is not defined, then we use 'uname -m' to attempt\r
+  # try to figure out the appropriate HOST_ARCH.\r
+  #\r
+  uname_m = $(shell uname -m)\r
+  $(info Attempting to detect HOST_ARCH from 'uname -m': $(uname_m))\r
+  ifneq (,$(strip $(filter $(uname_m), x86_64 amd64)))\r
+    HOST_ARCH=X64\r
+  endif\r
+  ifeq ($(patsubst i%86,IA32,$(uname_m)),IA32)\r
+    HOST_ARCH=IA32\r
+  endif\r
+  ifneq (,$(findstring aarch64,$(uname_m)))\r
+    HOST_ARCH=AARCH64\r
+  endif\r
+  ifneq (,$(findstring arm,$(uname_m)))\r
+    HOST_ARCH=ARM\r
+  endif\r
+  ifndef HOST_ARCH\r
+    $(info Could not detected HOST_ARCH from uname results)\r
+    $(error HOST_ARCH is not defined!)\r
+  endif\r
+  $(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)\r
+endif\r
 \r
 CYGWIN:=$(findstring CYGWIN, $(shell uname -s))\r
 LINUX:=$(findstring Linux, $(shell uname -s))\r