]>
Commit | Line | Data |
---|---|---|
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 |
11 | ifndef 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 | |
39 | endif\r | |
6780eef1 LG |
40 | \r |
41 | CYGWIN:=$(findstring CYGWIN, $(shell uname -s))\r | |
42 | LINUX:=$(findstring Linux, $(shell uname -s))\r | |
43 | DARWIN:=$(findstring Darwin, $(shell uname -s))\r | |
02539e90 ZL |
44 | ifeq ($(CXX), llvm)\r |
45 | BUILD_CC ?= $(CLANG_BIN)clang\r | |
46 | BUILD_CXX ?= $(CLANG_BIN)clang++\r | |
47 | BUILD_AS ?= $(CLANG_BIN)clang\r | |
48 | BUILD_AR ?= $(CLANG_BIN)llvm-ar\r | |
49 | BUILD_LD ?= $(CLANG_BIN)llvm-ld\r | |
50 | else\r | |
a61331e8 LG |
51 | BUILD_CC ?= gcc\r |
52 | BUILD_CXX ?= g++\r | |
53 | BUILD_AS ?= gcc\r | |
54 | BUILD_AR ?= ar\r | |
55 | BUILD_LD ?= ld\r | |
02539e90 | 56 | endif\r |
a61331e8 | 57 | LINKER ?= $(BUILD_CC)\r |
a9f6e0a4 | 58 | ifeq ($(HOST_ARCH), IA32)\r |
6780eef1 | 59 | ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/\r |
6780eef1 | 60 | \r |
9d5aab05 | 61 | else ifeq ($(HOST_ARCH), X64)\r |
6780eef1 | 62 | ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/\r |
6780eef1 | 63 | \r |
9d5aab05 | 64 | else ifeq ($(HOST_ARCH), ARM)\r |
4afd3d04 | 65 | ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/\r |
4afd3d04 | 66 | \r |
9d5aab05 | 67 | else ifeq ($(HOST_ARCH), AARCH64)\r |
e0ba625f | 68 | ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/\r |
9d5aab05 | 69 | \r |
ffa51b3b N |
70 | else ifeq ($(HOST_ARCH), RISCV64)\r |
71 | ARCH_INCLUDE = -I $(MAKEROOT)/Include/RiscV64/\r | |
72 | \r | |
9d5aab05 CG |
73 | else\r |
74 | $(error Bad HOST_ARCH)\r | |
e0ba625f LL |
75 | endif\r |
76 | \r | |
0deca401 | 77 | INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)\r |
b8a66170 | 78 | BUILD_CPPFLAGS = $(INCLUDE)\r |
b0ca5dae LE |
79 | \r |
80 | # keep EXTRA_OPTFLAGS last\r | |
81 | BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS)\r | |
82 | \r | |
438f3ad6 AF |
83 | ifeq ($(DARWIN),Darwin)\r |
84 | # assume clang or clang compatible flags on OS X\r | |
0d6de095 BF |
85 | BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \\r |
86 | -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g\r | |
438f3ad6 | 87 | else\r |
02539e90 ZL |
88 | ifeq ($(CXX), llvm)\r |
89 | BUILD_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 | |
93 | else\r | |
c4c8c340 FB |
94 | BUILD_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 | 98 | endif\r |
02539e90 ZL |
99 | endif\r |
100 | ifeq ($(CXX), llvm)\r | |
101 | BUILD_LFLAGS =\r | |
102 | BUILD_CXXFLAGS = -Wno-deprecated-register -Wno-unused-result\r | |
103 | else\r | |
a61331e8 | 104 | BUILD_LFLAGS =\r |
4fa9134e | 105 | BUILD_CXXFLAGS = -Wno-unused-result\r |
02539e90 | 106 | endif\r |
a9f6e0a4 | 107 | ifeq ($(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 | 113 | ifeq ($(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 |
117 | endif\r |
118 | endif\r | |
119 | \r | |
b8a66170 LE |
120 | # keep BUILD_OPTFLAGS last\r |
121 | BUILD_CFLAGS += $(BUILD_OPTFLAGS)\r | |
122 | BUILD_CXXFLAGS += $(BUILD_OPTFLAGS)\r | |
0deca401 | 123 | \r |
81502cee LE |
124 | # keep EXTRA_LDFLAGS last\r |
125 | BUILD_LFLAGS += $(EXTRA_LDFLAGS)\r | |
126 | \r | |
6780eef1 LG |
127 | .PHONY: all\r |
128 | .PHONY: install\r | |
129 | .PHONY: clean\r | |
130 | \r | |
131 | all:\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 |