]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Makefiles/header.makefile
065a998bf5de6569d89d41a53db9e8d341d0cc85
[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) -O2
72 ifeq ($(DARWIN),Darwin)
73 # assume clang or clang compatible flags on OS X
74 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-self-assign -Wno-unused-result -nostdlib -c -g
75 else
76 BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -c -g
77 endif
78 BUILD_LFLAGS =
79 BUILD_CXXFLAGS = -Wno-unused-result
80
81 ifeq ($(HOST_ARCH), IA32)
82 #
83 # Snow Leopard is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults
84 # to x86_64. So make sure tools match uname -m. You can manual have a 64-bit kernal on Snow Leopard
85 # so only do this is uname -m returns i386.
86 #
87 ifeq ($(DARWIN),Darwin)
88 BUILD_CFLAGS += -arch i386
89 BUILD_CPPFLAGS += -arch i386
90 BUILD_LFLAGS += -arch i386
91 endif
92 endif
93
94
95 .PHONY: all
96 .PHONY: install
97 .PHONY: clean
98
99 all:
100
101 $(MAKEROOT)/libs:
102 mkdir $(MAKEROOT)/libs
103
104 $(MAKEROOT)/bin:
105 mkdir $(MAKEROOT)/bin