]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Makefiles/header.makefile
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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 ifneq (,$(findstring riscv64,$(uname_m)))
32 HOST_ARCH=RISCV64
33 endif
34 ifneq (,$(findstring loongarch64,$(uname_m)))
35 HOST_ARCH=LOONGARCH64
36 endif
37 ifndef HOST_ARCH
38 $(info Could not detected HOST_ARCH from uname results)
39 $(error HOST_ARCH is not defined!)
40 endif
41 $(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)
42 endif
43
44 CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
45 LINUX:=$(findstring Linux, $(shell uname -s))
46 DARWIN:=$(findstring Darwin, $(shell uname -s))
47 ifeq ($(CXX), llvm)
48 BUILD_CC ?= $(CLANG_BIN)clang
49 BUILD_CXX ?= $(CLANG_BIN)clang++
50 BUILD_AS ?= $(CLANG_BIN)clang
51 BUILD_AR ?= $(CLANG_BIN)llvm-ar
52 BUILD_LD ?= $(CLANG_BIN)llvm-ld
53 else
54 BUILD_CC ?= gcc
55 BUILD_CXX ?= g++
56 BUILD_AS ?= gcc
57 BUILD_AR ?= ar
58 BUILD_LD ?= ld
59 endif
60 LINKER ?= $(BUILD_CC)
61 ifeq ($(HOST_ARCH), IA32)
62 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
63
64 else ifeq ($(HOST_ARCH), X64)
65 ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
66
67 else ifeq ($(HOST_ARCH), ARM)
68 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
69
70 else ifeq ($(HOST_ARCH), AARCH64)
71 ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
72
73 else ifeq ($(HOST_ARCH), RISCV64)
74 ARCH_INCLUDE = -I $(MAKEROOT)/Include/RiscV64/
75
76 else ifeq ($(HOST_ARCH), LOONGARCH64)
77 ARCH_INCLUDE = -I $(MAKEROOT)/Include/LoongArch64/
78
79 else
80 $(error Bad HOST_ARCH)
81 endif
82
83 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
84 BUILD_CPPFLAGS = $(INCLUDE)
85
86 # keep EXTRA_OPTFLAGS last
87 BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS)
88
89 ifeq ($(DARWIN),Darwin)
90 # assume clang or clang compatible flags on OS X
91 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \
92 -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g
93 else
94 ifeq ($(CXX), llvm)
95 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \
96 -fno-delete-null-pointer-checks -Wall -Werror \
97 -Wno-deprecated-declarations -Wno-self-assign \
98 -Wno-unused-result -nostdlib -g
99 else
100 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \
101 -fno-delete-null-pointer-checks -Wall -Werror \
102 -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict \
103 -Wno-unused-result -nostdlib -g
104 endif
105 endif
106 ifeq ($(CXX), llvm)
107 BUILD_LFLAGS =
108 BUILD_CXXFLAGS = -Wno-deprecated-register -Wno-unused-result
109 else
110 BUILD_LFLAGS =
111 BUILD_CXXFLAGS = -Wno-unused-result
112 endif
113 ifeq ($(HOST_ARCH), IA32)
114 #
115 # Snow Leopard is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults
116 # to x86_64. So make sure tools match uname -m. You can manual have a 64-bit kernal on Snow Leopard
117 # so only do this is uname -m returns i386.
118 #
119 ifeq ($(DARWIN),Darwin)
120 BUILD_CFLAGS += -arch i386
121 BUILD_CPPFLAGS += -arch i386
122 BUILD_LFLAGS += -arch i386
123 endif
124 endif
125
126 # keep BUILD_OPTFLAGS last
127 BUILD_CFLAGS += $(BUILD_OPTFLAGS)
128 BUILD_CXXFLAGS += $(BUILD_OPTFLAGS)
129
130 # keep EXTRA_LDFLAGS last
131 BUILD_LFLAGS += $(EXTRA_LDFLAGS)
132
133 .PHONY: all
134 .PHONY: install
135 .PHONY: clean
136
137 all:
138
139 $(MAKEROOT)/libs:
140 mkdir $(MAKEROOT)/libs
141
142 $(MAKEROOT)/bin:
143 mkdir $(MAKEROOT)/bin