From 9dbd082516fdd7100f99f0f389b8eef5ececab19 Mon Sep 17 00:00:00 2001
From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Date: Fri, 26 Jul 2019 17:34:26 -0400
Subject: [PATCH] BaseTools: makefile: adjust to build in under bitbake

Prepend the build flags with those of bitbake. This is to build
using the bitbake native sysroot include and library directories.

Note from Alex: this is not appropriate for upstream submission as
the recipe already does lots of similar in-place fixups elsewhere, so
this patch shold be converted to follow that pattern. We're not going
to fight against how upstream wants to configure the build.

Signed-off-by: Ricardo Neri <ricardo.neri@linux.intel.com>
Upstream-Status: Inappropriate [needs to be converted to in-recipe fixups]
---
 BaseTools/Source/C/Makefiles/header.makefile | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
index 55a7307a5e..e36e6a8f04 100644
--- a/BaseTools/Source/C/Makefiles/header.makefile
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -154,35 +154,34 @@ endif
 
 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
 INCLUDE += -I $(EDK2_PATH)/MdePkg/Include
-CPPFLAGS = $(INCLUDE)
+CPPFLAGS += $(INCLUDE)
 
 # keep EXTRA_OPTFLAGS last
 BUILD_OPTFLAGS = -O2 $(EXTRA_OPTFLAGS)
 
 ifeq ($(DARWIN),Darwin)
 # assume clang or clang compatible flags on OS X
-CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \
+CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror \
 -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g
 else
 ifneq ($(CLANG),)
-CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \
+CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -fwrapv \
 -fno-delete-null-pointer-checks -Wall -Werror \
 -Wno-deprecated-declarations -Wno-self-assign \
 -Wno-unused-result -nostdlib -g
 else
-CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \
+CFLAGS += -MD -fshort-wchar -fno-strict-aliasing -fwrapv \
 -fno-delete-null-pointer-checks -Wall -Werror \
 -Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict \
 -Wno-unused-result -nostdlib -g
 endif
 endif
 ifneq ($(CLANG),)
-LDFLAGS =
-CXXFLAGS = -Wno-deprecated-register -Wno-unused-result -std=c++14
+CXXFLAGS += -Wno-deprecated-register -Wno-unused-result -std=c++14
 else
-LDFLAGS =
-CXXFLAGS = -Wno-unused-result
+CXXFLAGS += -Wno-unused-result
 endif
+
 ifeq ($(HOST_ARCH), IA32)
 #
 # Snow Leopard  is a 32-bit and 64-bit environment. uname -m returns i386, but gcc defaults
