]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Makefiles/header.makefile
BaseTools: strip trailing whitespace
[mirror_edk2.git] / BaseTools / Source / C / Makefiles / header.makefile
1 ## @file
2 #
3 # The makefile can be invoked with
4 # HOST_ARCH = x86_64 or x64 for EM64T build
5 # HOST_ARCH = ia32 or IA32 for IA32 build
6 # HOST_ARCH = Arm or ARM for ARM build
7 #
8 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
9 # SPDX-License-Identifier: BSD-2-Clause-Patent
10
11 ifndef HOST_ARCH
12 #
13 # If HOST_ARCH is not defined, then we use 'uname -m' to attempt
14 # try to figure out the appropriate HOST_ARCH.
15 #
16 uname_m = $(shell uname -m)
17 $(info Attempting to detect HOST_ARCH from 'uname -m': $(uname_m))
18 ifneq (,$(strip $(filter $(uname_m), x86_64 amd64)))
19 HOST_ARCH=X64
20 endif
21 ifeq ($(patsubst i%86,IA32,$(uname_m)),IA32)
22 HOST_ARCH=IA32
23 endif
24 ifneq (,$(findstring aarch64,$(uname_m)))
25 HOST_ARCH=AARCH64
26 else ifneq (,$(findstring arm64,$(uname_m)))
27 HOST_ARCH=AARCH64
28 else ifneq (,$(findstring arm,$(uname_m)))
29 HOST_ARCH=ARM
30 endif
31 ifndef HOST_ARCH
32 $(info Could not detected HOST_ARCH from uname results)
33 $(error HOST_ARCH is not defined!)
34 endif
35 $(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)
36 endif
37
38 CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
39 LINUX:=$(findstring Linux, $(shell uname -s))
40 DARWIN:=$(findstring Darwin, $(shell uname -s))
41
42 BUILD_CC ?= gcc
43 BUILD_CXX ?= g++
44 BUILD_AS ?= gcc
45 BUILD_AR ?= ar
46 BUILD_LD ?= ld
47 LINKER ?= $(BUILD_CC)
48 ifeq ($(HOST_ARCH), IA32)
49 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
50
51 else ifeq ($(HOST_ARCH), X64)
52 ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
53
54 else ifeq ($(HOST_ARCH), ARM)
55 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
56
57 else ifeq ($(HOST_ARCH), AARCH64)
58 ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
59
60 else
61 $(error Bad HOST_ARCH)
62 endif
63
64 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
65 BUILD_CPPFLAGS = $(INCLUDE)
66
67 # keep EXTRA_OPTFLAGS last
68 BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS)
69
70 ifeq ($(DARWIN),Darwin)
71 # assume clang or clang compatible flags on OS X
72 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \
73 -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g
74 else
75 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \
76 -fno-delete-null-pointer-checks -Wall -Werror \
77 -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict \
78 -Wno-unused-result -nostdlib -g
79 endif
80 BUILD_LFLAGS =
81 BUILD_CXXFLAGS = -Wno-unused-result
82
83 ifeq ($(HOST_ARCH), IA32)
84 #
85 # Snow Leopard is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults
86 # to x86_64. So make sure tools match uname -m. You can manual have a 64-bit kernal on Snow Leopard
87 # so only do this is uname -m returns i386.
88 #
89 ifeq ($(DARWIN),Darwin)
90 BUILD_CFLAGS += -arch i386
91 BUILD_CPPFLAGS += -arch i386
92 BUILD_LFLAGS += -arch i386
93 endif
94 endif
95
96 # keep BUILD_OPTFLAGS last
97 BUILD_CFLAGS += $(BUILD_OPTFLAGS)
98 BUILD_CXXFLAGS += $(BUILD_OPTFLAGS)
99
100 # keep EXTRA_LDFLAGS last
101 BUILD_LFLAGS += $(EXTRA_LDFLAGS)
102
103 .PHONY: all
104 .PHONY: install
105 .PHONY: clean
106
107 all:
108
109 $(MAKEROOT)/libs:
110 mkdir $(MAKEROOT)/libs
111
112 $(MAKEROOT)/bin:
113 mkdir $(MAKEROOT)/bin