2010-03-01 00:39:39 +01:00
|
|
|
## @file
|
|
|
|
#
|
2010-11-15 03:51:34 +01:00
|
|
|
# The makefile can be invoked with
|
2017-11-28 04:18:50 +01:00
|
|
|
# HOST_ARCH = x86_64 or x64 for EM64T build
|
|
|
|
# HOST_ARCH = ia32 or IA32 for IA32 build
|
|
|
|
# HOST_ARCH = ia64 or IA64 for IA64 build
|
|
|
|
# HOST_ARCH = Arm or ARM for ARM build
|
2010-11-15 03:51:34 +01:00
|
|
|
#
|
2018-01-31 12:59:56 +01:00
|
|
|
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
|
2010-05-18 07:04:32 +02:00
|
|
|
# This program and the accompanying materials
|
2010-03-01 00:39:39 +01:00
|
|
|
# are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
# which accompanies this distribution. The full text of the license may be found at
|
|
|
|
# http://opensource.org/licenses/bsd-license.php
|
|
|
|
#
|
|
|
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
2010-11-15 03:51:34 +01:00
|
|
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
2018-01-31 12:59:56 +01:00
|
|
|
ifndef HOST_ARCH
|
|
|
|
#
|
|
|
|
# If HOST_ARCH is not defined, then we use 'uname -m' to attempt
|
|
|
|
# try to figure out the appropriate HOST_ARCH.
|
|
|
|
#
|
|
|
|
uname_m = $(shell uname -m)
|
|
|
|
$(info Attempting to detect HOST_ARCH from 'uname -m': $(uname_m))
|
|
|
|
ifneq (,$(strip $(filter $(uname_m), x86_64 amd64)))
|
|
|
|
HOST_ARCH=X64
|
|
|
|
endif
|
|
|
|
ifeq ($(patsubst i%86,IA32,$(uname_m)),IA32)
|
|
|
|
HOST_ARCH=IA32
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring aarch64,$(uname_m)))
|
|
|
|
HOST_ARCH=AARCH64
|
|
|
|
endif
|
|
|
|
ifneq (,$(findstring arm,$(uname_m)))
|
|
|
|
HOST_ARCH=ARM
|
|
|
|
endif
|
|
|
|
ifndef HOST_ARCH
|
|
|
|
$(info Could not detected HOST_ARCH from uname results)
|
|
|
|
$(error HOST_ARCH is not defined!)
|
|
|
|
endif
|
|
|
|
$(info Detected HOST_ARCH of $(HOST_ARCH) using uname.)
|
|
|
|
endif
|
2010-11-15 03:51:34 +01:00
|
|
|
|
|
|
|
CYGWIN:=$(findstring CYGWIN, $(shell uname -s))
|
|
|
|
LINUX:=$(findstring Linux, $(shell uname -s))
|
|
|
|
DARWIN:=$(findstring Darwin, $(shell uname -s))
|
|
|
|
|
2016-08-22 08:32:23 +02:00
|
|
|
BUILD_CC ?= gcc
|
|
|
|
BUILD_CXX ?= g++
|
|
|
|
BUILD_AS ?= gcc
|
|
|
|
BUILD_AR ?= ar
|
|
|
|
BUILD_LD ?= ld
|
|
|
|
LINKER ?= $(BUILD_CC)
|
2017-11-28 04:18:50 +01:00
|
|
|
ifeq ($(HOST_ARCH), IA32)
|
2010-11-15 03:51:34 +01:00
|
|
|
ARCH_INCLUDE = -I $(MAKEROOT)/Include/Ia32/
|
|
|
|
|
2017-12-28 01:23:56 +01:00
|
|
|
else ifeq ($(HOST_ARCH), X64)
|
2010-11-15 03:51:34 +01:00
|
|
|
ARCH_INCLUDE = -I $(MAKEROOT)/Include/X64/
|
|
|
|
|
2017-12-28 01:23:56 +01:00
|
|
|
else ifeq ($(HOST_ARCH), ARM)
|
2013-08-23 04:18:16 +02:00
|
|
|
ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
|
|
|
|
|
2017-12-28 01:23:56 +01:00
|
|
|
else ifeq ($(HOST_ARCH), AARCH64)
|
2014-09-24 23:07:53 +02:00
|
|
|
ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
|
2017-12-28 01:23:56 +01:00
|
|
|
|
|
|
|
else
|
|
|
|
$(error Bad HOST_ARCH)
|
2014-09-24 23:07:53 +02:00
|
|
|
endif
|
|
|
|
|
2010-11-15 03:51:34 +01:00
|
|
|
INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
|
2016-09-29 09:59:09 +02:00
|
|
|
BUILD_CPPFLAGS = $(INCLUDE) -O2
|
2014-09-16 02:38:12 +02:00
|
|
|
ifeq ($(DARWIN),Darwin)
|
|
|
|
# assume clang or clang compatible flags on OS X
|
2018-03-07 10:17:28 +01:00
|
|
|
BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -c -g
|
2014-09-16 02:38:12 +02:00
|
|
|
else
|
BaseTools/header.makefile: add "-Wno-restrict"
gcc-8 (which is part of Fedora 28) enables the new warning
"-Wrestrict" in "-Wall". This warning is documented in detail
at <https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html>; the
introduction says
> Warn when an object referenced by a restrict-qualified parameter (or, in
> C++, a __restrict-qualified parameter) is aliased by another argument,
> or when copies between such objects overlap.
It breaks the BaseTools build (in the Brotli compression library) with:
> In function 'ProcessCommandsInternal',
> inlined from 'ProcessCommands' at dec/decode.c:1828:10:
> dec/decode.c:1781:9: error: 'memcpy' accessing between 17 and 2147483631
> bytes at offsets 16 and 16 overlaps between 17 and 2147483631 bytes at
> offset 16 [-Werror=restrict]
> memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16));
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In function 'ProcessCommandsInternal',
> inlined from 'SafeProcessCommands' at dec/decode.c:1833:10:
> dec/decode.c:1781:9: error: 'memcpy' accessing between 17 and 2147483631
> bytes at offsets 16 and 16 overlaps between 17 and 2147483631 bytes at
> offset 16 [-Werror=restrict]
> memcpy(copy_dst + 16, copy_src + 16, (size_t)(i - 16));
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Paolo Bonzini <pbonzini@redhat.com> analyzed the Brotli source in detail,
and concluded that the warning is a false positive:
> This seems safe to me, because it's preceded by:
>
> uint8_t* copy_dst = &s->ringbuffer[pos];
> uint8_t* copy_src = &s->ringbuffer[src_start];
> int dst_end = pos + i;
> int src_end = src_start + i;
> if (src_end > pos && dst_end > src_start) {
> /* Regions intersect. */
> goto CommandPostWrapCopy;
> }
>
> If [src_start, src_start + i) and [pos, pos + i) don't intersect, then
> neither do [src_start + 16, src_start + i) and [pos + 16, pos + i).
>
> The if seems okay:
>
> (src_start + i > pos && pos + i > src_start)
>
> which can be rewritten to:
>
> (pos < src_start + i && src_start < pos + i)
>
> Then the numbers are in one of these two orders:
>
> pos <= src_start < pos + i <= src_start + i
> src_start <= pos < src_start + i <= pos + i
>
> These two would be allowed by the "if", but they can only happen if pos
> == src_start so they degenerate to the same two orders above:
>
> pos <= src_start < src_start + i <= pos + i
> src_start <= pos < pos + i <= src_start + i
>
> So it is a false positive in GCC.
Disable the warning for now.
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Cole Robinson <crobinso@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reported-by: Cole Robinson <crobinso@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2018-03-02 17:11:52 +01:00
|
|
|
BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict -Wno-unused-result -nostdlib -c -g
|
2014-09-16 02:38:12 +02:00
|
|
|
endif
|
2016-08-22 08:32:23 +02:00
|
|
|
BUILD_LFLAGS =
|
2016-12-16 06:07:10 +01:00
|
|
|
BUILD_CXXFLAGS = -Wno-unused-result
|
2010-11-15 03:51:34 +01:00
|
|
|
|
2017-11-28 04:18:50 +01:00
|
|
|
ifeq ($(HOST_ARCH), IA32)
|
2010-11-15 03:51:34 +01:00
|
|
|
#
|
|
|
|
# Snow Leopard is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults
|
|
|
|
# to x86_64. So make sure tools match uname -m. You can manual have a 64-bit kernal on Snow Leopard
|
|
|
|
# so only do this is uname -m returns i386.
|
|
|
|
#
|
2014-09-16 02:38:12 +02:00
|
|
|
ifeq ($(DARWIN),Darwin)
|
2016-08-22 08:32:23 +02:00
|
|
|
BUILD_CFLAGS += -arch i386
|
|
|
|
BUILD_CPPFLAGS += -arch i386
|
|
|
|
BUILD_LFLAGS += -arch i386
|
2010-11-15 03:51:34 +01:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
.PHONY: install
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
all:
|
|
|
|
|
|
|
|
$(MAKEROOT)/libs:
|
|
|
|
mkdir $(MAKEROOT)/libs
|
|
|
|
|
|
|
|
$(MAKEROOT)/bin:
|
|
|
|
mkdir $(MAKEROOT)/bin
|