]> git.proxmox.com Git - efi-boot-shim.git/blame - gnu-efi/Make.defaults
New upstream version 15.6
[efi-boot-shim.git] / gnu-efi / Make.defaults
CommitLineData
031e5cce
SM
1# -*- makefile -*-
2# Copyright (c) 1999-2007 Hewlett-Packard Development Company, L.P.
3# Contributed by David Mosberger <davidm@hpl.hp.com>
4# Contributed by Stephane Eranian <eranian@hpl.hp.com>
5#
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11#
12# * Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer.
14# * Redistributions in binary form must reproduce the above
15# copyright notice, this list of conditions and the following
16# disclaimer in the documentation and/or other materials
17# provided with the distribution.
18# * Neither the name of Hewlett-Packard Co. nor the names of its
19# contributors may be used to endorse or promote products derived
20# from this software without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
27# BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
32# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
33# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34# SUCH DAMAGE.
35#
36
37TOPDIR ?= $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
38
39ARCHES = ia32 x86_64 ia64 aarch64 arm mips64el
40
41#
42# Variables below overridable from command-line:
43# make VARNAME=value ...
44#
45
46#
47# Where to install the package. GNU-EFI will create and access
48# lib and include under the root
49#
50DESTDIR ?= /
51ifeq ($(origin INSTALLROOT),undefined)
52INSTALLROOT = $(DESTDIR)
53endif
54
55empty :=
56space := $(empty) $(empty)
57stripped = $(subst $(space),/,$(strip $(subst /,$(space),$(1))))
58unstripped = $(subst $(space),/,$(subst /,$(space),$(1)))
59is_absolute = $(subst $(call stripped,$(1)),$(empty),$(call unstripped,$(1)))
60
61override INSTALLROOT:=$(if $(call is_absolute,$(INSTALLROOT)),,$(TOPDIR)/)$(INSTALLROOT)
62
63PREFIX := /usr/local
64LIBDIR := $(PREFIX)/lib
65INSTALL := install
66
67# Compilation tools
68COMPILER ?= gcc
69ARCHIVER ?= gcc-ar
70HOSTCC := $(COMPILER)
71CC := $(CROSS_COMPILE)$(COMPILER)
72AS := $(CROSS_COMPILE)as
73LD := $(CROSS_COMPILE)ld
74AR := $(CROSS_COMPILE)$(ARCHIVER)
75RANLIB := $(CROSS_COMPILE)ranlib
76OBJCOPY := $(CROSS_COMPILE)objcopy
77
78ifneq ($(CCACHE_DISABLE),)
79export CCACHE_DISABLE
80endif
81
82# Host/target identification
83OS := $(shell uname -s)
84HOSTARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
85ARCH ?= $(shell $(CC) $(ARCH3264) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
86
87# FreeBSD (and possibly others) reports amd64 instead of x86_64
88ifeq ($(ARCH),amd64)
89 override ARCH := x86_64
90endif
91
92#
93# Where to build the package
94#
8119f718 95OBJDIR := $(abspath .)/$(ARCH)
031e5cce
SM
96
97#
98# Variables below derived from variables above
99#
100
101# Arch-specific compilation flags
102CPPFLAGS += -DCONFIG_$(ARCH)
103
104CFLAGS += -Wno-error=pragmas
105
106ifeq ($(ARCH),ia64)
107 CFLAGS += -mfixed-range=f32-f127
108endif
109
110ifeq ($(ARCH),ia32)
111 CFLAGS += -mno-mmx -mno-sse
112 ifeq ($(HOSTARCH),x86_64)
113 ARCH3264 = -m32
114 endif
115endif
116
117ifeq ($(ARCH),x86_64)
118 GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d.)
119 GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d.)
120 USING_CLANG := $(shell $(CC) -v 2>&1 | grep -q 'clang version' && echo clang)
121
122 # Rely on GCC MS ABI support?
123 GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
124 || ( [ $(GCCVERSION) -eq "4" ] \
125 && [ $(GCCMINOR) -ge "7" ] ) ) \
126 && echo 1)
8529e0f7 127 ifeq ($(USING_CLANG),clang)
031e5cce 128 CPPFLAGS += -DGNU_EFI_USE_MS_ABI -DGNU_EFI_USE_EXTERNAL_STDARG --std=c11
8529e0f7
SM
129 else ifeq ($(GCCNEWENOUGH),1)
130 CPPFLAGS += -DGNU_EFI_USE_MS_ABI -DGNU_EFI_USE_EXTERNAL_STDARG -maccumulate-outgoing-args --std=c11
031e5cce
SM
131 endif
132
133 CFLAGS += -mno-red-zone
134 ifeq ($(HOSTARCH),ia32)
135 ARCH3264 = -m64
136 endif
137endif
138
139ifneq (,$(filter $(ARCH),ia32 x86_64))
140 # Disable AVX, if the compiler supports that.
141 CC_CAN_DISABLE_AVX=$(shell $(CC) -Werror -c -o /dev/null -xc -mno-avx - </dev/null >/dev/null 2>&1 && echo 1)
142 ifeq ($(CC_CAN_DISABLE_AVX), 1)
143 CFLAGS += -mno-avx
144 endif
145endif
146
147ifeq ($(ARCH),mips64el)
148 CFLAGS += -march=mips64r2
149 ARCH3264 = -mabi=64
150endif
151
152#
153# Set HAVE_EFI_OBJCOPY if objcopy understands --target efi-[app|bsdrv|rtdrv],
154# otherwise we need to compose the PE/COFF header using the assembler
155#
031e5cce
SM
156ifneq ($(ARCH),arm)
157ifneq ($(ARCH),mips64el)
158export HAVE_EFI_OBJCOPY=y
159endif
160endif
031e5cce
SM
161
162ifeq ($(ARCH),arm)
163CFLAGS += -marm
164endif
165
166# Generic compilation flags
167INCDIR += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \
168 -I$(TOPDIR)/inc/protocol
169
170# Only enable -fpic for non MinGW compilers (unneeded on MinGW)
171GCCMACHINE := $(shell $(CC) -dumpmachine)
172ifneq (mingw32,$(findstring mingw32, $(GCCMACHINE)))
173 CFLAGS += -fpic
174endif
175
176IS_FREEBSD = $(findstring FreeBSD, $(OS))
177IS_DARWIN = $(findstring Darwin, $(OS))
178
179WARNFLAGS ?= -Wall -Wextra
180WERRFLAGS ?= -Werror
181OPTIMIZATIONS ?= -O2 -g
182
183ifneq "$(or $(IS_FREEBSD), $(IS_DARWIN))" ""
184CFLAGS += $(ARCH3264) $(OPTIMIZATIONS) \
185 $(WARNFLAGS) $(WERRFLAGS) \
186 -fshort-wchar -fno-strict-aliasing \
187 -ffreestanding -fno-stack-protector
188else
189CFLAGS += $(ARCH3264) $(OPTIMIZATIONS) \
190 $(WARNFLAGS) $(WERRFLAGS) \
191 -fshort-wchar -fno-strict-aliasing \
192 -ffreestanding -fno-stack-protector \
193 -fno-stack-check -nostdinc \
8529e0f7 194 $(CFLAGS_LTO) $(CFLAGS_GCOV) \
031e5cce
SM
195 -isystem $(TOPDIR)/../include/system \
196 -isystem $(shell $(CC) $(ARCH3264) -print-file-name=include) \
197 $(if $(findstring gcc,$(CC)),-fno-merge-all-constants,)
198endif
199
200ifeq "$(IS_DARWIN)" ""
201ARFLAGS += -U
202else
203ARFLAGS := rDv
204endif
205
206ASFLAGS += $(ARCH3264)
207LDFLAGS += -nostdlib --warn-common --no-undefined --fatal-warnings \
208 --build-id=sha1
209
210ifneq ($(ARCH),arm)
211export LIBGCC=$(shell $(CC) $(CFLAGS) $(ARCH3264) -print-libgcc-file-name)
212endif