]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Makefiles/header.makefile
7828bbe4dc0ed93788320c24e2b16cf24bf9f51b
[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 # This program and the accompanying materials
10 # are licensed and made available under the terms and conditions of the BSD License
11 # which accompanies this distribution. The full text of the license may be found at
12 # http://opensource.org/licenses/bsd-license.php
13 #
14 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
17 ifndef HOST_ARCH
18 #
19 # If HOST_ARCH is not defined, then we use 'uname -m' to attempt
20 # try to figure out the appropriate HOST_ARCH.
21 #
22 uname_m = $(shell uname -m)
23 $(info Attempting to detect HOST_ARCH from 'uname -m': $(uname_m))
24 ifneq (,$(strip $(filter $(uname_m), x86_64 amd64)))
25 HOST_ARCH=X64
26 endif
27 ifeq ($(patsubst i%86,IA32,$(uname_m)),IA32)
28 HOST_ARCH=IA32
29 endif
30 ifneq (,$(findstring aarch64,$(uname_m)))
31 HOST_ARCH=AARCH64
32 endif
33 ifneq (,$(findstring arm,$(uname_m)))
34 HOST_ARCH=ARM
35 endif
36 ifndef HOST_ARCH
37 $(info Could not detected HOST_ARCH from uname results)
38 $(error HOST_ARCH is not defined!)
39 endif
40 $(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)
41 endif
42
43 CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
44 LINUX:=$(findstring Linux, $(shell uname -s))
45 DARWIN:=$(findstring Darwin, $(shell uname -s))
46
47 BUILD_CC ?= gcc
48 BUILD_CXX ?= g++
49 BUILD_AS ?= gcc
50 BUILD_AR ?= ar
51 BUILD_LD ?= ld
52 LINKER ?= $(BUILD_CC)
53 ifeq ($(HOST_ARCH), IA32)
54 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
55
56 else ifeq ($(HOST_ARCH), X64)
57 ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
58
59 else ifeq ($(HOST_ARCH), ARM)
60 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
61
62 else ifeq ($(HOST_ARCH), AARCH64)
63 ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
64
65 else
66 $(error Bad HOST_ARCH)
67 endif
68
69 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
70 BUILD_CPPFLAGS = $(INCLUDE)
71
72 # keep EXTRA_OPTFLAGS last
73 BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS)
74
75 ifeq ($(DARWIN),Darwin)
76 # assume clang or clang compatible flags on OS X
77 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g
78 else
79 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -g
80 endif
81 BUILD_LFLAGS =
82 BUILD_CXXFLAGS = -Wno-unused-result
83
84 ifeq ($(HOST_ARCH), IA32)
85 #
86 # Snow Leopard is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults
87 # to x86_64. So make sure tools match uname -m. You can manual have a 64-bit kernal on Snow Leopard
88 # so only do this is uname -m returns i386.
89 #
90 ifeq ($(DARWIN),Darwin)
91 BUILD_CFLAGS += -arch i386
92 BUILD_CPPFLAGS += -arch i386
93 BUILD_LFLAGS += -arch i386
94 endif
95 endif
96
97 # keep BUILD_OPTFLAGS last
98 BUILD_CFLAGS += $(BUILD_OPTFLAGS)
99 BUILD_CXXFLAGS += $(BUILD_OPTFLAGS)
100
101 # keep EXTRA_LDFLAGS last
102 BUILD_LFLAGS += $(EXTRA_LDFLAGS)
103
104 .PHONY: all
105 .PHONY: install
106 .PHONY: clean
107
108 all:
109
110 $(MAKEROOT)/libs:
111 mkdir $(MAKEROOT)/libs
112
113 $(MAKEROOT)/bin:
114 mkdir $(MAKEROOT)/bin