]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Makefiles/header.makefile
90fb3453ad467ae6d6408bdcbaf50cf9ea3e1ef5
[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 endif
27 ifneq (,$(findstring arm,$(uname_m)))
28 HOST_ARCH=ARM
29 endif
30 ifndef HOST_ARCH
31 $(info Could not detected HOST_ARCH from uname results)
32 $(error HOST_ARCH is not defined!)
33 endif
34 $(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)
35 endif
36
37 CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
38 LINUX:=$(findstring Linux, $(shell uname -s))
39 DARWIN:=$(findstring Darwin, $(shell uname -s))
40
41 BUILD_CC ?= gcc
42 BUILD_CXX ?= g++
43 BUILD_AS ?= gcc
44 BUILD_AR ?= ar
45 BUILD_LD ?= ld
46 LINKER ?= $(BUILD_CC)
47 ifeq ($(HOST_ARCH), IA32)
48 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
49
50 else ifeq ($(HOST_ARCH), X64)
51 ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
52
53 else ifeq ($(HOST_ARCH), ARM)
54 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
55
56 else ifeq ($(HOST_ARCH), AARCH64)
57 ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
58
59 else
60 $(error Bad HOST_ARCH)
61 endif
62
63 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
64 BUILD_CPPFLAGS = $(INCLUDE)
65
66 # keep EXTRA_OPTFLAGS last
67 BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS)
68
69 ifeq ($(DARWIN),Darwin)
70 # assume clang or clang compatible flags on OS X
71 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g
72 else
73 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -g
74 endif
75 BUILD_LFLAGS =
76 BUILD_CXXFLAGS = -Wno-unused-result
77
78 ifeq ($(HOST_ARCH), IA32)
79 #
80 # Snow Leopard is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults
81 # to x86_64. So make sure tools match uname -m. You can manual have a 64-bit kernal on Snow Leopard
82 # so only do this is uname -m returns i386.
83 #
84 ifeq ($(DARWIN),Darwin)
85 BUILD_CFLAGS += -arch i386
86 BUILD_CPPFLAGS += -arch i386
87 BUILD_LFLAGS += -arch i386
88 endif
89 endif
90
91 # keep BUILD_OPTFLAGS last
92 BUILD_CFLAGS += $(BUILD_OPTFLAGS)
93 BUILD_CXXFLAGS += $(BUILD_OPTFLAGS)
94
95 # keep EXTRA_LDFLAGS last
96 BUILD_LFLAGS += $(EXTRA_LDFLAGS)
97
98 .PHONY: all
99 .PHONY: install
100 .PHONY: clean
101
102 all:
103
104 $(MAKEROOT)/libs:
105 mkdir $(MAKEROOT)/libs
106
107 $(MAKEROOT)/bin:
108 mkdir $(MAKEROOT)/bin