]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/Makefiles/header.makefile
BaseTools/header.makefile: add "-Wno-restrict"
[mirror_edk2.git] / BaseTools / Source / C / Makefiles / header.makefile
index 54d3c78f97a39467f5da3a1cf28a39a687e30da3..065a998bf5de6569d89d41a53db9e8d341d0cc85 100644 (file)
@@ -1,12 +1,12 @@
 ## @file\r
 #\r
 # The makefile can be invoked with\r
-# ARCH = x86_64 or x64 for EM64T build\r
-# ARCH = ia32 or IA32 for IA32 build\r
-# ARCH = ia64 or IA64 for IA64 build\r
-# ARCH = Arm or ARM for ARM build\r
+# HOST_ARCH = x86_64 or x64 for EM64T build\r
+# HOST_ARCH = ia32 or IA32 for IA32 build\r
+# HOST_ARCH = ia64 or IA64 for IA64 build\r
+# HOST_ARCH = Arm or ARM for ARM build\r
 #\r
-# Copyright (c) 2007 - 2010, 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
-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
 DARWIN:=$(findstring Darwin, $(shell uname -s))\r
 \r
-CC = gcc\r
-CXX = g++\r
-AS = gcc\r
-AR = ar\r
-LD = ld\r
-LINKER ?= $(CC)\r
-ifeq ($(ARCH), IA32)\r
+BUILD_CC ?= gcc\r
+BUILD_CXX ?= g++\r
+BUILD_AS ?= gcc\r
+BUILD_AR ?= ar\r
+BUILD_LD ?= ld\r
+LINKER ?= $(BUILD_CC)\r
+ifeq ($(HOST_ARCH), IA32)\r
 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/\r
-endif\r
 \r
-ifeq ($(ARCH), X64)\r
+else ifeq ($(HOST_ARCH), X64)\r
 ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/\r
-endif\r
 \r
-ifeq ($(ARCH), ARM)\r
+else ifeq ($(HOST_ARCH), ARM)\r
 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/\r
+\r
+else ifeq ($(HOST_ARCH), AARCH64)\r
+ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/\r
+\r
+else\r
+$(error Bad HOST_ARCH)\r
 endif\r
 \r
 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE) \r
-CPPFLAGS = $(INCLUDE)\r
+BUILD_CPPFLAGS = $(INCLUDE) -O2\r
 ifeq ($(DARWIN),Darwin)\r
 # assume clang or clang compatible flags on OS X\r
-CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -nostdlib -c -g\r
+BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-self-assign -Wno-unused-result -nostdlib -c -g\r
 else\r
-CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -nostdlib -c -g\r
+BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -c -g\r
 endif\r
-LFLAGS =\r
+BUILD_LFLAGS =\r
+BUILD_CXXFLAGS = -Wno-unused-result\r
 \r
-ifeq ($(ARCH), IA32)\r
+ifeq ($(HOST_ARCH), IA32)\r
 #\r
 # Snow Leopard  is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults \r
 #  to x86_64. So make sure tools match uname -m. You can manual have a 64-bit kernal on Snow Leopard\r
 #  so only do this is uname -m returns i386.\r
 #\r
 ifeq ($(DARWIN),Darwin)\r
-  CFLAGS   += -arch i386\r
-  CPPFLAGS += -arch i386\r
-  LFLAGS   += -arch i386\r
+  BUILD_CFLAGS   += -arch i386\r
+  BUILD_CPPFLAGS += -arch i386\r
+  BUILD_LFLAGS   += -arch i386\r
 endif\r
 endif\r
 \r