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