From b300c18ab899b3c899e5405c96c20a32e51d77c8 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Mon, 2 Jul 2018 23:10:28 -0400
Subject: [PATCH] xen: Fix menuconfig and add support for config fragments and

Upstream-Status: Inappropriate [oe specific, cross compile issue]

Signed-off-by: Diego Sueiro <diego.sueiro@arm.com>
commit e6972e689a980ab28637e94e48c77eeace6abde5

    xen/kconfig,menuconfig,mconf-cfg: Allow specification of ncurses location

    In some cross build environments such as the Yocto Project build
    environment it provides an ncurses library that is compiled
    differently than the host's version.  This causes display corruption
    problems when the host's curses includes are used instead of the
    includes from the provided compiler are overridden.  There is a second
    case where there is no curses libraries at all on the host system and
    menuconfig will just fail entirely.

    The solution is simply to allow an override variable in
    check-lxdialog.sh for environments such as the Yocto Project.  Adding
    a CROSS_CURSES_LIB and CROSS_CURSES_INC solves the issue and allowing
    compiling and linking against the right headers and libraries.

    Change-Id: Ibe8dfafc90655e3be2671dbbb0cb7f5631fc4d44
    Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
    cc: Michal Marek <mmarek@suse.cz>
    cc: linux-kbuild@vger.kernel.org
    Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>

---
 xen/tools/kconfig/mconf-cfg.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
 mode change 100755 => 100644 xen/tools/kconfig/mconf-cfg.sh

diff --git a/xen/tools/kconfig/mconf-cfg.sh b/xen/tools/kconfig/mconf-cfg.sh
old mode 100755
new mode 100644
index c812872d7f..56eb4fc79f
--- a/xen/tools/kconfig/mconf-cfg.sh
+++ b/xen/tools/kconfig/mconf-cfg.sh
@@ -4,6 +4,14 @@
 PKG="ncursesw"
 PKG2="ncurses"
 
+if [ "$CROSS_CURSES_LIB" != "" ]; then
+    echo libs=\'$CROSS_CURSES_LIB\'
+    if [ x"$CROSS_CURSES_INC" != x ]; then
+      echo cflags=\'$CROSS_CURSES_INC\'
+    fi
+    exit 0
+fi
+
 if [ -n "$(command -v pkg-config)" ]; then
 	if pkg-config --exists $PKG; then
 		echo cflags=\"$(pkg-config --cflags $PKG)\"
