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